function HideandUNhideObj(i){
        nav=document.getElementById('div'+i).style;
        if(nav.display=="none"){
                nav.display = 'block';
        } else {
                nav.display='none';
        }
}
function showHide(id){
        var obj=document.getElementById(id).style;
        if(obj.display=="none"){
                obj.display = 'inline';
        } else {
                obj.display='none';
        }
}
function toggle(object,id){
	var elem = document.getElementById(id);
	
	if (elem.className == 'show'){
		object.style.backgroundImage = 'url(/images/bg_languages.gif)';
		elem.className = '';
	} else {
		var elem1 = document.getElementById("sub-0");
		elem1.className = '';
		
		object.style.backgroundImage = 'url(/images/bg_languages-active.gif)';	
		elem.className = 'show';
	}
}

var subtimer;
var activesub;
function setTimer(menu){
	activesub=menu;
	subtimer = setTimeout('hidesub(this,\''+activesub+'\')', 1000)
}
function clearTimer(){
	clearTimeout(subtimer);
}
function hidesub(object,id){
	document.getElementById(id).className = '';
}

function checksearch(elem){
	elem 	= elem.keywords;
	lengte 	= elem.value.length;
	if (elem.value == "" || elem.value == systemtext["search-default-basic"] || lengte <= 2){
		alert(systemtext["search-empty"]);
		elem.focus();
		return false;
	}
	return true;
}
function erase_search(object){
	if (object.value != ''){
		object.value = '';
	}
}
function default_search(object){
	if (object.value == ''){
		object.value = systemtext["search-default-basic"];
	}
}
function erase_mail(object){
	if (object.value != ''){
		object.value = '';
	}
}
function default_mail(object){
	if (object.value == ''){
		object.value = systemtext["enews-default"];
	}
}
function checkenews(elem){
	elem = elem.email;
	if (elem.value == "" || elem.value == systemtext["enews-default"]){
		alert(systemtext["enews-empty"]);
		elem.focus();
		return false;
	}
	else{
		var email=/^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
		if(!email.test(elem.value)){
			elem.style.background="#FCC9C9";
			alert(systemtext["invalid-email"]);
			return false;
		} 
	}
	return true;
}
function check(which, verplicht, error, emailerror,id){
	
	if (document.getElementById(id)) document.getElementById(id).value = 'nospam';
	var empty 			= false;
	var radioaanwezig 	= false;
	var radios			= new Array();
	var lastradioindex	= 0;
	var radionames		= new Array();
	//var radios;// = new array()
	for (i=0;i<which.length;i++){
		var veld=which.elements[i];
		if(veld.type=="text"){
			//Maak alle achtergronden (weer) wit
			veld.style.background="#FFFFFF";
		}
		for (j=0;j<verplicht.length;j++){
			if(veld.type=="text" && veld.name==verplicht[j][0] && veld.value==''){
				veld.style.background="#FEC4C0";
				empty = true;
			}
			if(veld.type=="textarea" && veld.name==verplicht[j][0] && veld.value==''){
				veld.style.background="#FEC4C0";
				empty = true;
			}
			if(veld.type=="text" && veld.value!='' && veld.name=='email' && verplicht[j][1]=='email'){
				// E-mail check!
				var email=/^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
				if(!(email.test(veld.value))){
					veld.style.background="#FEC4C0";
					alert(emailerror);
					return false;
				}
			}
			if(veld.type=="radio" && veld.name==verplicht[j][0]){
				radioaanwezig 	= true;
				if (veld.name != radionames[radionames.length-1]) {
					radionames[radionames.length] = veld.name;
					lastradioindex++;
				}
				if (radios[lastradioindex] == undefined) {
					radios[lastradioindex] = 0; //standaard false
				}
				if (veld.checked){
					radios[lastradioindex] = 1; // er is een waarde geselecteerd
				}
			}
		}		
	}
	if(empty){
		alert(error);
		return false;
	} 
	if(radioaanwezig){
		for(var i=1; i<radios.length;i++){
			if (radios[i] == 0){
				alert("Please check one of the "+ radionames[i-1] +" options");
				return false;
			}
		}
	}else {
		//return false;
		return true;
	}
}
function updateTele(phone,country){ 
	//alert(country.replace("|",'"'));
	document.getElementById('telecontainer').style.display = 'block';
	document.getElementById('selectIt').innerHTML = country;	
	document.getElementById('tele').innerHTML = phone;
	//sIFR.replaceElement("h6", "/sifr2/sifr.swf", "#FFFFFF", null, null, "#CD0000", 0, 0, 0, 0);	
}
function setCookie(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +encodeURIComponent( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function showCallyou(){
		var html = '<iframe src="/index.php?action=callyou" width="100%" height="100%" scrolling="no" frameborder="0" allowtransparency="true" style="margin-left:60px;margin-top:60px"></iframe>';
		var objBody = document.getElementsByTagName("body").item(0);
		var objOverlay = document.createElement("div");
		var arrayPageSize = getPageSize();
		objOverlay.setAttribute('id','callyou');
		objOverlay.style.display = 'block';
		objOverlay.style.width = arrayPageSize[0];
		objOverlay.style.height = arrayPageSize[1];	
		objOverlay.innerHTML = html;
		objOverlay.onclick = function() { hideCallyou(); }
		objBody.appendChild(objOverlay);
		pageTracker._trackEvent('callYou', 'opened');
}
function hideCallyou(){
		pageTracker._trackEvent('callYou', 'closed');	
		var r = document.getElementById('callyou');
		r.parentNode.removeChild(r)
}
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/*
searchitem on home. Nu gaan start en endrentdatum mee
*/
function searchItem(){
	document.getElementById("s_startrent").value = document.getElementById("picker1").value;	
	document.getElementById("s_endrent").value = document.getElementById("picker2").value;
	return true;
}

/*stonden in de header eerst*/
function callForm(id,url){
	try {
		req.open('GET',url,true);		
		req.onreadystatechange=function(){
			if(req.readyState==4){
				if (req.responseText)
					document.getElementById(id).innerHTML = req.responseText;
			}
		}
		req.send(null);		
	} catch (e){
		alert(e);
		return null;	
	}
}
function getForm(form){
	callForm('form','/ajax.php?action=get'+form+'&taalcode='+taalcode);	
}
function catShow(slug){
	window.location.href = '/'+slug+'/';
}	
function manufShow(slug){
	window.location.href = '/mo_'+slug+'/';
}
function applicationShow(slug){ 
	window.location.href = '/a_'+slug+'/';
}
