
/*/***************************************************************************************************************************
/// <name>     8 Washington - Common Java Script Library</name>
/// <summary>  This JavaScript provides common functions for the Website.</summary>
/// <history>
///            Konrad Kyc [2010 © Vantagesoft.ca] - 2010-09-23 - Created.
/// </history>
///***************************************************************************************************************************/

var pageImages = []; 
var pageImageIndex = 0;
window.onresize = ResizeImageWrapper;

/// <summary> 
///  Initialize function that loads immediately when content is downloaded.
/// </summary>
$(document).ready(function(){
	ResizeImageWrapper();
	
	if(pageImages.length > 0)
	{
		$(".pageImageNavigation").show();
	}
	else
	{
		$(".pageImageNavigation").hide();
	}
	
	$("#prevPageImage").click(function(){
		$("#bgimg").fadeOut("slow", function(){
			var prevImageIndex = pageImageIndex - 1;
			
			// Ensure the correct range
			if(prevImageIndex < 0)
				prevImageIndex = pageImages.length - 1;
			
			// Update the current page image index
			pageImageIndex = prevImageIndex;
			
			$(this).attr("src", pageImages[prevImageIndex].imagePath);
			$(this).fadeIn("slow");
		});
	});
	
	$("#nextPageImage").click(function(){
		$("#bgimg").fadeOut("slow", function(){
			var nextImageIndex = pageImageIndex + 1;
			
			// Ensure the correct range
			if(nextImageIndex >= pageImages.length)
				nextImageIndex = 0;
			
			// Update the current page image index
			pageImageIndex = nextImageIndex;
			
			$(this).attr("src", pageImages[nextImageIndex].imagePath);
			$(this).fadeIn("slow");
		});		
	});	
});


/// <summary> 
///  Resizes the image wrapper dynamically so that proper expansion is done
///  to show the whole image on the page (but only to a maximum sepcified size)
/// </summary>
function ResizeImageWrapper() {
    var windowWidth = $(window).width();
    
    if (windowWidth <= 1300) {
        var wrapperWidth = windowWidth - 200;
        $("#right").css({ "width": wrapperWidth + "px" });
    }
    else {
        $("#right").css({ "width": "1110px" });
    }
}
