// JavaScript Document
var ImgHeight = 0;
var ImgWidth = 0;
var ImgDivId = 'HiddenImg';
var FonImgId ='FonImg';
//var BodyShellId = "ltable";
var	ImgDiv;
var	FonImg;
var	BodyShell;
var RunH;
var RunW;
//var Dir = '/img/big/';

function getBodyScrollTop()
{
	return self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
}

function ChangeImge( node, status )
{
	if ( ImgWidth > 0 )
	{
		clearTimeout ( A_Id );
	}
	RunH = 0;
    RunW = 0;
	ImgDiv = document.getElementById ( ImgDivId );
	FonImg = document.getElementById ( FonImgId );
	//BodyShell = document.getElementById ( BodyShellId );
	BodyShell = document.body;
	var H = BodyShell.clientHeight;
	FonImg.style.height = H + 'px';

	if ( status == 'display' )
	{

		var l = Math.floor ( document.body.clientWidth / 2 );
            
			ImgDiv.innerHTML = '<img src="'+ node +'" onclick="ChangeImge( this.src, \'none\' )" />';
		
	    	ImgDiv.style.display = 'block';
			ImgDiv.style.cursor = 'pointer';
			FonImg.style.display = 'block';
			
			var PositionScroll = Number( getBodyScrollTop() + 10 );
			ImgHeight = ImgDiv.clientHeight;
			if ( Number ( PositionScroll + ImgHeight ) < H )
			{
				ImgDiv.style.top = PositionScroll + 'px';
			}
			else
			{
				ImgDiv.style.top = Number ( H - ImgHeight ) + 'px';
				window.scrollTo( 0, Number ( H - ImgHeight ) );
			}
			
			ImgWidth = ImgDiv.clientWidth;
	   		ImgDiv.style.left = ( l - ( ImgWidth / 2 ) ) + 'px';
			openLayer();
	}
	else
	{
	   closeLayer();
	}
}
 
function openLayer()
{
	if ( RunW < ImgWidth || RunH < ImgHeight )
	{
		if ( RunW != ImgWidth )
		{
			RunW += 25;
		}
		if ( RunH != ImgHeight )
		{
			RunH += 25;
		}
		
		ImgDiv.style.clip =  'rect( auto, '+ RunW +'px, '+ RunH +'px, auto )';
		A_Id = setTimeout( 'openLayer()', 5 );
	}	
}

function closeLayer()
{
	if ( RunW < ImgWidth || RunH < ImgHeight )
	{
		if ( RunW != ImgWidth )
		{
			RunW += 25;
		}
		if ( RunH != ImgHeight )
		{
			RunH += 25;
		}
		
		ImgDiv.style.clip =  'rect( '+ RunH +'px, auto, auto, '+ RunW +'px )';
		A_Id = setTimeout( 'closeLayer()', 5 )
	}
	else
	{
		ImgDiv.style.display = 'none';
		FonImg.style.display = 'none';
	}
}

