//THE FOLLOWING FUNCTIONS ARE USED ON THE INDEX PAGE AND ITS RESPECTIVE IFRAMES

//This function randomizes the default and mouseOut background image
//flag of 0 = randomize, flag of 1 = return to previously loaded image

numImgs_architecture = 10; //<~~~~~MATCH this number to highest numbered randomized photo in architecture directory
numImgs_photography = 29; //<~~~~~MATCH this number to highest numbered randomized photo in photography directory

//USE THIS FUNCTION FOR MENU PAGES (RANDOM BACKGROUND)
function imgRandomizer(menuSection) {

	var numImgs = 0;
	switch(menuSection) //test to see which section this code is running for
	{
		case 'architecture':
			numImgs = numImgs_architecture;
		break;    
		case 'photography':
			numImgs = numImgs_photography;
		break;
	}

	var randomNum = Math.round(Math.random() * numImgs);
	
	var randomNumStr = '' + randomNum;
	
	while (randomNumStr.length < 4)
		randomNumStr = '0' + randomNumStr;
		
	window.parent.document.getElementById(menuSection).style.background='url(bg_' + menuSection + '/' + randomNumStr + '.jpg)';
	
}

//USE THIS FUNCTION FOR INDEX PAGES (RANDOM BACKGROUND)
function imgRandomizer_index(menuSection) {

	var numImgs = 0;
	switch(menuSection) //test to see which section this code is running for
	{
		case 'architecture':
			numImgs = numImgs_architecture;
		break;    
		case 'photography':
			numImgs = numImgs_photography;
		break;
	}

	var randomNum = Math.round(Math.random() * numImgs);
	
	var randomNumStr = '' + randomNum;
	
	while (randomNumStr.length < 4)
		randomNumStr = '0' + randomNumStr;

	parent.document.getElementById(menuSection).style.background='url(bg_' + menuSection + '/' + randomNumStr + '.jpg)';
	
}

//This function swaps the background image based on mouseOver - DEPRECIATED
function changeBgImg(whichImage) {

			window.parent.document.getElementById('photography').style.background='url(bg_photography/' + whichImage + '.jpg)';

}





//THE FOLLOWING FUNCTIONS ARE USED ON GALLERY PAGES

//This function defines the image size and sizes the div to fit
function divSize() { //THIS FUNCTION HAS BEEN DEPRECIATED
	
	var newWidth = document.mainImg.width; 
	var newHeight = document.mainImg.height;

	document.getElementById('img').style.width = newWidth;
	document.getElementById('img').style.height = newHeight;
	document.getElementById('img').style.overflow = "hidden"; //hide overflow to restrict everything to the image only
	document.getElementById('img').style.padding = "0";
	
	document.getElementById('mainBody').style.width = newWidth;
	document.getElementById('siteMap').style.width = newWidth;
}

//This function defines the image width and sizes the div to fit
function imageWidth () {
	var newWidth = document.mainImg.width; 
	return newWidth;
}

//This function defines the image height and sizes the div to fit
function imageHeight () {
	var newHeight = document.mainImg.height;
	return newHeight;
}

//This function displays the site map or link back to the homepage at the bottom of photography pages
function siteMap() {

	document.write('<BR><BR><CENTER>.:<a href="http://www.cluskillz.com/">home</a>');
	
	galleryHREF = location.href;
	var strloc = galleryHREF.indexOf('html/');
	galleryHREF = galleryHREF.slice(0,strloc);
	
	document.write('::<a href="' + galleryHREF + '">gallery</a>:.</CENTER>');
	
	document.write('<BR><BR><BR><span style="font-size: 8pt; font-style: italic">All photographs on this site unless otherwise specified are licensed under the <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/"><font color="gray"><u>Creative Commons Non-commercial No-derivative Works 3.0 License</u></font></a>. Usage for non-commercial purposes is allowed, provided that I, Calvin Lu, am credited along with a link to <a href="http://www.cluskillz.com/"><font color="gray"><u>http://www.cluskillz.com/</u></font></a>. Commercial uses and derivative works are forbidden without written consent. Please <a href="mailto:cluskillz@yahoo.com"><font color="gray"><u>contact me</u></font></a> as a courtesy prior to using my work. Thank you.</span>');

}
