/*
 * Get the screen resolution and modify the template accordingly.
 */

preparePage = function()
{
	background = "images/risingSun";
	
	if (typeof window.innerWidth != 'undefined')
	{
		screenWidth = window.innerWidth;
	}
	else if (typeof document.documentElement != 'undefined'
				&& typeof document.documentElement.clientWidth != 'undefined'
				&& typeof document.documentElement.clientWidth != 0)
	{
		screenWidth = document.documentElement.clientWidth;
	}
	else 
	{
		screenWidth = document.getElementByTagName('body')[0].clientWidth;
	}
	
	//get screen resolution
	if (screenWidth < 1024)
	{
		background += "1024x768.jpg";
	}
	else if (screenWidth < 1280)
	{
		background += "1280x1024.jpg";
	}
	else if (screenWidth < 1440)
	{
		background += "1440x900.jpg";
	}
	else 
	{
		background += "1680x1050.jpg";
	}
	
	//modify page background
	document.body.style.background = "#000 url(" + background + ") top center repeat-y";	
	document.body.style.backgroundAttachment = "fixed";
	
	//modify wrapper dimensions
	document.getElementById("wrapper").style.width = screenWidth + "px";
	document.getElementById("wrapper").style.left = -Math.floor(screenWidth / 2) + "px";
	
	//modify page dimensions
	document.getElementById("page").style.left = Math.floor((screenWidth - 841) / 2) + "px";
}

loadSlideshow = function()
{	
	if (window.images.length > 3) {
		
		for (i = 0; i < 3; i++) {
			document.getElementById('showcase0' + i).src = window.images[i].src;
		}	
	}
	else 
	{
		for (i = 0; i < window.images.length; i++) {
			document.getElementById('showcase0' + i).src = window.images[i].src;
		}
		document.getElementById('slideshowNavTop').style.display = 'none';
		document.getElementById('slideshowNavBtm').style.display = 'none';
	}
}

slideshowGoNext = function() 
{
	showcase00 = document.getElementById('showcase00');
	showcase01 = document.getElementById('showcase01');
	showcase02 = document.getElementById('showcase02');
	
	if (showcase02.src != window.images[window.images.length - 1].src) 
	{
		//move everything to the left one image and add a new image onto the end
		showcase00.src = showcase01.src;
		showcase01.src = showcase02.src;
		showcase02.src = window.images[window.currentLastImage + 1].src;
		
		window.currentFirstImage++;
		window.currentLastImage++;
	}
}

slideshowGoPrev = function() 
{
	showcase00 = document.getElementById('showcase00');
	showcase01 = document.getElementById('showcase01');
	showcase02 = document.getElementById('showcase02');
	
	if (showcase00.src != window.images[0].src) 
	{
		//move everything to the right one image and add a new image onto the end
		showcase02.src = showcase01.src;
		showcase01.src = showcase00.src;
		showcase00.src = window.images[window.currentFirstImage - 1].src;
		
		window.currentFirstImage--;
		window.currentLastImage--;
	}
}
