
/* Disable Right Mouseclick */
var specialcase = ((navigator.userAgent.indexOf('Mac') != -1) || document.all)
var flag = 0;
var msg = 'World Vision hecht grote waarde aan de bescherming en veiligheid van kinderen. Daarom is de rechtermuisklik mogelijkheid uitgezet. Zie \'Privacy\' rechtsonder.\n\nRight click disabled on images! World Vision cares about child privacy and security. Click the Privacy link at the bottom of this page for more information.';
var x,y,x1,y1,copyAttempt;

function copyRight()
{
	if (!(document.getElementById || document.all || document.layers)) return;
	if (specialcase && document.layers)
	{
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = special;
	}
	for (i=0;i<document.images.length;i++)
	{
		document.images[i].onmousedown = checkIt;
		document.images[i].onmouseup = function() {return false};
		if (specialcase)
		{
			document.images[i].onmousemove = special;
			document.images[i].onclick = clearIt;
		}
	}
}

function checkIt(e)
{
	copyAttempt = 0;
	if (window.Event)
	{
		x = e.screenX;
		y = e.screenY;
		theButt = (e.which == 3);
	}
	else
	{
		x = window.event.clientX;
		y = window.event.clientY;
		theButt = (window.event.button == 2);
	}
	if (theButt)
	{
		copyAttempt = 1;
		flag = 0;
		alert(msg);
		return false; // NN4 only
	}
	if (specialcase) flag = 1;
	return false;
}

function special(e)
{
	theObj = '';
	if (window.Event)
	{
		x1 = e.screenX;
		y1 = e.screenY;
		if (e.target.parentNode) theObj = e.target.parentNode.tagName;
	}
	else
	{
		x1 = window.event.clientX;
		y1 = window.event.clientY;
		theObj = window.event.srcElement.parentElement.tagName;
	}
	var isLink = (theObj == 'A');
	if (flag && (!isLink || ((Math.abs(x-x1) > 10) || (Math.abs(y-y1) > 10))))
	{
		copyAttempt = 1;
		flag = 0;
		alert(msg);
		return false;
	}
}

function clearIt()
{
	flag = 0;
	if (copyAttempt)
	{
		copyAttempt = 0;
		return false;
	}
}
// onload at bottom


/* generieke popup functie	*/	
function popup(url,hoogte,breedte)	{
	var height, width;
	if (document.all)
	    height = document.body.offsetHeight, width = document.body.offsetWidth;
	else if (document.layers)
	    height = window.innerHeight, width = window.innerWidth;
		
	var y = (height/4)-0, x = (width/4)-0;
	
	popupvenster = window.open(url,"venster","width="+breedte+",height="+hoogte+",toolbar=0,scrollbars=1,directories=0,status=0,menubar=0,location=0,resizable=0,top=" + y + ",screenY=" + y + ",left=" + x + ",screenX=" + x);

}
	
/* standaard popup script	*/	

	// voorbeelden:
	//  <a href="javascript:popup('pagina.html',400, 500, p_all);">
	//	popup("url", 1, 1, p_niets);
	//  popup("url", 300, 400, p_scrollbars);
	//  popup("url", 200, 300, p_fullscreen | p_menubar);
	//
	// mogelijke opties:
	//  p_scrollbars, p_resizable, p_toolbar, p_menubar, p_fullscreen, p_location en p_all
	//
	// in plaats van een getal bij de hoogte of breedte kun je ook een getal
	// tussen de 0 en de 1 in zetten. Dan word dit de verhouding qua groote op
	// het scherm. Bijvoorbeeld 0.5 zou de helft zijn.

	
	p_scrollbars = 1;
	p_resizable = 2;
	p_toolbar =  4;
	p_menubar =  8;
	p_fullscreen = 16;
	p_status = 64;
	p_location = 32;
	p_all = p_scrollbars | p_resizable | p_menubar | p_location | p_toolbar | p_status;
	
	p_niets = 0;

	

	function popup(url,breedte,hoogte, elementen) {
		var height, width;
		
		
/*		if (document.all)
		    height = document.body.offsetHeight, width = document.body.offsetWidth;
		else if (document.layers)
		    height = window.innerHeight, width = window.innerWidth;*/
			
		height = screen.height;
		width = screen.width;

		if (breedte<=0) {
			breedte = Math.round(breedte*width);
		}
		if (hoogte<=0) {
			hoogte = Math.round(hoogte*height);
		}

			
		var y = ((height-hoogte)/2), x = (width-breedte)/2;
		
		popupvenster = window.open(url,"venster",
			"width="+breedte+",height="+hoogte
			+",toolbar="+((elementen & p_toolbar)==0?'0':'1')
			+",scrollbars="+((elementen & p_scrollbars)==0?'0':'1')
			+",fullscreen="+((elementen & p_fullscreen)==0?'0':'1')
			+",directories=0,status="+((elementen & p_status)==0?'0':'1')
			+",menubar="+((elementen & p_menubar)==0?'0':'1')
			+",location="+((elementen & p_location)==0?'0':'1')
			+",resizable="+((elementen & p_resizable)==0?'0':'1')
			+",top=" + y + ",screenY=" + y + ",left=" + x + ",screenX=" + x);
	}

		
/* show/hide layers */

function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
   } else {
     obj.style.display="block";
   }
}



function getStyle( layer ) {
	if( document.getElementById ) {
		return document.getElementById( layer ).style
		} 
	else if( document.all ) {
		return document.all[layer].style
		} 
	else {
		return document[layer]
		}
	}

/*
function showLayer(laag)	{
	getStyle(laag).visibility = "visible";
	getStyle(laag).display = "block";
	}
	
function hideLayer(laag)	{
	getStyle(laag).visibility = "hidden";
	getStyle(laag).display = "none";
	}
*/

function showLayer(laag)	{
	if(typeof curLayer != "undefined")	{
		curLayer.style.display = "none";
	}
	document.getElementById(laag).style.display = "";
	curLayer = document.getElementById(laag);	
}

function toggleLayer(layer,status)	{
	if(status)	{
		getStyle(layer).visibility = "visible";
		getStyle(layer).display = "block";
	}
	else	{
		getStyle(layer).visibility = "hidden";
		getStyle(layer).display = "none";
	}
}	
	
/* empty formfield */
function makeEmpty(myFormObject)	{
	myFormObject.value = "";
	}
	
/* verwijdert alle child objectn */
function removeChildren(obj) {
		while (obj.firstChild) {
			obj.removeChild(obj.firstChild);
		}
	}
/* verwijdert alle kleinere zusjes */
function removeNextSiblings(obj)	{
	while(obj.nextSibling)	{
		obj.parentNode.removeChild(obj.nextSibling);
	}
}

function bestelFormClick(elm, i)	{
	if(elm.type == "checkbox")	{
		aantal = document.getElementById('aantal_'+i);
		if(elm.checked)	{
			aantal.value = 1;
			checkBoxes(elm, 10);
		}
		else	{
			aantal.value = "";
		}
	}
	else if(elm.type == "text")	{
		chkbx = document.getElementById('chkbx_'+i);
		if(elm.value!="")	{
			chkbx.checked = true;
		}
		else	{
			chkbx.checked = false;
		}
	}
}

function checkBoxes(curElement,maxChecked)	{
	
	//dit script loopt langs alle checkboxes en controleert of er niet teveel zijn aangevinkt.
	waarschuwing = "U kunt maximaal " + maxChecked  + " vinkjes tegelijk plaatsen";
	f = document.getElementById('bestelForm');
	checkedTeller = 0;
	aantalElementen = f.elements.length;
	
	for(i=0;i<aantalElementen;i++)	{
		if((f.elements[i].type == "checkbox") && (f.elements[i].checked == true))	{
			checkedTeller++;
			}
		}
	if((checkedTeller > maxChecked) && (curElement.checked == true))	{
		alert(waarschuwing);
		curElement.checked = false;
		}
	}
	
function checkBoxChecked()	{
	f = document.getElementById('bestelForm');
	checkedTeller = 0;
	aantalElementen = f.elements.length;
	
	for(i=0;i<aantalElementen;i++)	{
		if((f.elements[i].type == "checkbox") && (f.elements[i].checked == true))	{
			checkedTeller++;
		}
	}
	return checkedTeller;
}

function mailafriend()	{	//opent het mail-friend formulier layer
	showLayer('maf');
	//document.getElementById('footer').style.bottom = 0 + "px";
}


/*	WV specifiek	*/

function selectProvincie(prov)	{
	selectOption = document.getElementById('provSelect' + prov);
	selectOption.selected = true;
}
function show_pollcommentform()	{
	showLayer('pollCommentForm');
}

/*	sec.content mag niet langer zijn dan de prim. content	*/
//vind X en Y posities afhankelijk van je browser
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

DOM=(document.getElementById)?true:false;
IE=(document.all)?true:false;
IE4=(IE&&!DOM);
IE5=(IE&&DOM);
NS=(navigator.appName=="Netscape");
NS4=(NS&&!DOM);
NS6=(NS&&DOM);
OP5=(navigator.userAgent.indexOf("Opera")>-1&&DOM);

function getWidth()	{
    return (NS||OP5)?window.innerWidth:document.body.offsetWidth;
}
function getHeight()	{
    return (NS||OP5)?window.innerHeight:document.body.offsetHeight;
}
function trekGelijk()	{
	primCont = document.getElementById('primaryContent');
	secCon = document.getElementById('secondaryContent');
	//findPostY(primCont);
	//
	alert(primCont.offsetHeight);
	if(primCont.offsetHeight < secCon.offsetHeight)	{
		primCont.style.minHeight = secCon.offsetHeight + "px";
	}
	
	//secCon.styles.minHeight = 

}

// use multiple onload events
function addLoadEvent(func) {
    //http://simonwillison.net/2004/May/26/addLoadEvent/
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
	window.onload = func;
	} else {
		window.onload = function() {
	    	if (oldonload) {
	        	oldonload();
			}
			func();
		}
	}
}

// add hover-class to li-childs of #menu for IE
startList = function() {
	if (document.all && document.getElementById) {	//ie!
		
		//mainmenu
		mainmenuRoot = document.getElementById('mainMenu');
		liNodes = mainmenuRoot.getElementsByTagName("LI");
		for (i=0; i<liNodes.length; i++) {
			node = liNodes[i];
			if (node.nodeName=="LI") {

				node.onmouseover=function() {
					this.className+=" hover";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" hover", "");
				}
				
			}
		}
	}
}

function getFocus() {
	// onload at bottom
	window.focus();
}

function putSearchResultInTheRightPlace()	{
	// onload at bottom
	cse_result = document.getElementById('results_011482923304593572994:_gv8w5p5exk');

	
}

// onload at bottom

// Onloads
addLoadEvent(startList); // menu
//addLoadEvent(copyRight); // copyright rightclick
addLoadEvent(getFocus); // zorgt voor focus op het huidige venster, handig voor als je tussen verschillende vensters switcht bij corporate/wereldcadeus/sponsorprogramma's
addLoadEvent(putSearchResultInTheRightPlace);
addLoadEvent(noHttps);

//tijdelijke melding voor cadeaulijsten
function showCadeaulijstMededeling()    {
	alert("Fijn dat je voor een speciale gebeurtenis Wereldcadeaus wil (laten) bestellen.\nWe ontwikkelen hiervoor een speciale module met cadeaulijsten.\nTot februari 2008 kun je echter alleen Wereldcadeaus bestellen via het online bestelformulier.");
}

//kies voor een bedrag uit een selectbox of vul zelf wat in:
function FreeOverrulesFixed(selectboxObj, freetextObj)   {
	if(freetextObj.value!="")   {
        selectboxObj.options[0].selected = "selected";
	}
}
function FixedOverrulesFree(selectboxObj, freetextObj)   {
	if(selectboxObj.options[selectboxObj.selectedIndex].value!="")   {
        freetextObj.value = "";
	}
}

function noHttps()	{
	if ((location.protocol == "https:") && (location.host == "www.worldvision.nl"))	{
		nieuweurl = "http://www.worldvision.nl" + location.pathname + location.search;
		location.href = nieuweurl;
	}
}	 

function hoverBtn(status, idNumber){ //script for CSS button
	document.getElementById("specBtn"+idNumber).className = "specialButton"+status;		
} 
/*	code uitgezet op 11 aug 2008 vanwege scriptfout in IE6/7, volgens mij wordt het niet gebruikt. Johan.
var bas_cal, dp_cal, ms_cal; // declare the calendars as global variables 
	window.onload = function () { /*initialize any calendars on the page - in this case 3.*/ 
/*	
		dp_cal 	= new Epoch('dp_cal','popup',document.getElementById('date_field')); 	
	}; 
*/	
window.currentView = 0;

function showHideElement(id){
	if(id == ""){
		id=currentView;
	}
	var container = document.getElementById(id);
	var overLay = document.getElementById("overLayDiv");
	
	if(container.style.display == 'none'){container.style.display = ''; overLay.style.display = ''; currentView = id;}
	else{container.style.display = 'none'; overLay.style.display = 'none';}
	

}
window.beheerderView = 0;
function beheerderToggle(id){
//alert(id.search("Berichten"));
	if(id.search("mijnBerichten") != "-1"){x = document.getElementById("mijnBerichtenLink");x.className = ""; while(x.hasChildNodes()){x.removeChild(x.firstChild);} x.appendChild(document.createTextNode("mijn berichten"));}
	
	if( (id != beheerderView) && (beheerderView != 0) ){
		container		= document.getElementById(beheerderView);
		parentContainer = document.getElementById(beheerderView+"arrow");
		container.style.display = 'none'; parentContainer.style.background = 'transparent url(images/interface/bullet_orange.png) no-repeat scroll 4px 7px';
	}
	beheerderView = id;
	container		= document.getElementById(id);
	parentContainer = document.getElementById(id+"arrow");
	
	if(container.style.display == 'none'){container.style.display = ''; parentContainer.style.background = 'transparent url(images/interface/bullet_orange_down.png) no-repeat scroll 2px 4px';}
	else{container.style.display = 'none'; parentContainer.style.background  = 'transparent url(images/interface/bullet_orange.png) no-repeat scroll 2px 4px';}
}	

function viewBerichten(whoToShow){		
	container 	= document.getElementById("berichten");	
	aContainers = container.getElementsByTagName("div");
	geenBericht = document.getElementById("geenBerichten");
	
	removeChildren(geenBericht);			
	i = aContainers.length;
	for(a=0; a<i; ++a){
		foundElement = aContainers[a];
		if(foundElement.className == "berichtContainer"){		
			if(whoToShow == 0){foundElement.style.display = "none";document.getElementById("bekijkNieuw0").className = "active";document.getElementById("bekijkNieuw1").className = "";}
			else{			   foundElement.style.display = "block";			   document.getElementById("bekijkNieuw1").className = "active";document.getElementById("bekijkNieuw0").className = "";}
		}		
	}
	if(whoToShow == 0){ 				
		newText = document.createTextNode("Er zijn geen nieuwe berichten");		
		geenBericht.appendChild(newText); 
	//alert('ss');
	}
	
}

function cl_verwijderAdreboek(id,who){
	toContinue = confirm("Weet u zeker dat u \""+who+"\" wilt verwijderen?");
	
	if(toContinue == true){location.href= "cadeaulijsten_beheer.php?p=adresboek&e=verwijder&id="+id;}
}

function addToCart(productId, isChecked){
	get = "xml_addProductToCart.php?product="+productId+"&status="+isChecked;
	loadXMLDoc(get, callBackForTotalProducts);
}

function callBackForTotalProducts(){
	if ((req.readyState == 4) && (req.status == 200)) {
		container 	= document.getElementById("cadeausInWinkelWagen");
		
		while(container.hasChildNodes()){container.removeChild(container.lastChild);}		
		
		x 			= req.responseXML.getElementsByTagName("totalProducts")[0].firstChild.data;
		newText 	= document.createTextNode(x);
		container.appendChild(newText);
	}
}

function cl_checkEmailFieds(id){
	error = 0;

	onderwerp = document.getElementById('emailOnderwerp'+id).value;
	bericht = document.getElementById('emailBericht'+id).value;
	
	removeChildren(document.getElementById("errorOnderwerp"+id)); 
	removeChildren(document.getElementById("errorBericht"+id));
	
	if(onderwerp == ""){document.getElementById("errorOnderwerp"+id).appendChild(document.createTextNode("Dit is geen geldig onderwerp")); error = 1;}
	if(bericht == ""){  document.getElementById("errorBericht"+id).appendChild(document.createTextNode("Dit is geen geldig bericht"));     error = 1;}
	
	
	if(error != 1){				
		get = "xml_cl_send_emails.php?cadeaulijstId="+id+"&onderwerp="+onderwerp+"&bericht="+bericht;
		document.getElementById("frm_sendEmail"+id).style.display = "none";
		
		div = document.createElement("div");
		div.id = "status"+id;
		div.appendChild(document.createTextNode("Een ogenblik geduld, het bericht wordt verstuurd."));
		document.getElementById("mijnEmails"+id).appendChild(div);
		
		loadXMLDoc(get, displayClEmail);
	}

}

function displayClEmail(){
	if ((req.readyState == 4) && (req.status == 200)) {
        
		id = req.responseXML.getElementsByTagName("id")[0].firstChild.data;
		removeChildren(document.getElementById("status"+id));	
		removeChildren(document.getElementById("headText"+id));
		
									
		document.getElementById("status"+id).appendChild(document.createTextNode("Je e-mail is succesvol verstuurd naar al je gasten van deze cadeaulijst."));
        document.getElementById("headText"+id).appendChild(document.createTextNode("Bedankt voor het versturen van je e-mail!"));
        
        
    }
}







