function setupPage()
{
	resizeUI();
	window.onresize = resizeUI;
}

function resizeUI()
{
	var vOffset = 251;	
	var hOffset = 40;
	var minHeight = 640;
	var maxHeight = 980;
	var minWidth = 848;
	var maxWidth = 1180;
	var maxRatio = 1.5;
	var currentBodyPaddingTop = 7;
	var bodyHeight = document.body.clientHeight;
	var bodyWidth = document.body.clientWidth;

	// Set Height
	
	var newHeight = bodyHeight - vOffset;
	if (bodyHeight < minHeight)
		newHeight = minHeight - vOffset;
	else if (bodyHeight > maxHeight)
		newHeight = maxHeight - vOffset;
		
 	var contentDiv = document.getElementById("contentdiv");			
	contentDiv.style.height = newHeight + "px";
	
	// Set Width

	var newWidth = bodyWidth - hOffset;
	var ratio = bodyWidth/bodyHeight;
	
	if (ratio > maxRatio)
		newWidth = (bodyHeight * maxRatio) - hOffset;
	
	if (newWidth < minWidth)
		newWidth = minWidth;
	else if (newWidth > maxWidth)
		newWidth = maxWidth;
	
	document.getElementById("border-outer").style.width = newWidth + "px";
	document.getElementById("copyright").style.width = newWidth + "px";
	
	// Center Horizontally
	
	var newPaddingTop = (bodyHeight > maxHeight) ? 
		(bodyHeight-maxHeight)/3 : currentBodyPaddingTop;
	document.body.style.paddingTop = newPaddingTop + "px";
}

function loadFlashViewer(galleryFolder, flashContainer)
{
	var fo = new SWFObject(galleryFolder + "/viewer.swf", "viewer", "100%", "100%", "8", "#ffffff");
	fo.addVariable("xmlDataPath", galleryFolder + "/gallery.xml");
	fo.addVariable("preloaderColor", "0x46c3d3");
	fo.addParam("wmode", "transparent");		
	fo.write(flashContainer);	
}

function newEmail(user,domain) 
{ 
	var aadress = "mailto:" + user + "@" + domain; 
	window.location = aadress; 
}
