// JavaScript Document
function CheckformA(activeelement){	
	var bOK=true; var require="";	
	switch (activeelement.form.name){
		case "about": 
			require="Naam,Nieuwsbrief"; //Telefoon,E-mail,
		
			break;
		case "exp": require="Naam,E-mail,text,Nieuwsbrief"; break; // ervaringen
		case "enquete": require="Naam,Nieuwsbrief"; break;
		case "service": require="Naam,Nieuwsbrief"; break;
		case "search-detail-booking":require="Naam,Nieuwsbrief";  break;
		default: break;
	}
	
	if(require.indexOf(activeelement.name)>-1){
		var v=activeelement.value;
		switch(activeelement.tagName){
		case "SELECT": break; // if(v.indexOf("keuze")>-1)){bOK=false;} 
		case "TEXTAREA": break; // if(activeelement.innerHTML==""){bOK=false;} 
		case "INPUT":  
			switch(activeelement.type){
			case "text": 
				
				break;
			case "radio": if(v==""){bOK=false;} break;
			default:break;					
			}
			break;
		default: break;
		}
		
	}
	
	switch(activeelement.name){
		case "Naam":  break;
				
	}
	
	//e=activeelement.ownerDocument.getElementById("errMsg");
}



function filterCheck(obj){	
	if(obj.checked) $(obj).up().up().addClassName('active');	
	else			$(obj).up().up().removeClassName('active');	
}

function chr(iIn){ return String.fromCharCode(iIn);}

function setOPT(value){
	 var today=new Date(); var expire = new Date(); expire.setTime(today.getTime() + 3600000*24*30); // ms
	 document.cookie = "opt" +  "="+  escape(value) + ";expires=" + expire.toGMTString(); 
}

function setNAW(value){
	 var today=new Date(); var expire = new Date(); expire.setTime(today.getTime() + 3600000*24*30); // ms
	 document.cookie = "naw" +  "="+  escape(value) + ";expires=" + expire.toGMTString(); 
}

function AddFavForm(frmId){	
	//alert(document.history);
	form=document.getElementById(frmId); 	
	SetFav(frmId, form.text.value,form.combiname.value);	
	r=form.referrer.value.split("&");
	r=r[0].split("?source=");
	r=r[1] + ".php";
	//alert(r);
	window.location=r+form.referrer.value;
	//alert(document.history);
}

function DelFav(id){	
	if(id==null){return '';} else {id=MY_FAVNAME+id;}
	s=document.cookie; s=unescape(s); var sout='';// site's all cookies
	var r=confirm("Deze woning verwijderen uit de favorieten?");
	if(r){
	if(s.indexOf(id) >-1){
		document.cookie =  id +"= ; expires=Thu, 01-Jan-70 00:00:01 GMT";  
		window.location=window.location;
	}
	}
}

function SetFav(id,value,friendlyName,nDays) {
 friendlyName=friendlyName + ''; value=value+'';// id.replace(".","");
 var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=30; expire.setTime(today.getTime() + 3600000*24*nDays);
 var oldval= GetFav(); 
 document.cookie = MY_FAVNAME + id + "="+  escape(id+"|"+friendlyName+"|"+value) + ";expires=" + expire.toGMTString(); 
 if(oldval.indexOf(id)>-1){  alert(friendlyName + ' bijgewerkt in de favorieten'); } else { alert(friendlyName + ' toegevoegd aan favorieten');}
}

function GetFav(optionalID) {	
	if(optionalID==null){optionalID=MY_FAVNAME;} else {optionalID=MY_FAVNAME+optionalID;}
	s=document.cookie; s=unescape(s); var sout='';// site's all cookies
	t=s.split(";");	for(i=0;i<t.length;i++){ if(t[i].indexOf(optionalID) >-1){ s=t[i]; s=s.split(optionalID); s=s[1].split("="); sout=sout+ s[1]+chr(11);	}}
	sout=sout.substr(0,-1); return sout;
}
function GetFavs(){	
	s=document.cookie; s=unescape(s); var aout=Array();// site's all cookies
	
	t=s.split(";");	for(i=0;i<t.length;i++){ 
		s=t[i]; s=t[i].split(MY_FAVNAME); s=s[1].split("="); s=s.split("|"); aout[i]['ID']=s[0]; aout[i]['Name']=s[1];aout[i]['Text']=s[2];		
	}
	return aout;	
}

function GetFavsStr(){
	alert('');
	s=document.cookie; s=unescape(s); var sout='';// site's all cookies
	t=s.split(";");	for(i=0;i<t.length;i++){ s=t[i]; s=t[i].split("="); s=s[1].split("|"); sout+=s[0]+',';}
	sout=sout.substr(0,-1); alert(sout+" functie"); return sout;
}

function favCount(){ s=GetFav(); s=s.split(chr(11)); return s.length; }



function xDeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

function xSetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  }
  
function Load(obj){ }

function Resize(obj){  }

function getClientSizeA() {
  var myWidth = 0, myHeight = 0;
  //alert(this.innerWidth);
  var wnd= this.window; var doc=this.document;
  alert( typeof( wnd.innerWidth )); alert(doc);
  if( typeof( wnd.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = wnd.innerWidth;
    myHeight = wnd.innerHeight;
  } else if( doc.documentElement && ( doc.documentElement.clientWidth || doc.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = doc.documentElement.clientWidth;
    myHeight = doc.documentElement.clientHeight;
  } else if( doc.body && ( doc.body.clientWidth || doc.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = doc.body.clientWidth;
    myHeight = doc.body.clientHeight;
  }
  var dim;
  dim[0] = myWidth;
  dim[1] = myHeight;
  return dim;
}
