var d = document;
var offsetfromcursorY=15 // y offset of tooltip
var ie=d.all && !window.opera;
var ns6=d.getElementById && !d.all;
var tipobj,op;
         
function tooltip(el,txt, msgbox, name, price ) {
	msgbox = msgbox || 'mess';
    tipobj=d.getElementById(msgbox);
    tipobj.innerHTML = 
    	"<div class='info'>" +
    	"<div class='product_name'>" + name + "</div>" +
    	"<div class='product_price'>Öåíà " + price + " ð.</div>" +
    	"</div>" +
    	"<img id='mainpic' border=0 " +
    	"src='http://www.vsemayki.ru/catalog_img/" + txt + "/man/white_250.jpg' />" +
    "";
    op = 0.1;  
    tipobj.style.opacity = op;
    tipobj.style.visibility="visible";
    el.onmousemove=positiontip;
    appear();
}
 
function hide_info(el, msgbox) {
	msgbox = msgbox || 'mess';
    d.getElementById(msgbox).style.visibility='hidden';
    el.onmousemove='';
}
 
function ietruebody(){
return (d.compatMode && d.compatMode!="BackCompat")? d.documentElement : d.body
}
 
function positiontip(e) {
    var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
    var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
    var winwidth=ie? ietruebody().clientWidth : window.innerWidth-20
    var winheight=ie? ietruebody().clientHeight : window.innerHeight-20
     
    var rightedge=ie? winwidth-event.clientX : winwidth-e.clientX;
    var bottomedge=ie? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;
 
    if (rightedge < tipobj.offsetWidth)  tipobj.style.left=curX-tipobj.offsetWidth+"px";
    else tipobj.style.left=curX+"px";
 
    if (bottomedge < tipobj.offsetHeight) tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
    else tipobj.style.top=curY+offsetfromcursorY+"px";
}
 
function appear() {
    if(op < 1) {
        op += 0.02;
        tipobj.style.opacity = op;
        tipobj.style.filter = 'alpha(opacity='+op*100+')';
        t = setTimeout('appear()', 30);
    }
}
function changePreview( id )
{
	obj = document.getElementById( "mayka_"+id );
	obj.src = "/catalog_img/"+id+"/main.jpg";
}
function hidePreview( id, color, model )
{
	obj = document.getElementById( "mayka_"+id );
	obj.src = "/catalog_img/" + id + "/" + model + "/" + color + "_250.jpg";
}
//mainpic.innerHTML="<img id=\"mainpic\" border=0 style=\"position:absolute; left:5px; z-index: 10;\" src=\"http://www.vsemayki.ru/catalog_img/795/man/blue_250.jpg\"/>";
