/*****************************************************************************/
/* Photo Album																 */
/* Author: William Barry 													 */
/* Version 1.0			 													 */
/* 						 													 */
/*****************************************************************************/

var largeHTML;
var largeImage;

function showLarge(folder, image)
{
	var width = getWindowWidth();
	var height = getWindowHeight();
	var scrollHeight = getScrollHeight() + 20;

	document.getElementById('large_container').style.width = "" + width + "px";
	document.getElementById('large_container').style.height = "" + height + "px";
	document.getElementById('large_bg').style.height = ""  + height + "px";
	document.getElementById('large').innerHTML = "<h1 style=\"margin-top: 40px;\">Loading image...</h1>";
	document.getElementById('large').style.top = "" + scrollHeight + "px";
	document.getElementById('large_container').style.display = "block";
	
	largeImage = folder + "/large/" + image;

    ajax_request("functions.php?action=showLarge&folder="+folder+"&image="+image,
        function (text) 
		{ 
			largeHTML = text; 
			
			tempImage = new Image();
			tempImage.src = largeImage;
			tempImage.onload = function()
			{
				document.getElementById('large').innerHTML = largeHTML;
			}
		}, 
        function() { document.getElementById('large').innerHTML = "<h1>Error retrieving image.</h1>"; }
    );
}

function hideLarge()
{
	document.getElementById('large_container').style.display = "none";
}

function getScrollHeight()
{
	var top = 0;
	if (document.documentElement.scrollTop) //ie
		top = document.documentElement.scrollTop;
	else if (window.pageYOffset) //ns
		top = window.pageYOffset;

	return top;
}

function getWindowHeight()
{
	var height = getDivHeight('container');
	var h = 0;

	if (window.innerHeight) //ns
		h = window.innerHeight;
	else if (document.body.clientHeight) //ie
		h = document.body.clientHeight;

	if (h > height)
		height = h;

	return height;
}

function getWindowWidth()
{
	if (window.innerWidth) //ns
		return window.innerWidth;
	else if (document.body.clientWidth)
		return document.body.clientWidth;
	else
		return 0;
}

function getDivHeight(div)
{
	var d = document.getElementById(div);
	var divHeight = 0;
	
	if(d.offsetHeight)
		divHeight = d.offsetHeight;
	else if(d.style.pixelHeight)
		divHeight = d.style.pixelHeight;

	return divHeight;
}

function fixContentHeight()
{
	var sideColHeight = getDivHeight('side_col') + 125;
	var contentHeight = getDivHeight('content_container');
	
	if (contentHeight < sideColHeight)
		document.getElementById('content').style.height = sideColHeight + "px";		
}

