var interval;

var hoernchen_var_x=0;
var hoernchen_var_y=0;

function XObject(id) {
   if (document.getElementById) {
      this.element = document.getElementById(id);
      this.style = this.element.style;
      this._visible="visible";
      this._hidden="hidden";
   }
   else if (document.all && !document.doctype) {
      this.element = document.all[id];
      this.style = this.element.style;
      this._visible="visible";
      this._hidden="hidden";
   }
   else if (document.layers || (document.all && document.doctype)) {
      this.element = document.layers[id];
      this.style = this.element;
      this._visible="show";
      this._hidden="hide";
   }
   
   this.x = parseInt(this.style.left);
   this.y = parseInt(this.style.top);
   this.zIndex = this.style.zIndex;
   this.width = this.style.width;
   this.height = this.style.height;
   this.documentHeight=0;
   this.documentWidth=0;
   //alert(this.toString());
   this.initSize();

}

XObject.prototype.initSize=function(){
if (document.layers) {

      this.documentHeight=document.height;
      this.documentWidth=document.width;

   }
   else if(document.documentElement && document.documentElement.offsetHeight){
   
      this.documentHeight=document.body.scrollHeight;
      if(document.documentElement.offsetHeight>this.documentHeight)this.documentHeight=document.documentElement.offsetHeight;
      this.documentWidth=document.body.scrollWidth;
      if(document.documentElement.offsetWidth>this.documentWidth)this.documentWidth=document.documentElement.offsetWidth;
    

   }else if(document.all){
  // alert(document.body);
   this.documentHeight=document.body.scrollHeight;
      this.documentWidth=document.body.scrollWidth;
   }
   
}

XObject.prototype.toString=function(){
   var message="";
  message+="document.all = "+(document.all?"true":"false")+"\n";
  message+="document.layers = "+(document.layers?"true":"false")+"\n";
  message+="document.getElementById = "+(document.getElementById?"true":"false")+"\n";
  message+="document.documentElement = "+(document.documentElement?"true":"false")+"\n";
  message+="document.documentElement.scrollLeft = "+(document.documentElement.scrollLeft?"true":"false")+"\n";
  message+="document.documentElement.scrollTop = "+(document.documentElement.scrollTop?"true":"false")+"\n";
   message+="documentHeight = "+(this.documentHeight)+"\n";
  message+="documentWidth = "+(this.documentWidth)+"\n";
  message+="------------------\n";
  message+="x = "+this.x+"\n";
  message+="y = "+this.y+"\n";
  message+="width = "+this.width+"\n";
  message+="height = "+this.height+"\n";
  message+="zIndex = "+this.zIndex+"\n";
  message+="style.left = "+this.style.left+"\n";
  message+="style.top = "+this.style.top+"\n";
   return message;

}
function findPosX(obj)
{
        var curleft = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else if (obj.x)
                curleft += obj.x;
        return curleft;
}

function findPosY(obj)
{
        var curtop = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (obj.y)
                curtop += obj.y;
        return curtop;
}

var isMacIE=(document.all && !window.opera && document.doctype);
XObject.prototype.getPosition=function(){
	var element=this.element;
	var check_element = element;
	var return_coords = [0,0];
	if(this.style.position=="absolute"){
		return_coords[0]=parseInt(this.style.left);
		return_coords[1]=parseInt(this.style.top);
	}
	else
	{
	
	if ((document.getElementById || document.all) && !isMacIE)
		{
		return_coords[0] = check_element.offsetLeft;
		return_coords[1] = check_element.offsetTop;
		
		while (check_element.offsetParent){
			check_element = check_element.offsetParent;
			return_coords[0] += check_element.offsetLeft;
			return_coords[1] += check_element.offsetTop;
			
		
		}
		}
	else if(isMacIE){
		
		
		
		return_coords[0] = check_element.offsetLeft;
		return_coords[1] = check_element.offsetHeight;
			
		
		
		str2=check_element.id+"="+check_element.offsetLeft+" - "+check_element.offsetHeight+"<br> ";
		while (check_element.parentElement && check_element.parentElement.tagName.toLowerCase()!="body"){
			
			check_element = check_element.parentElement;
			return_coords[0] += check_element.offsetLeft;
			return_coords[1] += check_element.offsetTop;
			
			str2+=check_element.tagName+" - "+check_element.offsetLeft+" - "+check_element.offsetHeight+"<br>";
		

		}

		return return_coords;
	}
	else if (document.layers)
		{
		return_coords[0] = check_element.x;
		return_coords[1] = check_element.y;
		// see if element needs to be told who its parent is
		if (typeof nested_in == 'object')
			{
			check_element = nested_in;
			return_coords[0] += check_element.pageX;
			return_coords[0] += check_element.pageY;
			}
		
		}
		else if(isSafari || isMacIE){
		var return_coords2=new Array();
		
		
		
		return_coords[0] = check_element.offsetLeft;
		return_coords[1] = check_element.offsetTop;


		
		
		str2=check_element.id+"="+check_element.offsetLeft+" - "+check_element.offsetHeight+"<br> ";
		while (check_element.offsetParent && check_element.offsetParent.tagName.toLowerCase()!="body"){
			
			check_element = check_element.offsetParent;
			return_coords[0] += check_element.offsetLeft;
			if(check_element.offsetHeight>0)return_coords[1] = check_element.offsetHeight;
			
			str2+=check_element.tagName+" - "+check_element.offsetLeft+" - "+check_element.offsetHeight+"<br>";
		
		}

		return return_coords;
		if((return_coords2[1]<return_coords[1]  && return_coords2[1]<bodyHeight) &&
		 (return_coords2[0]<return_coords[0]   && return_coords2[0]<bodyWidth)){
		return return_coords2;
		}
		else
		{
		return return_coords;
		}
	}

	}
	
	
	return return_coords;
}

XObject.prototype.getBody=function(){
     if( document.documentElement && 
    ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    	return document.documentElement;
    }
    else
    {	
    	if(document.documentElement)return document.documentElement;
    	return document.body;
    }
    
}

XObject.prototype.moveTo=function(x,y,maxX,maxY,minY){
	var mx=x;
	var my=y;
	if(maxX!=false){
		if(x>maxX)x=maxX;
	}
	if(maxY!=false){
		if(y>maxY)y=maxY;
	}
	if(minY!=false){
	
		if(y<minY)y=minY;
	}
	if(mx!=false){
	
		if(document.all && !window.opera && document.doctype){
			this.style.position="absolute";
			this.style.visibility="hidden";
			this.style.visibility="visible";
			this.style.left=x+"px";
		}
		else
		{
		this.style.left=parseInt(x)+"px";
		}
		this.x = parseInt(this.style.left);
	
	}
	if(my!=false){
		if(document.all && !window.opera && document.doctype){

			this.style.top=y+"px";

		}
		else
		{
		this.style.top=parseInt(y)+"px";
		}
		this.y = parseInt(this.style.top);
		
	}
}


XObject.prototype._getBrowserSize=function(){
  var w = 0;
  var h = 0;
  // Netscape
  if( window.innerWidth ) {
 
    w = window.innerWidth;
    h = window.innerHeight;
    
  }
  else // DOM und IE
  {
  	w=this.getBody().clientWidth;
	h=this.getBody().clientHeight;
  
  }
  
  var x,y;
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}
 
  return [parseInt(x),parseInt(y)];
}

XObject.prototype.resizeTo=function(w,h){
	if(w!=false){
	
		this.style.width=w+"px";
		this.width = this.style.width;
	}
	if(h!=false){
		this.style.height=h+"px";
		this.height = this.style.height;
	}
	
}

XObject.prototype._getScrollPosition=function(){
  var x=0;
  var y=0;

  // Netscape Browser
  if( window.pageYOffset ) {
    x = window.pageXOffset;
    y = window.pageYOffset;
  } 
  else
  // DOM Kompatibel und IE
  {
  	x=this.getBody().scrollLeft;
	y=this.getBody().scrollTop;
	  if(x<1)x=0;
	  if(y<1)y=0;
  }
  
  return [ x, y ];
}

XObject.prototype.show=function(){
	this.element.style.visibility=this._visible;
	
}

XObject.prototype.hide=function(){
	this.element.style.visibility=this._hidden;

}


var obj;
var hoernchen;

var friend;
var add=163;
add=35;

var inited=false;
var isOpera=(typeof window.opera != "undefined");
var fuchsHeight=105;
function initObject(){

	obj=new XObject("testobject");

	hoernchen=new XObject("hoernchen"); 

	friend=new XObject("hoernchensFriend");

	try{
	// OPERA
	if(isOpera){

		add+=17;

	}
	}
	catch(Exception)
	{
	
	}

	

	attachHoernchen();
	inited=true;
	
		obj.initSize();
	hoernchen.initSize();
	friend.initSize();

	interval=window.setInterval("positionTop();",3000);

positionTop();
attachHoernchen();
positionTop();
obj.show();
}




window.onscroll=function(){
	if(document.layers)MM_reloadPage();
		positionTop();
		attachHoernchen();
};
window.onresize=function(){
	if(document.layers)MM_reloadPage();
	

		positionTop();
	attachHoernchen();
	positionTop();
};



var inited=false;
var hinited=false;
function handleScroll(e){

	if(!inited) return;
	obj.initSize();
	hoernchen.initSize();
	friend.initSize();
			
		positionTop();
		
}

function handleResize(e){
	if(!inited) return;
	obj.initSize();
	hoernchen.initSize();
	friend.initSize();
			if(document.layers)MM_reloadPage();
		positionTop();
		attachHoernchen();
}

function checkIt(string)
{
	place = navigator.userAgent.toLowerCase().indexOf(string);
	
	return place;
}




var isSafari=(checkIt("safari")>-1);
var macNotSupported=(checkIt("mac")>-1)&&!isSafari;

function positionTop(){


	var size=obj._getBrowserSize();
	var scrollPos=obj._getScrollPosition();

	var maxadd=200;
	maxadd=0;
	if(document.all && !isOpera && document.doctype){
	   maxadd=70;
	}
	maxadd=70;
;

	var greenB=new XObject("greenBottom");
	var greenBPos=greenB.getPosition();
	
	var submenuBottom=new XObject("submenuBottom");
	
	var submenuBottomPos=submenuBottom.getPosition();
	
	
	var min=parseInt(submenuBottomPos[1])+10;
	var max=obj.documentHeight-maxadd;
	max=parseInt(greenBPos[1])-20;
	
	if(isSafari){
		max-=40;
	}
	friendPos=friend.getPosition();
	max=parseInt(friendPos[1])+80;
	if(isMacIE){
		
		max=parseInt(friendPos[1])-25;
	}
	
	
		
	
	var submenuO=new XObject("submenuTable");
	var subPos=submenuO.getPosition();
	var isubmenuO=new XObject("innerSubmenuTable");
	
	var isubmenuOPos=isubmenuO.getPosition();
	
	if(isSafari){
		//min=isubmenuOPos[0];
		
		var min=parseInt(submenuBottomPos[1])+parseInt(isubmenuOPos[1]);
	}
	else
	{
	//min+=isubmenuOPos[1];
	}
	
	
	var submenuHeight=parseInt(isubmenuO.element.height);
	var iT=new XObject("submenuTable");
	var iPos=iT.getPosition();
	if(scrollPos[1]==0)scrollPos[1]=1;
	//window.status="y="+(scrollPos[1]+size[1]-add)+" max="+max+" height="+obj.documentHeight+"scrollPos.y="+scrollPos[1]+" size[1]="+size[1]+" add="+add+" min="+(min)+" subtablePos="+subPos[1];
	obj.moveTo((document.all && !window.opera && document.doctype)?iPos[0]+130:iPos[0]+130,scrollPos[1]+size[1]-add,false,max,min);

}
function positionTopReload(){
	positionTop();
}



function attachHoernchen(){
	

	var iT=new XObject("innerTable");
	var iPos=iT.getPosition();
	var coords=friend.getPosition();
	var docW=hoernchen.documentWidth;
	var docH=hoernchen.documentHeight;
	var xP=coords[0];
	var yP=coords[1];
	try{
	if(document.all && !isOpera && document.doctype){

		xP=iPos[0]+655;//-1154;

		
		if(!hinited){

			yP=docH-140-58;
			yP=coords[1]-141;

			hinited=true;
		}
		else
		{
		
			yP=docH-157-58;
			yP=coords[1]-141;
		}
		
		
	}
	else
	{
		xP-=210-59;
		if(document.all && !isOpera){

		yP+=18-58;
		}
		else
		{

		yP+=19-58;
		}

		hinited=true;
	}
	}
	catch(Exception){
	
	}

	hoernchen.moveTo(xP+hoernchen_var_x,yP+hoernchen_var_y,false,false,false);

	if(!isOpera && !macNotSupported && !isMacIE){
		hoernchen.show();
               // alert(hoernchen.style.visibility);
	}
	else
	{
	//	hoernchen.moveTo(-1400,-1400,false,false);
	//alert(hoernchen.style.visibility);	
//hoernchen.hide();
document.xmlrpc.width=0;
document.xmlrpc.height=0;
//hoernchen.element.style.left="-800px";
//alert(hoernchen.element.style.width);
 //alert(hoernchen.element.style.visibility);
	//hoernchen.style.overflow="hidden";
}
}


//-->
