//TYPO3 code

var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){if(msie4){theObject.blur();}}
function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}
return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}
return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}

// redirect to top
if (top.location != self.location) { top.location.href = document.location.href; }

// JavaScript Document
(function() {

 var siteLocation ="fileadmin/templates/";
 
 var image1 = new Image();
 	image1.src =  siteLocation + "images/i_home.gif";
 var image2 = new Image();
	image2.src =  siteLocation + "images/i_home_o.gif";
 var image3 = new Image();
	image3.src =  siteLocation + "images/i_contact.gif";
 var image4 = new Image();
	image4.src =  siteLocation + "images/i_contact_o.gif";
 var image5 = new Image();
	image5.src =  siteLocation + "images/i_sitemap.gif";
 var image6 = new Image();
	image6.src =  siteLocation + "images/i_sitemap_o.gif";

})();

function roll(img_name, img_src) {
	   var siteLocation ="fileadmin/templates/";
       //var siteLocation ="";
	   var imageover = siteLocation + "images/" + img_src
       document[img_name].src = imageover;
   }
   
function show(element){
           //element.className += "hover";
		   if (element.tagName != "LI"){return;}
			//alert(element.tagName);	   
		   var elementLeft = getElementPosition(element).left;
		   var ParentPos = getElementPosition(element.parentNode).left;
		   //var NewChildPos = elementLeft-ParentPos;
		   var NewChildPos = elementLeft;
		  // alert (NewChildPos);
		  //alert ("ParentPos: " + ParentPos + "\nelementLeft: " + elementLeft+ "\nNewChildPos: " + NewChildPos);
		   var childNodeUL;
		   // Find UL Child 
		   var children = element.childNodes;
		   		for (var i = 0; i < children.length; i++ )
				{
					if (children.item(i).tagName == "UL") {childNodeUL = children.item(i);}
				}
			//re-assign position!
			if(childNodeUL) {
			childNodeUL.style.left = NewChildPos + 'px';
			//alert(NewChildPos + 'px');
			//alert ("ParentPos: " + ParentPos + "\nelementLeft: " + elementLeft+ "\nNewChildPos: " + NewChildPos);
			//if outside de headerbox move box to left	
 			//if ((NewChildPos+195) > 960 ){childNodeUL.style.left = NewChildPos-(195-element.offsetWidth)+ 'px';}
 			if ((NewChildPos + 195) > (960 + ParentPos)  ){childNodeUL.style.left = NewChildPos-(195 - element.offsetWidth + 7)+ 'px';}
 			}
 }

function getElementPosition(elemID){
	var offsetTrail = elemID;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail){
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
	}

	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
   return {left:offsetLeft,top:offsetTop};
}
