<!--
// @@@
// @@ Author: Bas van Dorst
// @@ Date: 2007-02-16
// @@ Last change: 2007-02-16
// @@ Version: 1
// @@ Revision: 0
// @@ Copyright: Ecommany B.V.
// @@ Description: Standaard Javascript functies
// @@$

function toggle(xxx,currSet) {
	var el = document.getElementById(currSet);
	var inputs = el.getElementsByTagName("INPUT");
	for (i=0; i<inputs.length; i++) {
		if (inputs[i].type.toLowerCase()=="checkbox") {
			 if(xxx.checked === false) {
			 	inputs[i].checked = false;
			} else {
				inputs[i].checked = true;
			}
		}
	}
}

function acceptVoorwaarden(element) {
	var el = document.getElementById('categorie');
	var inputs = el.getElementsByTagName("INPUT");
	for (i=0; i<inputs.length; i++) {
		if(element.checked === true) {
			inputs[i].disabled = false;
		} else {
			inputs[i].checked = false;
			inputs[i].disabled = true;
		}
	}
}

function Check(theForm) {
  //check NAW gegevens
  re = /'*\(*\w*/;

	if (re.exec(theForm.fNaam.value)=='') { alert('Vul uw naam in'); theForm.fNaam.focus(); return (false); }
	if (re.exec(theForm.fEmail.value)=='') { alert('Vul aub uw e-mail adres in'); theForm.fEmail.focus(); return (false); }
	
	if (re.exec(theForm.fEmail.value)!='') {
		checkOK = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY@.-_0123456789';
		checkStr = theForm.fEmail.value;
		allValid = true;
		for (i=0; i<checkStr.length; i++) {
			ch = checkStr.charAt(i);
			for (j=0; j<checkOK.length; j++) if (ch==checkOK.charAt(j)) break;
			if (j==checkOK.length) {
				allValid = false;
				break;
			}
		}
		if (checkStr.indexOf('@')<3) allValid = false;
		if (checkStr.length-3<checkStr.lastIndexOf('.')) allValid = false;
		if (checkStr.lastIndexOf('.')<checkStr.indexOf('@')+3) allValid = false;
		if (!allValid && theForm.fEmail.value!='') {
		alert('Geen geldig e-mail adres opgegeven');
			theForm.fEmail.focus();
			return (false);
		}
	}
	selectedItems=0;
	var el = document.getElementById('categorie');
	var inputs = el.getElementsByTagName("INPUT");
	for (i=0; i<inputs.length; i++) {
		if(inputs[i].checked === true && (inputs[i].name == "fCategorie[]" || inputs[i].name == "fRichtlijn" || inputs[i].name == "fRichtlijnen[]" )) {
		 selectedItems++;
		}
	}
	if(selectedItems == 0) {alert('Selecteer minimaal 1 categorie'); return (false); }
}	



// code voor openen soort alt text

 d=document;
 l=d.layers;
 op=navigator.userAgent.indexOf('Opera')!=-1;
 px='px';

 var menuTimer = null;
 var timerRunning = false;
 var menuActive = '';

 function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
 function sE(e){l?e.visibility='show':e.style.visibility='visible';}
 function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
 function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x+px;}
 function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y+px;}
 function gX(e){l?x=e.left:op?x=e.style.pixelLeft:x=e.style.left;if(isNaN(x))x=Number(x.substr(0,x.length-2));return x}
 function gY(e){l?y=e.top:op?y=e.style.pixelTop:y=e.style.top;if(isNaN(y))y=Number(y.substr(0,y.length-2));return y}
 function gIX(i){if(l)x=i.x;x=i.offsetLeft;tmp=i.offsetParent;while(tmp!=null){x+=tmp.offsetLeft;tmp=tmp.offsetParent}return x}
 function gIY(i){if(l)y=i.y;y=i.offsetTop;tmp=i.offsetParent;while(tmp!=null){y+=tmp.offsetTop;tmp=tmp.offsetParent}return y}

 function positionMenu(e,dx,dy) {
	x = gIX(d['pos_'+e]);
	y = gIY(d['pos_'+e]);
	el = gE(e);
	sX(el,x+dx);
	sY(el,y+dy);
 }

 function hideMenu(e,t) {
	if (t==0) {
		hE(gE(e));
		menuActive = '';
	} else {
		menuTimer = setTimeout('hE(gE(\''+e+'\'));menuActive=\'\'',t);
		timerRunning = true;
	} // if
 }

 function showMenu(e) {
	if(timerRunning) {
		clearTimeout(menuTimer);
		timerRunning = false;
	} // if
	if (menuActive!='' && e!=menuActive) hideMenu(menuActive,0);
	menuActive = e;
	delta_x=16; // 0
	delta_y=0; // 0
	if (e=='conc') delta_x=-160;
	if (e=='conc') delta_y=10;
	if (e=='overw') delta_x=-160;
	if (e=='overw') delta_y=10;
	positionMenu(e,delta_x,0);
	positionMenu(e,0,delta_y);
	sE(gE(e));
 }
 
function contentVul(contentKnop) 
{
	for (i=1; i<6; i++) 
	{
		// inhoud van verstopte div in de content div laden van de tabel
		if (contentKnop==i) 
		{
			eval('document.getElementById(\'div_content\').innerHTML = document.getElementById(\'content'+i+'\').innerHTML');
		}
		
		// alle tabjes lichte kleur maken
		if (document.getElementById('tab_knop_'+i)) {
			document.getElementById('tab_knop_'+i).bgColor='#ffffff';
		}
		
		// alle linkjes lichte kleur maken
		var exists = document.getElementById('knop_link_'+i);
		if (exists)
		{
			document.getElementById('knop_link_'+i).style.color='#808080';
			document.getElementById('knop_link_'+i).style.fontWeight='bold';
			document.getElementById('tab_knop_'+i).className ='tab_inactive';
		}
		// alle knoppen lichte kleur maken
	}
	
	// als tabje geselecteerd is een andere bgcolor geven
	var exists = document.getElementById('knop_link_'+contentKnop);
	if (exists) 
	{
		document.getElementById('knop_link_'+contentKnop).style.color='#000000';
		document.getElementById('knop_link_'+contentKnop).style.fontWeight='bold';
		document.getElementById('tab_knop_'+contentKnop).className ='tab_active';
	}
	
	setContentHeight();
}

function getInnerHeight(win) {
 h=0;
 if (win.innerHeight) 
  h = win.innerHeight;
 else if (win.document.documentElement && win.document.documentElement.clientHeight) 
  h = win.document.documentElement.clientHeight;
 else if (win.document.body) 
  h = win.document.body.clientHeight;
 return h;
}

function getHeight(jsObj) {
	h=0;
	if (jsObj.style) { // Als style aanwezig is (fix IE).
		if (jsObj.clip) {
			h = jsObj.clip.height;
		}
		else {
			if (jsObj.style.pixelHeight) {
				h = jsObj.style.pixelHeight;
			}
			else {
				h = jsObj.offsetHeight;
			}
		}
	}
	return h;
}

function setHeight(jsObj,h) {
	if (jsObj.clip) {
		jsObj.clip.height=h;
	} else {
		if(jsObj.style.pixelHeight) {
			jsObj.style.pixelHeight=h;
		} else {
			jsObj.style.height=h+'px';
		}
	}
}

function addLoadEvent(func) {
 var oldonload = window.onload;
 if (typeof window.onload != 'function') {
  window.onload = func;
 } else {
  window.onload = function() {
   oldonload();
   func();
  }
 }
}

function setContentHeight() {
	var wh, kh, ch;

	kh = -1;
	ch = -1;
	
	wh = getInnerHeight(window);
	if (document.getElementById('div_content')) {
		ch = getHeight(gE('div_content'));
	}
	if (document.getElementById('id_kaart')) {
		kh = getHeight(gE('id_kaart'));
		if ((wh-184)>(ch+36)) { // 184 is hooge totaan kaart (onder de tabjes) en 16 px voor disclaimer tekst
			setHeight(gE('id_kaart'), (wh-184));
		}
		if ((ch+36)>kh) { // ruimte voor heading
			setHeight(gE('id_kaart'), (ch+36));
		}
	}
	if (document.getElementById('id_content')) {
		ch = getHeight(gE('id_content'));
		
		var browser = navigator.userAgent; // Info browser.
		
		if ((wh-81)>ch) { // 111 is hooge tot aan lijn (onder de tabjes) en 16 px voor disclaimer tekst min padding ruimte 2x15
			if (browser.search("Firefox") != '-1') { // -97 pixels voor Firefox.
				setHeight(gE('id_content'), (wh - 97))
			}
			else {
				setHeight(gE('id_content'), (wh - 81))
			}
		}
	}
}

function setContent() {
	var i, tc
	if (document.getElementById('div_content')) {
		i=1;
		if (document.getElementById('content4')) {
			tc = document.getElementById('content4').innerHTML;
			if (tc!="") {
				i=4;
			}
		}
		if (document.getElementById('content3')) {
			tc = document.getElementById('content3').innerHTML;
			if (tc!="") {
				i=3;
			}
		}
		if (document.getElementById('content2')) {
			tc = document.getElementById('content2').innerHTML;
			if (tc!="") {
				i=2;
			}
		}
		if (document.getElementById('content1')) {
			tc = document.getElementById('content1').innerHTML;
			if (tc!="") {
				i=1;
			}
		}
		contentVul(i);
	} else {
		setContentHeight();
	}
}

addLoadEvent(setContent);
//-->

