
	if (window.ssl==null) {
		ssl = false;
	}
	if ((ssl!=null) && (ssl==true)) {
		if ((location.protocol == "http:") && (location.host == "www.gospel.nl"))	{
			nieuweurl = "https://" + location.hostname + location.pathname + location.search;
			location.href = nieuweurl;
		}
	} else {
		if ((location.protocol == "https:") && (location.host == "www.gospel.nl"))	{
			nieuweurl = "http://" + location.hostname + location.pathname + location.search;
			location.href = nieuweurl;
		}
	}
	/* roll overs */
	function hilite(naam)	{
		if (navigator.appName.indexOf("Explorer") != -1){
			document.images[naam].src = 	"images/interface/menu_" + naam + "_on.jpg";
			window.status = naam.substr(0,1).toUpperCase() + naam.substr(1);
			return true;
			}
		}

	function lolite(naam)	{

		if (navigator.appName.indexOf("Explorer") != -1){
			document.images[naam].src = 	"images/interface/menu_" + naam + ".jpg";
			window.status = "Plica Protect";
			return true;
			}
		}

/*	cookie zetten en lezen	*/
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

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


	/* 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/2)-100, x = (width/2)-220;

		popupvenster = window.open(url,"venster","width="+breedte+",height="+hoogte+",toolbar=0,scrollbars=no,directories=0,status=0,menubar=0,location=0,resizable=0,top=" + y + ",screenY=" + y + ",left=" + x + ",screenX=" + x);

		}


	/* grote fotos tonen in popup */

	function fotovergroten(jpgnaam)	{
		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/2)-100, x = (width/2)-220; // default values
		if((!window.grotefotovenster) || (grotefotovenster.closed))	{
			grotefotovenster = window.open("about:blank","fotovenster","width=440,height=330,toolbar=0,scrollbars=0,directories=0,status=0,menubar=0,location=0,resizable=0,top=" + y + ",screenY=" + y + ",left=" + x + ",screenX=" + x);
			}
		grotefotovenster.document.location.href = "foto.php";
		setTimeout('update("' + jpgnaam + '")',500)
		}

	function update(jpgnaam)	{

		grotefotovenster.document.theImage.src = "images/vergroot/" + jpgnaam + "_large.jpg"
		grotefotovenster.document.focus();
		}





//wishlist related
	function addToWishlist(bestelnr)	{
		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/2)-100, x = (width/2)-220; // default values
		wishlistvenster = window.open("wishlist_add.php?ID=" + bestelnr,"wishlist","width=440,height=330,toolbar=0,scrollbars=0,directories=0,status=0,menubar=0,location=0,resizable=0,top=" + y + ",screenY=" + y + ",left=" + x + ",screenX=" + x);
		}


/* Statusbalk */
function showstatus(bericht)	{
	parent.window.status = bericht;
	return true;
	}

function clearstatus()	{
	window.status = "";
	return true;
	}

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 writeText( layer,text ) {
	if( document.getElementById ) {
		obj = document.getElementById( layer );
		obj.innerHTML = text;
		alert('bla');
		document.normalize();
	} else if( document.all ) {
		document.all[layer].innerHTML = text;
	} else {
		document[layer].document.open();
		document[layer].document.write( text );
		document[layer].document.close();
	}
}

//update aantallen + subtotalen in winkelmandje

	function update(form,sleutel,waarde)	{
		if ( (waarde > 0) ) {
			bevestig = window.confirm('De hoeveelheden van sommige artikelen kunnen gewijzigd zijn.\nDaarom moet je het winkelmandje opnieuw berekenen voor je naar de volgende stap kunt.\n Wil je het winkelmandje nu herberekenen?');
			if (bevestig)	{
				form.update_sleutel.value = sleutel;
				form.update_aantal.value = waarde;
				return form.submit();
   			}
	    }
		else	{
			waarde = 1;
			update(form,sleutel,waarde);
			}
		}


/* handig op de afrekenpagina */
function swapvisible(laag,modus,laag2,modus2)	{
	getStyle(laag).visibility = modus;
	getStyle(laag2).visibility = modus2;

	if(modus == 'visible')	{
		getStyle(laag).display = 'block';
		}
	else	{
		getStyle(laag).display = 'none';
		}

	if(modus2 == 'visible')	{
		getStyle(laag2).display = 'block';
		}
	else	{
		getStyle(laag2).display = 'none';
		}
	}

/* ook voor afrekenpagina */
function bezorgkeuze(boxstatus)	{
	if(boxstatus)	{
		swapvisible('bezorggedeelte','visible','bezorgkeuze','visible');
		}
	else	{
		swapvisible('bezorggedeelte','hidden','bezorgkeuze','visible');
		}
	}


function number_format(getal) {
	//deze functie formateert nummer zoals bij PHP number_format dit doet
    var fixedNum = Math.round(parseFloat(getal) * 100) / 100;
    var sFixedNum = new String(fixedNum);
    var aFixedNum = sFixedNum.split(".");

    var i = (aFixedNum[1]) ? aFixedNum[1].length : 0;
    if (i == 0) sFixedNum += ".";
    while (i < 2) {
        sFixedNum += "0";
        i++;
    }
	return sFixedNum
}

/* wel of niet tonen van de machtigings-tekst + invulveld voor rekeningnummer op de afrekenpagina*/
function showKorting	(useIt,korting,totaalprijs)	{

	//korting mag niet groter zijn dan totaalprijs!
	if(korting > totaalprijs)	{
		korting = totaalprijs;
	}

	elmTotaalprijs = document.getElementById('totaalBedrag');
	elmSpaarRegel = document.getElementById('spaarRegel');
	elmSpaarBedrag = document.getElementById('spaarBedrag');

	//wis alles uit de elmSpaarBedrag-span
	for (i=elmSpaarBedrag.childNodes.length-1; i>=0; i-- )	{
		elmSpaarBedrag.removeChild(elmSpaarBedrag.childNodes.item(i));
	}
	//wis alles uit de totaalBedrag-span
	for (i=elmTotaalprijs.childNodes.length-1; i>=0; i-- )	{
		elmTotaalprijs.removeChild(elmTotaalprijs.childNodes.item(i));
	}

	if(useIt)	{
		//nieuwe bedragen wegschrijven naar document
		kortingTextNode = document.createTextNode("- \u20AC " + number_format(korting,2));
		elmSpaarBedrag.appendChild(kortingTextNode);
		totaalprijsTextNode = document.createTextNode("\u20AC " + number_format((totaalprijs-korting),2));
		elmTotaalprijs.appendChild(totaalprijsTextNode);

		if(korting >= totaalprijs)	{
			//verberg betaalinfo
			getStyle('payparts').visibility = 'hidden';
			getStyle('payparts').display = 'none';
		}
		//toon kortingsregel in factuur
		getStyle('spaarRegel').visibility = "visible";
		getStyle('spaarRegel').display = "block";
	}
	else	{
		//nieuwe bedragen wegschrijven naar document
		kortingTextNode = document.createTextNode("- \u20AC " + number_format(0,2));
		elmSpaarBedrag.appendChild(kortingTextNode);
		totaalprijsTextNode = document.createTextNode("\u20AC " + number_format(totaalprijs,2));
		elmTotaalprijs.appendChild(totaalprijsTextNode);

		//toon betaalinfo
		getStyle('payparts').visibility = 'visible';
		getStyle('payparts').display = 'block';
		//verberg kortingsregel in factuur
		getStyle('spaarRegel').visibility = "hidden";
		getStyle('spaarRegel').display = "none";
	}

}


/* beperking van het aantal karakters in een textarea */
		function countchars(tekstareaObject,limit)	{

			 var nogtegaan = limit - tekstareaObject.value.length;
			 if(nogtegaan < 0)	{
			 	alert('Je hebt geen karakter meer over!');
			 	tekstareaObject.value = tekstareaObject.value.substring(0,limit);
				nogtegaan = 0;
			 	}

		}
/* Partner Programma */
	function partnerProgramma(productID) {
	//function partnerProgramma(i, page, hash) {
		//partner = window.open("partner/index.php?id="+i+(hash!=null?"&hash="+escape(hash):"")+(page!=null?"&page="+escape(page):""),"partner", "width=400,height=320,x=200,y=100,top=100,left=200");
		windowopen = "http://www.gospel.nl/partner/index.php";
		if (productID) {
			windowopen += "?function=specific&productID=" + productID;
		}
		partner = window.open(windowopen, "partner", "width=400,height=320,x=200,y=100,top=100,left=200");
	}


	function showGospelTAF(state)	{	//state = a of p (active/passive)
		//KEES KRAAY layer
		if(state == "a")	{
			document.getElementById('tellafriend').style.visibility = "visible";
		}	else	{
			document.getElementById('tellafriend').style.visibility = "hidden";
		}
		/*
		if((!Get_Cookie('gospeltaf')) || state=="a")	{
			TAFwindow = window.open("tellafriend_kraayenoord.php","partner", "width=450,height=500,x=200,y=100,top=100,left=200");
		}
		*/
	}

	function makeEmpty(myFormObject)	{
		myFormObject.value = "";
		}

/* Vraag en Aanbod */
	function deleteAd(advertentieID)	{
		zekerweten = confirm("Klik op 'OK' om je advertentie te verwijderen\nKlik op 'Cancel' je advertentie te behouden");
		if(zekerweten)	{
			location.href = "vea_delad.php?veaID=" + advertentieID;
			}
		}
	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;
	}