var eth_div;

var eth_image_width_search=400;
var eth_image_width_list=400;

function eth_hide_image(el)
{
    if (eth_div && eth_div.parentNode) eth_div.parentNode.removeChild(eth_div);
    eth_div=null;
}
function eth_show_image(el,leftside)
{
    eth_hide_image(el);
    var fl=el,x=leftside?-(eth_image_width_list+15):80,y=0;
    for (;fl;fl=fl.offsetParent) {
        x+=fl.offsetLeft;
        y+=fl.offsetTop;
    }
    var s=el.src.split('?')[1]
    if (!s) return;
    s=s.split('&');
    var thid=0,i;
    for (i=0;i<s.length;i++) if (s[i].indexOf('id=')==0) {
        thid=s[i].substr(3)
    }
    function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function winSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth,myHeight];
}

function supfun()
    {
        eth_hide_image(el);
	img.style.display="block"
        eth_div=document.createElement('div')
        var st=getScrollXY()[1];
        y-=Math.floor(img.height/2)
        if (y<st+5) y=st+5;
        else {
            var h=winSize()[1];
            if (y+img.height+25>st+h) y=st+h-25-img.height;
        }
        
        eth_div.innerHTML='<div style="position:absolute;display:block;left:'+x+'px;top:'+y+
            'px;padding:10px;background-color:#777777"></div>';
        eth_div=eth_div.firstChild;
        eth_div.appendChild(img)
        document.body.appendChild(eth_div)
        
    }
    
    var img=new Image()
    img.onload=supfun;
    img.src="/obrazek.php?id="+thid+'&w='+(leftside?eth_image_width_list:eth_image_width_search);
    
    
}
