﻿var pleft = 0;
var ptop = 0;
var incr = 0;
var id_books = 0;
var bwidth = 0;
var show = 1;


function showpicture(id, bw, bh, obj, mwidth, mheight) {
        id_books = id;
		bwidth = bw;
		picturediv = document.getElementById("bigpic");

        pleft = 0;
        ptop = 0;
        while(obj) {
	        pleft += obj.offsetLeft;
	        ptop += obj.offsetTop;
	        obj = obj.offsetParent;
        }
        

		picturediv.style.left = pleft + 'px';
		picturediv.style.top = ptop + 'px';
		picturediv.innerHTML = "<div style='color:white;z-index:10000' onmouseout='hidepicture()' onmousemove='show=1'><a href='/books/" + id + "/default.aspx'><img style=\"maxwidth:" +mwidth + "\" id='"+id_books+"' border=0 src='http://rznbooks.ru/images/images_s/"+id_books+".jpg'></a></div></div></div>";
		bpic = new Image();
		bpic.src = "http://goodreads.ru/images/images_full/"+id_books+".jpg";
		bpic.onload = function () {
				//document.getElementById("loading-pic").innerHTML = "";
				pic.src = bpic.src;
			}

		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) {
		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;
	}
	
}

