function to_old_win(url)
{
	opener.location.href = url;
}

function expand(subnav)
{
	if (document.getElementById) {
		if (document.getElementById(subnav).style.display == '') document.getElementById(subnav).style.display = 'none';
		else document.getElementById(subnav).style.display = '';
	} else if (document.all) {
		if (document.all[subnav].style.display == '') document.getElementById(subnav).style.display = 'none';
		else document.all[subnav].style.display = '';
	} else if (document.layers) {
		location.href='inventory.php';
	}
}

function popupDetail(id)
{
	// detect the window resolution
	var width = screen.width;
	if (width > 810)
	{
		detail = window.open("popup1024.php?id=" + id,"detail","toolbars=0,menu=0,status=0,width=970,height=700,status=0,toolbar=0,left=100,top=50");
	}
	else
	{
		detail = window.open("popup800.php?id=" + id,"detail","toolbars=0,menu=0,status=0,width=750,height=530,status=0,toolbar=0,left=100,top=20");
	}
}

function zoom(id, index)
{
	var width = screen.width;
	if (document.getElementById('enlargement').style.display == '')
	{
		document.getElementById('enlargement').style.display = 'none';
		document.images['enlargedImage'].src='images/p.gif';
		if (width > 810)
		{
			document.getElementById('navBarNormal').style.visibility = 'visible';
			document.getElementById('navBarZoom').style.visibility = 'hidden';
		}
		else
		{
			document.getElementById('navBarNormal800').style.visibility = 'visible';
			document.getElementById('navBarZoom800').style.visibility = 'hidden';
		}
	}
	else
	{
		if (width > 810)
		{
			/* Previously the enlarged image boundary was
				652x870. Considering the window dimensions of 970x700,
				a boundary of 870x600 is saner. Of course, this makes
				enlargement pointless for landscape images. */
			document.images['enlargedImage'].src='thumbnail.php?image=' + id + '_' + index + '.jpeg&width=870&height=600&mode=fit';
			document.getElementById('navBarNormal').style.visibility = 'hidden';
			document.getElementById('navBarZoom').style.visibility = 'visible';
		}
		else
		{
			/* window 750x530, previous boundary 510x680, new 650x430 */
			document.images['enlargedImage'].src='thumbnail.php?image=' + id + '_' + index + '.jpeg&width=650&height=430&mode=fit';
			document.getElementById('navBarNormal800').style.visibility = 'hidden';
			document.getElementById('navBarZoom800').style.visibility = 'visible';
		}
		document.getElementById('enlargement').style.display = '';

	}
}

function enlargePhoto(id,index)
{
	var width, height;

	if (screen.width > 810) {
		width = 450;
		height = 600;
	} else {
		width = 330;
		height = 440;
	}

	var kewlhtml =
		'<a href="javascript:zoom(\'' + id + '\',' + index +
		');"><img src="thumbnail.php?image=' + id + '_' + index +
		'.jpeg&width=' + width + '&height=' + height + '&mode=fit' +
		'" style="border:1px solid #666666;" border="0"></a>';

	if (document.getElementById)
		document.getElementById('bigImage').innerHTML = kewlhtml;
	else if (document.all)
		document.all['bigImage'].innerHTML = kewlhtml;

	/*else if (document.layers)*/
}

function SetNav(index)
{
	if (document.getElementById) {
		document.getElementById('nav' + index).className = 'navOn';
	} else if (document.all) {
		document.all['nav' + index].className = 'navOn';
	}
}
