function updateMainWindow() {     

  window.opener.location.reload(true);
	window.close();
    

}

function updateMainWindowNoClose() {
  window.opener.location.reload(true);
}

function redirMainWindow(url) {
  window.opener.location = url;
	window.close();

}


var arrInput = new Array(0);
var arrInput2 = new Array(0);
var arrInput3 = new Array(0);
  var arrInputValue = new Array(0);
  var arrInputValue2 = new Array(0);
  var arrInputValue3 = new Array(0);

function addInput(lapsi) {
  arrInput.push(arrInput.length);
  arrInput2.push(arrInput2.length);
  arrInput3.push(arrInput3.length);
  arrInputValue.push("");
  arrInputValue2.push("");
  arrInputValue3.push("");
  display(lapsi);
}

function display(lapsi) {
  document.getElementById('parah').innerHTML="";
  for (intI=0;intI<arrInput.length;intI++) {
    document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInput2[intI],arrInput3[intI], arrInputValue[intI], arrInputValue2[intI], arrInputValue3[intI], lapsi);
  }
}

function saveValue(intId,strValue) {
  arrInputValue[intId]=strValue;
}  
function saveValue2(intId,strValue) {
  arrInputValue2[intId]=strValue;
}
function saveValue3(intId,strValue) {
  arrInputValue3[intId]=strValue;
}


function createInput(id, id2, id3, value, value2, value3, lapsi) {
	lapsi_nro = id +1;
	
	if(lapsi_nro > 25) {
		document.getElementById('lisaappa').disabled = true;		
	}  else {
		document.getElementById('lisaappa').disabled = false;
	}
	 if(lapsi_nro < 2){
		document.getElementById('poistappa').disabled = true;
	} else {
		document.getElementById('poistappa').disabled = false;
	}
	 //document.getElementById('lapsi_maara').innerHTML=lapsi_nro;
  if (lapsi == '1') {
  
    return ''+ lapsi_nro + ' <b>lapsen tiedot</b> <br /><table><tr><td>Etunimi:</td><td><input type="text" name="etunimi[]" id="lapsi' + id + '" onChange="javascript:saveValue('+ id +',this.value)" value="' + value + '" /></td></tr><tr><td>Sukunimi:</td><td><input type="text" name="sukunimi[]" id="lapsi' + id + '" onChange="javascript:saveValue2('+ id +',this.value)" value="' + value2 + '" /></td></tr><tr><td>Hetu:</td><td><input type="text" name="hetu[]" id="lapsi' + id + '" onChange="javascript:saveValue3('+ id +',this.value)" value="' + value3 + '" /></td></tr></table>';
  } 
}

function deleteInput(yhthenk) {
  if (arrInput.length > 0) { 
     arrInput.pop();
     arrInput2.pop();
     arrInput3.pop();
     arrInputValue.pop();
     arrInputValue2.pop();
     arrInputValue3.pop();
  }
  display(yhthenk); 
}

