var Engine = {
	detect: function() {
		var UA = navigator.userAgent;
		this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
		this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
		this.isOpera = /Opera/.test(UA);
		this.isMSIE  = (/MSIE/.test(UA) && !this.isOpera);
		this.isMSIE7 = this.isMSIE && !(/MSIE 6\./.test(UA) && !this.isOpera);
	}
}
Engine.detect();

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// popup
function popup (url,name,h,v,sc,st) {
	var win;
	win = window.open(url,name,'width='+h+',height='+v+',scrollbars='+sc+',resizable=no,resize=no,toolbar=no,status='+st+',directories=no,menubar=no,location=no');
	win.focus();
}



	
function myPop(e) {
	// gegen IE
	if (!e) var e = window.event;
	var a = e.target ? e.target : e.srcElement;

	// neues Fenster mit dem link aus href="..."
	if (typeof e != 'undefined' && e.tagName == "A") {
		var newwin = window.open(a.href);
	} else if (this.tagName == "A") {
		var newwin = window.open(this.href);
	}
	return !newwin;                               
}

function initNavigation(bHideDD)
{
	if (!document.getElementById('navi')) return;
	
	var iUlCounter = 0;
	var oNavi = document.getElementById('navi');
	
	for (var i=0; i<oNavi.childNodes.length; i++)
	{
		if (oNavi.childNodes[i].nodeName=='LI')
		{
			iUlCounter++;

			if (bHideDD && iUlCounter>=3 && iUlCounter<=6)
			{
				$('navi').childNodes[i].onmouseover = function()
				{
					if (!document.getElementById('popuplayer') || 
						document.getElementById('popuplayer') && document.getElementById('popuplayer').style.display == 'none')
					{
						Element.hide('select-country-websites');
						Element.show('select-country-websites-fake');
						Element.hide('select-contact-worldwide');
						Element.show('select-contact-worldwide-fake');
					}
					this.className+="hover";
				} // $('navi').childNodes[i].onmouseover = function()
				
				$('navi').childNodes[i].onmouseout = function()
				{
					if (!document.getElementById('popuplayer') || 
						document.getElementById('popuplayer') && document.getElementById('popuplayer').style.display == 'none')
					{
						Element.show('select-country-websites');
						Element.hide('select-country-websites-fake');
						Element.show('select-contact-worldwide');
						Element.hide('select-contact-worldwide-fake');
					}
					this.className=this.className.replace("hover", "");
				} // $('navi').childNodes[i].onmouseout = function()
			} // if (iUlCounter>=3 && iUlCounter<=5)
			else
			{
				oNavi.childNodes[i].onmouseover = function()
				{
					this.className+="hover";
				} // oNavi.childNodes[i].onmouseover = function()
				
				oNavi.childNodes[i].onmouseout = function()
				{
					this.className=this.className.replace("hover", "");
				} // oNavi.childNodes[i].onmouseout = function()
			} // Ende else
		} // if (oNavi.childNodes[i].nodeName=='LI')
	} // for (var i=0; i<oNavi.childNodes.length; i++)
} // window.onload = function()

function openInWindow(mDropDown, sTarget)
{
	var oNewWin = null;
	
	if (typeof mDropDown=='string')
	{
		if (document.getElementById('form-search-productname').elements['tx_editfiltersystem_pi1[name]'])
			document.getElementById('form-search-productname').elements['tx_editfiltersystem_pi1[name]'].focus();
		oNewWin = window.open(mDropDown, sTarget);
	}
	else if (mDropDown.value!='')
	{
		if (document.getElementById('form-search-productname').elements['tx_editfiltersystem_pi1[name]'])
			document.getElementById('form-search-productname').elements['tx_editfiltersystem_pi1[name]'].focus();
		oNewWin = window.open(mDropDown.value, sTarget);
	} // if (oDropDown.value!='')
	
	if (oNewWin)
	{
		oNewWin.focus();
	} // if (oNewWin)
	
	return false;
} // Ende Funktion openInWindow


function init()
{
	// alle Links holen
	var links = document.getElementsByTagName('a');
	
	// ruechwaerts (schneller) durch alle Links
	for (var i = links.length; i != 0; i--) {
		
		// alle Links in var a
		var a = links[i-1];
		
		// Element ueberspringen, die nicht <a ...>
		if (!a.href) continue;

		// alle Links mit der Klasse "extern"
		if (a.className && a.className.indexOf('extern') != -1) a.onclick = myPop;
	}
	
	// Navigation fuer den IE<=6 aufbereiten
	if (Engine.isMSIE && !Engine.isMSIE7)
	{
		initNavigation(/lcs\/(de|en)\/$/.test(window.location) || /lcs\/(de|en)\/home_test\/$/.test(window.location) ||
			/lcs\/(de|en)\/index\.php$/.test(window.location) || /lcs\/(de|en)\/home_test\/index\.php$/.test(window.location));
	} // if (!Engine.isMSIE)
} // window.onload = function()

// Onload
window.onload = init;

