var NoPopupsDone = 0;
var CurrWindowOpen = window.open;
var CurrWindowOpen2 = window.open;
var orig_setTimeout = window.setTimeout;
var orig_setInterval = window.setInterval;
if ( window.showModelessDialog ) { var orig_showModelessDialog = window.showModelessDialog;} if ( window.showModalDialog ) { var orig_showModalDialog = window.showModalDialog;} 
var cnt = 0;
var popupType = "direct";
var KPF_LOG_URL = "";
var KPF_TIMEOUT = 100;
var onUnloadFlag = false;
var KPF_CompleteLoaded = false;
function nullMethod() {}
function nullWindow() {	 this.window = new Object(); this.document = new Object(); this.document.open=this.document.close=this.document.write=this.document.writeln=nullMethod; this.alert=this.back=this.blur=this.captureEvents=this.clearInterval=this.clearTimeout=this.close=this.confirm=this.dump=this.escape=this.focus=this.forward=this.GetAttention=this.getSelection=this.home=this.moveBy=this.moveTo=this.open=this.print=this.prompt=this.releaseEvents=this.resizeBy=this.resizeTo=this.scroll=this.scrollBy=this.scrollByLines=this.scrollByPages=this.scrollTo=this.setCursor=this.setInterval=this.setTimeout=this.sizeToContent=this.stop=this.unescape=this.updateCommands=nullMethod;}
function destroyIframe(ifr){ if (ifr != document.getElementById("kpfLogFrame"))   { var x = ifr.parentNode.removeChild(ifr);    delete x;  };}
function sendStream(s, idx, kpf_pt){ try {        var ifr = document.getElementById("kpfLogFrame");   var tmp = ifr.cloneNode(true);   tmp.id  = "ifr_" + idx;   var s2 = "srv=" + document.location + "&url=" + s + "&pty=" + kpf_pt;   tmp.src = KPF_LOG_URL + escape(s2);   document.body.appendChild(tmp); } catch (e) {   orig_setTimeout("sendStream('" + s + "', " + idx + ",'" + kpf_pt + "')", KPF_TIMEOUT); }}
function sendUrl(url){ if (onUnloadFlag)   sendStream(url, cnt++, popupType); else  {  try {   orig_setTimeout("sendStream('" + url + "', cnt++,'" + popupType + "')", KPF_TIMEOUT);  }   catch (e)   {}	  }}
function newOpen(url, name, atr) {wnd = new nullWindow();wnd.focus = nullWindow;wnd.opener = this.window;sendUrl(url);return(wnd); }
function newOpen2(url, name, atr) { sendUrl(url); return(new nullWindow());}
function stopPopups(kpf_pt) { popupType = kpf_pt; CurrWindowOpen = window.open; window.open = newOpen2; }
function startPopups(kpf_pt) { window.open = CurrWindowOpen;  popupType = kpf_pt;}
function my_setTimeout(one, two) { try {  return orig_setTimeout("stopPopups('ontimer');"+one+";startPopups('direct');", two); }  catch (e)  {}}
function my_setInterval(one, two) { try {  return orig_setInterval("stopPopups('ontimer');"+one+";startPopups('direct');", two); }  catch (e)  { }}
function my_onload() { var my_retcode = true; stopPopups("onload"); if(orig_onload)  my_retcode = orig_onload(); startPopups("direct"); KPF_CompleteLoaded = true; return my_retcode; }
function my_unload() {  var my_retcode = true; var cnt = 0; stopPopups("onunload"); onUnloadFlag = true; if(orig_onunload)   my_retcode = orig_onunload(); startPopups("direct"); return my_retcode;}
function my_windowopen(url, name, atr){ if ( (! KPF_CompleteLoaded) || (document.all && event != null && event.type == "mouseover") )  {  if ( ! KPF_CompleteLoaded) {   popupType = "direct";  }  else {   popupType = "mouseover";  }  sendUrl(url);  popupType = "direct"; } else {   try {   return CurrWindowOpen2(url, name, atr);  }   catch (e)   {}  }}
function my_showModelessDialog (url , arguments , features) { if (!NoPopupsDone) {   var wnd = new nullWindow();  popupType = "direct_dialog";  sendUrl(url);  popupType = "direct";  return wnd; } if (popupType!="direct" | (event && event.type == "mouseover") ) {   var curr_popup = popupType;  if (event && event.type == "mouseover") {   popupType = "mouseover";  }    popupType = popupType+"_dialog";  sendUrl(url);  popupType = curr_popup;  return ( new nullWindow() ); } else {   return ( orig_showModelessDialog(url , arguments , features) );  } }
function my_showModalDialog (url , arguments , features) { if (!NoPopupsDone) {   popupType = "direct_dialog";  sendUrl(url);  popupType = "direct";  return ""; } if (popupType!="direct" | (event && event.type == "mouseover") ) {   var curr_popup = popupType;  if (event && event.type == "mouseover") {   popupType = "mouseover";  }    popupType = popupType+"_dialog";  sendUrl(url);  popupType = curr_popup;  return ""; } else {   return ( orig_showModalDialog(url , arguments , features) );  } }
function nopopups() { if(!NoPopupsDone)   {  NoPopupsDone = 1;  orig_onload = window.onload;  orig_onunload = window.onunload;  window.onload = my_onload;  window.onunload = my_unload;  window.open = my_windowopen;  }}
window.setTimeout = my_setTimeout;window.setInterval = my_setInterval;window.open = newOpen;if ( orig_showModelessDialog ) { window.showModelessDialog = my_showModelessDialog;}if ( orig_showModalDialog ) { window.showModalDialog = my_showModalDialog;}

var userAgent = navigator.userAgent.toLowerCase();
var is_safari = ((userAgent.indexOf("safari") != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_firefox = (userAgent.indexOf("firefox") != -1);
var is_mac = (userAgent.indexOf("macintosh") != -1);
var is_konqueror = (userAgent.indexOf('konqueror') != -1);

var menucurrent = null;
var menutimer = null;
var menuoffsetx = 0;
var menuoffsety = 0;
var menuclickbar = true;
var trackerproblem = null;

function MenuInit()
{
	if (is_safari)
	{
		menuoffsetx = 7;
		menuoffsety = 8;
		menuclickbar = false;
	}
	if (is_konqueror)
		menuclickbar = false;
	document.getElementById("tab_home").onmouseover = HoverTabOver;
	document.getElementById("tab_home").onmouseout = HoverTabOut;
	document.getElementById("tab_home_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_home_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_home_menu").style.display = "none";
	document.getElementById("tab_home_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_home_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}
	document.getElementById("tab_bindwerk").onmouseover = HoverTabOver;
	document.getElementById("tab_bindwerk").onmouseout = HoverTabOut;
	document.getElementById("tab_bindwerk_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_bindwerk_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_bindwerk_menu").style.display = "none";
	document.getElementById("tab_bindwerk_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_bindwerk_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}
	document.getElementById("tab_karton").onmouseover = HoverTabOver;
	document.getElementById("tab_karton").onmouseout = HoverTabOut;
	document.getElementById("tab_karton_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_karton_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_karton_menu").style.display = "none";
	document.getElementById("tab_karton_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_karton_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}
	document.getElementById("tab_restauratie").onmouseover = HoverTabOver;
	document.getElementById("tab_restauratie").onmouseout = HoverTabOut;
	document.getElementById("tab_restauratie_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_restauratie_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_restauratie_menu").style.display = "none";
	document.getElementById("tab_restauratie_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_restauratie_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}
	document.getElementById("tab_specials").onmouseover = HoverTabOver;
	document.getElementById("tab_specials").onmouseout = HoverTabOut;
	document.getElementById("tab_specials_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_specials_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_specials_menu").style.display = "none";
	document.getElementById("tab_specials_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_specials_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}

	document.getElementById("tab_offerte").onmouseover = HoverTabOver;
	document.getElementById("tab_offerte").onmouseout = HoverTabOut;
	document.getElementById("tab_offerte_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_offerte_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_offerte_menu").style.display = "none";
	document.getElementById("tab_offerte_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_offerte_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}
	document.getElementById("tab_contact").onmouseover = HoverTabOver;
	document.getElementById("tab_contact").onmouseout = HoverTabOut;
	document.getElementById("tab_contact_menu").onmouseover = HoverMenuOver;
	document.getElementById("tab_contact_menu").onmouseout = HoverMenuOut;
	document.getElementById("tab_contact_menu").style.display = "none";
	document.getElementById("tab_contact_menu").style.position = "absolute";
	if (menuclickbar)
	{
		var table = document.getElementById("tab_contact_menu");
		var rows = table.getElementsByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			cell = rows[i].getElementsByTagName("td");
			cell[0].onclick = ClickBar;
		}
	}


}

function HoverTabOver()
{
	if (menutimer != null)
			clearTimeout(menutimer);
	if ((menucurrent != null) && (menucurrent != this.id))
		MenuClose(menucurrent+"_menu");
	MenuOpen(this.id);
	menucurrent = this.id;
	this.className = "topbar_tab_active";
	document.getElementById(this.id+"_image").className = "image_menu_active";
}

function HoverTabOut()
{
	menutimer = setTimeout("MenuClose('"+this.id+"_menu');",500);
}

function HoverMenuOver()
{
	if (menutimer != null)
		clearTimeout(menutimer);
}

function HoverMenuOut()
{
	menutimer = setTimeout("MenuClose('"+this.id+"');",500);
}

function MenuOpen(idname)
{
	menu = document.getElementById(idname+"_menu");
	tab = document.getElementById(idname);
	menu.style.display = "";
	menu.style.left = (getElementPosX(tab)+menuoffsetx)+"px";
	menu.style.top = (getElementPosY(tab)+19+menuoffsety)+"px";
}

function MenuClose(idname)
{
	document.getElementById(idname).style.display = "none";
	document.getElementById(menucurrent).className = "topbar_tab_inactive";
	document.getElementById(menucurrent+"_image").className = "image_menu_inactive";
}

function ClickBar()
{
	links = this.getElementsByTagName("a");
	if (links.length > 0)
		window.location = links[0].href;
}

function getElementPosX(object)
{
	var curleft = 0;
	if (object.offsetParent)
	{
		while (object.offsetParent)
		{
			curleft += object.offsetLeft
			object = object.offsetParent;
		}
	}
	else if (object.x)
		curleft += object.x;
	return curleft;
}

function getElementPosY(object)
{
	var curtop = 0;
	if (object.offsetParent)
	{
		while (object.offsetParent)
		{
			curtop += object.offsetTop
			object = object.offsetParent;
		}
	}
	else if (object.y)
		curtop += object.y;
	return curtop;
}

function CloseButtonInit()
{
	document.getElementById("closebutton").onclick = CloseButton;
}

function CloseButton()
{
	window.close();
}

function TrackerProblemPopUp(page)
{
	if (trackerproblem && !trackerproblem.closed)
	{
		trackerproblem.location = page;
		trackerproblem.focus();
		return;
	}
	trackerproblem = window.open(page,"trackerproblem_window","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=425,top=50,left=50");
	trackerproblem.focus();
}// JavaScript Document
