var tip_j = new Image(); tip_j.src = 'images/tip_j.jpg';
var tip_p = new Image(); tip_p.src = 'images/tip_p.jpg';
var tip_r = new Image(); tip_r.src = 'images/tip_r.jpg';
var tip_s = new Image(); tip_s.src = 'images/tip_s.jpg';
var tip_v = new Image(); tip_v.src = 'images/tip_v.jpg';

var nav_j = new Image(); nav_j.src = 'images/nav_j_on.jpg';
var nav_p = new Image(); nav_p.src = 'images/nav_p_on.jpg';
var nav_r = new Image(); nav_r.src = 'images/nav_r_on.jpg';
var nav_s = new Image(); nav_s.src = 'images/nav_s_on.jpg';
var nav_v = new Image(); nav_v.src = 'images/nav_v_on.jpg';

var wnd;
var g_blnActive = false;
var g_intMax;
var g_intLineHeight;
var g_objDiv;
var g_strDirection;

function openWin(p_strType, p_strFile)
{
	/*
	var intDiff1 = document.getElementById('h').offsetTop - 76; //153 || 142
	if (intDiff1 > 142) { intDiff1 = intDiff1 - (intDiff1 - 142) + 1; } 

	var intDiff2 = document.getElementById('bdy').clientHeight; // 851
	if (intDiff2 < 851)  { intDiff2 = ((851 - intDiff2)); }
	if (intDiff2 > 851)  { intDiff2 = ((851 - intDiff2) / 2); }
	if (intDiff2 == 851) { intDiff2 = 0; }

	alert(intDiff1 + ' x ' + intDiff2);
	*/

	var intDiff2 = parseInt((996 - screen.availHeight) / 2);
	var intDiff3 = parseInt((document.getElementById('bdy').clientHeight - 900) / 2);
	//alert(intDiff1 + ' x ' + intDiff2 + ' x ' + intDiff3);

	var intDiff1 = parseInt((996 - screen.availHeight) / 2);
	var intDiff2 = parseInt((document.getElementById('bdy').clientHeight - 900) / 2);
	//alert(intDiff1 + ' x ' + intDiff2 + '\n' + parseInt(intDiff1+intDiff2) + '\navailHeight (996) : ' + screen.availHeight + '\nclientHeight (900) : ' + document.getElementById('bdy').clientHeight);

	var wnd = window.open('/photography_view.asp?type=' + p_strType + '&file=' + p_strFile,'','width=670,height=710,scrollbars=yes,toolbars=no');
	wnd.moveTo(((screen.availWidth/2)-(670/2)),((screen.availHeight/2)-(710/2)) - (intDiff1 + intDiff2)); 
	//wnd.moveTo(((screen.availWidth/2)-(670/2)), intDiff1 + intDiff2);
}

function scrl(p_objDiv, p_intAddVal)
{
	g_objDiv = p_objDiv;
	g_objDiv.style.display = ''; 

	var intVal = parseInt(g_objDiv.style.height) + p_intAddVal;
	if (intVal < 4) intVal = 4;

	g_objDiv.style.height = intVal + 'px';

	// expand parents with children
	do
	{
		if (p_objDiv.parentNode.id != '')
		{
			var intVal = parseInt(p_objDiv.parentNode.style.height) + p_intAddVal;
			if (intVal < 4) intVal = 4;
			p_objDiv.parentNode.style.height = intVal + 'px';

			p_objDiv = p_objDiv.parentNode;
		}
		else
		{
			p_objDiv = null;
		}
	}
	while (p_objDiv != null);

	if (eval("(parseInt(g_objDiv.style.height.substr(0,g_objDiv.style.height.indexOf('x') - 1)) " + g_strDirection + " g_intMax)") == true)
	{
		// recurse
		setTimeout("scrl(g_objDiv, g_intLineHeight)", 5);
	}
	else
	{
		// finish
		if (g_intLineHeight > 0)
			g_objDiv.style.height = g_intMax + 'px';
		else
			g_objDiv.style.display = 'none';

		g_blnActive = false;
	}
}

function proc(p_objDiv, p_intCount)
{
	if (g_blnActive == false)
	{
		g_objDiv = p_objDiv;
		g_blnActive = true;

		if (g_objDiv.style.display == '')
		{
			document.getElementById('i' + p_objDiv.id.substr(6)).src = 'images/folder.gif';

			g_intLineHeight = -19;
			g_intMax = 4;
			g_strDirection = '>';

			var blnHide = true;
		}
		else
		{
			document.getElementById('i' + p_objDiv.id.substr(6)).src = 'images/folder_open.gif';

			g_intLineHeight = 19;
			g_intMax = parseInt(g_intLineHeight * p_intCount);
			g_strDirection = '<';
					
			var blnHide = false;
		}

		window.setTimeout('scrl(g_objDiv, g_intLineHeight)', 5);

		if (blnHide) CollapseChildren(p_objDiv);
	}
}

function CollapseChildren(p_objDiv)
{
	// make sure all children are collapsed
	for (var x=1; p_objDiv.childNodes.length > x; x++)
	{
		if (p_objDiv.childNodes[x].id != '')
		{
			CollapseChildren(p_objDiv.childNodes[x]);

			document.getElementById('i' + p_objDiv.childNodes[x].id.substr(6)).src = 'images/folder.gif';

			p_objDiv.childNodes[x].style.height  = g_intMax + 'px';
			p_objDiv.childNodes[x].style.display = 'none';
		}
	}
}
