function clearOptions(value){
	
	switch (value){
		case "include_form":
			setRadioButton("include_sitemap_ans2",true);
		break;
		case "include_sitemap":
			resetSelect("include_form");
		break;

	}
}

function resetSelect(id){
		if(document.getElementById(id)){
			document.getElementById(id).selectedIndex=0;
		}
}

function setRadioButton(id,value){
	if(document.getElementById(id)){
		document.getElementById(id).checked=value;
	}
}

function showFormRequestLoginData(strAction){
	
	if(document.getElementById("alertMessageLogin")){
		document.getElementById("alertMessageLogin").innerHTML="&nbsp;";
	}
	
	if(document.getElementById("frmLogin") && document.getElementById("frmRequestLoginData")){
		switch(strAction){
			case "open":
				document.getElementById("frmLogin").style.display="none";
				document.getElementById("frmRequestLoginData").style.display="block";
				setFocusOnObject("frmRequestLoginData","EMAIL_required");	
			break;
			case "close":
				document.getElementById("frmRequestLoginData").style.display="none";
				document.getElementById("frmLogin").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 handleClickOption(obj){
	
	if(obj!=undefined&&obj!=""){
		switch(obj.name){
			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":
				if(obj.value!="" && document.getElementById("WORK_MANAGES_FLAGANS1")){
					if(document.getElementById("WORK_MANAGES_FLAGANS1").checked==false){
						document.getElementById("WORK_MANAGES_FLAGANS1").checked=true;
					}
				}
			break;
			
			case "WORK_MANAGES_INDIRECT":
				if(obj.value!="" && document.getElementById("WORK_MANAGES_FLAGANS1")){
					if(document.getElementById("WORK_MANAGES_FLAGANS1").checked==false){
						document.getElementById("WORK_MANAGES_FLAGANS1").checked=true;
					}
				}
			break;
		}
	}
}

var blnOnValidate = false;

function submitFormBackground(){

	if(blnOnValidate == false){
	 	if(validateFormBackground()==true){
	 		enableAllDisabled("frmBackground");
	 		document.getElementById("frmBackground").submit();
	 	}
	 	else
	 	{
	 	return false;
		}
	 		
	}	
}



function validateFormBackground(){
	blnOnValidate = true;
	
	//check work manages
	var objWorkManagesFlagY = document.getElementById("WORK_MANAGES_FLAGANS1");
	var objWorkManagesDirect = document.getElementById("WORK_MANAGES_DIRECT");
	var objWorkManagesIndirect = document.getElementById("WORK_MANAGES_INDIRECT");
	
	if(objWorkManagesFlagY!=null && objWorkManagesDirect!=null && objWorkManagesIndirect!=null){
		if(objWorkManagesFlagY.checked==true){
			var intDirect = myTrim(objWorkManagesDirect.value);
			var intInDirect = myTrim(objWorkManagesIndirect.value);
			if(intDirect==""){
				intDirect = 0;
			}
			else
			{
				intDirect = parseInt(intDirect);
			}
			if(intInDirect==""){
				intInDirect = 0;
			}
			else
			{
				intInDirect = parseInt(intInDirect);
			}
			
			
			if(intDirect==0 && intInDirect==0){
				objWorkManagesDirect.value = "";
				objWorkManagesIndirect.value = "";
			}
			
			
		}
		else
		{
			objWorkManagesDirect.value="";
			objWorkManagesIndirect.value="";
		}
	}
	
	
	
	
	var blnValidate = validate('frmBackground','btn_OK');
	if(blnValidate == true){
		if(document.forms["frmBackground"].set_ATTRIBUTE_27){
			if(document.forms["frmBackground"].set_ATTRIBUTE_27.length!=undefined){
				for(var i = 0; i < document.forms["frmBackground"].set_ATTRIBUTE_27.length;i++){
					if(document.forms["frmBackground"].set_ATTRIBUTE_27[i].checked==true){
						document.getElementById("ATTRIBUTE_27").value="["+document.forms["frmBackground"].set_ATTRIBUTE_27[i].value+"]";
						i=document.forms["frmBackground"].set_ATTRIBUTE_27.length;	
					}
				}
			}
			else
			{
				if(document.forms["frmBackground"].set_ATTRIBUTE_27.checked==true){
					document.getElementById("ATTRIBUTE_27").value="["+document.forms["frmBackground"].set_ATTRIBUTE_27.value+"]";
				}	
			}
		}
		
		if(document.forms["frmBackground"].set_ATTRIBUTE_48){
			if(document.forms["frmBackground"].set_ATTRIBUTE_48.length!=undefined){
				for(var i = 0; i < document.forms["frmBackground"].set_ATTRIBUTE_48.length;i++){
					if(document.forms["frmBackground"].set_ATTRIBUTE_48[i].checked==true){
						document.getElementById("ATTRIBUTE_48").value="["+document.forms["frmBackground"].set_ATTRIBUTE_48[i].value+"]";
						i=document.forms["frmBackground"].set_ATTRIBUTE_48.length;	
					}
				}
			}
			else
			{
				if(document.forms["frmBackground"].set_ATTRIBUTE_48.checked==true){
					document.getElementById("ATTRIBUTE_48").value="["+document.forms["frmBackground"].set_ATTRIBUTE_48.value+"]";
				}	
			}
		}
		
		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 = '/configuration/templates/scripts/checkSessionMember.qms?x='+escape(new Date());
}

function validateSendToFriend(){
	var blnCorrectEmail;
	var blnMyReturn = true;
	var strAlert="";
	var strEmail="";
	if(document.getElementById("btnOkSendToFriend")){
		document.getElementById("btnOkSendToFriend").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 = getTranslation("txtAlertWrongEmailaddress","U heeft één of meerdere e-mailadressen niet correct ingevuld.");
					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(document.getElementById("btnOkSendToFriend")){
				document.getElementById("btnOkSendToFriend").disabled=false;
			}
			//return false;
		}
	}
	else
	{
		if(document.getElementById("btnOkSendToFriend")){
			document.getElementById("btnOkSendToFriend").disabled=false;
		}
		alert(strAlert);
		//return false;
	}	
}

function setPWD(){
	var strPWD="";
	if(document.getElementById("BIRTHDAY_required")){
		strPWD = strPWD + formatNumber(parseFloat(document.getElementById("BIRTHDAY_required").value,0),"00") + "-";
		strPWD = strPWD + formatNumber(parseFloat(document.getElementById("BIRTHMONTH_required").value,0),"00") + "-";
		strPWD = strPWD + document.getElementById("BIRTHYEAR_required").value;
		document.getElementById("VERIFY_PWD").value = strPWD;
	}
}

function validateFormVerify(){
	if(validate("frmVerify","btnOkVerify")==true){
		setPWD();
		document.getElementById("frmVerify").submit()
	}
}

function checkObj(obj,objId){
	if(myTrim(obj.value)!="" && document.getElementById(objId)){
		document.getElementById(objId).checked=true;
		obj.setAttribute("required","true");
	}
}
function confirmUnregister(idForm,idBtn){
	if(validate(idForm,idBtn)==true){
		if(document.getElementById(idForm)){
			if (confirm(getTranslation("textConfirmUnregister",""))==true){
				document.getElementById(idForm).submit();	
			}
			else
			{
				blnFormSubmit = false;
				if(document.getElementById(idBtn)){
					document.getElementById(idBtn).disabled=false;
				}	
			}
		}
	}
}

//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 (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=''
	}
}


