var lb = null;
var closeTimer=null;

function changeCatalogImg(img)
{
    lb.show_box(img, "catalogBigImage");
}

function fSendToLightBoxTheArt(img, txt, width, height)
{        
	if(lb ==  null)
		lb = new  DLightBox(width, height);
	lb.show_box(img, "theArtBigImage");
	document.getElementById("theArt_imgTxt").innerHTML = txt;	
	//lb.frame.style.overflow = "hidden";	
}

function fSendToLightBoxCatalog(img, width, height, imgNum, numOfPic)
{        
	if(lb ==  null)
		lb = new  DLightBox(width, height);
	lb.show_box(img, "catalogBigImage");
	imgNo = imgNum;	
	if (numOfPic == 3)
	{
	    document.getElementById("catalogImg4").style.display = "none";
	}
	else
	{	    	    
	    document.getElementById("catalogImg4").style.display = "inline";	    
	}
	//lb.frame.style.overflow = "hidden";		
}

function fHideLightBox()
{
	 if(lb ==  null)
		return;
	lb.hide_box();
}

function DLightBox_WindowSize()
{
	if (navigator.appName=="Netscape")
	{
		var winW = window.innerWidth;
		var winH = window.innerHeight;		
	}
	else
	{
		var winW = document.documentElement.clientWidth;
		var winH = document.documentElement.clientHeight;		
	}
	return [winW,winH];
}

function DLightBox_Size(width, height)
{    
	this.contentDiv = document.getElementById("lightBoxContent");		
	this.contentDiv.style.width = width +"px";
	this.contentDiv.style.height = height +"px";
	var DLightBox_windowSize = DLightBox_WindowSize();	
	this.contentDiv.style.left = ((DLightBox_windowSize[0] - width)/2) + 'px';
	this.contentDiv.style.top = ((DLightBox_windowSize[1] - height)/2) + 'px';
}

function DLightBox(width, height)
{
	this.contentDiv = document.getElementById("lightBoxContent");		
	this.bDiv = document.getElementById("lightBox");
	this.bDiv.style.height = document.body.offsetHeight;
	if(navigator.userAgent.indexOf("MSIE 6.0") != -1)
	{
	    this.bDiv.style.marginLeft = "110px";
	}
	//this.frame = document.getElementById("lightBoxFrame");
	DLightBox_Size(width, height);
	this.selectInputs = document.getElementsByTagName("SELECT");
	this.timer=null;
}

DLightBox.prototype.show_box = function(img, imgId)
{	
	this.bDiv.style.display = "block";
	document.getElementById(imgId).src = img;
	this.contentDiv.style.display = "block";
	slc = this.selectInputs;
	var i=0;
	for(i=0;i<slc.length;i++)
	{
		slc[i].style.visibility="hidden";
	}	
	//this.contentDiv.innerHTML = '';
	//this.contentDiv.appendChild(this.frame);
	
	 
}
DLightBox.prototype.hide_box = function()
{	 
	 this.bDiv.style.display = "none";
	 this.contentDiv.style.display = "none";
	 slc = this.selectInputs;
	 var i=0;
	 var oThis = this;
	 for(i=0;i<slc.length;i++)
	{
		slc[i].style.visibility="visible";
	}
}
 DLightBox.prototype.close_tmp = function()
 {
	var box = 	lb.contentDiv;
	box.filters[0].apply();
	box.innerHTML ="<div class='fltt'></div>";
	//alert(lb.frame);	
	box.filters[0].play(3);
	timer = setInterval(lb.close_box,8);   
	
	
 }
 DLightBox.prototype.close_box = function()
 {
	 var box = 	lb.contentDiv;
	  if(box.offsetHeight>20)
		 {
			box.style.height = (box.offsetHeight - 20) + 'px';
		 }
	
	 else
	 {
		 
		lb.hide_box();
		clearInterval(timer);
		timer = null;
	 }
 }

 var timer = null;
 function close_box()
 {
	// timer = setInterval(lb.close_box,2);
	lb.close_tmp();
 }
