
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, obj[type+fn] );
    obj[type+fn] = null;
  } else
    obj.removeEventListener( type, fn, false );
}

function getGlobalCoord(e)
{
	var e;

	if (!e)	{
		document.MouseX = parseInt(event.clientX + document.body.scrollLeft);
		document.MouseY = parseInt(event.clientY + document.body.scrollTop);	
	} else {
		document.MouseX = parseInt(e.pageX);
		document.MouseY = parseInt(e.pageY);	
	}
	if(window.onaftermousemove)
	{
		window.onaftermousemove(document.MouseX,document.MouseY);
	}
	return ;
}

function showInfoText(html)
{
	var InfoTag = document.getElementById("InfoTag");
	var InfoContent = $("InfoContent")
	InfoContent.innerHTML = html;
	InfoTag.style.left 	= (document.MouseX) + "px";
	InfoTag.style.top 	= (document.MouseY + 20) + "px";	
	return false; 
}

function hideInfoText()
{
	document.getElementById("InfoContent").innerHTML = "";
	document.getElementById("InfoTag").style.top = "-1000px";
	document.getElementById("InfoTag").style.left = "-1000px";
	return false; 
}



function getIEVersionNumber() {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}


function prepareBackgroundPNG()
{
	var ieVersion =  getIEVersionNumber();
	if (ieVersion < 1 || ieVersion > 6)
		return;
	
	var s1pix = "/Images/pix.gif"
	var obj = null;
	var sResult = "";

	for( var i = 0; i < document.all.length; i++)
	{
		obj = document.all[i];
		
//		if ( false && obj.background && obj.background.match(/\.png$/) != null ) 
//		{
//			if ( obj.sizingMethod == undefined ) // crop, image, scale
//				obj.sizingMethod = "crop"; 
//			obj.style.background = "";
//			obj.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.background + "', sizingMethod='" + obj.sizingMethod +"');";
//			obj.background = "";
//
//		}
		if ( (obj.tagName == "IMG" || obj.tagName == "INPUT") && obj.src.match(/\.png$/) != null ) 
		{
			if ( obj.sizingMethod == undefined ) // crop, image, scale
				obj.sizingMethod = "image"; 
			obj.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "', sizingMethod='" + obj.sizingMethod +"');";
			obj.src = s1pix;
		} 
	}
}


function getWindowInfo()
{
	var scrOfX = 0, 	scrOfY = 0;
	var myWidth = 0, 	myHeight = 0;
	var myAbsWidth = 0, myAbsHeight = 0;
	
	if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		  //IE6 standards compliant mode
		  scrOfY = document.documentElement.scrollTop;
		  scrOfX = document.documentElement.scrollLeft;
	}
	else if( typeof( window.pageYOffset ) == 'number' ) {
	  //Netscape compliant
	  scrOfY = window.pageYOffset;
	  scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	  //DOM compliant
	  scrOfY = document.body.scrollTop;
	  scrOfX = document.body.scrollLeft;
	}  

	if(document.documentElement)
	{
		myAbsWidth = document.getElementsByTagName("body")[0].scrollWidth;
   		myAbsHeight = document.getElementsByTagName("body")[0].scrollHeight;
	}else if(document.body  && document.body.scrollWidth)
	{
		myAbsWidth = document.body.scrollWidth;
	   	myAbsHeight = document.body.scrollHeight;
	}
			
			
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;

	} 
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;

	}

	return {
		scrollX: 			scrOfX,
		scrollY: 			scrOfY,
		visibleWidth: 		myWidth,
		visibleHeight: 		myHeight,
		absWidth:			myAbsWidth,
		absHeight:			myAbsHeight,
		mouseX:				document.MouseX,
		mouseY:				document.MouseY	
	};

}


var poped = false
var popedLogin = false
function popUp(templateName,queryVars)
{
	var addQuery = '';
	if( queryVars )
		for(var k in queryVars)
			addQuery += '&'+ escape(k)+'='+escape(queryVars[k]);
	closePopUp();
	var windowInfo = getWindowInfo();
	document.getElementById("popUp").src = "/popUp.php?templateName="+templateName+addQuery;
	document.getElementById("registerPopUp").style.display 	= "";
	popedLogin = poped = true;	
	window.onresize()
}


function closePopUp(){
	
	var windowInfo = getWindowInfo();	
	document.getElementById('registerPopUp').style.display='none'
	//document.getElementById("popUp").src = "about:blank";
	document.getElementById("registerPopUp").style.height = windowInfo.absHeight +"px";
	document.getElementById("popUp").style.height = "70px";
	popedLogin = poped = false;

}


function removeBottomNavigation(){
	document.getElementById("bottomNavigationPlacer").style.display = "";
	var windowInfo 				= getWindowInfo();
	var topPadding 				= 107;
	var lNavi 					= document.getElementById("leftBottomNavigation");
	var topMenuHeight			= parseInt(document.getElementById("leftTopNavigation").offsetHeight);

	var bottomMenuAvailHeight 	= parseInt(document.getElementById("leftBottomNavigation").offsetHeight);
	var menuHeight				= document.getElementById("bottomNavigationPlacer").offsetHeight
	
	//var bottomMenuHeight 		= parseInt(document.getElementById("bottomNavigationPlacer").offsetHeight):
	var leftSidebarHeight 		= parseInt(document.getElementById("leftSidebar").offsetHeight);
	
	var newPadding 				= windowInfo.visibleHeight+windowInfo.scrollY-(topMenuHeight+menuHeight+topPadding);

	if( newPadding < 0)
		newPadding = 0;	
	if( newPadding > (bottomMenuAvailHeight - menuHeight) )
		newPadding = (bottomMenuAvailHeight - menuHeight);
	
	lNavi.style.paddingTop  = newPadding + "px";
	
	
	//Math.max()*/
}

addEvent(window,"load",function(){
	prepareBackgroundPNG();
	var so = new SWFObject("/Images/streifen.swf",			"hpmicro", "730", "60", "#FFFFFF");
	so.addParam("wmode", "opaque");
	so.write("streifen");
	removeBottomNavigation()
});

document.onmousemove = getGlobalCoord; //window.onaftermousemove =

window.onresize = window.onscroll = function()
{

	if(poped)
	{
		var windowInfo = getWindowInfo();
		document.getElementById("registerInner").style.top 		= parseInt(windowInfo.scrollY-((document.getElementById("registerInner").offsetHeight-windowInfo.visibleHeight)/2)) + "px";
	}
	removeBottomNavigation()
}

var onPopUpLoaded = function()
{
	var h;
	var iFrame 				= document.getElementById("popUp");
	var cntrlDiv 			= document.getElementById("registerPopUp");
	var lastDisplayStauts 	= cntrlDiv.style.display;
	
	if( iFrame.src == "about:blank")
		return;
	
	iFrame.style.height = "0px";	
	
	cntrlDiv.style.display = "block";
	
	if(iFrame.contentDocument) 											// DOM
		h = iFrame.contentDocument.body.scrollHeight;
	else if (iFrame.contentWindow && iFrame.contentWindow.document) 	// IE5.5+ windows
	{
		h = iFrame.contentWindow.document.body.scrollHeight;
	}
	
	cntrlDiv.style.display = lastDisplayStauts;
	
	iFrame.style.height = h + "px";

	var windowInfo = getWindowInfo();
	document.getElementById("registerPopUp").style.height 	= windowInfo.absHeight; //  getScrollXY()[1] + 
	document.getElementById("registerInner").style.top 		= parseInt(windowInfo.scrollY-((document.getElementById("registerInner").offsetHeight-windowInfo.visibleHeight)/2)) + "px";

}

function search(s)
{
	//alert(s);
	popUp("search",{s:s});
}
