function getAbsolutePosition(element) 
{
    var r = { x: element.offsetLeft, y: element.offsetTop };
    if (element.offsetParent) {
    var tmp = getAbsolutePosition(element.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
    }
    return r;
};

function getPageSize(){
        
        var xScroll, yScroll;
        
        if (window.innerHeight && window.scrollMaxY) {        
                xScroll = window.innerWidth + window.scrollMaxX;
                yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
        }
        
        var windowWidth, windowHeight;
        
//        console.log(self.innerWidth);
//        console.log(document.documentElement.clientWidth);

        if (self.innerHeight) {        // all except Explorer
                if(document.documentElement.clientWidth){
                        windowWidth = document.documentElement.clientWidth; 
                } else {
                        windowWidth = self.innerWidth;
                }
                windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
        }        
        
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
                pageHeight = windowHeight;
        } else { 
                pageHeight = yScroll;
        }

//        console.log("xScroll " + xScroll)
//        console.log("windowWidth " + windowWidth)

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){        
                pageWidth = xScroll;                
        } else {
                pageWidth = windowWidth;
        }
//        console.log("pageWidth " + pageWidth)

        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
        return arrayPageSize;
}

function getPageScroll(){

        var xScroll, yScroll;

        if (self.pageYOffset) {
                yScroll = self.pageYOffset;
                xScroll = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){         // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
                xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
                xScroll = document.body.scrollLeft;        
        }

        arrayPageScroll = new Array(xScroll,yScroll) 
        return arrayPageScroll;
}

function evalScript(scripts)
{ try
  { if(scripts != "")
    { var script = "";
      scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
                                   if (scripts !== null) script += arguments[1] + "\n";
                                    return "";});
      if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
    }
    return false;
  }
  catch(e)
  { alert(e)
  }
}

function Numsort (a, b) 
{
  return a - b;
}

function Assozsort (a, b) 
{
	return (a > b) - (a < b);
}


function isNumber(str) {
  for(var position=0; position<str.length; position++){
	var chr = str.charAt(position)
        if  ( (chr < "0") || (chr > "9") ) 
              return false;
  };      
  return true;
};


function checkPLZ(plz)
{
	//if(isNaN(plz)) return false;
	if (plz.length < 3) return false;
	return true;
}

function autofocus()
{
	
}
//Event.observe(window, 'load', function() { loadAC();});

function showTeaserToolTip(obj,infoID)
{
	var ttip = document.getElementById('tooltip');	
	if (!ttip)
	{						
		var objBody = document.getElementsByTagName("body")[0];
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','tooltip');
		objOverlay.style.width = "165px";        
		objOverlay.style.display = "none";
		objBody.appendChild(objOverlay);     
    
		var ttip = document.getElementById('tooltip');	
	}
	
	var infoObj = document.getElementById(infoID);
	if (infoObj)
	{
		var pos = getAbsolutePosition(obj); 
		ttip.innerHTML = infoObj.innerHTML;
		ttip.style.top = eval(pos.y + obj.offsetHeight) + "px";
		ttip.style.left = eval(pos.x - 8) + "px";
		ttip.style.display = "";
	}
	
	obj.onmouseout = function()
	{
		if (document.getElementById('tooltip'))
			document.getElementById('tooltip').style.display = "none";
	}
}

function showSymbolInfo(obj,txt,fixID)
{
	var aim = document.getElementById('SymbolInfo');
	var aim_helper = document.getElementById('SymbolInfoHelper');
	if (!aim)
	{						
		var objBody = document.getElementsByTagName("body")[0];
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','SymbolInfo');
		objOverlay.style.display = "none";
		objBody.appendChild(objOverlay);     
		
		
	    var objHelper = document.createElement("div");
	    objHelper.setAttribute('id','SymbolInfoHelper');
	    objHelper.style.position = "absolute";
	    objHelper.style.zIndex = "1000";
	    //objHelper.style.left = "500px";
	    objHelper.style.top = "-10000px";
	    objHelper.style.visibility = "hidden";
	    objHelper.style.display = "inline";  
	    objBody.appendChild(objHelper);
	    
	    var aim = document.getElementById('SymbolInfo');
	    var aim_helper = document.getElementById('SymbolInfoHelper');		
	}
	
	var fixObj = fixID ? document.getElementById(fixID) : false;
	
	if (obj)
	{
		obj.onmouseout = function() 
		{
			document.getElementById('SymbolInfo').style.display = 'none';
			//new Effect.Appear('SymbolInfo',{to:0,duration:0.1,afterFinish:function(){document.getElementById('SymbolInfo').style.display = 'none';}});
		};
		
		aim.onmouseout = function() 
		{
			document.getElementById('SymbolInfo').style.display = 'none';
			//new Effect.Appear('SymbolInfo',{to:0,duration:0.1,afterFinish:function(){document.getElementById('SymbolInfo').style.display = 'none';}});
		};
		
		aim.innerHTML = txt;
		aim_helper.innerHTML = txt;
		
		var px,py;
		if (fixObj)
		{
			var fixPos = getAbsolutePosition(fixObj);
			px = fixPos.x;
			
			var pos = getAbsolutePosition(obj);
			py = pos.y + obj.offsetHeight + 3;
			
			var imgPfeil = aim.getElementsByTagName('img')[0];
			var imgX = pos.x - fixPos.x - 8 + (obj.offsetWidth/2);
			//var imgX = pos.x - fixPos.x - (imgPfeil.offsetWidth/2) + (obj.offsetWidth/2);
			imgPfeil.style.left = eval( imgX ) + "px";			
		}
		else
		{			
			var pos = getAbsolutePosition(obj);
			//py = pos.y - obj.offsetHeight - aim_helper.offsetHeight - 10;
			py = pos.y - aim_helper.offsetHeight - 30;
			px = pos.x - 239/2;
			
			var imgPfeil = aim.getElementsByTagName('img')[0];
			//var imgX = pos.x - fixPos.x - 8 + (obj.offsetWidth/2);
			//var imgX = pos.x - fixPos.x - (imgPfeil.offsetWidth/2) + (obj.offsetWidth/2);
			var imgX = 239/2 - 8 + (obj.offsetWidth/2);;
			imgPfeil.style.left = eval( imgX ) + "px";	
		}
		
		aim.style.left = eval(px) + "px";
		aim.style.top = eval(py) + "px";
		
		document.getElementById('SymbolInfo').style.display = '';
		//new Effect.Appear(aim.id,{to:1,duration:0.1});
	}
}