var show_tooltip = true;

var text = new Array();
text["de"] = new Object();
text["en"] = new Object();
text["de"]["switchoff_tooltip"] = "Hinweis abschalten";
text["de"]["infoshelp_tooltip"] = "Infos/Hilfe";
text["en"]["switchoff_tooltip"] = "switch-off notice";
text["en"]["infoshelp_tooltip"] = "Info/Help";

var active_tip = 0;

function get_Position (obj)
{
    var result = { top:0, left:0 };
    if(!obj) 
		return result;
    else if(typeof obj == 'string' ) 
		obj = document.getElementById(obj);
    if(typeof obj != 'object' ) 
		return result;
    if(typeof obj.offsetTop != 'undefined') {
         result.left = result.top = 0;
         while (obj && obj.tagName != 'BODY') {
              result.top  += parseInt( obj.offsetTop );
              result.left += parseInt( obj.offsetLeft );
              obj = obj.offsetParent;
         }
    }
    return result;
}

function show_tip(id) {
	if (document.cookie.indexOf("tip=dload_off") > 0) 
		show_tooltip = false;

	if (!show_tooltip || !document.getElementById("tip"+id)) {
		link_element = document.getElementById("dload"+id);
		location.href = link_element.href.replace("?r=rf","?r=oc"); 
		return;
	}
	
	var tt_content = "";
	tt_content = "<div style='margin:2px 9px;'><div style='float:right; color:black; cursor:pointer; width:15px; height:15px;' onclick='hide_tip("+id+"); return false'></div></div><br class='clearer' />";
	tt_content += "<div style='width:251px; height:170px;' onclick='hide_tip("+id+"); return false'> </div><br class='clearer' />";
	tt_content += "<span style='float:left; width:20px; height:20px;'></span><a href='#' onclick='deactivate_tip("+id+"); return false'>"+text[lang]['switchoff_tooltip']+"</a> <!--| <a href='#'>"+text[lang]['infoshelp_tooltip']+"</a>-->";

	
	var image_format = "gif";
	if ((navigator.appCodeName == "Mozilla" && navigator.appName=="Netscape") || (navigator.userAgent.indexOf("MSIE") != -1 && navigator.appVersion.substring(0, 1) >= 7)) 
		image_format = "png";
		
	var tip_element = document.getElementById("tip"+id);
	tip_element.style.backgroundImage = "url(layout/tooltip_rightclicksaveas_"+lang+"."+image_format+")";
	
	if (id == active_tip) { 
		hide_tip(id); 
		return; 
	}
	
	if (tip_element.style.visibility == "hidden" || tip_element.style.visibility == "")  {
		
		if (active_tip >= 1 && active_tip != id) {
			hide_tip(active_tip);
		}
	
		element_position = get_Position("dload"+id);
  		tip_element.style.top  = (element_position.top-105)+"px"; //  - 103
  		tip_element.style.left  = (element_position.left+62)+"px";

		tip_element.innerHTML = tt_content;
  		tip_element.style.visibility = "visible";
		active_tip = id;
		
		//return;
	}
}

function deactivate_tip(id) {
	show_tooltip = false;
	var a = new Date();
	a = new Date(a.getTime() +1000*60*60*24*365);
	document.cookie = 'tftooltip=dload_off; path=/; expires='+a.toGMTString()+';'; 
	hide_tip(id); 
	return;
}

function hide_tip(id) {
	tip_element = document.getElementById("tip"+id);
	tip_element.innerHTML = "";
	tip_element.style.visibility = "hidden";

	active_tip = 0;
	return;
}

