// # # # # # # # # # # # # # # # # # # # # # # # # #
// # sts_ToolTip.js 
// # 
// # Copyright Stefan Siemon, Alle Rechte vorbehalten.  
// # 
// # Letztes Update: 04.04.2009

var dom=document.getElementById?1:0;
var ie=document.all&&!window.opera?1:0;
var ns4=document.layers?1:0;

var objbody=null;
var winwidth=0;
var winheight=0;

var clientpos=new vector(0, 0);
var scrollpos=new vector(0, 0);

function vector(x, y){
    this.x = x;
    this.y = y;
}

function getobjbody() {
	if (dom)        objbody=document.getElementById("body");
    else if (ie)    objbody=document.body; 
    else            objbody=null;    
    return objbody
}

function clientHeightWidth(){
    if(dom||ie) {
        winwidth = objbody.clientWidth;
	    winheight = objbody.clientHeight;    		
	}else{
		winwidth = window.innerWidth;
		winheight = window.innerHeight;
	}
}

function clientscrollxy(){
	if (dom||ie){
        scrollpos.x = objbody.scrollLeft;
		scrollpos.y = objbody.scrollTop;
	}else{				
        scrollpos.x = window.pageXOffset;
		scrollpos.y = window.pageYOffset;		
    }
}

function clientxy(e){
    if (ie) {
		clientpos.x = event.clientX + objbody.scrollLeft;
        clientpos.y = event.clientY + objbody.scrollTop;
	} else 
		if (dom) {
	    	clientpos.x = e.clientX + objbody.scrollLeft;
    		clientpos.y = e.clientY + objbody.scrollTop;
		} else {
			clientpos.x = e.pageX;
			clientpos.y = e.pageY;
		}
}

function getobj(id) {
    if (dom)        return document.getElementById(id);  
    else if (ie)    return document.all[id];		
    else            return document.layers[id];
}

function getobjstyle(id) {
    if (dom)        return document.getElementById(id).style;  
    else if (ie)    return document.all[id].style;
    else            return document.layers[id];
}

function getobjtop(obj) {
    if (dom)        return parseInt(obj.style.top);
	else if (ie)    return obj.style.pixelTop;
	else            return obj.top;
}

function getobjleft(obj) {	
	if (dom)        return parseInt(obj.style.left);
	else if (ie)    return obj.style.pixelLeft;
    else            return obj.left;
}

function showobj(obj) {
    if (dom||ie)    obj.style.visibility='visible';
    else            obj.visibility = "show";
return 			
}

function hiddenobj(obj) {
	if (dom||ie)    obj.style.visibility='hidden';
	else            obj.visibility = "hide";
return 			
}

function getobjindex(obj) {
	if (dom||ie)    return obj.style.zIndex;
	else            return obj.zIndex;
}

function setobjindex(obj, new_index) {
    if (dom||ie)    obj.style.zIndex =  new_index;
	else            obj.zIndex =        new_index;
}

function objmoveto(obj,offsetleft,offsettop) {
	if (dom) {
		obj.style.left = parseInt(obj.style.left) + offsetleft + 'px';
		obj.style.top = parseInt(obj.style.top) + offsettop + 'px';
	} else {
    	if (ie) {
	    	obj.style.pixelLeft += offsetleft;
		    obj.style.pixelTop += offsettop;			
		} else {
			obj.left += offsetleft;
			obj.top += offsettop;
		}
	}
}

function setobjposi(obj,left,top){
    if(dom) {
        obj.style.top = top + 'px';
        obj.style.left = left + 'px';
    }else{
        if (ie) {
            obj.style.pixelTop = top;
    	    obj.style.pixelLeft = left;
        }else{	    
    	    obj.top = top;
            obj.left = left;
        }
    }
}


// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
// ### Tooltip functions

var tooltipobj=null;
var tooltiptextobj=null;
var tooltiptext='';
var tooltipeinschalten=false;
var tooltipsichtbar=false;
var tooltiptimershow=null;
var tooltipokay=false;

function tooltip(obj,breit,hoch) {
	if(tooltipokay)	
		if(obj) 
			if(obj.src) {
				var bild=obj.src;
				bild=bild.replace(/_mini1\./g, '.');
				bild=bild.replace(/_mini\./g, '.');

				//if (obj.getAttribute('title')!='')  obj.setAttribute('title','.')
				//obj.removeAttribute("title");
				//obj.removeAttribute("alt");
				
				if (obj.getAttribute('alt')!='')  obj.setAttribute('alt','');
				
				
				tooltipshow(obj,bild,breit,hoch); 
			}else tooltiphide(); 
		else tooltiphide();
}

function tooltiphide(){
	if(tooltipokay){
		if (tooltiptimershow) window.clearTimeout(tooltiptimershow);
		tooltipeinschalten=false;
		tooltipsichtbar=false;
		hiddenobj(tooltipobj)
	}
}

function tooltipshow(obj,bild,breit,hoch) {
	if(tooltipokay){
		clientHeightWidth();
		if ((winheight>400)&&(winwidth>500)){
			
//			var ttobj= getobj('tt');
//			var ttwidth = ttobj.clientWidth;
//		    vat ttheight = ttobj.clientHeight;    		
			
			var hochbreit='';		
			if (breit>0) hochbreit+=' width="'+breit+'"'; else if (breit<0) breit=Math.abs(breit); else breit=250; 
			if (hoch>0) hochbreit+=' height="'+hoch+'"'; else if (hoch<0) hoch=Math.abs(hoch); else hoch=250; 
			
//			if (ttwidth>100) breit = ttwidth-20;
//			if (ttheight >100) hoch= ttheight -20;
			
			
			var x = clientpos.x+15;
			var y = clientpos.y+15;
	
			clientscrollxy();	
			if ((x+breit-scrollpos.x>winwidth-20)&&(breit<winwidth)) 
				{
					x=winwidth-breit+scrollpos.x-20;
					if ((y+hoch-scrollpos.y>winheight-10)&&(hoch<winheight)) y=y-hoch-50;				
				}
			else
				if ((y+hoch-scrollpos.y>winheight-10)&&(hoch<winheight)) 
					{
						y=winheight-hoch+scrollpos.y-10;
					}
					

			
			setobjposi(tooltipobj,x,y);
			var txtNeu='<img src="'+bild+'"'+hochbreit+'>';
			if (tooltiptext!=txtNeu) {		
 				if (tooltipsichtbar) tooltiphide();

				tooltiptext=txtNeu;
				tooltiptextobj.innerHTML=tooltiptext;				

				if (!tooltipeinschalten) {
					tooltipeinschalten=true;
					if (tooltiptimershow!=null) window.clearTimeout(tooltiptimershow);
					tooltiptimershow=window.setTimeout("tooltipshowdo();", 300);	
				}
			}else{
				if (!tooltipeinschalten) {
					tooltipeinschalten=true;
					tooltipshowdo();
				}
			}		
		}
	}
}

function tooltipshowdo(){
	if (tooltipeinschalten) {
		tooltipsichtbar=true;
		showobj(tooltipobj);			
	}
}

function tooltipinit(){
	if(dom||ie){
		document.onmousemove = clientxy;
		getobjbody();
		
		document.write('<div id="tt" style="position:absolute; visibility:hidden; top:1px; left:1px; z-index:999;" onmouseover="tooltiphide();"><table cellSpacing="0" cellPadding="0" border="0"><tr><td colspan="3" style="filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.40;" bgcolor="#333333"><img src="/pixel.gif" height="5" width="5" alt=""></td></tr><tr><td style="filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.40;" bgcolor="#333333"><img src="/pixel.gif" height="5" width="5" alt=""></td><td><div style="border: 1px solid #666666; background-color:#f9f9f9;"><div id="tttext" style="border: 2px solid #ffffff;"></div></div></td><td style="filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.40;" bgcolor="#333333"><img src="/pixel.gif" height="5" width="5" alt=""></td></tr><tr><td colspan="3" style="filter:alpha(opacity=40);-moz-opacity:0.4;opacity:0.40;" bgcolor="#333333"><img src="/pixel.gif" height="5" width="5" alt=""></td></tr></table></div>');
			
		tooltipobj=getobj('tt');
		tooltiptextobj=getobj('tttext');
		tooltiptext=null;
		tooltipokay=true;
	}
}

tooltipinit();