
//dynamic DIV resizing
var img_width=0;
var img_height=0;
var timer;
var idp;
//DIV starting width and height goes here

timer = null;
idp=0;
window.captureEvents(Event.CLICK);
 
 
function DisplayGrow(idp,lastrow)
{
	
	
    var growImg 	 = window.document.getElementById('div' + idp);
	var innerdiv 	 = window.document.getElementById('innerdiv' + idp);
	var tdpos 		 = window.document.getElementById('tdid' + idp);
	var visibleDivId = window.document.getElementById('visibleDivId').value

	if (visibleDivId!="" )
	{
	window.document.getElementById('div'+visibleDivId).style.width		 = 0+'px';
	window.document.getElementById('div'+visibleDivId).style.height		 = 0+'px';
	window.document.getElementById('innerdiv'+visibleDivId).style.width  = 0+'px';
	window.document.getElementById('innerdiv'+visibleDivId).style.height = 0+'px';
	
	window.document.getElementById('div'+visibleDivId).style.position		= 'absolute';
	window.document.getElementById('div'+visibleDivId).style.visibility		= 'hidden';
	window.document.getElementById('div'+visibleDivId).style.display 		= 'none';
	window.document.getElementById('innerdiv'+visibleDivId).style.position	= 'absolute';
	window.document.getElementById('innerdiv'+visibleDivId).style.visibility= 'hidden';
	window.document.getElementById('innerdiv'+visibleDivId).style.display   = 'none';
	}
	
	growImg.style.width 	= 0+'px';
    growImg.style.height 	= 0+'px';
	
	//for finding the relative position
	pScreenWidth=window.screen.width;
	pScreenHeight=window.screen.height;
	
	pDocWidth=window.document.width;
	pDocHeight=window.document.height;
	
	qvleft	= (zxcPos(tdpos)[0]);
	qvtop	= (zxcPos(tdpos)[1]);
	
	
	
	//if ((parseInt(pScreenHeight)-280)>=(parseInt(pScreenHeight)/2))
	if ((parseInt(pScreenHeight)-parseInt(qvtop)) >= 250)
	{
		if (lastrow == 1 )
			{tdleft	= (qvleft-80)+'px';}
		else
			{tdleft	= (qvleft)+'px';}
		tdtop	= (qvtop+20)+'px';
	}
	else
	{
		if (lastrow == 1 )
			{tdleft	= (qvleft-80)+'px';}
		else
			{tdleft	= (qvleft)+'px';}
		tdtop	= (qvtop-270)+'px';
	}
	
	
 	/*if (lastrow == 1 )
	{
	tdleft	= (zxcPos(tdpos)[0]-80)+'px';
	tdtop	= (zxcPos(tdpos)[1]-280)+'px';
	}
	else
	{
	tdleft	= (zxcPos(tdpos)[0])+'px';
	tdtop	= (zxcPos(tdpos)[1]-280)+'px';
	}*/
	
	
	
	growImg.style.left		= tdleft;
    growImg.style.top		= tdtop;
	
	window.document.getElementById('visibleDivId').value=idp;
	
	growImg.style.visibility='visible';
	growImg.style.display 	= '';
	
    growImg.style.width		= img_width+'px';
    growImg.style.height	= img_height+'px';
	innerdiv.style.width	= img_width+'px';
    innerdiv.style.height	= img_height+'px';
 
    if(img_width != 220) 
	{
        img_width  += 20;
        img_height += 24;
        timer = setTimeout('DisplayGrow('+idp+','+lastrow+')', 3);
    } 
	else 
	{
			
		innerdiv.style.left		= tdleft;
		innerdiv.style.top		= tdtop;
		innerdiv.style.width	= img_width+'px';
		innerdiv.style.height	= img_height+'px';
		
		innerdiv.style.position = 'static';
		innerdiv.style.visibility='visible';
		innerdiv.style.display  = '';
		
		img_width  =0;
        img_height =0;
        clearTimeout(timer);
		
		/*alert('pScreenWidth'+pScreenWidth);
		alert('pScreenHeight'+pScreenHeight);
		alert('pDocWidth'+pDocWidth);
		alert('pDocHeight'+pDocHeight);*/
		//alert('qvleft'+qvleft);
		//alert('qvtop'+qvtop);
		//alert (event.screenX);
		//window.moveTo(0,0);
		
		
    }
}

function zxcPos(zxcobj)
{ 
    zxclft=zxcobj.offsetLeft;
    zxctop=zxcobj.offsetTop;
    while(zxcobj.offsetParent!=null)
    {
        zxcpar =zxcobj.offsetParent;
        zxclft+=zxcpar.offsetLeft;
        zxctop+=zxcpar.offsetTop;
        zxcobj =zxcpar;
    }
    return [zxclft,zxctop];
}

function DisplayShrink(idp,flag) 
{
	var growImg  = window.document.getElementById('div' + idp);
	var innerdiv = window.document.getElementById('innerdiv' + idp);

	if (flag==1)
	{
	img_width  = 220;
	img_height = 220;
	innerdiv.style.position   = 'absolute';
	innerdiv.style.visibility = 'hidden';
	innerdiv.style.display 	  = 'none';
	innerdiv.style.width      = 0+'px';
	innerdiv.style.height     = 0+'px';
	}
	
    growImg.style.width		  = img_width+'px';
    growImg.style.height	  = img_height+'px';
	
    if(img_width != 0) 
	{
        img_width  -= 20;
        img_height -= 20;
        timer = setTimeout('DisplayShrink('+idp+',0)', 3);
    }
	else 
	{
		growImg.style.position		= 'absolute';
		growImg.style.visibility	= 'hidden';
		growImg.style.width			= 0+'px';
		growImg.style.height		= 0+'px';
        clearTimeout(timer);
    }
	
}


