var gPicWidth = 0;
var gPicHeight = 0;
var windowHeight = 0;
var timerID;

function popImage2(tPictureHref,tSymbol,tWidth,tHeight) {

	if(o("powiekszenie")==null){
		return;	
	}	
	gPicWidth = tWidth;
	gPicHeight = tHeight;
	
	o('obrazek').style.backgroundImage = "url('"+tPictureHref+"')";
	
	width = tWidth;
	height = tHeight;
	var myWidth = 0, myHeight = 0;
	
	windowHeight = getVisibleHeight();
	updatePopup();
	
	o('powiekszenie').style.display = "block";
	o('obrazek').style.display = "";
}

function popClose2(){
	o('powiekszenie').style.display='none';
	o('obrazek').style.backgroundImage = "";
}


function updatePopup() {
	
	var start = 1;
	//alert(parseInt(timerID));
	if(isNaN(parseInt(timerID)) && o('powiekszenie').style.display=="none"){
		var myWidth = 10;
		var myHeight = 10;
	}
	else{
	   var myWidth = o('obrazek').style.width.replace('px','');
	   var myHeight = o('obrazek').style.height.replace('px','');
	}

   if(myWidth=='')	myWidth = 0;
   if(myHeight=='')	myHeight = 0;
   var desWidth = gPicWidth;
   var desHeight = gPicHeight;
 
   var easingWidth = calcEasing(desWidth , myWidth);
   var easingHeight = calcEasing(desHeight , myHeight);
   width = parseInt(myWidth) + easingWidth;
   height = parseInt(myHeight) + easingHeight;
   
	o('obrazek').style.width = (width)+"px";
	o('obrazek').style.height = (height)+"px";
	
	if (document.documentElement && document.documentElement.scrollTop)	 theTop = document.documentElement.scrollTop;
	else theTop = document.body.scrollTop;	
	o('powiekszenie').style.top = (theTop+(windowHeight/2)-(height/2)-45)+'px';	
	o('powiekszenie').style.left = (document.body.scrollLeft+((document.body.clientWidth)/2)-(width/2)-5)+'px';
	
   if( ((desWidth<=width && easingWidth>=0) || (desWidth>width && easingWidth<=0)) && 
		((desHeight<=height && easingHeight>=0) || (desHeight>height && easingHeight<=0))) {
   		clearTimeout(timerID);
		timerID = '';
		start = 0;
   }
   
   if(start) timerID = setTimeout("updatePopup()", 1);
}

function calcEasing(main, current){
	var Interval = (main - current)/10;
	if(Interval>=0)	Interval = Math.ceil(Interval);
	else Interval = Math.floor(Interval);
	return Interval;
}
