// JavaScript Document
<!--

function getDimensions() {
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	return {x: x, y:y};
}

var testDiv;



function getTDHeight(){
	var dims = getDimensions();
	contentTopDiv = document.getElementById("content_top")
	contentBotDiv = document.getElementById("content_bottom")
	contentTop = getPixelsFromTop(contentTopDiv);
	contentBottom = getPixelsFromTop(contentBotDiv);
	contentHeight = contentBottom - contentTop;
	if(dims.y > contentHeight){
		document.getElementById("rechterbalk").style.height = dims.y + "px";
	}else{
		document.getElementById("rechterbalk").style.height = contentHeight;
	}
	document.getElementById("topfotopos").style.zIndex = 50;
	
	rechtsTopDiv = document.getElementById("rechterbalk")
	rechtsBotDiv = document.getElementById("rechtsonder")
	rechtsTop = getPixelsFromTop(rechtsTopDiv);
	rechtsBottom = getPixelsFromTop(rechtsBotDiv);
	rechtsHeight = rechtsBottom - rechtsTop;
	//alert(contentHeight + ' ' + rechtsHeight);
	//alert(dims.y + ' ' + rechtsHeight + ' ' +  contentHeight + ' ' + (rechtsHeight + 130 + "px"));
	if(contentHeight > dims.y){	
		document.getElementById("siteTB").style.height = contentHeight + 60 + "px";
		document.getElementById("rechterbalk").style.height = contentHeight + 60 + "px";
	}
	if(rechtsHeight > contentHeight){
		document.getElementById("siteTB").style.height = rechtsHeight + 60 + "px";
		document.getElementById("rechterbalk").style.height = rechtsHeight + 60 + "px";
	}
}


function getPixelsFromTop(obj){
	objFromTop = obj.offsetTop;
	while(obj.offsetParent!=null) {
		objParent = obj.offsetParent;
		objFromTop += objParent.offsetTop;
		obj = objParent;
	}
	return objFromTop;
}

function showMenu(id){
	//var productElement = document.getElementById("child" + id);
		//if (productElement != null){
			//if(document.getElementById("child" + id).style.display == 'none'){
			//	document.getElementById("child" + id).style.display = 'block';
			//}else{
			//	document.getElementById("child" + id).style.display = 'none';
			//}
		//}
	var i=1;
	while (i<20){
		var productElement = document.getElementById("child" + i);
		if (productElement != null){
			if (i == id){
				if(document.getElementById("child" + i).style.display == 'none'){
					document.getElementById("child" + i).style.display = 'block';
				}else{
					document.getElementById("child" + i).style.display = 'none';
				}
			} else{
				document.getElementById("child" + i).style.display = 'none';
			}
		}
		i=i+1;
	}
}




window.onload = function() {
	var dims = getDimensions();
	getTDHeight();
}

window.onresize = function() {
	var dims = getDimensions();
	getTDHeight();
}

function deleteProduct(id, txt) {
	if (confirm(txt)) {
		window.location = 'publicaties_bestellen.php?action=delete&id=' + id;
		GetAllCookies(30);
	}
}

function SetCookie(c_name, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(document.getElementById(c_name).value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function GetAllCookies(expiredays) {
	if (window.location.pathname.search('publicaties_bestellen.php') >= 0) {
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + expiredays);
		var velden = new Array('txt_firstname', 'txt_between', 'txt_lastname', 'txt_email', 'txt_institution', 'txt_address_deliver', 'txt_zipcode_deliver', 'txt_city_deliver', 'txt_address_invoice', 'txt_zipcode_invoice', 'txt_city_invoice');
		var veld;
		var v;
		for (v in velden) {
			veld = velden[v];
			c_start = document.cookie.indexOf(veld);
			if (c_start != -1) {
				c_start = c_start + veld.length + 1;
				c_end = document.cookie.indexOf(";", c_start);
				document.getElementById(veld).value = unescape(document.cookie.substring(c_start, c_end));
			}
		}
	}
}

function GetCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}

// --> 
