window.onload = PageLoad;
//window.onresize = SetPageHeight;


function NoBorder() {
	//haalt randen om flash objects weg in XP
	oObjects = document.getElementsByTagName("object");
	for (var nTeller = 0; nTeller < oObjects.length; nTeller++){
		oObjects[nTeller].outerHTML = oObjects[nTeller].outerHTML;
	}

	oObjects = document.getElementsByTagName("embed");
	for (var nTeller = 0; nTeller < oObjects.length; nTeller++){
		oObjects[nTeller].outerHTML = oObjects[nTeller].outerHTML;
	}
}

function PageLoad() {
	
	NoBorder();
	SetPageHeight();

		
	
}

function SetPageHeight() {

	if (typeof(tdContent) == 'object') { //niet op homepage
		var nTopHeight = 100;
		var nHeight = tdContent.scrollHeight+nTopHeight;
	
		if (document.body.scrollHeight > nHeight) {
			nHeight = document.body.scrollHeight;
		}
	
		if (typeof(tdMenuBG) == 'object') { // niet bij popup
			//alert(tdMenuBG.scrollHeight)
			if ((tdMenuBG.scrollHeight+nTopHeight) > nHeight) {
				nHeight = tdMenuBG.scrollHeight+nTopHeight;
			}
		}
	
		if (typeof(tblBody) == 'object') { // niet bij popup
			//alert(nHeight)
			//tblBody.style.height = nHeight;
			//tblBody.style.height = nHeight+20; //disclaimer + copyright (oude ontwerp)
			tblBody.style.height = nHeight+190;
		}
	}
	
//	var nPaginahoogte = 500;
//	if (document.all){
//		nPaginahoogte = document.body.offsetHeight-268;
//	}else{
//		nPaginahoogte = document.body.scrollHeight;
//	}
//	document.getElementById('divKopjeKoffieZwart').style.height = nPaginahoogte;
	
}


function navToPage(nHID,nPID,sPNAME, nCAT){
	sPNAME = sPNAME.replace(/ /g,"")
	sPNAME = sPNAME.replace(/&/g,"_")
	location.href="?"+sPNAME+".html=&hId="+nHID+"&pId="+nPID+"&cat="+nCAT

}

function checkLengte(oInput, intMaxlength){
	if (!isNaN(intMaxlength)) {
		//alert('['+oInput.name+']');
		if (oInput.value.length > intMaxlength) {
	
			alert('U heeft het maximale aantal karakters bereikt.');
			oInput.value = oInput.value.substring(0, intMaxlength);

		}
	}
}


function zoekOpTrefwoord(nHoofdItemID){

	if(txtTrefwoord.value.length < 3){
		alert('Een trefwoord moet uit minimaal 3 karakters bestaan, u heeft '+ txtTrefwoord.value.length +' karakters ingevoerd.');
		txtTrefwoord.select();
		return false;
	}

	location.href = "/default.asp?mod=CMS&hId="+ nHoofdItemID +"&pId=Zoeken&tw=" + txtEncode(txtTrefwoord.value)
	
}

function txtEncode(sUnEncode){

	sEncode = sUnEncode.replace(/a/g,'%61')
	sEncode = sEncode.replace(/A/g,'%41')
	
	sEncode = sEncode.replace(/e/g,'%65')
	sEncode = sEncode.replace(/E/g,'%45')
	
	sEncode = sEncode.replace(/i/g,'%69')
	sEncode = sEncode.replace(/I/g,'%49')
	
	sEncode = sEncode.replace(/o/g,'%6F')
	sEncode = sEncode.replace(/O/g,'%4F')
	
	sEncode = sEncode.replace(/s/g,'%73')
	sEncode = sEncode.replace(/S/g,'%53')
	
	sEncode = sEncode.replace(/ /g,'%20')
	sEncode = sEncode.replace(/</g,'%3C')
	sEncode = sEncode.replace(/>/g,'%3E')
	
	
	return sEncode
}

function showDiv(){

	divContactMenu.style.display = 'block'
	
}

function hideDiv(){

	divContactMenu.style.display = 'none';

}

function anderepagina(paginanummer){
	
	oFrm = document.frmReultaatTonen;
	
	oFrm.HP.value = paginanummer;
	
	oFrm.submit();
	
}

function validEmail(adres) {
	var restantAdres;
	var boolAdresOK = true;
	if (adres == '' || adres.indexOf('@') < 0) { 
		boolAdresOK = false; // er moet een @ in staan
	} else {
		restantAdres = adres.substring(adres.indexOf('@') + 1, adres.length);
		if (restantAdres.indexOf('.') < 1) {
			boolAdresOK = false; // na de @ moet een . staan met minstens een karacter ertussen
		} else {
			restantAdres = restantAdres.substring(restantAdres.indexOf('.') + 1, restantAdres.length);
			if(restantAdres.length < 2) {
				boolAdresOK = false; // na de . moeten minimaal 2 tekens staan
			}
		}
	}
	
	// ook op rare tekens controleren
	if (boolAdresOK) {
		var lcAdres = adres.toLowerCase();
		var strToegestaan = "1234567890-_@qwertyuiopasdfghjklzxcvbnm.";
		for (var i = 0; i < lcAdres.length; i++) {
			letter = lcAdres.substring(i,i+1);
			if (strToegestaan.indexOf(letter) < 0) {
				//lcAdres bevat geen waarde uit strToegestaan
				boolAdresOK = false;
			}
		}
	}
	return boolAdresOK;
}

var oImgHomepage = new Image(225, 63); //height, width
oImgHomepage.src = "/img_layout/btn_homepage.png";

var oImgHomepageMo = new Image(225, 63); //height, width
oImgHomepageMo.src = "/img_layout/btn_homepage_over.png";

var oImgIconTwitter = new Image(18, 18); //height, width
oImgIconTwitter = "/img_layout/twitter_icon.png";

var oImgIconHyves = new Image(18, 18); //height, width
oImgIconHyves = "/img_layout/hyves_icon.png";

var oImgIconGoogle = new Image(18, 18); //height, width
oImgIconGoogle = "/img_layout/google_icon.png";

var oImgIconFacebook = new Image(18, 18); //height, width
oImgIconFacebook = "/img_layout/facebook_icon.png";

var oImgIconTwitterGr = new Image(18, 18); //height, width
oImgIconTwitterGr = "/img_layout/twitter_icon_gr.png";

var oImgIconHyvesGr = new Image(18, 18); //height, width
oImgIconHyvesGr = "/img_layout/hyves_icon_gr.png";

var oImgIconGoogleGr = new Image(18, 18); //height, width
oImgIconGoogleGr = "/img_layout/google_icon_gr.png";

var oImgIconFacebookGr = new Image(18, 18); //height, width
oImgIconFacebookGr = "/img_layout/facebook_icon_gr.png";

function inputContactFocus(idExtra, focus){
	document.getElementById('tdIDInputLeft' + idExtra).className = 'tdInputLeft' + focus;
	document.getElementById('tdIDInputRight' + idExtra).className = 'tdInputRight' + focus;
	document.getElementById('tdIDInputCenter' + idExtra).className = 'tdInputCenter' + focus;
}


function textareaContactFocus(idExtra, focus){
	document.getElementById('tdIDTextareaLeft' + idExtra).className = 'tdTextareaLeft' + focus;
	document.getElementById('tdIDTextareaRight' + idExtra).className = 'tdTextareaRight' + focus;
	document.getElementById('tdIDTextareaCenter' + idExtra).className = 'tdTextareaCenter' + focus;
}


//---------------- JQUERY FUNCTIES

$(document).ready(function() {
  $('#slidebottom #divButtonInformatieBar').click(function() {
    $(this).next().slideDown('normal');
  });
  $('#slidebottom #divButtonInformatieBar').click(function() {
	setTimeout(function(){
	$('.inner').fadeOut(500);}, 5000);
  });
});

$(document).ready(function() {
  $('#slideHomepageID #divButtonInformatieBar').click(function() {
    $(this).next().slideDown('normal');
  });
  $('#slideHomepageIDTabel').mouseout(function() { // #slideHomepageID #divButtonInformatieBar
	setTimeout(function(){
	$('.divInfoBarHomepage').fadeOut(500);}, 10);
  });
});


var boolKoffieTonen = false
$(document).ready(function() {
  $('#divHoekjeWitHolder').click(function() {
	if (boolKoffieTonen) {
		$('#divKopjeKoffieZwart').fadeOut(800);
		$('#divHoekjeZwart').fadeOut(0);
		$('#divHoekjeWit').fadeIn(800);
		boolKoffieTonen = false
	}else{
		$('#divKopjeKoffieZwart').fadeIn(800);
		$('#divHoekjeZwart').fadeIn(800);
		$('#divHoekjeWit').fadeOut(0);
		boolKoffieTonen = true
	}

  });
});


//---------------- EINDE JQUERY FUNCTIES
