function clearOptions(value){
	
	switch (value){
		case "include_form":
			setRadioButton("include_sitemap_ans2",true);
		break;
		case "include_sitemap":
			resetSelect("include_form");
		break;

	}
}

function resetSelect(id){
	var objTemp = document.getElementById(id);
	if(objTemp!=null){
		objTemp.selectedIndex=0;
	}
}

function setRadioButton(id,value){
	var objTemp = document.getElementById(id);
	if(objTemp!=null){
		objTemp.checked=value;
	}
}

function showFormRequestLoginData(strAction){
	var objAlertMessageLogin = document.getElementById("alertMessageLogin");
	if(objAlertMessageLogin!=null){
		objAlertMessageLogin.innerHTML="&nbsp;";
	}
	
	var objFormLogin = document.getElementById("frmLogin");
	var objRequestLoginData = document.getElementById("frmRequestLoginData");
	
	if(objFormLogin!=null && objRequestLoginData!=null){
		switch(strAction){
			case "open":
				objFormLogin.style.display="none";
				objRequestLoginData.style.display="block";
				setFocusOnObject("frmRequestLoginData","EMAIL_required");	
			break;
			case "close":
				objRequestLoginData.style.display="none";
				objFormLogin.style.display="block";	
				setFocusOnObject("frmLogin","USERCODE_required;PASSWORD_required");	
			break;	
		}
	}
}


function hideShowHtmlObjects(strValue){
	var e = document.getElementsByTagName("select");
	
	if(strValue=="hide"){
		for(var i = 0; i <e.length;i++){
			e[i].style.display="none";
		}
		
	}
	else if(strValue=="show"){
		for(var i = 0; i <e.length;i++){
			e[i].style.display="";
		}
	}
	
}

function childrenBirthDates(obj,strType,intMin,intMax){
	var arrId = new Array();
	
	var intDiff = 0;
	if(obj.value!=""){
		var intAmount = obj.value
	}
	else
	{
		var intAmount = 0;
	}
	if(document.getElementById("container_"+strType)){
		if(intAmount == 0){
			var e = document.getElementById("tbl_"+strType).getElementsByTagName("tr");
				
			intDiff = e.length
			
			while(intDiff>0){
				
				//document.getElementById("tbl_"+strType).removeChild(e[e.length-1]);
				if(e[e.length-1].attributes){
					
					if(e[e.length-1].getAttribute("id")!=undefined && e[e.length-1].getAttribute("id")!=""){
						e[e.length-1].parentNode.removeChild(e[e.length-1]);
						e = document.getElementById("tbl_"+strType).getElementsByTagName("tr");
						if(e.length==0){
							intDiff = -1;	
						}
						else
						{
							intDiff = intDiff - 1;
						}
					}
					else
					{
						intDiff = -1;
					}
				}
				else
				{
					intDiff = -1;
				}
			}
			document.getElementById("tbl_"+strType).style.display="none"
		}
		else
		{
			if( (intAmount < intMin) || (intAmount > intMax) ){
				alert( getTranslation("TextNumberMustBe","Number must be ") + intMin + getTranslation("TextAtLeastAnd"," at least  and ") + intMax + getTranslation("TextAtMost","  at most."));
			}
			else
			{
				document.getElementById("CHILDREN_FLAGANS0_required").checked=true;
				document.getElementById("tbl_"+strType).style.display="block";
				var intLengthChildren = 0;
				if(document.getElementById("tbl_" + strType)){
					var e = document.getElementById("tbl_"+strType).getElementsByTagName("tr");
					if(e.length>0){
						if(e[e.length-1].attributes){
							if(e[e.length-1].getAttribute("id")!=undefined && e[e.length-1].getAttribute("id")!=""){
								intLengthChildren = parseFloat(GetID(e[e.length-1].getAttribute("id"),strType)) + 1;
							}
						}
					}
				}
				
				//var e = document.getElementById("container_"+strType).getElementsByTagName("div");
				
				//if(intAmount < e.length){
				if(intAmount < intLengthChildren){
					
					intDiff = intLengthChildren - intAmount
					
					while(intDiff>0){
						var e = document.getElementById("tbl_"+strType).getElementsByTagName("tr");
						//document.getElementById("tbl_"+strType).removeChild(e[e.length-1]);
						e[e.length-1].parentNode.removeChild(e[e.length-1]);
						intDiff = intDiff - 1;
					}
					
				}
				//else if(intAmount > e.length){
				else if(intAmount > intLengthChildren){
					//intDiff = intAmount - e.length
					intDiff = intAmount - intLengthChildren
					for(i=0;i<intDiff;i++){
						//var e = document.getElementById("container_"+strType).getElementsByTagName("div");
						//var e = document.getElementById("container_"+strType).getElementsByTagName("tr");
						
						//var intObjCount = e.length;
						var intObjCount = (intLengthChildren+i);
						
						var tblObj = document.getElementById("tbl_"+strType).getElementsByTagName("tbody")[0];
						
						var newTr = document.createElement("tr");
						newTr.setAttribute("id",strType + intObjCount);
						tblObj.appendChild(newTr);
						
						var newTd = document.createElement("td");
						newTd.appendChild(document.createTextNode(intObjCount + 1));
						newTd.setAttribute("align","center");
						newTr.appendChild(newTd);
						
						var newTd = document.createElement("td");
						newTd.setAttribute("align","center");
						newTr.appendChild(newTd);
						
						if(strSystemBrowser=="Internet Explorer"){
							newTd.innerHTML = "<input class=\"clsTextboxBirthDate\" type=\"text\" required=\"true\" id=\""+strType + "_birthday" + intObjCount + "\" name=\""+strType + "_birthday" + intObjCount + "\" maxlength=\"2\" onKeyUp=\"isNumeric(this)\" value=\"\" \/>"; 
						}
						else
						{
						
							arrId[arrId.length] = strType + "_birthday" + intObjCount;
							var newInput = document.createElement("input");
							newInput.setAttribute("type","text");
							newInput.className = "clsTextboxBirthDate";
							newInput.setAttribute("id",arrId[arrId.length-1]);
							newInput.setAttribute("name",arrId[arrId.length-1]);
							newInput.setAttribute("maxlength","2");
							newInput.setAttribute("required","true");
							newTd.appendChild(newInput);
							
						
						}
						
						var newTd = document.createElement("td");
						newTd.setAttribute("align","center");
						newTr.appendChild(newTd);
						
						
						if(strSystemBrowser=="Internet Explorer"){
							newTd.innerHTML = "<input class=\"clsTextboxBirthDate\" type=\"text\" required=\"true\" id=\""+strType + "_birthmonth" + intObjCount + "\" name=\""+strType + "_birthmonth" + intObjCount + "\" maxlength=\"2\" onKeyUp=\"isNumeric(this)\" value=\"\" \/>"; 
						}
						else
						{	
							arrId[arrId.length] = strType + "_birthmonth" + intObjCount;
							var newInput = document.createElement("input");
							newInput.setAttribute("type","text");
							newInput.setAttribute("id",arrId[arrId.length-1]);
							newInput.setAttribute("name",arrId[arrId.length-1]);
							newInput.setAttribute("required","true");
							newInput.setAttribute("maxlength","2");
							newInput.className="clsTextboxBirthDate";
							newTd.appendChild(newInput);
						}
						
						
						var newTd = document.createElement("td");
						newTd.setAttribute("align","center");
						newTr.appendChild(newTd);
						
						if(strSystemBrowser=="Internet Explorer"){
							newTd.innerHTML = "<input class=\"clsTextboxBirthDate\" type=\"text\" required=\"true\" id=\""+strType + "_birthyear" + intObjCount + "\" name=\""+strType + "_birthyear" + intObjCount + "\" maxlength=\"4\" onKeyUp=\"isNumeric(this)\" value=\"\" \/>"; 
						}
						else
						{	
							arrId[arrId.length] = strType + "_birthyear" + intObjCount;
							var newInput = document.createElement("input");
							newInput.setAttribute("type","text");
							newInput.setAttribute("id",arrId[arrId.length-1]);
							newInput.setAttribute("name",arrId[arrId.length-1]);
							newInput.setAttribute("required","true");
							newInput.setAttribute("maxlength","4");
							newInput.className="clsTextboxBirthDate";
							newTd.appendChild(newInput);
						}
						
						
						var newTd = document.createElement("td");
						newTd.setAttribute("align","center");
						newTd.setAttribute("id","frmBackground"+strType+"_gender"+intObjCount);
						newTd.className="clsEmptyCell";
						//newTd.appendChild(document.createTextNode("&nbsp;"));
						newTr.appendChild(newTd);
						
						var newTd = document.createElement("td");
						newTd.setAttribute("align","center");
						newTr.appendChild(newTd);
						
						
						if(strSystemBrowser=="Internet Explorer"){
							newTd.innerHTML = "<input type=\"radio\" name=\""+strType+"_gender"+intObjCount+"\" id=\""+strType+"_gender"+intObjCount+"ANS0\" value=\"M\" class=\"clsRadioCheckbox\" required=\"true\" \/>"; 
						}
						else
						{	
						var newInput = document.createElement("input");
						newInput.setAttribute("type","radio");
						newInput.setAttribute("required","true");
						newInput.setAttribute("value","M");
						newInput.className = "clsRadioCheckbox";
						newInput.setAttribute("id",strType+"_gender"+intObjCount+"ANS0");
						newInput.setAttribute("name",strType+"_gender"+intObjCount);
						newTd.appendChild(newInput);
						}
						
						var newTd = document.createElement("td");
						newTd.setAttribute("align","center");
						newTr.appendChild(newTd);
						
						if(strSystemBrowser=="Internet Explorer"){
							newTd.innerHTML = "<input type=\"radio\" name=\""+strType+"_gender"+intObjCount+"\" id=\""+strType+"_gender"+intObjCount+"ANS1\" value=\"F\" class=\"clsRadioCheckbox\" required=\"true\" \/>"; 
						}
						else
						{	
						var newInput = document.createElement("input");
						newInput.setAttribute("type","radio");
						newInput.setAttribute("required","true");
						newInput.setAttribute("value","F");
						newInput.className = "clsRadioCheckbox";
						newInput.setAttribute("id",strType+"_gender"+intObjCount+"ANS1");
						newInput.setAttribute("name",strType+"_gender"+intObjCount);
						newTd.appendChild(newInput);
						}
						
					
					}
					//registreren van events
					for(var i=0;i<arrId.length;i++){
						var tempId = arrId[i];					
						registerEventListener(document.getElementById(tempId), "keyup", function(){var strValue=myTrim(this.value); if(strValue!=""){ if(strValue != parseFloat(strValue)){ this.value = ""};} ;});
					}
					
	
				}
			}
		}
	}	
	
	
}

function noChildren(){
	clearAlert("frmBackground","have_children");
	document.getElementById("CHILDREN_IN_HOUSE").value="0";
	document.getElementById("CHILDREN_IN_HOUSE_BIRTHDATES").value="";
	document.getElementById("CHILDREN_OUT_HOUSE").value="0";
	document.getElementById("CHILDREN_OUT_HOUSE_BIRTHDATES").value="";
	childrenBirthDates(document.getElementById("CHILDREN_IN_HOUSE"),"child_in_house","","");
	childrenBirthDates(document.getElementById("CHILDREN_OUT_HOUSE"),"child_out_house","","");
}

function handleClickOption(obj){
	
	if(obj!=undefined&&obj!=""){
		switch(obj.name){
			case"set_workcurrent":
				if(obj.value=="5"){
					//nee
					var objSetWorkHours = document.getElementById("frmBackground")["set_workcurrenthours"];
					
					if(objSetWorkHours!=null){
						if(objSetWorkHours.length!=undefined){
							for(var i=0; i < objSetWorkHours.length;i++){
								objSetWorkHours[i].setAttribute("required","false");
								objSetWorkHours[i].checked=false;
								objSetWorkHours[i].disabled=true;
							}
							
						}
						else
						{
							objSetWorkHours.setAttribute("required","false");
							objSetWorkHours.checked=false;
							objSetWorkHours.disabled=true;
						}
						
						var objSetWorkHoursRequiredMark = document.getElementById("requiredMark_set_workcurrenthours");
						if(objSetWorkHoursRequiredMark!=null){
							objSetWorkHoursRequiredMark.innerHTML = "";
						}
					}
					
					var objWorkManagesFlag = document.getElementById("frmBackground")["WORK_MANAGES_FLAG"];
					if(objWorkManagesFlag!=null){
						if(objWorkManagesFlag.length!=undefined){
							for(var i=0; i < objWorkManagesFlag.length;i++){
								objWorkManagesFlag[i].setAttribute("required","false");
								objWorkManagesFlag[i].checked=false;
								objWorkManagesFlag[i].disabled=true;
							}
							
						}
						else
						{
							objWorkManagesFlag.setAttribute("required","false");
							objWorkManagesFlag.checked=false;
							objWorkManagesFlag.disabled=true;
						}
						
						var objWorkManagesDirectRequiredMark = document.getElementById("requiredMark_WORK_MANAGES_DIRECT");
						if(objWorkManagesDirectRequiredMark!=null){
							objWorkManagesDirectRequiredMark.innerHTML = "";
						}
					}
					
					var objWorkManagesDirect = document.getElementById("WORK_MANAGES_DIRECT");
					if(objWorkManagesDirect!=null){
						objWorkManagesDirect.value="";
						objWorkManagesDirect.setAttribute("required","false");
						objWorkManagesDirect.disabled=true;
						
					}
					var objWorkManagesIndirect = document.getElementById("WORK_MANAGES_INDIRECT");
					if(objWorkManagesIndirect!=null){
						objWorkManagesIndirect.value="";
						objWorkManagesIndirect.setAttribute("required","false");
						objWorkManagesIndirect.disabled=true;
					}
				
				
				}
				else
				{
					
					var objSetWorkHours = document.getElementById("frmBackground")["set_workcurrenthours"];
					if(objSetWorkHours!=null){
						if(objSetWorkHours.length!=undefined){
							for(var i=0; i < objSetWorkHours.length;i++){
								objSetWorkHours[i].setAttribute("required","true");
								objSetWorkHours[i].disabled=false;
							}
							
						}
						else
						{
							objSetWorkHours.setAttribute("required","true");
							objSetWorkHours.disabled=false;
						}
					}
					
					var objWorkManagesFlag = document.getElementById("frmBackground")["WORK_MANAGES_FLAG"];
					if(objWorkManagesFlag!=null){
						if(objWorkManagesFlag.length!=undefined){
							for(var i=0; i < objWorkManagesFlag.length;i++){
								objWorkManagesFlag[i].setAttribute("required","true");
								objWorkManagesFlag[i].disabled=false;
							}
							
						}
						else
						{
							objWorkManagesFlag.setAttribute("required","true");
							objWorkManagesFlag.disabled=false;
						}
						
					}
					var objWorkManagesDirect = document.getElementById("WORK_MANAGES_DIRECT");
					if(objWorkManagesDirect!=null){
						objWorkManagesDirect.disabled=false;
					}
					var objWorkManagesIndirect = document.getElementById("WORK_MANAGES_INDIRECT");
					if(objWorkManagesIndirect!=null){
						objWorkManagesIndirect.disabled=false;
					}
				
				}
				
					
				
			break;
			
			//case"set_workcurrenthours":
			//break;
			
			
			case"WORK_MANAGES_FLAG":
				if(obj.value=="N"){
					if(document.getElementById("WORK_MANAGES_FLAGANS1")){
						setObjRequired('WORK_MANAGES_DIRECT','false','frmBackground');
					}
					if(document.getElementById("WORK_MANAGES_INDIRECT")){
						setObjRequired('WORK_MANAGES_INDIRECT','false','frmBackground')
					}
				}
				else if(obj.value=="Y"){
					
					if(document.getElementById("WORK_MANAGES_INDIRECT")){
						setObjRequired('WORK_MANAGES_INDIRECT','true','frmBackground')
					}
					if(document.getElementById("WORK_MANAGES_FLAGANS1")){
						setObjRequired('WORK_MANAGES_DIRECT','true','frmBackground');
					}
				}
			break;
			
			case "WORK_MANAGES_DIRECT":
				
				var objWorkManagesFlagAns1 = document.getElementById("WORK_MANAGES_FLAGANS1");
				if(obj.value!="" && objWorkManagesFlagAns1!=null){
					if(objWorkManagesFlagAns1.checked==false){
						objWorkManagesFlagAns1.checked=true;
					}
				}
			break;
			
			case "WORK_MANAGES_INDIRECT":
				var objWorkManagesFlagAns1 = document.getElementById("WORK_MANAGES_FLAGANS1");
				if(obj.value!="" && objWorkManagesFlagAns1!=null){
					if(objWorkManagesFlagAns1.checked==false){
						objWorkManagesFlagAns1.checked=true;
					}
				}
			break;
			
			case "CHILDREN_FLAG":
				
				var objChildrenInHouse = document.getElementById("CHILDREN_IN_HOUSE");
				var objChildrenOutHouse = document.getElementById("CHILDREN_OUT_HOUSE");
				if(objChildrenInHouse!=null && objChildrenOutHouse!=null){
					if(obj.value=="N"){
						clearAlert("frmBackground","have_children");
						
						var objChildrenInHouseBirthDates = document.getElementById("CHILDREN_IN_HOUSE_BIRTHDATES");
						var objChildrenOutHouseBirthDates = document.getElementById("CHILDREN_OUT_HOUSE_BIRTHDATES");
						
						objChildrenInHouse.value="0";
						if(objChildrenInHouseBirthDates!=null){
							objChildrenInHouseBirthDates.value="";
						}
						objChildrenOutHouse.value="0";
						if(objChildrenOutHouseBirthDates!=null){
							objChildrenOutHouseBirthDates.value="";
						}
						childrenBirthDates(objChildrenInHouse,"child_in_house","","");
						childrenBirthDates(objChildrenOutHouse,"child_out_house","","");
						objChildrenInHouse.disabled=true;
						objChildrenOutHouse.disabled=true;
						var objRequiredMark_have_children = document.getElementById("requiredMark_have_children");
						if(objRequiredMark_have_children!=null){
							objRequiredMark_have_children.innerHTML = "";
						}
						
					}
					else if(obj.value=="Y"){
						objChildrenInHouse.disabled=false;
						objChildrenOutHouse.disabled=false;
					}
				}
					
				break;
				
				case "HOUSE_OWNER_FLAG":
					var objContainerAttr77 = document.getElementById("containerAttr77");
					var objSelectAttr77 = document.getElementById("Attribute77");
					if(obj.value=="N"){
						if(objContainerAttr77!=null){
							objContainerAttr77.style.display="block";
						}
						if(objSelectAttr77!=null){
							setObjRequired('Attribute77','true','frmBackground');
						}
						
					}
					else if(obj.value=="Y"){
						if(objSelectAttr77!=null){
							setObjRequired('Attribute77','false','frmBackground');
							objSelectAttr77.selectedIndex=0;
						}
						if(objContainerAttr77!=null){
							objContainerAttr77.style.display="none";
						}
					}
				break;
			}
			
	}
}

var blnOnValidate = false;

function submitFormBackground(objCollection){

	if(blnOnValidate == false){
	 	if(validateFormBackground(objCollection)==true){
	 		enableAllDisabled("frmBackground");
	 		document.getElementById("frmBackground").submit();
	 	}
	}	
}

function submitFormNaw(strNameForm, myBtn, strSetFocusIds, objCollection){
	if(blnOnValidate == false){
	 	if(validate(strNameForm,myBtn,strSetFocusIds,objCollection)==true){
	 		document.getElementById(strNameForm).submit();
	 	}
	 	else
	 	{
	 		blnFormSubmit = false;
			blnOnValidate = false;
			return false;
		}
	}	
}



function validateFormBackground(objCollection){
	
	var textForgotRequiredField = getCollectionValue(objCollection,"textForgotRequiredField","");
	var textBirthdateDontExcists = getCollectionValue(objCollection,"textBirthdateDontExcists","");
	var textYearOutOfRange = getCollectionValue(objCollection,"textYearOutOfRange","");
	var blnCheckChildren = true;
	var blnComposeBirthDates = false;
	//check kinderen
	
	
	blnOnValidate = true;
	
	var objChildrenInHouse = document.getElementById("CHILDREN_IN_HOUSE");
	var objChildrenOutHouse = document.getElementById("CHILDREN_OUT_HOUSE");
	
	var objChildrenInHouseBirthDates = document.getElementById("CHILDREN_IN_HOUSE_BIRTHDATES");
	var objChildrenOutHouseBirthDates = document.getElementById("CHILDREN_OUT_HOUSE_BIRTHDATES");
	
	if(document.getElementById("CHILDREN_FLAGANS0_required") && document.getElementById("frmBackgroundhave_children")&&objChildrenInHouse!=null&&objChildrenOutHouse!=null&&objChildrenInHouseBirthDates!=null&&objChildrenOutHouseBirthDates!=null){
		if(document.getElementById("CHILDREN_FLAGANS0_required").checked==true){
			if(myTrim(objChildrenInHouse.value)==""){
				var intChildrenInHouse = 0;
			}
			else
			{
				var intChildrenInHouse = parseInt(myTrim(objChildrenInHouse.value))
			}
			if(myTrim(objChildrenOutHouse.value)==""){
				var intChildrenOutHouse = 0;
			}
			else
			{
				var intChildrenOutHouse = parseInt(myTrim(objChildrenOutHouse.value))
			}
			
			
			if(intChildrenInHouse == 0 && intChildrenOutHouse == 0){
			
				setAlert("frmBackground","have_children");
				blnCheckChildren = false;
				var strResponse = textForgotRequiredField;
				alert(strResponse);
			}
			else
			{
				clearAlert("frmBackground","have_children");
				blnComposeBirthDates = true;
			}
		}
		else
		{
			clearAlert("frmBackground","have_children");
			objChildrenInHouse.value="0";
			objChildrenInHouseBirthDates.value="";
			objChildrenOutHouse.value="0";
			objChildrenOutHouseBirthDates.value="";
		}
	}
	if (blnCheckChildren == true){
		var blnValidate = validate('frmBackground','btn_OK');
	}
	if(blnValidate == true){
		
		var objSetEducation = document.forms["frmBackground"].set_education;
		if(objSetEducation!=null){
			if(objSetEducation.length!=undefined){
				for(var i = 0; i < objSetEducation.length;i++){
					if(objSetEducation[i].checked==true){
						document.getElementById("EDUCATION_COMPLETED").value="["+objSetEducation[i].value+"]";
						i=objSetEducation.length;	
					}
				}
			}
			else
			{
				if(objSetEducation.checked==true){
					document.getElementById("EDUCATION_COMPLETED").value="["+objSetEducation.value+"]";
				}	
			}
		}
		var objSetLivingsituation = document.forms["frmBackground"].set_livingsituation;
		if(objSetLivingsituation!=null){
			if(objSetLivingsituation.length!=undefined){
				for(var i = 0; i < objSetLivingsituation.length;i++){
					if(objSetLivingsituation[i].checked==true){
						document.getElementById("LIVING_SITUATION").value="["+objSetLivingsituation[i].value+"]";
						i=objSetLivingsituation.length;	
					}
				}
			}
			else
			{
				if(objSetLivingsituation.checked==true){
					document.getElementById("LIVING_SITUATION").value="["+objSetLivingsituation.value+"]";
				}	
			}
		}
		var objSet_educationcurrent = document.forms["frmBackground"].set_educationcurrent;
		if(objSet_educationcurrent!=null){
			if(objSet_educationcurrent.length!=undefined){
				for(var i = 0; i < objSet_educationcurrent.length;i++){
					if(objSet_educationcurrent[i].checked==true){
						document.getElementById("EDUCATION_CURRENT").value="["+objSet_educationcurrent[i].value+"]";
						i=objSet_educationcurrent.length;	
					}
				}
			}
			else
			{
				if(objSet_educationcurrent.checked==true){
					document.getElementById("EDUCATION_CURRENT").value="["+objSet_educationcurrent.value+"]";
				}	
			}
		}
		var objSet_workcurrent = document.forms["frmBackground"].set_workcurrent;
		if(objSet_workcurrent!=null){
			if(objSet_workcurrent.length!=undefined){
				for(var i = 0; i < objSet_workcurrent.length;i++){
					if(objSet_workcurrent[i].checked==true){
						document.getElementById("WORK_CURRENT").value="["+objSet_workcurrent[i].value+"]";
						i=objSet_workcurrent.length;	
					}
				}
			}
			else
			{
				if(objSet_workcurrent.checked==true){
					document.getElementById("WORK_CURRENT").value="["+objSet_workcurrent.value+"]";
				}	
			}
		}
		var objSet_workcurrenthours = document.forms["frmBackground"].set_workcurrenthours;
		if(objSet_workcurrenthours!=null){
			if(objSet_workcurrenthours.length!=undefined){
				for(var i = 0; i < objSet_workcurrenthours.length;i++){
					if(objSet_workcurrenthours[i].checked==true){
						document.getElementById("WORK_CURRENT_HOURS").value="["+objSet_workcurrenthours[i].value+"]";
						i=objSet_workcurrenthours.length;	
					}
				}
			}
			else
			{
				if(objSet_workcurrenthours.checked==true){
					document.getElementById("WORK_CURRENT_HOURS").value="["+objSet_workcurrenthours.value+"]";
				}	
			}
		}
		var objSet_income = document.forms["frmBackground"].set_income;
		if(objSet_income!=null){
			if(objSet_income.length!=undefined){
				for(var i = 0; i < objSet_income.length;i++){
					if(objSet_income[i].checked==true){
						document.getElementById("INCOME").value="["+objSet_income[i].value+"]";
						i=objSet_income.length;	
					}
				}
			}
			else
			{
				if(objSet_income.checked==true){
					document.getElementById("INCOME").value="["+objSet_income.value+"]";
				}	
			}
		}
		var objSet_ATTRIBUTE_76 =document.forms["frmBackground"].set_ATTRIBUTE_76;
		if(objSet_ATTRIBUTE_76!=null){
			if(objSet_ATTRIBUTE_76.length!=undefined){
				for(var i = 0; i < objSet_ATTRIBUTE_76.length;i++){
					if(objSet_ATTRIBUTE_76[i].checked==true){
						document.getElementById("ATTRIBUTE_76").value="["+objSet_ATTRIBUTE_76[i].value+"]";
						i=objSet_ATTRIBUTE_76.length;	
					}
				}
			}
			else
			{
				if(objSet_ATTRIBUTE_76.checked==true){
					document.getElementById("ATTRIBUTE_76").value="["+objSet_ATTRIBUTE_76.value+"]";
				}	
			}
		}
		
		
		var dteNowStart = new Date();
		var intStartYeardteNowStart = dteNowStart.getFullYear() 
		var intTempValue = "";
		if(blnComposeBirthDates == true){
			//[1978-12-29,F]
			var setValues=true;
			var e = document.getElementById("container_child_in_house").getElementsByTagName("tr");
			if(e.length>0){
				var strTemp="";
				for(var i = 0; i<e.length;i++){
					if(e[i].getAttribute("id")!=undefined && e[i].getAttribute("id")!="" ){
						
						var tempCount = GetID(e[i].getAttribute("id"),"child_in_house");
						var tempYear = myTrim(document.getElementById("child_in_house_birthyear"+tempCount).value);
						if(tempYear != "" && parseFloat(tempYear) > (intStartYeardteNowStart - 100)){
							var arrDates = new Array();
							arrDates["year"] = myTrim(document.getElementById("child_in_house_birthyear"+tempCount).value);
							arrDates["month"] = parseFloat(myTrim(document.getElementById("child_in_house_birthmonth"+tempCount).value))-1;
							arrDates["day"] = myTrim(document.getElementById("child_in_house_birthday"+tempCount).value);
							
							var blnCheckBirthDate = isValidBirthDate(arrDates);
							
							if(blnCheckBirthDate==true){
								strTemp=strTemp+"[";
								strTemp=strTemp+document.getElementById("child_in_house_birthyear"+tempCount).value;
								strTemp=strTemp+"-";
								intTempValue = parseFloat(myTrim(document.getElementById("child_in_house_birthmonth"+tempCount).value));
								if(intTempValue < 10){
									intTempValue = "0"+intTempValue;
								}
								strTemp=strTemp+intTempValue;
								strTemp=strTemp+"-";
								intTempValue = parseFloat(myTrim(document.getElementById("child_in_house_birthday"+tempCount).value));
								if(intTempValue < 10){
									intTempValue = "0"+intTempValue;
								}
								strTemp=strTemp+intTempValue;
								strTemp=strTemp+",";
								
								for(var y=0;y<document.forms["frmBackground"]["child_in_house_gender"+tempCount].length;y++){
									if(document.forms["frmBackground"]["child_in_house_gender"+tempCount][y].checked==true){
										strTemp=strTemp+document.forms["frmBackground"]["child_in_house_gender"+tempCount][y].value;
										y=document.forms["frmBackground"]["child_in_house_gender"+tempCount].length;
									}
								}	
								strTemp=strTemp+"]";
								clearAlert("frmBackground","child_in_house_birthdate"+tempCount);
							}
							else
							{
								setAlert("frmBackground","child_in_house_birthdate"+tempCount);
								strResponse = textBirthdateDontExcists;
								setValues = false
							
							}
						}
						else
						{
								
							setAlert("frmBackground","child_in_house_birthyear"+tempCount);
							strResponse = textYearOutOfRange;
							setValues = false;
						}
					}
				}
				if(setValues == true){
					document.getElementById("CHILDREN_IN_HOUSE_BIRTHDATES").value=strTemp;
				}
			}
			
			//var e = document.getElementById("container_child_out_house").getElementsByTagName("div");
			var e = document.getElementById("container_child_out_house").getElementsByTagName("tr");
			if(e.length>0){
				//var tempCount = GetID(e[e.length-1].id,"child_in_house");
				var strTemp="";
				for(var i = 0; i<e.length;i++){
					
					if(e[i].getAttribute("id")!=undefined && e[i].getAttribute("id")!=""){
						
						var tempCount = GetID(e[i].getAttribute("id"),"child_out_house");
					
						//var tempYear = myTrim(document.getElementById("child_out_house_birthyear"+i).value);
						var tempYear = myTrim(document.getElementById("child_out_house_birthyear"+tempCount).value);
						if(tempYear != "" && parseFloat(tempYear) > (intStartYeardteNowStart - 100)){
							var arrDates = new Array();
							arrDates["year"] = myTrim(document.getElementById("child_out_house_birthyear"+tempCount).value);
							arrDates["month"] = parseFloat(myTrim(document.getElementById("child_out_house_birthmonth"+tempCount).value))-1;
							arrDates["day"] = myTrim(document.getElementById("child_out_house_birthday"+tempCount).value);
							var blnCheckBirthDate = isValidBirthDate(arrDates);
							
							if(blnCheckBirthDate==true){
							
								strTemp=strTemp+"[";
								strTemp=strTemp+document.getElementById("child_out_house_birthyear"+tempCount).value;
								strTemp=strTemp+"-";
								intTempValue = parseFloat(myTrim(document.getElementById("child_out_house_birthmonth"+tempCount).value));
								if(intTempValue < 10){
									intTempValue = "0"+intTempValue;
								}
								strTemp=strTemp+intTempValue;
								strTemp=strTemp+"-";
								intTempValue = parseFloat(myTrim(document.getElementById("child_out_house_birthday"+tempCount).value));
								if(intTempValue < 10){
									intTempValue = "0"+intTempValue;
								}
								strTemp=strTemp+intTempValue;
								strTemp=strTemp+",";
								
								for(var y=0;y<document.forms["frmBackground"]["child_out_house_gender"+tempCount].length;y++){
									if(document.forms["frmBackground"]["child_out_house_gender"+tempCount][y].checked==true){
										strTemp=strTemp+document.forms["frmBackground"]["child_out_house_gender"+tempCount][y].value;
										y=document.forms["frmBackground"]["child_out_house_gender"+tempCount].length;
									}
								}	
								strTemp=strTemp+"]";
								clearAlert("frmBackground","child_out_house_birthdate"+tempCount);
							}
							else
							{
								setAlert("frmBackground","child_out_house_birthdate"+tempCount);
								strResponse = textBirthdateDontExcists;
								setValues = false
							}
						}
						else
						{
								setAlert("frmBackground","child_out_house_birthyear"+i);
								strResponse = textYearOutOfRange;
								setValues = false
						}
					}
				}
				if(setValues == true){
					document.getElementById("CHILDREN_OUT_HOUSE_BIRTHDATES").value=strTemp;
				}
			}
		}
		
		if(setValues == false){
			alert(strResponse);
			blnFormSubmit = false;
			blnOnValidate = false;
			document.getElementById("btn_OK").disabled=false;
			return false;
		}
		else
		{
		return true;	
		}
	}
	else
	{
		blnFormSubmit = false;
		blnOnValidate = false;
		document.getElementById("btn_OK").disabled=false;
		return false;
	}
}


function HeartBeatSite(){
	var img = new Image(1,1);
	img.src = "/lpz-configuration/configuration/templates/scripts/checkSessionMember.qms?x="+escape(new Date());
}

function validateSendToFriend(strWrongEmailaddress){
	var blnCorrectEmail;
	var blnMyReturn = true;
	var strAlert="";
	var strEmail="";
	
	var btnOk = document.getElementById("btnOkSendToFriend");
	if(btnOk!=null){
		btnOk.disabled=true;
	}
	
	var	e = document.getElementById("frmSendToFriend").getElementsByTagName("input");
	
	for(var i = 0; i < e.length;i++){
		if(e[i].type.toUpperCase()=="TEXT"){
			if( e[i].name.indexOf('NAME_')==-1 && e[i].name.indexOf('EMAIL')!=-1 && e[i].value!=""){
				blnCorrectEmail = echeck(e[i].value);
				if(blnCorrectEmail==false){
					strAlert = strWrongEmailaddress;
					blnMyReturn = false;
					document.getElementById("frmSendToFriend"+ e[i].name).className="clsLabelAlert";
				}
				else
				{
					document.getElementById("frmSendToFriend"+ e[i].name).className="clsLabel";
				}
			}
		}
	}
	
	if(blnMyReturn==true){
		if(validate('frmSendToFriend')==true){
	 		document.getElementById("frmSendToFriend").submit();
		}
		else
		{
			if(btnOk!=null){
				btnOk.disabled=false;
			}
			//return false;
		}
	}
	else
	{
		if(btnOk!=null){
				btnOk.disabled=false;
		}
		alert(strAlert);
		//return false;
	}	
}


function validateFormRegister(){
	if(validate("frmRegister","btnOkfrmRegister")==true){
		document.getElementById("frmRegister").submit()
	}
}

function checkObj(obj,objId){
	
	var tempObj = document.getElementById(objId);
	if(myTrim(obj.value)!="" && tempObj!=null){
		tempObj.checked=true;
		obj.setAttribute("required","true");
	}
}

function confirmUnregister(idForm,idBtn, strConfirmMessage){
	
	if(strConfirmMessage==undefined||strConfirmMessage==""){
		strConfirmMessage = "Geen vertaling voor bevestiging uitschrijven! : textConfirmUnregister"
	}
	
	if(validate(idForm,idBtn)==true){
		
		var objForm = document.getElementById(idForm);
		
		if(objForm!=null){
			if (confirm(strConfirmMessage)==true){
				objForm.submit();	
			}
			else
			{
				blnFormSubmit = false;
				var objBtn = document.getElementById(idBtn);
				if(objBtn!=null){
					objBtn.disabled=false;
				}	
			}
		}
	}
}

function MyLoginAs(mem,pwd){

var objForm = document.getElementById("frmLoginAs");
if(mem!= undefined && pwd != undefined && objForm!=null){
		if(mem != "" && pwd != ""){
			document.getElementById("frmLoginAs_USERCODE").value=mem;
			document.getElementById("frmLoginAs_PASSWORD").value=pwd;
			objForm.submit();
		}
	}
}

//tooltip
/*
ddrivetip('TEXT TO DISPLAY', 'OPTIONAL BACKGROUND COLOR', OPTIONAL TIP WIDTH)
The last two parameters are optional, and not specifying them causes the script to default to the settings within your CSS file. With that in mind, here are a few actual usage examples:
<a href="http://www.yahoo.com" onMouseover="ddrivetip('Visit Yahoo.com')";
 onMouseout="hideddrivetip()">Search Engine</a>
 <DIV onMouseover="ddrivetip('This DIV has a tip!', '#EFEFEF')";
 onMouseout="hideddrivetip()">Some text here. Some text here.</div>
 <a href="http://yahoo.com" onMouseover="ddrivetip('Yahoo\'s Site', 'yellow', 250)";
 onMouseout="hideddrivetip()">Yahoo</a>
 One last important point: If your tooltip description contains apostrophes ('), be sure to backslash them first, as illustrated in the last example ("Yahoo\'s Site"), or an error will occur.
*/

var enabletip=false;
var ie=document.all;
var ns6=document.getElementById && !document.all;
var offsetxpoint=-20 //Customize x offset of tooltip;
var offsetypoint=20 //Customize y offset of tooltip;
var tipobj;
function initToolTip(){
	if (ie||ns6){
		tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";
	}
	document.onmousemove=positiontip;
}

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth, thePadding, theFontSize){
	if(tipobj==undefined){
		return;
	}
	if (ns6||ie){
		if (typeof thewidth!="undefined" && thewidth!=""){ 
			tipobj.style.width=thewidth+"px";
		}
		if (typeof thePadding!="undefined" && thePadding!=""){ 
			tipobj.style.padding=thePadding+"px";
		}
		if (typeof theFontSize!="undefined" && thecolor!=""){ 
			tipobj.style.fontSize=theFontSize;
		}
		if (typeof thecolor!="undefined" && thecolor!=""){ 
			tipobj.style.backgroundColor=thecolor;
			tipobj.innerHTML=thetext;
			enabletip=true;
			return false
		}
	}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
	
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
	
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth){
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
		}
		else if (curX<leftedge){
			tipobj.style.left="5px";
		}
		else
		{
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px";
		}
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight){
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
		}
		else
		{
			tipobj.style.top=curY+offsetypoint+"px"
			tipobj.style.visibility="visible"
		}
	}
}

function hideddrivetip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

function openDashBoard(strAction,strMemValue, strTextClose, strPath){
	if(strMemValue==""){
		return;
	}
	var objBody = $("body");
	var objWrapper = $("#portaal-wrapper");
	var intScreenWidth = getMyBodyWidth();
	var intScreenHeight = getMyBodyHeight();
	var objOverLayDashboard = $("#dashboardContainer");
	var objOverLayDashboardBackGround = $("#dashboardBackground");
	var objOverLayDashboardControl = $("#dashboardBackgroundControl");
	var containerDivDashboard = $("#silverlightControlHost");
	switch(strAction){
		case "show":
		
			var myDisplayW = parseFloat(objBody.width());
			var myDisplayH = parseFloat(objWrapper.height());
			
			if(myDisplayH < intScreenHeight){
				myDisplayH = intScreenHeight;
			}
			myDisplayH = myDisplayH - 10;
			
			if(objOverLayDashboardBackGround.length==0){
				var newDiv = $("<div>");
				newDiv.attr("id","dashboardBackground");
				newDiv.attr("class","clsOverLayDashBoardBackGround");
				$("body").append(newDiv);
				objOverLayDashboardBackGround = $("#dashboardBackground");
			}
			
			if(objOverLayDashboard.length==0){
				var newDivOverLayDashboard = $("<div>");
				newDivOverLayDashboard.attr("id","dashboardContainer");
				newDivOverLayDashboard.attr("class","clsOverLayDashboard");
				$("body").append(newDivOverLayDashboard);
				objOverLayDashboard = $("#dashboardContainer");
				
				var newDiv = $("<div>");
				newDiv.attr("id","dashboardBackgroundControl");
				newDiv.attr("class","clsOverLayControl");
				newDivOverLayDashboard.append(newDiv);
				
				
				var newA = $("<a>").html(strTextClose);
				newA.attr("href","javascript: openDashBoard('hide')");
				newDiv.append(newA);
				objOverLayDashboardControl = $("#dashboardBackgroundControl");
				
				/*var myA_H = parseFloat(objOverLayDashboardControl.height());
				var newDivDashboard = $("<div>");
				newDivDashboard.attr("id","silverlightControlHost");
				newDivOverLayDashboard.append(newDivDashboard);
				newDivDashboard.css("width",myDisplayW+"px");
				newDivDashboard.css("height",(myDisplayH-myA_H)+"px");
				containerDivDashboard = $("#silverlightControlHost");
				*/
				 
			}
		
			
		
			objOverLayDashboardBackGround.css("width",myDisplayW+"px");
			objOverLayDashboardBackGround.css("height",myDisplayH+"px");
			
			objOverLayDashboard.css("width",myDisplayW+"px");
			objOverLayDashboard.css("height",myDisplayH+"px");
			
			objOverLayDashboardBackGround.show();
			objOverLayDashboard.show();
			
			
			if(containerDivDashboard.length==0){
				var myA_H = parseFloat(objOverLayDashboardControl.height());
			
				var newDivDashboard = $("<div>");
				newDivDashboard.attr("id","silverlightControlHost");
				objOverLayDashboard.append(newDivDashboard);
				newDivDashboard.css("width",myDisplayW+"px");
				newDivDashboard.css("height",(myDisplayH-myA_H)+"px");
				containerDivDashboard = $("#silverlightControlHost");
			}
			
			containerDivDashboard.html(embedSilverlight(null, "sl1", "", strMemValue,strPath));
			
			$(window).bind({
				resize : function(){
					resizeDashboard(objBody,objWrapper,objOverLayDashboardBackGround,objOverLayDashboard,objOverLayDashboardControl,containerDivDashboard)
				}
			});

		
		break;
	case "hide":
	
		if(containerDivDashboard.length!=0){
			containerDivDashboard.html("");
		}
		if(objOverLayDashboard.length!=0){
			objOverLayDashboard.hide();
		}
		if(objOverLayDashboardBackGround.length!=0){
			objOverLayDashboardBackGround.hide();
		}
		
		$(window).unbind("resize");
	break;
	}
	
}

function embedSilverlight(parentElement, pluginId, userContext, intValueParams,path) {
    var altHtml = pluginId == "sl1" ? null : "<!--not installed-->";
    
    return Silverlight.createObject(path,
    parentElement,
    pluginId,
    {
        width: "100%", height: "100%", 
        background: "white", alt: altHtml, 
        version:"4.0.50826.0", autoUpgrade:"true",
        initParams:intValueParams
    },
    { onError: onSLError, onLoad: onSLLoad },
    "", 
    userContext);
}

function onSLLoad(plugIn, userContext, sender) {
    window.status +=
        plugIn.id + " loaded into " + userContext + ". ";
}

function onSLError(sender, args) {
    // Display error message.
}

function resizeDashboard(objBody,objWrapper,objBackGround,objContainer,objControl,objSilverLight){

	if(objBody==null){
		return;
	}
	
	var intScreenWidth = getMyBodyWidth();
	var intScreenHeight = getMyBodyHeight();
	
	
	var myDisplayW = parseFloat(objBody.width());
	var myDisplayH = parseFloat(objWrapper.height());
	if(myDisplayH < intScreenHeight){
			myDisplayH = intScreenHeight;
	}
	myDisplayH = myDisplayH - 10;

	
	var myA_H = parseFloat(objControl.height());
	var intBackGroundWidth = intScreenWidth;
	if(intBackGroundWidth < objWrapper.width()){
		intBackGroundWidth = objWrapper.width()
	}
	
	objBackGround.css("width",intBackGroundWidth+"px");
	objBackGround.css("height",myDisplayH+"px");
			
  objContainer.css("width",myDisplayW+"px");
	objContainer.css("height",myDisplayH+"px");
	
	objSilverLight.css("width",myDisplayW+"px");
	objSilverLight.css("height",(myDisplayH-myA_H)+"px");
	
}


var $activeObjMessage = null;
var blnDoSubmitForm = true;


function sendFormByAjax(objCollection){
	if(blnDoSubmitForm==false){
		return;
	}
	var strIdContainerMessage = $.trim(getCollectionValue(objCollection,"strIdContainerMessage",""));
	var strActionUrl = $.trim(getCollectionValue(objCollection,"strActionUrl",""));
	var idForm = $.trim(getCollectionValue(objCollection,"idForm",""));
	var lanQms = $.trim(getCollectionValue(objCollection,"lanQms",""));
	var strMem = $.trim(getCollectionValue(objCollection,"mem",""));
	var strFormType = $.trim(getCollectionValue(objCollection,"formtype",""));
	var idCheckDashboard = $.trim(getCollectionValue(objCollection,"idCheckDashboard",""));
	var idContainer = $.trim(getCollectionValue(objCollection,"idContainer",""));
	var textForgotRequiredField = $.trim(getCollectionValue(objCollection,"textForgotRequiredField",""));
	var strFormaction = $.trim(getCollectionValue(objCollection,"formaction","")); 
	var strRef = $.trim(getCollectionValue(objCollection,"strRef","")); 
	var $containerMessage = $("#"+strIdContainerMessage);
	var blnAdd_account = getCollectionValue(objCollection,"add_account","false");
	var strIdSurvey = getCollectionValue(objCollection,"idSurvey","");
	var strDepnr = getCollectionValue(objCollection,"depcode","");
	var blnAddDep = getCollectionValue(objCollection,"add_dep","false");
	var strMessageAlphaNumeric = getCollectionValue(objCollection,"messageAlphaNumeric","");
	var strTextEmailDontMatch = getCollectionValue(objCollection,"textEmailDontMatch","");
	var strAlertErrorInEmailAddress = getCollectionValue(objCollection,"alertErrorInEmailAddress","");
	var strIdCheckBox = getCollectionValue(objCollection,"idCheckBox","");
	
	
	var blnFormValid = true;
	var blnFormValidAlphaNumeric = true;
	var strData="";
	var strTempValue;
	var strTempName;
	var strEmail="";
	var strEmailCheck = "";
	var strObjEmailName="";
	
	if(strActionUrl.indexOf("?")==-1){
		var strDate = Date();
		strDate = escape(strDate);
		strActionUrl = strActionUrl +"?ts"+strDate
	}
	
	$containerMessage.css("display","none").html("");
	$activeObjMessage = $containerMessage;
	
	if(idCheckDashboard !=""){
		var $objCheckDashboard = $("#"+idCheckDashboard);
		if($objCheckDashboard.length==0){
			return;
		}
		var strValue = "N";
		if($objCheckDashboard[0].checked==true){
			strValue = "Y";
		}
		if(strData!=""){
			strData = strData+"&";
		}
		strData = strData+"attr83="+strValue;
	}
	else if(blnAdd_account==true && idContainer!=""){
		//alert("idContainer = " + idContainer)
		if(strData!=""){
			strData = strData+"&";
		}
		strData = strData+"new=true";
	}
	
	if(strFormaction == "set_survey_completed"){
		var strMesQuestionnairesAreCompleted = getCollectionValue(objCollection,"strMesQuestionnairesAreCompleted","");
		var strMesSureToFillInQuestionnaires = getCollectionValue(objCollection,"strMesSureToFillInQuestionnaires","");
		if(strIdCheckBox==""){
			return;
		}
		var strQuestion;
		var strValueAttribute52;
	
		var obj52 = document.getElementById(strIdCheckBox);
		if(obj52 == null){
			return;
		}
		var blnResetObj52;
		if(obj52.checked==true){
			strQuestion = strMesQuestionnairesAreCompleted;
			strValueAttribute52 = "Y";
			blnResetObj52 = false;
		}
		else
		{
			strQuestion = strMesSureToFillInQuestionnaires;
			strValueAttribute52 = "N";
			blnResetObj52 = true
		}
		if(confirm(strQuestion)==false){
			obj52.checked = blnResetObj52;
			return;
		}
		if(strData!=""){
			strData = strData+"&";
		}
		strData = strData+"ATTRIBUTE_52="+escape(strValueAttribute52);
		//create arr
		var $arrInput = $("#"+idForm+" #"+idContainer+" [ref='forminput']");
		$arrInput.attr("validated","false");
	
	}
	else if(strFormaction == "delete"){
		var strMessageConfirm = getCollectionValue(objCollection,"strMessageConfirm","");
		var strMessageNoSelection = getCollectionValue(objCollection,"strMessageNoSelection","");
		var $arrInput = $("#"+idForm+" #"+idContainer+" input[ref='"+strRef+"']:checked");
		var intObjFound = $arrInput.length;
		if(intObjFound==0){
			alert(strMessageNoSelection);
			return;
		}
		if(confirm(strMessageConfirm)==false){
			return;
		}
	}
	else
	{
		var $arrInput = $("#"+idForm+" #"+idContainer+" [ref='forminput']");
		$arrInput.attr("validated","false");
  }		
  	var $formInputElement;
  	$arrInput.each( function() {
  		$formInputElement = $(this);
  		strTempValue = $.trim($formInputElement.val());
  		strTempName = $formInputElement.attr("name");
  		
  		var strTempType = $formInputElement.attr('type');
  		if(strTempType!=undefined){
  			strTempType = strTempType.toUpperCase();
  		}
  		if(strTempType=="CHECKBOX"){
	  		var blnGroupCheckboxValid = true;
				var blnGroupRequired=false;
				var strGroupName = $formInputElement.attr("groupname");
				if(strGroupName!=undefined && strGroupName!=null && strGroupName!=""){
					if($formInputElement.attr("validated")!="true"){
						var intItemsRequired= $formInputElement.attr("items_required");
						if(intItemsRequired!=undefined && intItemsRequired!=null && intItemsRequired!=""){
							intItemsRequired = parseInt(intItemsRequired);
						}
						else
						{
							intItemsRequired = 0;
						}
						if(intItemsRequired>0){
							blnGroupRequired = true
							var arrGroupChecked = $("#"+idForm+" #"+idContainer+" input:checkbox[groupname='"+strGroupName+"']:checked")
							if(arrGroupChecked.length){
								var intGroupLengthChecked = arrGroupChecked.length;
							}
							else
							{
								var intGroupLengthChecked = 0;
							}
							if(intGroupLengthChecked<intItemsRequired){
								blnFormValid = false;
								blnGroupCheckboxValid = false;
							}
						}
						//else if($formInputElement.attr("checked")==true){
						//	blnInputGiven = true;
						//}	
						var $inputGroupElements = $("#"+idForm+" #"+idContainer+" input:checkbox[groupname='"+strGroupName+"']");
						var $inputGroupElement;
						$inputGroupElements.each( function() {
							$inputGroupElement = $(this);
							$inputGroupElement.attr("validated","true");
							var strNameTempElement = $inputGroupElement.attr("name");
							var strIdTempElement = $inputGroupElement.attr("id");
							//if($inputGroupElement.attr("checked")==true||$inputGroupElement.attr("checked")=="checked"){
							if (getObjAttrChecked($inputGroupElement)){
								if(strData!=""){
									strData = strData+"&";
								}
								strData += strNameTempElement + "=" + escape($inputGroupElement.val()); //
								if(blnGroupRequired==true){
									clearAlert(idContainer,strIdTempElement);
								}
							}
							else
							{
								
								if(blnGroupRequired==true&&blnGroupCheckboxValid == false){
									blnFormValid = false;
									//containerFrmSubscribeForSurvey , surveycode_1
									setAlert(idContainer,strIdTempElement);
								}
								else if(blnGroupRequired==true&&blnGroupCheckboxValid == true){
									clearAlert(idContainer,strIdTempElement);
								}
								if(strData!=""){
									strData = strData+"&";
								}
								strData += strNameTempElement + "=off";
							}
						});
					}
				}
				else
				{
					//if($formInputElement.attr("checked")==true||$formInputElement.attr("checked")=="checked"){
					if (getObjAttrChecked($formInputElement)){
						if(strData!=""){
							strData = strData+"&";
						}
						strData += strTempName + "=" + escape($formInputElement.val()); //
						if($formInputElement.attr("required")=="required" || $formInputElement.attr("required")==true){
							clearAlert(idContainer,strTempName);
						}
					}
					else
					{
						if($formInputElement.attr("required")=="required" || $formInputElement.attr("required")==true){
							blnFormValid = false;
							setAlert(idContainer,strTempName);
						}
						if(strData!=""){
							strData = strData+"&";
						}
						strData += strTempName + "=off";
					}
				}
	  	
	  	
	  	}
	  	else if(strTempType=="RADIO"){
	  			if($formInputElement.attr("validated")!="true"){
		  			var strTempval = $("#"+idForm+" input:radio[name='"+strTempName+"']:checked").val();
		  			$("#"+idForm+" input:radio[name='"+strTempName+"']").attr("validated","true");
		  			if(strTempval!=undefined&&strTempval!=""){
		  				if(strData!=""){
								strData = strData+"&";
							}
		  				strData += strTempName + "=" + escape(strTempval); //
		  				if($formInputElement.attr("required")=="required" || $formInputElement.attr("required")==true){
	  						//library.js
	  						clearAlert(idContainer,strTempName);
	  					}
		  			}
		  			else
		  			{
		  				//strData += strTempName + "=off&";
		  				if($formInputElement.attr("required")=="required" || $formInputElement.attr("required")==true){
		  					blnFormValid = false;
		  					//library.js
		  					setAlert(idContainer,strTempName);
		  				}
		  			}
	  			}
	  	}
	  	else if(strTempType=="SELECT-MULTIPLE"){
	  			$("#"+$formInputElement.attr('id')+" option").each(function(i) {  
						var $option = $(this);
						$option.attr("selected", "selected");  
					}); 
	  			var strTempVal = $.map($formInputElement, function(e) {return $(e).val(); });
	  			if(strData!=""){
							strData = strData+"&";
						}
	  			strData += strTempName + "=" + escape(strTempVal); //
	  			if(strTempVal!=""){
	  				if($formInputElement.attr("required")=="required"  || $formInputElement.attr("required")==true){
	  					//library.js
	  					clearAlert(idContainer,strTempName);
	  				}
	  			}
	  			else
	  			{
	  				if($formInputElement.attr("required")=="required"  || $formInputElement.attr("required")==true){
	  					blnFormValid = false;
	  					//library.js
	  					setAlert(idContainer,strTempName);
	  				}
	  			}
	  	}
	  	else
	  	{
  		
		  		if(strTempName!="new_mem_id"){
			  		
			  		if(strTempName.toUpperCase()=="EMAIL"||strTempName.toUpperCase()=="LBLEMAIL"){
			  			strEmail = strTempValue;
			  			strObjEmailName = strTempName;
			  		}
			  		if(strTempName.toUpperCase()=="EMAILCHECK"||strTempName.toUpperCase()=="LBLEMAILREPEAT"){
			  			strEmailCheck = strTempValue;
			  		}
			  		
			  		if(strData!=""){
							strData = strData+"&";
						}
			  		strData = strData+strTempName+"="+escape(strTempValue);
			  		var blnRequiredValid = true;
			  		var attrRequired = $formInputElement.attr("required");
			  		if(attrRequired=="true"||attrRequired=="required"){
			  			if(strTempValue==""){
			  				setAlert(idContainer,strTempName);
			  				blnFormValid = false;
			  				blnRequiredValid = false;
			  			}
			  			else
			  			{
			  				clearAlert(idContainer,strTempName);
			  			}
			  		}
		  			var attrOnlyAlphaNumeric = $formInputElement.attr("only_alpha_numeric");
			  		if((attrOnlyAlphaNumeric=="true"||attrOnlyAlphaNumeric=="only_alpha_numeric")&&strTempValue!=""){
			  			if(alphaNumericCheck(strTempValue)==false){
			  				setAlert(idContainer,strTempName);
			  				blnFormValidAlphaNumeric = false;
			  			}
			  			else
			  			{
			  				if(blnRequiredValid==true){
			  					clearAlert(idContainer,strTempName);
			  				}
			  			}
			  		}
		  		}
		  }
		});
		var strAlert = ""
		if(blnFormValid == false){
			if(strAlert!=""){
				strAlert = strAlert + "\n";
			}
			strAlert = strAlert + textForgotRequiredField;
		}
		if(blnFormValidAlphaNumeric==false){
			if(strAlert!=""){
				strAlert = strAlert + "\n";
			}
			strAlert = strAlert + strMessageAlphaNumeric;
		}
		
		if(strEmail!=""&&strEmailCheck!=""&&blnFormValid==true&&blnFormValidAlphaNumeric==true){
			if(echeck(strEmail)==false){
				blnFormValid = false;
				if(strAlert!=""){
					strAlert = strAlert + "\n";
				}
				strAlert = strAlert + strAlertErrorInEmailAddress
				setAlert(idContainer,strObjEmailName);
			}
			else if(strEmail!=strEmailCheck){
				blnFormValid = false;
				if(strAlert!=""){
					strAlert = strAlert + "\n";
				}
				strAlert = strAlert + strTextEmailDontMatch
				setAlert(idContainer,strObjEmailName);
			}
			else
			{
					clearAlert(idContainer,strObjEmailName);
			}
		
		}
		
		
		if(blnFormValid==false || blnFormValidAlphaNumeric==false){
			alert(strAlert);
			return;
		}
		
	
	if(strData==""){
		return;
	}
	
	if(strData!=""){
			strData = strData+"&";
		}
	strData = strData+"mem="+strMem+"&lanQms="+lanQms+"&formtype="+strFormType+"&container="+idContainer+"&messagecontainer="+strIdContainerMessage+"&idForm="+idForm;
	
	if(strIdSurvey!=""){
		if(strData!=""){
			strData = strData+"&";
		}
		strData = strData+"survey="+strIdSurvey;
	}
	if(strDepnr!=""){
		if(strData!=""){
			strData = strData+"&";
		}
		strData = strData+"depcode="+strDepnr;
	}
	
	if(blnAddDep.toString()=="true"){
		if(strData!=""){
			strData = strData+"&";
		}
		strData = strData+"adddep=true";
		
	}
	
	//alert(strData);
	//return
	
	var blnHandleRequest = true;
	
	showOverlayOnSubmit({"action":"show","container":idForm});
		
	blnDoSubmitForm = false;
	$.ajax({
		type: "POST",
		cache:false,
		url: strActionUrl,
		data: strData,
		complete: function(XMLHttpRequest){
			blnDoSubmitForm = true;
			if(blnHandleRequest == true){
				var response = XMLHttpRequest.responseText;
				//alert(response)
				response = cmsUnescapeResponse(response);	
				
				var strMessage = "";
				if(response.indexOf('foo}{') != -1) {
					response = response.replace("foo}{","");
					if(response.indexOf('{') != -1 && response.indexOf(':') != -1) {
						var obj = $.parseJSON(response);
						//alert(obj.reloadform)
						if(obj.reloadform=="true"){
							blnDoSubmitForm = true;
							getHtmlByAjax(obj)
						}
						if(obj.result == parseFloat(obj.result)){
							if (obj.result < 0){
								if(obj.message!=undefined){
									strMessage = obj.message
								}
								var strAddClass = "clsMessageNegative";
								var strRemoveClass = "clsMessagePositive";
							}
							else if(obj.result>-1){
								if(obj.message!=undefined){
									strMessage = obj.message
								}
								var strAddClass = "clsMessagePositive";
								var strRemoveClass = "clsMessageNegative";
							}
							
							if($containerMessage!=null && strMessage!=""){
								$containerMessage.html(strMessage).removeClass(strRemoveClass).addClass(strAddClass).show();
							}
							if(obj.scrollToTop=="true" && $containerMessage!=null){
								var positionTop = getY($containerMessage[0])-20;
								if(positionTop < 0){
										positionTop = 0;
								}
								$(window).scrollTop(positionTop);
							}
							
						}
					}
				}
			}
			showOverlayOnSubmit({"action":"hide","container":idForm});
		},
		error:function (XMLHttpRequest, strTemp, errorThrown) {
		  // typically only one of textStatus or errorThrown 
		  // will have info
		  //this; // the options for this ajax request
			if(errorThrown!=undefined){
				blnHandleRequest = false;
			}
			//alert(XMLHttpRequest.responseText)
			$containerMessage.html(XMLHttpRequest.responseText).show();
		}
	});
	
	
}

function getY(oElement) {
    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}


function showOverlayOnSubmit(objCollection){
	
	var strAction = getCollectionValue(objCollection,"action","");
	var strObjContainer =  getCollectionValue(objCollection,"container","");
	var blnShowProcessingMessage = getCollectionValue(objCollection,"blnShowProcessingMessage","");
	if(blnShowProcessingMessage==""){
		blnShowProcessingMessage=true;
	}
	
	strObjContainer = $.trim(strObjContainer);
	var objFormContainer = $("#"+strObjContainer);

	if(objFormContainer.length==0){
		return;	
	}
	
	var messageInOverLay = strObjContainer + "messageInOverLayOnSubmit";
	var overLayOnSubmitBackGround = strObjContainer+"OverLayOnSubmitBackGround";
	var objOverLayOnSubmitBackGround = $("#"+overLayOnSubmitBackGround);
	
	var overLayOnSubmit = strObjContainer+"OverLayOnSubmit"
	var objOverLayOnSubmit = $("#"+overLayOnSubmit);
		
	switch(strAction){
		case "show":
			
			var myDisplayW = parseFloat(objFormContainer.width());
			var myDisplayH = parseFloat(objFormContainer.height());
		
			if(objOverLayOnSubmit.length==0){
				var newDiv = $("<div>");
				newDiv.attr("id",overLayOnSubmit);
				newDiv.attr("class","clsOverLayOnSubmit");
				objFormContainer.prepend(newDiv);
				objOverLayOnSubmit = $("#"+overLayOnSubmit);
			}
			if(objOverLayOnSubmitBackGround.length==0){
				var newDiv = $("<div>");
				newDiv.attr("id",overLayOnSubmitBackGround);
				newDiv.attr("class","clsOverLayOnSubmitBackGround");
				objFormContainer.prepend(newDiv);
				objOverLayOnSubmitBackGround = $("#"+overLayOnSubmitBackGround);
			}
		
			if(blnShowProcessingMessage==true){
				var objmessageInOverLayOnSubmit = $("#"+messageInOverLay);
				
				if(objmessageInOverLayOnSubmit.length==0){
					var newDivMessage = $("<div>").html("<span>Processing...</span>");
					$(newDivMessage).attr("id",messageInOverLay);
					$(objOverLayOnSubmit).append(newDivMessage);
					var span_message_css = {
					    "margin":myDisplayH/2+"px 30px 0px 30px",
						"background-color":"#fff",
						"border":"1px solid #606061",
						"padding":"3px",
						"display":"block"
					 }
					
					$("#"+overLayOnSubmit+" span").css(span_message_css);
				}
			}

			objOverLayOnSubmitBackGround.css("width",myDisplayW+"px");
			objOverLayOnSubmitBackGround.css("height",myDisplayH+"px");
			
			objOverLayOnSubmit.css("width",myDisplayW+"px");
			objOverLayOnSubmit.css("height",myDisplayH+"px");
			
			objOverLayOnSubmitBackGround.show();
			objOverLayOnSubmit.show();
			
		
		break;
	case "hide":
		if(objOverLayOnSubmit.length!=0){
			objOverLayOnSubmit.hide();
		}
		if(objOverLayOnSubmitBackGround.length!=0){
			objOverLayOnSubmitBackGround.hide();
		}
	break;
	}
	
}

function toggleCheckbox(obj,containerId,strRef){
	var blnCheck = obj.checked;

	$("#"+containerId+" input[ref='"+strRef+"']").each( function() {
  		if($(this).attr('type').toUpperCase()=="CHECKBOX"){
  			if(blnCheck==true){
  				$(this)[0].checked=true;
  				//$(this).attr("checked","checked");
  			}
  			else
  			{
  				$(this)[0].checked=false;
  				//$(this).removeAttr("checked")
  			}
  	
  		}
	});
}

var t_getHtmlByAjax = null;

function setTypedSearch(objCollection){
	if(t_getHtmlByAjax!=null){
		clearTimeout(t_getHtmlByAjax);
		t_getHtmlByAjax = null;
	}
	
	t_getHtmlByAjax=setTimeout(function(){getHtmlByAjax(objCollection)},300);
	
}

function setActiveMessageContainer(idActiverMessageContainer){
	var $objTemp=$("#"+idActiverMessageContainer);
	if($objTemp.length>0){
		$activeObjMessage=$objTemp;
	}
}

function getHtmlByAjax(objCollection){
	
	if(blnDoSubmitForm==false){
		return;
	}
	
	if(t_getHtmlByAjax!=null){
		clearTimeout(t_getHtmlByAjax);
		t_getHtmlByAjax = null;
	}

	var blnHideMessage = getCollectionValue(objCollection,"blnHideMessage","true");
	var strIdContainerMessage = $.trim(getCollectionValue(objCollection,"strIdContainerMessage","containerMessageForm"));
	var strViewType = $.trim(getCollectionValue(objCollection,"strViewType","view"));
	var strIdContainer = $.trim(getCollectionValue(objCollection,"idContainer",""));
	var idForm = $.trim(getCollectionValue(objCollection,"idForm",""));
	var strActionUrl = $.trim(getCollectionValue(objCollection,"strActionUrl",""));
	var blnReplaceOuterHtml = getCollectionValue(objCollection,"blnReplaceOuterHtml","true");
	var lanQms = $.trim(getCollectionValue(objCollection,"lanQms",""));
	var strMem = $.trim(getCollectionValue(objCollection,"mem",""));
	var strFormType = $.trim(getCollectionValue(objCollection,"formtype",""));
	var strIdSurvey = $.trim(getCollectionValue(objCollection,"idSurvey",""));
	
	var strFieldname = $.trim(getCollectionValue(objCollection,"fieldname",""));
	var strSort = $.trim(getCollectionValue(objCollection,"sort",""));
	var strIdContainerFilter = $.trim(getCollectionValue(objCollection,"idContainerFilter",""));
	var strActionFilter = $.trim(getCollectionValue(objCollection,"actionFilter",""));
	var strMove = $.trim(getCollectionValue(objCollection,"move",""));
	var strIdListStep = $.trim(getCollectionValue(objCollection,"idListStep",""));
	var blnShowSame = $.trim(getCollectionValue(objCollection,"showSame","false"));
	var strDebnr = $.trim(getCollectionValue(objCollection,"depcode",""));
	
	var blnResetCounter = $.trim(getCollectionValue(objCollection,"resetCounter","false"));
	var strRef = $.trim(getCollectionValue(objCollection,"strRef",""));
	var strIdCounter = $.trim(getCollectionValue(objCollection,"idCounter",""));
	var strSurveycode = $.trim(getCollectionValue(objCollection,"surveycode",""));
	
	
	if(strActionUrl==""){
		return;
	}
	
	if(strActionUrl.indexOf("?")==-1){
		var strDate = Date();
		strDate = escape(strDate);
		strActionUrl = strActionUrl +"?ts"+strDate
	}
	
	var $containerMessage = $("#"+strIdContainerMessage);
	var $defaultContainer = $("#"+strIdContainer);
	
	if($defaultContainer.length==0){
		return;
	}
	
	var strQuery = "container="+escape(strIdContainer);
	if(strViewType!=""){
		strQuery+="&viewtype="+escape(strViewType);
	}
	
	if(strIdListStep!=""){
		var intStep = $("#"+strIdListStep).val();

		if(isNumber(intStep)==true){
			if(strQuery!=""){
					strQuery = strQuery+"&";
			}
	  	strQuery = strQuery+"step="+escape(intStep);
		}
	}
	
	if(blnShowSame.toString()=="true"){
		if(strQuery!=""){
				strQuery = strQuery+"&";
		}
  	strQuery = strQuery+"showsame=true";
	}
	
	/*{'abortUrl':'https://nld.test2.lpz-um.eu/index.html',
	'moveToLast':'true',
	'move':'1',
	'showSame':'false',
	'strIdContainerMessage':'messageContainerListSurveyPat',
	'idContainer':'reloadContainerSurveysPat',
	'idForm':'containerListSurveyPat',
	'idListStep':'list-survey-step',
	'actionFilter':'set',
	'blnReplaceOuterHtml':'false',
	'formtype':'2',
	'IdSurvey':'524',
	'formtype':'2',
	'lanQms':'Dutch',
	'strActionUrl':'https://nld.test2.lpz-um.eu/lpz-configuration/configuration/templates/scripts/getHtmlByAjax.qms?ts=407454917361111',
	
	'idContainerFilter':'containerListFilter'}*/
	
	var strTempValue = "";
	var strTempName = "";
	if(strIdContainerFilter!=""&&strActionFilter!=""){
		$arrFilterObjects = $("#"+strIdContainerFilter+ " [ref='filterItem']");
		if($arrFilterObjects.length>0){
			switch(strActionFilter){
				
				case"clear":
					if(strQuery!=""){
							strQuery = strQuery+"&";
					}
			  	strQuery = strQuery+"clearfilter="+escape("true");
					$arrFilterObjects.each( function() {
						switch($(this)[0].tagName.toUpperCase()){
							case "SELECT":
								$(this)[0].selectedIndex=0;
								break;
							default:
							$(this).val("");
							break;
						}
					});
				break;
				default:
					if(strQuery!=""){
							strQuery = strQuery+"&";
					}
			  	strQuery = strQuery+"filterset="+escape(strActionFilter);
					$arrFilterObjects.each( function() {
			  		strTempValue = $.trim($(this).val());
			  		strTempName = $(this).attr("name");
			  		if(strQuery!=""){
							strQuery = strQuery+"&";
						}
			  		strQuery = strQuery+strTempName+"="+escape(strTempValue);
					});
				break;
			}
		}
	}
	
	if(blnHideMessage==true){
		if($activeObjMessage!=null){
			$activeObjMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
			$activeObjMessage = null;
		}
		$containerMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
	}
	$activeObjMessage = $containerMessage;
	
	showOverlayOnSubmit({"action":"show","container":idForm});
	
	if(strFieldname!=""){
		if(strQuery!=""){
			strQuery = strQuery+"&";
		}
		strQuery = strQuery+"fieldname="+strFieldname
	}
	
	if(strSort!=""){
		if(strQuery!=""){
			strQuery = strQuery+"&";
		}
		strQuery = strQuery+"sort="+strSort
	}
	
	if(strMove!=""){
		if(strQuery!=""){
			strQuery = strQuery+"&";
		}
		strQuery = strQuery+"move="+strMove
	}
	
	if(strQuery!=""){
			strQuery = strQuery+"&";
	}
	strQuery = strQuery+"mem="+strMem+"&lanQms="+lanQms+"&formtype="+strFormType
	if(strIdSurvey!=""){
		if(strQuery!=""){
			strQuery = strQuery+"&";
		}
		strQuery = strQuery+"survey="+strIdSurvey
	}
	if(strDebnr!=""){
		if(strQuery!=""){
			strQuery = strQuery+"&";
		}
		strQuery = strQuery+"depcode="+strDebnr
	}
	if(strSurveycode!=""){
		if(strQuery!=""){
			strQuery = strQuery+"&";
		}
		strQuery = strQuery+"surveycode="+strSurveycode
	}
	
	//alert(strQuery)
	
	blnDoSubmitForm=false
	var blnHandleRequest = true;
	
	$.ajax({
		type: "POST",
		cache:false,
		url: strActionUrl,
		data:strQuery,
		success: function(strdata) {
			
			if(blnHandleRequest == true){
				strdata = cmsUnescapeResponse(strdata);
				//alert(strdata)
				if(strdata.indexOf("foo}{")!=-1){
					strdata = strdata.replace("foo}{","");
					
					//if(strdata==""){
					//	return;
					//}
					
					if(blnReplaceOuterHtml==false){
						$defaultContainer.html(strdata);
					}
					else
					{
						$defaultContainer.outerHTML(strdata);
					}
					if(blnHideMessage==true){
						$containerMessage.html("").hide();
					}
					
					if(blnResetCounter.toString()=="true" && strRef!="" && strIdCounter!=""){
						var $arrInput = $("#"+idForm+" input[ref='"+strRef+"']");
						if($arrInput.length>0){
							$("#"+strIdCounter).html($arrInput.length);
						}
					}
					
				}
			}
		},
			error:function (XMLHttpRequest, strTemp, errorThrown) {
			  // typically only one of textStatus or errorThrown 
			  // will have info
			  //this; // the options for this ajax request
			  if(errorThrown!=undefined){
				blnHandleRequest = false;
			  }
			  
			  $defaultContainer.html(XMLHttpRequest.responseText);
			}
	});
	
	blnDoSubmitForm=true;
	showOverlayOnSubmit({"action":"hide","container":idForm});
}

function addImporter(objCollection){
	var idForm =  $.trim(getCollectionValue(objCollection,"idForm",""));
	var idContainer =  $.trim(getCollectionValue(objCollection,"idContainer",""));
	var intMaxAccounts =  getCollectionValue(objCollection,"intMaxAccounts","0");
	var messageMaxAccountsReached =  getCollectionValue(objCollection,"messageMaxAccountsReached","");
	var strMessageForgotRequired =  getCollectionValue(objCollection,"textForgotRequiredField","");
	var strIdContainerMessage =  $.trim(getCollectionValue(objCollection,"strIdContainerMessage",""));
	var strSave = getCollectionValue(objCollection,"strSave","");
	var strActionUrl = $.trim(getCollectionValue(objCollection,"strActionUrl",""));
	var strSelectLanguage = $.trim(getCollectionValue(objCollection,"strSelectLanguage",""));
	var lanQms = $.trim(getCollectionValue(objCollection,"lanQms",""));
	var strFormType = $.trim(getCollectionValue(objCollection,"formtype",""));
	var strScrolldown = $.trim(getCollectionValue(objCollection,"scrolldown",""));
	var intObjFound = 0;
	var intNewAccount = 0;
	intMaxAccounts = parseInt(intMaxAccounts);
	
	var objContainer = $("#"+idContainer);
	if(objContainer.length==0){
		return;
	}
	
	var $containerMessage = $("#"+strIdContainerMessage);
	
	if($activeObjMessage!=null){
			$activeObjMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
			$activeObjMessage = null;
	}
	
	var arrInput = $("#"+idContainer+" tr[id^='child_']");
	//var arrInput = $("#"+idContainer+" input[ref='"+strRef+"']");
	intObjFound = arrInput.length;
	if(intMaxAccounts>0 && intObjFound >= intMaxAccounts){
		alert(messageMaxAccountsReached);
		return;
	}
	intNewAccount = intObjFound+1;
	//opbouw nieuwe rij
	
	var strClass = ""
	if (intObjFound > 0 && ((intObjFound/2) != parseInt((intObjFound/2))) ){
		strClass = "clsOdd"
	}
	
	var formId = "child_" + intNewAccount;
	
	var $objNewRow = $("<tr>").attr("id", formId);
	if(strClass!=""){
		$objNewRow.attr("class",strClass);
	}
	var $objNewTd = $("<td>").attr("class","clsCheckBoxContainer");
	$objNewRow.append($objNewTd);
	var $objDiv = $("<div>").attr("class","clsCheckBoxContainer");
	$objNewTd.append($objDiv)
	//var $objCheckBox = $("<input>").attr("name","new_mem_id").attr("id",formId+"new").attr("type","checkbox").attr("ref",strRef).attr("class","clsRadioCheckbox")
	//$objDiv.append($objCheckBox)
	if(strSelectLanguage==""){
		var $objNewInput = $("<input>").attr("name","language").attr("id",formId+"language").attr("type","hidden").attr("ref","forminput").val(lanQms);
		$objDiv.append($objNewInput)
	}
	
	
	
	var $objNewTd = $("<td>").append($("<div>").attr("class","clsId"))
	$objNewRow.append($objNewTd);
	var $objNewTd = $("<td>");
	$objNewRow.append($objNewTd);
	var $objDiv = $("<div>").attr("class","clsPassword")
	$objNewTd.append($objDiv)
	//var $objInput = $("<input>").attr("name","password").attr("id","password_"+intNewAccount).attr("type","text").attr("ref","forminput").attr("class","clsInput").attr("required","true")
	//$objDiv.append($objInput)
	
	var $objNewTd = $("<td>");
	$objNewRow.append($objNewTd);
	var $objDiv = $("<div>").attr("class","clsIdResponsible")
	$objNewTd.append($objDiv)
	var $objInput = $("<input>").attr("name","name").attr("id",formId+"name").attr("type","text").attr("ref","forminput").attr("class","clsInput")
	$objDiv.append($objInput)
	
	var $objNewTd = $("<td>").append($("<div>").attr("class","clsCompleteQuestionnaires"))
	$objNewRow.append($objNewTd);
	
	if(strSelectLanguage!=""){
		var $objNewTd = $("<td>").append($("<div>").attr("class","clsLanguage").html("<select name=\"language\" id=\""+formId+"language\" ref=\"forminput\" required=\"true\" class=\"clsSelect\">" + cmsUnescapeResponse(strSelectLanguage) +"</select>"))
		$objNewRow.append($objNewTd);
	}
	
	var $objNewTd = $("<td>")
	$objNewRow.append($objNewTd);	
	var $objNewDiv = $("<div>").attr("class","clsAction");
	$objNewTd.append($objNewDiv);
	
	var strCollection = "{"
	strCollection = strCollection + "'mem':'0',"
	strCollection = strCollection + "'add_account':'true',"
	strCollection = strCollection + "'idContainer':'child_" + intNewAccount +  "',"
	strCollection = strCollection + "'idForm':'" + idForm + "',"
	strCollection = strCollection + "'textForgotRequiredField':'" + strMessageForgotRequired + "',"
	strCollection = strCollection + "'strIdContainerMessage':'" + strIdContainerMessage + "',"
	strCollection = strCollection + "'strActionUrl':'" + strActionUrl + "',"
	strCollection = strCollection + "'formtype':'" + strFormType + "',"
	strCollection = strCollection + "'lanQms':'" + lanQms + "'"
	
	
	strCollection = strCollection + "}"
	
	var $objNewA = $("<a>").attr("class","clsAction").attr("href","javascript: sendFormByAjax(" + strCollection + ")").html(strSave)
	$objNewDiv.append($objNewA);
	
	if($("#"+idContainer+" tr").length>0){
		$objNewRow.insertAfter("#"+idContainer+" > tr:last");
	}
	else
	{
		objContainer.append($objNewRow);
	}
	if(strScrolldown=="true"){
		var posScrolledTop = $("#portaal-wrapper").height();
		var intScroll = posScrolledTop;
	}
	else
	{
		var posScrolledTop = $(window).scrollTop();
		var heightNewTr = $objNewRow.height();
		var intScroll = posScrolledTop+heightNewTr;
		
	}	
		$(window).scrollTop(intScroll);
	//window.scroll(x-coord, y-coord) 
	
}

function addDepartment(objCollection){
	
	var idForm =  $.trim(getCollectionValue(objCollection,"idForm",""));
	var idContainer =  $.trim(getCollectionValue(objCollection,"idContainer",""));
	var intMaxDepartments =  getCollectionValue(objCollection,"intMaxDepartments","0");
	var messageMaxDepartmentsReached =  getCollectionValue(objCollection,"messageMaxDepartmentsReached","");
	var strMessageForgotRequired =  getCollectionValue(objCollection,"textForgotRequiredField","");
	var strIdContainerMessage =  $.trim(getCollectionValue(objCollection,"strIdContainerMessage",""));
	//var strRef =  $.trim(getCollectionValue(objCollection,"strRef","forminput"));
	var strSave = getCollectionValue(objCollection,"strSave","");
	var strActionUrl = $.trim(getCollectionValue(objCollection,"strActionUrl",""));
	var strSelectLanguage = $.trim(getCollectionValue(objCollection,"strSelectLanguage",""));
	var lanQms = $.trim(getCollectionValue(objCollection,"lanQms",""));
	var strFormType = $.trim(getCollectionValue(objCollection,"formtype",""));
	var strMessageCodeAlreadyExist = $.trim(getCollectionValue(objCollection,"strMessageCodeAlreadyExist",""));
	var strRef = $.trim(getCollectionValue(objCollection,"strRef",""));
	var strMessageAlphaNumeric = getCollectionValue(objCollection,"messageAlphaNumeric","");
	var strScrolldown = $.trim(getCollectionValue(objCollection,"scrolldown",""));	
	var intObjFound = 0;
	var intNewAccount = 0;
	//intAcounts = parseInt(intAcounts);
	intMaxDepartments = parseInt(intMaxDepartments);
	
	var objContainer = $("#"+idContainer);
	if(objContainer.length==0){
		return;
	}
	
	var $containerMessage = $("#"+strIdContainerMessage);
	
	if($activeObjMessage!=null){
			$activeObjMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
			$activeObjMessage = null;
	}
	
	var arrInput = $("#"+idContainer+" tr[id^='child_']");
	//var arrInput = $("#"+idContainer+" input[ref='"+strRef+"']");
	intObjFound = arrInput.length;
	if(intMaxDepartments>0 && intObjFound >= intMaxDepartments){
		alert(messageMaxDepartmentsReached);
		return;
	}
	intNewAccount = intObjFound+1;
	//opbouw nieuwe rij
	
	var strClass = ""
	if (intObjFound > 0 && ((intObjFound/2) != parseInt((intObjFound/2))) ){
		strClass = "clsOdd"
	}
	
	var formId = "child_" + intNewAccount;
	
	var $objNewRow = $("<tr>").attr("id", formId);
	if(strClass!=""){
		$objNewRow.attr("class",strClass);
	}
	var $objNewTd = $("<td>").attr("class","clsCheckBoxContainer");
	$objNewRow.append($objNewTd);
	var $objDiv = $("<div>").attr("class","clsCheckBoxContainer");
	$objNewTd.append($objDiv);
	
	var $objNewTd = $("<td>");
	$objNewRow.append($objNewTd);
	var $objDiv = $("<div>").attr("class","clsDepartmentCode");
	$objNewTd.append($objDiv);
	
	var $objInput = $("<input>").attr("name","code").attr("id",formId+"code").attr("type","text").attr("ref","forminput").attr("class","clsInput").attr("required","true").attr("only_alpha_numeric","true").attr("onkeyup","checkMyMaxLength(this,'my_maxlength')").attr("my_maxlength","3").attr("maxlength","3").attr("onblur","checkObjValueAlphaNumeric(this,{'idForm':'"+formId+"','message':'"+strMessageAlphaNumeric+"'})");
	//.attr("onblur","checkNumber(this,'00')")
	
	
	
	$objDiv.append($objInput)

	var $objNewTd = $("<td>");
	$objNewRow.append($objNewTd);
	var $objDiv = $("<div>").attr("class","clsDepartmentName")
	$objNewTd.append($objDiv)
	var $objInput = $("<input>").attr("name","name").attr("id",formId+"name").attr("type","text").attr("ref","forminput").attr("class","clsInput").attr("required","true").attr("only_alpha_numeric","true").attr("onblur","checkObjValueAlphaNumeric(this,{'idForm':'"+formId+"','message':'"+strMessageAlphaNumeric+"'})");
	$objDiv.append($objInput)
	
	
	var $objNewTd = $("<td>")
	$objNewRow.append($objNewTd);	
	var $objNewDiv = $("<div>").attr("class","clsAction");
	$objNewTd.append($objNewDiv);
	
	var strCollection = "{"
	strCollection = strCollection + "'depcode':'-1',"
	strCollection = strCollection + "'add_dep':'true',"
	strCollection = strCollection + "'depcode':'',"
	strCollection = strCollection + "'idObjDepCode':'" + formId + "code',"
	strCollection = strCollection + "'idContainer':'child_" + intNewAccount +  "',"
	strCollection = strCollection + "'idForm':'" + idForm + "',"
	strCollection = strCollection + "'textForgotRequiredField':'" + strMessageForgotRequired + "',"
	strCollection = strCollection + "'strIdContainerMessage':'" + strIdContainerMessage + "',"
	strCollection = strCollection + "'strActionUrl':'" + strActionUrl + "',"
	strCollection = strCollection + "'formtype':'" + strFormType + "',"
	strCollection = strCollection + "'strRef':'" + strRef+ "',"
	strCollection = strCollection + "'strMessageCodeAlreadyExist':'" + strMessageCodeAlreadyExist + "',"
	strCollection = strCollection + "'messageAlphaNumeric':'" + strMessageAlphaNumeric + "',"
	strCollection = strCollection + "'lanQms':'" + lanQms + "'"
	strCollection = strCollection + "}"
	
	var $objNewA = $("<a>").attr("class","clsAction").attr("href","javascript: saveDepartment(" + strCollection + ")").html(strSave)
	$objNewDiv.append($objNewA);
	
	if($("#"+idContainer+" tr").length>0){
		$objNewRow.insertAfter("#"+idContainer+" > tr:last");
	}
	else
	{
		objContainer.append($objNewRow);
	}
	
	if(strScrolldown=="true"){
		var posScrolledTop = $("#portaal-wrapper").height();
		var intScroll = posScrolledTop;
	}
	else
	{
		var posScrolledTop = $(window).scrollTop();
		var heightNewTr = $objNewRow.height();
		var intScroll = posScrolledTop+heightNewTr;
		
	}	
	
	$(window).scrollTop(intScroll);
	
	//window.scroll(x-coord, y-coord) 
	
	
	
}

function saveDepartment(objCollection){
	var idForm = $.trim(getCollectionValue(objCollection,"idForm",""));
	var strDebnr = $.trim(getCollectionValue(objCollection,"depcode",""));
	var strIdObjDepCode = $.trim(getCollectionValue(objCollection,"idObjDepCode",""));
	var strIdContainer = $.trim(getCollectionValue(objCollection,"idContainer",""));
	var strRef = $.trim(getCollectionValue(objCollection,"strRef",""));
	var blnAddDep = $.trim(getCollectionValue(objCollection,"add_dep","false"));
	var strMessageCodeAlreadyExist = $.trim(getCollectionValue(objCollection,"strMessageCodeAlreadyExist",""));
	
	var $objToSave = $("#"+idForm+" #"+strIdContainer+" #"+strIdObjDepCode);
	
	if($objToSave.length==0){
		return;
	}
	var strValueToSave = $.trim($objToSave.val());
	

	if(blnAddDep.toString()=="true"){
		
		var $objCheck = $("#"+idForm+" [ref='"+strRef+"'][value='"+strValueToSave+"']");
		
		if($objCheck.length == 0){
			clearAlert(strIdContainer,"code");
			//send form
			sendFormByAjax(objCollection);
			//alert("OK");
			return;
		}
		if($objCheck.length > 0){
			alert(strMessageCodeAlreadyExist);
			setAlert(strIdContainer,"code");
			return;
		}
		
	}
	else
	{
		
	
		var $objCheck = $("#"+idForm+" [ref='"+strRef+"'][value='"+strValueToSave+"']");
		
		if($objCheck.length == 0){
			clearAlert(strIdContainer,"code");
			//send form
			sendFormByAjax(objCollection);
			//alert("OK");
			return;
		}
		
		if($objCheck.length == 1){
			var idCheckInput =$("#"+idForm+" [ref='forminput'][value='"+strValueToSave+"']").attr("id");
			if(idCheckInput == strIdObjDepCode&&idCheckInput!=undefined){
				clearAlert(strIdContainer,"code");
				//send form
				sendFormByAjax(objCollection);
				//alert("OK");
				return;
				
			}
			else
			{
				alert(strMessageCodeAlreadyExist);
				setAlert(strIdContainer,"code");
				return;
			}
		}
		else
		{
			alert(strMessageCodeAlreadyExist);
			setAlert(strIdContainer,"code");
			return;
		}
	}
	
	
}

function getScreenHeight(){
	var myScreenY;
	myScreenY = screen.height;
	myScreenY = myScreenY - 50;
	return myScreenY;
}

function getScreenWidth(){
	var myScreenX;
	myScreenX =screen.width;
	if(myScreenX > 1000){
		myScreenX = 1000;
	}
	return myScreenX;
}

var surveyPopupWindow = null;
var blnProceedOpenWindow = true;

function surveyPopupWindowDirect(strUrl){
	
	if($activeObjMessage!=null){
		$activeObjMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
		$activeObjMessage = null;
	}
	
	if(blnProceedOpenWindow==true){
		blnProceedOpenWindow = false;
		var myScreenX = getScreenWidth();
		var myScreenY = getScreenHeight();
	
		if(surveyPopupWindow!=null){
			surveyPopupWindow.close();
			surveyPopupWindow = null;
		}
		surveyPopupWindow = window.open(strUrl,"surveyNewWindow","height="+myScreenY+",width="+myScreenX+",scrollbars=yes,resizable=yes");
		
		surveyPopupWindow.focus();
		blnProceedOpenWindow = true;
	}
}

function openPageXmlDownload(objCollection){
	var idMessageContainer = $.trim(getCollectionValue(objCollection,"idMessageContainer",""));
	var strNameForm = $.trim(getCollectionValue(objCollection,"nameForm",""));
	var txtDownloadInProgressPleaseHavePatience = $.trim(getCollectionValue(objCollection,"txtDownloadInProgressPleaseHavePatience","Download in progresss...<br/>Please have patience."));
	var objForm = document.forms[strNameForm];
	if(objForm==null){
		return;
	}
	
	if($activeObjMessage!=null){
		$activeObjMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
		$activeObjMessage = null;
	}
	
	$activeObjMessage = $("#messageContainerXmlDownload");
	
	$activeObjMessage.html(txtDownloadInProgressPleaseHavePatience).show();
	
	if(blnProceedOpenWindow==true){
		blnProceedOpenWindow = false;
		objForm.submit();
		blnProceedOpenWindow=true;
	}
}

function surveyPopup(objCollection){ 
	
	var strNameForm = $.trim(getCollectionValue(objCollection,"nameForm",""));
	var strIdForm = $.trim(getCollectionValue(objCollection,"idForm",""));
	var strIdSurvey = $.trim(getCollectionValue(objCollection,"idSurvey",""));
	var strIdRepeat = $.trim(getCollectionValue(objCollection,"idRepeat",""));
	var blnUsePopup =$.trim(getCollectionValue(objCollection,"blnUsePopup","true"));
	
	var objForm = document.forms[strNameForm];
	if(objForm==null){
		return;
	}
	
	if($activeObjMessage!=null){
		$activeObjMessage.html("").removeClass("clsMessageNegative").removeClass("clsMessagePositive").hide();
		$activeObjMessage = null;
	}
	
	objForm.SURVEY_ID.value=strIdSurvey;
	
	if(strIdRepeat !=""){
		objForm.REPEAT_ID.value=strIdRepeat;
	}
	
	if(blnUsePopup.toString()=="false"){
		objForm.submit();
		return;
	}
	if(blnProceedOpenWindow==true){
		blnProceedOpenWindow = false;
		var myScreenX = getScreenWidth();
		var myScreenY = getScreenHeight();

		if(surveyPopupWindow!=null){
			surveyPopupWindow.close();
			surveyPopupWindow = null;
		}
		surveyPopupWindow = window.open("","surveyNewWindow","height="+myScreenY+",width="+myScreenX+",scrollbars=yes,resizable=yes");
		objForm.target = "surveyNewWindow";
		objForm.submit();
		surveyPopupWindow.focus();
		blnProceedOpenWindow=true;
	}
	
}

function reloadParent(objCollection){
	var strUrl = $.trim(getCollectionValue(objCollection,"abortUrl",""));
	
	if(strUrl==''){
		strUrl='/';
	}
	
	getHtmlByAjax(objCollection)
	
	
	/*var strTempLocation = document.location.href;
	if(strTempLocation.indexOf(strUrl)!=-1){
		var objStep = document.getElementById("list-survey-step");
		if(objStep!=null){
			objStep.value=parseInt(objStep.value)-1;
		}
		//document.getElementById("frm_Survey").submit();
		//document.location.href = document.location.href;
		getListSurveys("","","","","",blnNew);
	}
	else
	{
		if(strUrl.indexOf("?")==-1){
			strUrl=strUrl+"?move-last=true"
		}
		else
		{
			strUrl=strUrl+"&move-last=true"
		}
		document.location.href = strUrl;
	}*/
}

function openCloseSurveyResultContainer(objId){
	
	var objContainer = document.getElementById("container_"+objId);
	var objTitle = document.getElementById("title_"+objId);
	var objControl = document.getElementById("control_"+objId);
	
	if(objContainer!=null && objTitle!=null && objControl!=null){
		switch(objTitle.className){
			case "clsSurveyTitleOpen":
				objContainer.className="clsContainerRapportClosed";
				objTitle.className="clsSurveyTitleClosed";
			break;
			case "clsSurveyTitleClosed":
				objContainer.className="clsContainerRapportOpen";
				objTitle.className="clsSurveyTitleOpen";
			break;
		}
	}
}
