window.onerror = null;

tooltip = {
	attr_name: "tooltip",
	blank_text: "- Откроется в новом окне",
	newline_entity: "  ", 
	max_width: 0,
	delay: 50,
	t: document.createElement("DIV"),
	c: null,
	g: false,

	m: function(e){
		if (tooltip.g){
			oCanvas = document.getElementsByTagName(
			(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
			)[0];
			x = window.event ? event.clientX + oCanvas.scrollLeft : e.pageX;
			y = window.event ? event.clientY + oCanvas.scrollTop : e.pageY;
			tooltip.a(x, y);
		}
	},

	d: function(){
		tooltip.t.setAttribute("id", "tooltip");
		document.body.appendChild(tooltip.t);
		a = document.all ? document.all : document.getElementsByTagName("*");
		aLength = a.length;
		for (var i = 0; i < aLength; i++){
			if (!a[i] || !a[i].getAttribute) continue;
			tooltip_title = a[i].getAttribute("title"); 
			if (tooltip_title && typeof tooltip_title != "string") tooltip_title = "";

			tooltip_alt = a[i].getAttribute("alt");
			tooltip_blank = a[i].getAttribute("target") && a[i].getAttribute("target") == "_blank" && tooltip.blank_text;
			if (tooltip_title || tooltip_blank){
				a[i].setAttribute(tooltip.attr_name, tooltip_blank ? (tooltip_title ? tooltip_title + " " + tooltip.blank_text : tooltip.blank_text) : tooltip_title);
				if (a[i].getAttribute(tooltip.attr_name)){
					a[i].removeAttribute("title");
					if (tooltip_alt && a[i].complete) a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}else if (tooltip_alt && a[i].complete){
				a[i].setAttribute(tooltip.attr_name, tooltip_alt);
				if (a[i].getAttribute(tooltip.attr_name)){
					a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}
			if (!a[i].getAttribute(tooltip.attr_name) && tooltip_blank){
				//
			}
		}
		document.onmousemove = tooltip.m;
		window.onscroll = tooltip.h;
		tooltip.a(-99, -99);
	},
	s: function(e){
		d = window.event ? window.event.srcElement : e.target;
		if (!d.getAttribute(tooltip.attr_name)) return;
		s = d.getAttribute(tooltip.attr_name);
		if (tooltip.newline_entity){
			s = s.replace(/\&/g,"&amp;");
			s = s.replace(/\</g,"&lt;");
			s = s.replace(/\>/g,"&gt;");
			s = s.replace(eval("/" + tooltip.newline_entity + "/g"), "<br />");
			tooltip.t.innerHTML = s;
		}else{
			if (tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
			tooltip.t.appendChild(document.createTextNode(s));
		}
		tooltip.c = setTimeout("tooltip.t.style.visibility = 'visible';", tooltip.delay);
		tooltip.g = true;
	},

	h: function(e){
		tooltip.t.style.visibility = "hidden";
		if (!tooltip.newline_entity && tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
		clearTimeout(tooltip.c);
		tooltip.g = false;
		tooltip.a(-99, -99);
	},

	l: function(o, e, a){
		if (o.addEventListener) o.addEventListener(e, a, false);
		else if (o.attachEvent) o.attachEvent("on" + e, a);
			else return null;
	},

	a: function(x, y){
		oCanvas = document.getElementsByTagName(
		(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
		)[0];
		
		w_width = oCanvas.clientWidth ? oCanvas.clientWidth + oCanvas.scrollLeft : window.innerWidth + window.pageXOffset;
		w_height = window.innerHeight ? window.innerHeight + window.pageYOffset : oCanvas.clientHeight + oCanvas.scrollTop;

		tooltip.t.style.width = ((tooltip.max_width) && (tooltip.t.offsetWidth > tooltip.max_width)) ? tooltip.max_width + "px" : "auto";
		
		t_width = tooltip.t.offsetWidth;
		t_height = tooltip.t.offsetHeight;

		tooltip.t.style.left = x + 8 + "px";
		tooltip.t.style.top = y + 8 + "px";
		
		if (x + t_width > w_width) tooltip.t.style.left = w_width - t_width + "px";
		if (y + t_height > w_height) tooltip.t.style.top = w_height - t_height + "px";
	}
}

var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
if (root){
	if (root.addEventListener) root.addEventListener("load", tooltip.d, false);
	else if (root.attachEvent) root.attachEvent("onload", tooltip.d);
}
if(document.cookie.indexOf('hottab=')==-1){
var hott1=new Image(18, 33);
var hott2=new Image(18, 33);
hott1.src="http://futer.ru/img/b1.gif";
hott2.src="http://futer.ru/img/b2.gif";
document.write("<div id='hottab'><img alt='Hottabic' width='18' height='33' border='0' /></div>");
document.getElementById('hottab').style.position='absolute';
var sHeight=screen.height-20;
var sWidth=screen.width-400;
document.getElementById('hottab').style.top=sHeight*Math.random()+10+'px';
document.getElementById('hottab').style.left=sWidth*Math.random()+10+'px';
document.getElementById('hottab').style.display='none';
document.getElementById('hottab').style.filter="alpha(opacity:0)";
document.getElementById('hottab').style.KHTMLOpacity="0";
document.getElementById('hottab').style.MozOpacity="0";
document.getElementById('hottab').style.opacity="0";
document.getElementById('hottab').getElementsByTagName('img')[0].src=hott1.src;
setTimeout("pshih(1, 0);", Math.random()*10000+10000);
function smex(pik, kol){
document.getElementById('hottab').getElementsByTagName('img')[0].src=hott2.src;
if(kol<20){
if(pik){
document.getElementById('hottab').style.top=parseInt(document.getElementById('hottab').style.top)-2+'px';
pik=0;
}else{
document.getElementById('hottab').style.top=parseInt(document.getElementById('hottab').style.top)+2+'px';
pik=1;
}
setTimeout('smex('+pik+', '+(kol+1)+');', 50);
}else{
document.getElementById('hottab').getElementsByTagName('img')[0].src=hott1.src;
setTimeout("pshih(0, 100);", 100);
}
}
function pshih(vis, value){
if(vis){
if(value==0){
if(document.body.scrollTop){
var scrollT=document.body.scrollTop;
}else if(window.pageYOffset){
var scrollT=window.pageYOffset;
}else{
scrollT=0;
}
document.getElementById('hottab').style.top=parseInt(document.getElementById('hottab').style.top)+scrollT+'px';
}
if(value>=100){
smex(1, 0);
document.getElementById('hottab').style.filter="alpha(opacity:100)";
document.getElementById('hottab').style.KHTMLOpacity="1";
document.getElementById('hottab').style.MozOpacity="1";
document.getElementById('hottab').style.opacity="1";
}else{
document.getElementById('hottab').style.display='block';
value=value+4;
if(value<10){var b='0';}else{var b='';}
document.getElementById('hottab').style.filter="alpha(opacity:"+value+")";
document.getElementById('hottab').style.KHTMLOpacity="0."+b+value;
document.getElementById('hottab').style.MozOpacity="0."+b+value;
document.getElementById('hottab').style.opacity="0."+b+value;
setTimeout('pshih(1, '+value+')', 1);
}
}else{
if(value<=0){
document.getElementById('hottab').style.display='none';
document.getElementById('hottab').style.filter="alpha(opacity:0)";
document.getElementById('hottab').style.KHTMLOpacity="0";
document.getElementById('hottab').style.MozOpacity="0";
document.getElementById('hottab').style.opacity="0";
var date = new Date();
date.setMinutes(date.getMinutes()+10);
document.cookie="hottab=1; expires="+date.toGMTString()+"; path=/;";
}else{
value=value-4;
if(value<10){var b='0';}else{var b='';}
document.getElementById('hottab').style.filter="alpha(opacity:"+value+")";
document.getElementById('hottab').style.KHTMLOpacity="0."+b+value;
document.getElementById('hottab').style.MozOpacity="0."+b+value;
document.getElementById('hottab').style.opacity="0."+b+value;
setTimeout('pshih(0, '+value+')', 1);
}
}
}
}
