function alignToCenter(el)
{
	with(el)
	{
		style.left = ((document.body.clientWidth - clientWidth) / 2  + document.body.scrollLeft) + "px";
		style.top = ((document.body.clientHeight - clientHeight) / 2  + document.body.scrollTop) + "px";
	}
}

function display(el, value)
{
	with(el.style)	
		display = value;	
}

function visibility(el, value)
{
	with(el.style)
		visibility = value;
}

function show(elem)
{
	visibility(elem, "hidden");
	display(elem, "block");
	alignToCenter(elem);
	setOpacity(elem, 0);
	visibility(elem, "visible");
	if(!isOpera)
		process(getOpacity(elem), 5, 100, 50, elem, "opacity", "", "");
}

function hide(elem)
{
	if(isOpera)
		display(elem, "none");
	else
		process(getOpacity(elem), 5, 0, 50, elem, "opacity", "", "hide");
}

function addLoadEvToImg(img)
{
	if(isFF)
		addEvt(img, "load", ifImgLoaded);
	else if(isIE)
		addEvt(img, "readystatechange", ifImgLoaded);
}

function ifImgLoaded()
{
	show(box);
}

var pict = createObj("img", "pict", 0, "block", 0);
var box = createObj("div", "box", 0, "none", 0);
var mess = createObj("div", "mess", 0, "none", 0);

with(box.style)
{
	position = "absolute";
	border = "solid 3px #000";
	cursor = "pointer";
}

with(mess.style)
{
	position = "absolute";
	padding = "10px";
	fontSize = "15px";
	color = "#b00";
	border = "solid 2px #b00";
	background = "#fff";
	textAlign = "center";
	cursor = "pointer";
}

addEvt(box, "mousedown", hideImg);
addEvt(mess, "mousedown", hideMess);

box.appendChild(pict);
addLoadEvToImg(pict);

function showImg(src)
{	
	pict.src = src;
	
	if(isOpera)
		show(box);
}

function hideImg()
{
	hide(box);
}

function showMess(message)
{
	mess.innerHTML = message;
	show(mess);
}

function hideMess()
{
	hide(mess);
}

initObj[initObj.length] = function()
{
	document.body.appendChild(box);
	document.body.appendChild(mess);
};

vsObj = new Array();

function process(cv, vs, lv, sd, lE, prop, d, addF)
{
	vsObj[2] = cv; //currvalue
	vsObj[3] = vs; //valuestep
	vsObj[4] = lv; //limitvalue
	vsObj[5] = sd; //stepduration
	
	vsObj[6] = lE;	//linkElem
	vsObj[7] = prop; //property
	vsObj[8] = d; //dem
	vsObj[10] = ((vsObj[2] <= vsObj[4]) ? 1 : (-1)); //sign_vs
	vsObj[11] = addF; //additional_function
	
	vsObj[9]();
	
	vsObj[0]();	
}

vsObj[0] = function()
{
	vsObj[1]();
	
	vsObj[2] += (vsObj[3] * vsObj[10]);
	
	if((vsObj[2] * vsObj[10]) <= (vsObj[4] * vsObj[10]))
		setTimeout(vsObj[0], vsObj[5]);
	else if(vsObj[11] == "hide")
		display(vsObj[6], "none");
};

vsObj[9] = function()
{
	if(vsObj[7] == "left")
		vsObj[1] = function(){vsObj[6].style.left = vsObj[2] + vsObj[8];};
		
	if(vsObj[7] == "top")
		vsObj[1] = function(){vsObj[6].style.top = vsObj[2] + vsObj[8];};
		
	if(vsObj[7] == "width")
		vsObj[1] = function(){vsObj[6].style.width = vsObj[2] + vsObj[8];};
		
	if(vsObj[7] == "height")
		vsObj[1] = function(){vsObj[6].style.height = vsObj[2] + vsObj[8];};
		
	if((vsObj[7] == "opacity") && isIE)
		vsObj[1] = function(){vsObj[6].style.filter = "alpha(opacity=" + vsObj[2] + ")";};
		
	if((vsObj[7] == "opacity") && isFF)
		vsObj[1] = function(){vsObj[6].style.MozOpacity = vsObj[2]/100;};
};

function setOpacity(el, value)
{
	with(el.style)
	{
		if(isIE)
			filter = "alpha(opacity=" + value + ")";
		
		if(isFF)
			MozOpacity = value / 100;
	}
}

function getOpacity(el)
{
	var opacity;
	
	if(isIE)
		{			
			opacity = parseInt(el.style.filter.substr(14, 3));
		}
	else if(isFF)
		opacity = el.style.MozOpacity * 100;
	
	return opacity;
}

