var pleft = 0;
var ptop = 0;
var incr = 0;
var id_books = '';
var bwidth = 0;
var show = 1;
var name = '';
var id = '';



function showpicture(id, name, bw, bh, pos, mwidth, mheight) {
      id_books = id;
      bwidth = bw;
      picturediv = document.getElementById("bigpic");
      var book_href = 'index.php?section=book&artic=' + id_books;
      pleft = pos.x;
      ptop = pos.y;
      if (navigator.userAgent.indexOf("MSIE 7.0")!=-1) { pleft -= 11; }
      picturediv.style.left = pleft + 'px';
      picturediv.style.top = ptop + 'px';
      picturediv.innerHTML = "<div onmouseout='hidepicture()' onmousemove='show=1'><a href='" + book_href + "'><img id='"+id_books+"' src='picts/"+name+"' border='0'></a></div><div id='loading-pic' onmouseout='hidepicture()' onmousemove='show=1'></div><div id='noshow' onmouseout='hidepicture()' onmousemove='show=1'><a href='" + book_href + "'>Подробнее</a></div>";
      bpic = new Image();
      bpic.onload = function () {
            document.getElementById("loading-pic").innerHTML = "";
            pic.src = bpic.src;
         }
      bpic.src = "picts/" + name;
      pic = document.getElementById(id_books);
      pic.width = mwidth;
      picturediv.style.display = "block";
      increase();
}

function hidepicture() {
   show = 0;
   setTimeout('starthide()', 20);
}

function starthide() {
   if (show == 0) {
      document.getElementById("noshow").style.display = "none";
      pic.width = pic.width - 10;
      pleft = pleft + 5;
      ptop = ptop + 5;
      picturediv.style.left = pleft + 'px';
      picturediv.style.top = ptop + 'px';
      if (pic.width > 100) setTimeout('starthide()', 0); else picturediv.style.display = "none";
   }
}



function increase() {
        if ((pic.width + incr)>bwidth) incr = (bwidth-pic.width); else incr = 10;
        pic.width = pic.width + incr;

        pleft = pleft - Math.round(incr/2);
        ptop = ptop - Math.round(incr/2);
        picturediv.style.left = pleft + 'px';
        picturediv.style.top = ptop + 'px';

        if (pic.width < bwidth) {
                setTimeout('increase()', 0);
        }
        else {
                if (bpic.complete) pic.src = bpic.src;
                document.getElementById("noshow").style.display = "block";
                if (document.getElementById("cover_buy_button"+id_books)) document.getElementById("cover_buy_button"+id_books).style.display = "block";
        }

        if (pic.width > 100) document.getElementById("loading-pic").style.display = "block";
}


function absPosition(obj) {
        var x = y = 0;
        while(obj) {
                x += obj.offsetLeft;
                y += obj.offsetTop;
                obj = obj.offsetParent;
        }
        return {x:x, y:y};
}