function ShowPopDiv(popdiv, preload, divpict, pict){
	this.interval;
	this.imgChange = null;
	this.defaultWidth = '300';
	this.defaultHeight = '300';
	this.spaceTop = 20;
	this.spaceLeft = 20;
	
	this.preloadWidth = 40;
	this.preloadHeight = 40;
	
	this.defaultTop = 0;
	this.defaultLeft = 0;
	
	this.popDiv = document.getElementById(popdiv);
	this.divPreload = document.getElementById(preload);
	this.divPict = document.getElementById(divpict);
	this.imgPict = document.getElementById(pict);
	
	
	this.getClientWidth = function()
	{
	  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
	}
	
	this.getClientHeight = function()
	{
	  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	}
	
	this.imgChangeF = function(url_pict){
		if(this.imgChange.complete == true )
		{
			clearInterval(this.interval);
			if(this.popDiv.style.display == 'block'){
				this.popDiv.style.display = 'none';
				var pictWidth  = this.imgChange.width;
				var pictHeight = this.imgChange.height;
	
				this.imgPict.src = url_pict;
				this.imgPict.width = pictWidth;
				this.imgPict.height = pictHeight;
				this.popDiv.style.width = pictWidth + this.spaceLeft + 'px';
				this.popDiv.style.height = pictHeight + this.spaceTop + 'px';
	
				var body = document.getElementsByTagName("body").item(0);
				
				var bodyWidth = 0;
				var bodyHeight = 0;
	
				if(window.innerWidth){
					bodyWidth = window.innerWidth;
				}
				else{
					bodyWidth = body.offsetWidth;
				}
				
				bodyWidth = this.getClientWidth();
			  	bodyHeight = this.getClientHeight();
				
				scrollTop = parseInt(document.body.scrollTop + document.documentElement.scrollTop);	
				scrollLeft = parseInt(document.body.scrollLeft + document.documentElement.scrollLeft);	

				popDivStyleTop = parseInt((bodyHeight - pictHeight)/2) + scrollTop + 'px';
				popDivStyleLeft = parseInt((bodyWidth - pictWidth)/2) + scrollLeft + 'px';
				
				if(popDivStyleTop < 0){
					popDivStyleTop = 0;
				}
				if(popDivStyleLeft < 0){
					popDivStyleLeft = 0;
				}
				this.popDiv.style.top = popDivStyleTop;
				this.popDiv.style.left = popDivStyleLeft;
				
				this.divPreload.style.display = 'none';
				
				this.popDiv.style.display = 'block';
				this.divPict.style.display = 'block';
			}
			this.imgChange = null;
		}
	}
	this.imgChangeF.parent = this;
	
	this.ShowPict = function(url_pict){
		if(this.imgChange != null) return;
		if(this.popDiv){
			this.imgPict.src = TPL_PATH + 'images/blank.gif';
			this.imgPict.width = this.defaultWidth + 'px';
			this.imgPict.height = this.defaultHeight + 'px';
			this.popDiv.style.width = this.defaultWidth + 'px';
			this.popDiv.style.height = this.defaultHeight + 'px';
			var body = document.getElementsByTagName("body").item(0);
			
			var bodyWidth = 0;
			var bodyHeight = 0;

			bodyWidth = this.getClientWidth();
			bodyHeight = this.getClientHeight();
				
			scrollTop = parseInt(document.body.scrollTop + document.documentElement.scrollTop);	
			scrollLeft = parseInt(document.body.scrollLeft + document.documentElement.scrollLeft);	
			
			this.defaultTop = parseInt((bodyHeight - this.defaultHeight)/2) + scrollTop;
			this.defaultLeft = parseInt((bodyWidth - this.defaultWidth)/2) + scrollLeft;

			if(this.defaultTop < 0){
				this.defaultTop = 0;
			}

			if(this.defaultLeft < 0){
				this.defaultLeft = 0;
			}

			this.popDiv.style.top = this.defaultTop + 'px';
			this.divPreload.style.top =  parseInt((this.defaultHeight - this.preloadHeight)/2)  +'px';
			this.popDiv.style.left = this.defaultLeft + 'px';
			this.divPreload.style.left = parseInt((this.defaultWidth - this.preloadWidth)/2)  +'px';			

			this.divPreload.style.display = 'block';
			this.popDiv.style.display = 'block';
			this.divPict.style.display = 'none';
			var img = new Image();
			img.src = url_pict;
			this.imgChange = img;
			this.interval = setInterval('spd.imgChangeF("' + url_pict + '")', 1000);

		}
		return false;
	 }
	this.ShowPict.parent = this;
	
	
}
var spd = new ShowPopDiv('popdiv','preload', 'div_pict','pict_normal');
