 var topMargin 	= 85;  // Wert fuer Aufloesungen <= 1024 Breite
 var slideTime	= 1000;

/*
 * return the true position as (x,y) array of a certain element
 */
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

 // adjusts the layer position relative to the breadcrumbs
 function adjustFloatingLayer() {
		document.getElementById('floatLayer').style.left = findPos(document.getElementById('header'))[0]+10;
 }

 // detect screen height 
 if (navigator.appName!='Microsoft Internet Explorer' && navigator.appVersion.indexOf("Mac")==-1) {
	 //var toolkit = java.awt.Toolkit.getDefaultToolkit();
	 //var screen_size = toolkit.getScreenSize();
	 //screen_height = screen_size.height;	
	 //if (screen_height>768) {
	 if (document.body.clientHeight>786) {
		//topMargin = 100;
		topMargin = 350;
	 } 
 }

 var ns6 = (!document.all && document.getElementById); 
 var ie4 = (document.all);
 var ns4 = (document.layers);
 var ie6 = (document.documentElement);

 
function floatObject() { 
 findHt =	(ns6||ns4) ? innerHeight : document.body.clientHeight;
} 

function main() { 
if (ns4) { 
 this.currentY 	= document.floatLayer.top; 
 this.scrollTop	= window.pageYOffset;
 mainTrigger();
 } else if(ns6) {
 this.currentY = parseInt(document.getElementById('floatLayer').style.top); 
 this.scrollTop = scrollY;
  mainTrigger(); 
 } else if(ie4) { 
 this.currentY 	= floatLayer.style.pixelTop;
 this.scrollTop	= document.body.scrollTop; 
 mainTrigger();
	} 
 } 
 function mainTrigger() { 
 var newTargetY	= this.scrollTop + this.topMargin ;
 
 if ( this.currentY != newTargetY ) { 
 if ( newTargetY != this.targetY ) { 
 this.targetY = newTargetY
  floatStart(); 
  } 
  animator(); 
  } 
  } 
  function floatStart() { 
  var now	= new Date() 
  this.A		= this.targetY - this.currentY 
  this.B		= Math.PI / ( 2 * this.slideTime ) 
  this.C		= now.getTime() 
  if (Math.abs(this.A) > this.findHt) { 
  this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt 
  this.A = this.A > 0 ? this.findHt : -this.findHt 
  } else {	 
  this.D = this.currentY 
   } 
  } 
  function animator() { 
  var now	= new Date() 
  var newY	= this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D 
  newY		= Math.round(newY) 
  if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) { 
  if ( ie4 )floatLayer.style.pixelTop = newY 
  if ( ns4 )document.floatLayer.top = newY
  if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px" 
  } 
 } 

 
 function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function setCookie(mode) {	
	document.all.loginLayerExtendedImg.src='../views/setLoginLayerInfo.jsp?mode='+(mode?'yes':'no');
	top.document.all.loginLayerExtended.value=mode;
}
function loginLayerExtended() {
	return !(getCookie('loginLayerExtended')=='false');
}
function resizeIFrame() {
	//find the height of the internal page		
	/*
	if (navigator.appName=='Opera') {
		var the_height=parent.document.getElementById('loginframe').contentWindow.document.body.scrollHeight;
    } else if (navigator.appName=='Microsoft Internet Explorer') {
		var the_height=parent.document.getElementById('loginframe').contentWindow.document.body.scrollHeight;
	} else {
		var the_height=parent.document.getElementById('loginframe').contentWindow.document.body.offsetHeight;
	}
	*/
	var the_height=parent.document.getElementById('loginframe').contentWindow.document.getElementById('loginTable').scrollHeight;
	
    //change the height of the iframe
    if (the_height>0) parent.document.getElementById('loginframe').height=the_height;

}
function hideLoginLayer() {	
	if (document.getElementById('loginlayer_cell1')) hide(document.getElementById('loginlayer_cell1'));
	if (document.getElementById('loginlayer_cell2')) hide(document.getElementById('loginlayer_cell2'));
	if (document.getElementById('loginlayer_cell3')) hide(document.getElementById('loginlayer_cell3'));
	if (document.getElementById('loginlayer_cell4')) hide(document.getElementById('loginlayer_cell4'));		
	if (document.getElementById('loginlayer_hide')) hide(document.getElementById('loginlayer_hide'));
	if (document.getElementById('loginlayer_show')) show(document.getElementById('loginlayer_show'));
	resizeIFrame();
	setCookie(false);		
}
function showLoginLayer() {
	if (document.getElementById('loginlayer_cell1')) show(document.getElementById('loginlayer_cell1'));
	if (document.getElementById('loginlayer_cell2')) show(document.getElementById('loginlayer_cell2'));
	if (document.getElementById('loginlayer_cell3')) show(document.getElementById('loginlayer_cell3'));
	if (document.getElementById('loginlayer_cell4')) show(document.getElementById('loginlayer_cell4'));		
	if (document.getElementById('loginlayer_hide')) show(document.getElementById('loginlayer_hide'));
	if (document.getElementById('loginlayer_show')) hide(document.getElementById('loginlayer_show'));		
	resizeIFrame();
	setCookie(true);	
}