Event.observe(window, 'load', init);

var win = null;
var image_html = {};
var image = null;

function init()
{
	win = {
		login:$('login'),
		reg:$('registration')
	}
}
function login()
{
	darkenPage();
	coords = centerElCoords(win.login);
	win.login.style.display = "block";
	win.login.style.top = coords.y+"px";
	win.login.style.left = coords.x+"px";
}
function registration()
{
	alert('here');
}
function close()
{
	darkenPage();
	win.login.style.display = "none";
}
function doOver(top)
{
	$('intro').style.backgroundPosition = 0+"px -"+top+"px";
}
function doClear()
{
	$('intro').style.backgroundPosition = "0px 0px";
}
function image_preload(id,num)
{
	darkenPage();
	var main = document.createElement("div");
	main.id = 'image_main';
	image_html.main = main;
	var container = document.createElement("div");
	container.id = 'image_main_container';
	image_html.container = container;
	container.className = 'clearfix';
	var im = document.createElement("div");
	im.id = 'image_cont';
	image_html.im = im;
	var sub = document.createElement("div");
	sub.id = 'image_sub';
	image_html.sub = sub;
	
	container.appendChild(im);
	container.appendChild(sub);
	main.appendChild(container);
	document.body.appendChild(main);
	
	var image = new Array();
	for(var i=1; i<counter_images; i++)
	{
		image[i] = new Image(); image[i].src = BASEURL+"admin/system/application/db_images/product_"+id+"/image_"+i+"_small.jpg";
		image_html.sub.innerHTML += "<a href='javascript:image_load("+id+","+i+")'><img src='"+image[i].src+"'></a>";
	}
	image_html.sub.innerHTML += "<a class='close' href='javascript:closeImage()'>Затвори</a>";
	image_load(id,num);
}
function image_load(id,num)
{
	image_html.im.className = "loading";
	image = new Image();
	image.id = id;
	image.num = num;
	image.onload = image_show;
	image.src = BASEURL+"admin/system/application/db_images/product_"+id+"/image_"+num+".jpg";
}
function image_show()
{
	var width = this.width;
	var height = this.height;
	var x = width-501;
	image_html.container.style.width = 600+x+"px";
	image_html.container.style.height = height+2+"px";
	image_html.im.style.width = width+2+"px";
	image_html.im.style.height = height+2+"px";
	image_html.im.className = "";
	image_html.im.innerHTML = "<img src='"+this.src+"'>";
}
function closeImage()
{
	document.body.removeChild(image_html.main)
	image = null;
	darkenPage();
}