function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(doRegioTool);
addLoadEvent(doIEhover);

function do_continentchange(theForm) {
	while (theForm.lang.options.length > 1) {
		theForm.lang.options[(theForm.lang.options.length - 1)] = null;
	}
	theForm.lang.style.display = "none";
	if (theForm.reg.value == "eu") {
		theForm.lang.options[0]= new Option("Language", "", true, true);
		theForm.lang.options[1]= new Option("Nederlands", "nl", true, false);
		theForm.lang.options[2]= new Option("Français", "fr", true, false);
		theForm.lang.options[3]= new Option("English", "en", true, false);
		theForm.lang.options[4]= new Option("Deutsch", "de", true, false);
		theForm.lang.options[5]= new Option("Español", "es", true, false);
		theForm.lang.style.display = "inline";
	}
	if (theForm.reg.value == "us") {
		theForm.lang.options[0]= new Option("Language", "", true, true);
		theForm.lang.options[1]= new Option("Français", "fr", true, false);
		theForm.lang.options[2]= new Option("English", "en", true, false);
		theForm.lang.options[3]= new Option("Español", "es", true, false);
		theForm.lang.style.display = "inline";
	}
	if (theForm.reg.value == "or") {
		theForm.lang.options[0]= new Option("Language", "", true, true);
		theForm.lang.options[1]= new Option("Nederlands", "nl", true, false);
		theForm.lang.options[2]= new Option("Français", "fr", true, false);
		theForm.lang.options[3]= new Option("English", "en", true, false);
		theForm.lang.options[4]= new Option("Deutsch", "de", true, false);
		theForm.lang.options[5]= new Option("Español", "es", true, false);
		theForm.lang.style.display = "inline";
	}
}
function do_go(theForm) {
	if (theForm.lang.value != "") {
		url = theForm.site_eu.value;
		document.location="http://"+url+"/"+theForm.lang.options[theForm.lang.selectedIndex].value;
	}
}
/*
function do_go(theForm) {
	var error = 0;
	if (theForm.reg.value == "") {
		alert(lbl_lang_select_continent);
		error++;
	}
	if (theForm.lang.value == "" && error == 0) {
		alert(lbl_lang_select_language);
		error++;
	}
	if (!error) {
		switch(theForm.reg.options[theForm.reg.selectedIndex].value) {
			case "eu": 
				url = theForm.site_eu.value;
				break;
			case "us": 
				url = theForm.site_us.value;
				break;
			case "ot": 
				url = theForm.site_ot.value;
				break;
		}
		document.location="http://"+url+"/"+theForm.lang.options[theForm.lang.selectedIndex].value;
	}
}
*/

function doRegioTool() {
	var tool = document.getElementById("doRegioTool");
	var tooltip = document.getElementById("startform");
	if (tool && tooltip) {
		tool.onclick = function() {
			tooltip.style.display = "block";
			return false;
		}
	}
}
function closeRegioTool() {
	var tooltip = document.getElementById("startform");
	if (tooltip) {
		tooltip.style.display = "none";
		return false;
	}
}

function setActiveBlock(id,container) {
	var th = document.getElementById(container);
	if (th) {
		var lis = th.getElementsByTagName("li");
		for(i=0;i<lis.length;i++) {
			lis[i].className = "";
		}
	}
	var this_prod = document.getElementById(id);
	if (this_prod) {
		this_prod.className = "active";
	}
}

function doIEhover() {
	if(navigator.appName=="Microsoft Internet Explorer") {
		var productsNav = document.getElementById("products_nav");
		if(productsNav) {
			var LIs = productsNav.getElementsByTagName("li");
			for(var i=0; i<LIs.length; i++) {
				if(LIs[i].parentNode.id=="products_nav") {
					LIs[i].onmouseover = function() {
						this.className="sHover";
					}
					LIs[i].onmouseout = function() {
						this.className="";
					}
				}
			}
		}
	}
		
	var productsCats = document.getElementById("products_cats");
	if(productsCats) {
		var DIVs = productsCats.getElementsByTagName("div");
		for(var i=0; i<DIVs.length; i++) {
			if(DIVs[i].className=="frontImagePPt") {
				DIVs[i].onmouseover = function() {
					if(navigator.appName=="Microsoft Internet Explorer") {
						this.className="frontImagePPt_sHover";
					}
					mouseEvents(this.id.replace("pc",""),'over');
				}
				DIVs[i].onmouseout = function() {
					if(navigator.appName=="Microsoft Internet Explorer") {
						this.className="frontImagePPt";
					}
					mouseEvents(this.id.replace("pc",""),'out');
				}
			}
		}
	}
}

mouseEvents = function(el,event) {
	//alert(el+" "+event);
	var pos19 = "0px 4px"; 		var posA19 = "-100px 4px"; //-89px
	var pos20 = "0px -16px"; 	var posA20 = "-100px -16px"; 
	var pos21 = "0px -36px"; 	var posA21 = "-100px -36px"; 
	var pos22 = "0px -56px"; 	var posA22 = "-100px -56px";
	var pos23 = "0px -76px"; 		var posA23 = "-100px -76px";
	var pos24 = "0px -96px"; 		var posA24 = "-100px -96px";
	var pos25 = "0px -336px"; 	var posA25 = "-100px -336px";
	var pos583 = "0px -136px"; 	var posA583 = "-100px -136px";
	var pos505 = "0px -156px"; 	var posA505 = "-100px -156px";
	var pos68 = "0px -256px"; 	var posA68 = "-100px -256px";
	var pos69 = "0px -276px"; 	var posA69 = "-100px -276px";
	var pos70 = "0px -296px"; 	var posA70 = "-100px -296px";
	if (event == "over") {
		document.getElementById('cat_nav_'+el).style.backgroundPosition = eval("posA"+el);
	}
	if (event == "out") {
		document.getElementById('cat_nav_'+el).style.backgroundPosition = eval("pos"+el);
	}
}



/*******************************
IMAGEPOP
(c) 2003, Peter Bailey, http://www.peterbailey.net
Modified by Skyzyx Genesis, http://www.skyzyx.com

- Works in IE5+, Gecko 0.94+ (maybe earlier?)
- Downlevel for Opera.
- Probably works in KHTML browsers
*******************************/

function imgPop(imageURL) {
	if (document.getElementById && navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		var imgWin = window.open('about:blank','imgWin','width=200, height=200, left=200, top=100');

		with (imgWin.document)
		{
			writeln('<html><head><title>Loading...</title>');
			writeln('<style type="text/css"><!-- body { margin: 0px; } --></style></head>');
			writeln('<body onload="self.focus();"><img id="pic" style="display:none" /></body></html>');
			close();		
		}

		var img = new Image();
		img.onload = function() { sizeImgWin(imgWin, img); };
		img.src = imageURL;
	}
	else window.open(imageURL);
}
	
function sizeImgWin(win, img) {
   	var new_w = img.width;
	var new_h = img.height;
	var old_w = win.innerWidth || win.document.body.offsetWidth;
	var old_h = win.innerHeight || win.document.body.offsetHeight;

	if (!new_w) { new_w = old_w; }
	if (!new_h) { new_h = old_h; }

	new_w -= old_w; new_h -= old_h;
	win.resizeBy(new_w,new_h);
	win.document.title = img.src.substring(img.src.lastIndexOf("/")+1);
	var pic = win.document.getElementById('pic');
	pic.src = img.src;
	pic.style.display = 'block';

	sw=screen.width;
	sh=screen.height;

	var leftPos=((sw-new_w)/2)-100; // Exactly centered.
	var topPos=((sh-new_h)/2)-(100+(((sh-new_h)/2)*0.1)); // Centered, then moved up 10%
	//win.moveTo(leftPos, topPos);
}


function popup(url, width, height) {
	theWidth = width;
	theHeight = height;
	theTop = Math.ceil((screen.height-theHeight*1.5)/2);
	theLeft = Math.ceil((screen.width-theWidth)/2);
	winopts = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,copyhistory=0,width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft;
	smallwindow=window.open(url,"Popup",winopts);
	smallwindow.focus();
}

