var CookieValue = readCookie("ToonToelichting")

onload = function(){
	resizeMainPage()
	if(CookieValue == "true"){
		laadIframe('glaskompas.asp')
	}else{
		laadIframe('help/start_introductie.asp')
	}
}
onresize = function(){
	resizeMainPage()
}

var resizeMainPage = function(){
	var availW, availH, hoogte, breedte

	if(document.all){
		availW = document.body.clientWidth
		availH = document.body.clientHeight
	}else{
		availW = innerWidth
		availH = innerHeight
	}

	if(document.getElementById("ContentFrame")){
		document.getElementById("ContentFrame").style.height	= (availH = availH - 80 - 20 - 20 - 15 - 23) + "px"
	}
}

var laadIframe = function(IframeURL){
	var objI			= document.getElementById("ContentFrame")
	var objF			= document.getElementById("footerCell")
	var objFinnerHTML	= ""

	if(objI){
		objI.src = IframeURL
		if(IframeURL.search(/start/gi) != -1){
			objFinnerHTML	= "<input type='checkbox' value='' id='ToelichtingCheck' OnClick='ToelichtingCheckHandler(this.checked)'"
			if(CookieValue == "true"){
				objFinnerHTML += " checked"
			}
			objFinnerHTML += "><label for='ToelichtingCheck'>Deze informatie niet meer tonen tijdens het opstarten</label>"
		}else{
			objFinnerHTML	= "<A href='javascript:laadIframe(\"help/disclaimer.asp\")' class='navigatieHref' style='padding-left:0px;'>disclaimer</A><A href='http://www.saint-gobain-glass.com/ce' target='_blank'  class='navigatieHref' style='padding-left:20px;'>CE-markering</A><A href='http://www.sggs.nl/Nederland/Glas%20informatie/Productie_en_functies_van_glas/Functies_van_glas/Energiebesparingscalculator.asp' target='_blank'  class='navigatieHref' style='padding-left:20px;'>besparingscalculator</A><A href='http://www.sggs.nl/Nederland/Glas%20informatie/Product_zoeken/Product_zoeken.asp' target='_blank' title='Zoek via de SGGS website' class='navigatieHref' style='padding-left:620px;'>zoek</A>"
		}

		if(objF){
			objF.innerHTML	= objFinnerHTML
		}
	}
}

var ToelichtingCheckHandler = function(waarde){
	saveCookie("ToonToelichting", waarde, 28)
}

var loginHandler = function (waarde){
	if(waarde){
		document.getElementById("loginHref").innerHTML	= "Uitloggen"
		document.getElementById("loginHref").href		= "javascript:popup('popup', 'uitloggen.asp', 550, 600, true)"
		document.getElementById("ContentFrame").src		= "glaskompas.asp?pro=true"
	}else{
		document.getElementById("loginHref").innerHTML	= "Inloggen"
		document.getElementById("loginHref").href		= "javascript:laadIframe('inloggen.asp')"
		document.getElementById("ContentFrame").src		= "help/start_introductie.asp"
	}
}

var popup = function(popupName, pageURL, pageWidth, pageHeight, scroll){
	var scrollText = ""

	try{popfnwin.close()}
	catch(e){};
	if(typeof scroll != "undefined"){
		if(scroll){
			scrollText = "scrollbars=1,"
		}
	}

	popfnwin=window.open(pageURL, popupName, "resizable=1,status=1," + scrollText + "WIDTH="+pageWidth+",HEIGHT="+pageHeight)
}

var wisselnavigatie = function(url){
	url = url.toLowerCase();

	var a = [
		["introductielink",		"help/start_introductie.asp"],
		["gebruiklink",			"help/start_gebruiksaanwijzing.asp"],
		["faqlink",				"bestekken.asp"],
		["glaskompaslink",		"glaskompas.asp"],
		["glaskompasProlink",	"glaskompas.asp?pro=true"],
		["contactlink",			"help/contact.asp"]
	];

	var l = a.length;

	if(url == ""){
		url = a[0][1];
	}

	for(var i = 0; i < l; i++){
		if(document.getElementById(a[i][0])){
			document.getElementById(a[i][0]).className = "navigatieHref";
		}
		if(url == a[i][1]){
			document.getElementById(a[i][0]).className = "navigatieHrefActief";
		}
	}
}
