timerID=null;
tmp_height=0
tmp_width=0
xtop=0;
xleft=0;

function show_gal(top, left, img, width, height, typ)
{
 xtop = top;
 xleft = left;
 timerID = setTimeout("show_gallery("+top+","+left+",'"+img+"','"+width+"','"+height+"', '"+typ+"')",300);
}

function hide_gallery()
{
  var el=document.getElementById("img_show");
  el.style.display='none';
  if(timerID!=null)
     clearTimeout(timerID);
}

function show_gallery(top, left, img, width, height, typ)
{
    var el=document.getElementById("img_show");
    tmp_height = el.style.height = height;
    tmp_width = el.style.width = width;
    el.style.display = 'block';
    move_gallery(xtop, xleft, typ);
    el.innerHTML='<img id="img_show_pic" border="0" src="' + img + '"  alt="" />';
}

function move_gallery(top, left, typ)
{
    var el = document.getElementById("img_show");
    if(el.style.display == 'block')
    {

      if(typ=='n')
      {
        if (document.documentElement)
        {
         el.style.top = document.documentElement.scrollTop + top - (tmp_height / 2) - 30 + "px";
         el.style.left = document.documentElement.scrollLeft + left - tmp_width - 35  + "px" ;
        }
        else if(document.body)
        {
         el.style.top = document.body.scrollTop + top - (tmp_height / 2) - 30 + "px";
         el.style.left = document.body.scrollLeft + left - tmp_width - 35  + "px";
        }
      }
      else
      {
        if (document.documentElement)
        {
         el.style.top = document.documentElement.scrollTop + top - tmp_height - 80+ "px";
         el.style.left = document.documentElement.scrollLeft + left - (tmp_width / 2) + "px" ;
        }
        else if(document.body)
        {
         el.style.top = document.body.scrollTop + top - tmp_height - 80 + "px";
         el.style.left = document.body.scrollLeft + left - (tmp_width / 2)  + "px";
        }
      }
    }
    else
    {
     xtop = top;
     xleft = left;
    }
}

