var commonDivHt = 685;
var footerTop = 1205;

function loadHome() {
	//window.location = "index.html";

	clrDiv("commonDiv");
	
	//adding to normal adjustment for this page
	var thisCommonDivHt = 300;
	var thisFooterTop = 790;	
	
	document.getElementById('galleryMenu').style.visibility = 'visible';
	document.getElementById('commonDiv').style.height = thisCommonDivHt + 'px';
	document.getElementById('footer').style.marginTop = thisFooterTop + 'px';

	updateSS('menu');
	document.getElementById("commonDiv").innerHTML = document.getElementById("commonDivInnerHTML").value;
}

function bodyOnLoad() {
	//stuff to prevent image stealing
	document.body.ondragstart = "return false";
	document.body.onselectstart = "return false";
	
	chkRefresh();
	
	createPlayer();
	
	document.getElementById("commonDivInnerHTML").value = document.getElementById("commonDiv").innerHTML;
}

function loadSS() {
	var ssImg = [];
	var slides = [];
	var ct = 0;
	
	ssImg = getSSImages();
	
	while (ct < ssImg.length) {
		slides[ct] = ["resources/images/slideshow/" + ssImg[ct] + "?" + genRand(), ""];
		ct = ct+1;	
	}
	
	slides.no_controls = 1;
	slides.fadecolor = '#000000';
	new inter_slide(slides);
}

function loadCat(whichOne) {
	updateSS(whichOne);
	clrDiv("commonDiv");

	var thisCommonDivHt = commonDivHt;
	var thisFooterTop = footerTop;

	//if type has no categories, readjust
	if ((whichOne == "illus") || (whichOne == "figure") || (whichOne == "still") || (whichOne == "graphic")) {
		thisCommonDivHt = thisCommonDivHt - 45;
		thisFooterTop = thisFooterTop - 45;
	}

	document.getElementById('commonDiv').style.height = thisCommonDivHt + 'px';
	document.getElementById('footer').style.marginTop = thisFooterTop + 'px';

	document.getElementById('galleryMenu').style.visibility = 'hidden';

	document.getElementById('commonDiv').innerHTML = "<iframe id='catIFrame' src='cat_" + whichOne + ".html' frameborder='no' width='100%' height='100%' scrolling='no'></iframe>";
}

function loadPricing() {
	updateSS("menu");
	clrDiv("commonDiv");
	
	//adding to normal adjustment for this page
	var thisCommonDivHt = commonDivHt+230;
	var thisFooterTop = footerTop+230;	
	
	document.getElementById('galleryMenu').style.visibility = 'hidden';
	document.getElementById('commonDiv').style.height = thisCommonDivHt + 'px';
	document.getElementById('footer').style.marginTop = thisFooterTop + 'px';

	document.getElementById('commonDiv').innerHTML = "<iframe id='commonIFrame' name='commonIFrame' frameborder=0 style='width:100%; height:100%; background-color:#1c1c1c;' src='menu_pricing.html'></iframe>";
}

function loadPaypal() {
	clrDiv("commonDiv");	

	document.getElementById('commonDiv').innerHTML = "<iframe id='commonIFrame' name='commonIFrame' frameborder=0 style='width:100%; height:100%; background-color:#1c1c1c;' src='menu_pricing_pay.html'></iframe>";
}

function loadFAQ() {
	updateSS("menu");
	clrDiv("commonDiv");
	
	document.getElementById('galleryMenu').style.visibility = 'hidden';
	document.getElementById('commonDiv').style.height = commonDivHt + 'px';
	document.getElementById('footer').style.marginTop = footerTop + 'px';

	document.getElementById('commonDiv').innerHTML = "<iframe id='commonIFrame' name='commonIFrame' frameborder=0 style='width:100%; height:100%; background-color:#1c1c1c;' src='menu_faq.html'></iframe>";
}

function loadContact() {
	updateSS("menu");
	clrDiv("commonDiv");
	
	//adding to normal adjustment for this page
	var thisCommonDivHt = commonDivHt-200;
	var thisFooterTop = footerTop-200;	
	
	document.getElementById('galleryMenu').style.visibility = 'hidden';
	document.getElementById('commonDiv').style.height = thisCommonDivHt + 'px';
	document.getElementById('footer').style.marginTop = thisFooterTop + 'px';

	document.getElementById('commonDiv').innerHTML = "<iframe id='commonIFrame' name='commonIFrame' frameborder=0 style='width:100%; height:100%; background-color:#1c1c1c;' src='menu_contact.html'></iframe>";
}

function loadAbout() {
	updateSS("menu");
	clrDiv("commonDiv");
	
	//adding to normal adjustment for this page
	var thisCommonDivHt = commonDivHt-400;
	var thisFooterTop = footerTop-400;	
	
	document.getElementById('galleryMenu').style.visibility = 'hidden';
	document.getElementById('commonDiv').style.height = thisCommonDivHt + 'px';
	document.getElementById('footer').style.marginTop = thisFooterTop + 'px';

	document.getElementById('commonDiv').innerHTML = "<iframe id='commonIFrame' name='commonIFrame' frameborder=0 style='width:100%; height:100%; background-color:#1c1c1c;' src='menu_about.html'></iframe>";
}

function loadLinks() {
	updateSS("menu");
	clrDiv("commonDiv");
	
	//adding to normal adjustment for this page
	var thisCommonDivHt = commonDivHt-200;
	var thisFooterTop = footerTop-200;	
	
	document.getElementById('galleryMenu').style.visibility = 'hidden';
	document.getElementById('commonDiv').style.height = thisCommonDivHt + 'px';
	document.getElementById('footer').style.marginTop = thisFooterTop + 'px';

	document.getElementById('commonDiv').innerHTML = "<iframe id='commonIFrame' name='commonIFrame' frameborder=0 style='width:100%; height:100%; background-color:#1c1c1c;' src='menu_links.html'></iframe>";
}

function updateSS(param) {
	baseDir = "resources/images/page/";
	
	portImg = baseDir + 'page_port.jpg';
	photoImg = baseDir + 'page_photo.jpg';
	illusImg = baseDir + 'page_illus.jpg';
	figureImg = baseDir + 'page_figure.jpg';
	natureImg = baseDir + 'page_nature.jpg';
	stillImg = baseDir + 'page_still.jpg';
	abstractImg = baseDir + 'page_abstract.jpg';
	threeImg = baseDir + 'page_3d.jpg';
	animImg = baseDir + 'page_anim.jpg';
	graphicImg = baseDir + 'page_graphic.jpg';
	ornamImg = baseDir + 'page_ornam.jpg';
	menuImg = baseDir + 'page_menu.jpg';
	
	defaultImg = 'resources/images/slideshow/01_slideshow.jpg';
	innerImg = '';
	
	if (param == "port") {
		innerImg = portImg;
	} else if (param == "photo") {
		innerImg = photoImg;
	} else if (param == "illus") {
		innerImg = illusImg;
	} else if (param == "figure") {
		innerImg = figureImg;
	} else if (param == "nature") {
		innerImg = natureImg;
	} else if (param == "still") {
		innerImg = stillImg;	
	} else if (param == "abstract") {
		innerImg = abstractImg;
	} else if (param == "3d") {
		innerImg = threeImg;
	} else if (param == "anim") {
		innerImg = animImg;
	} else if (param == "graphic") {
		innerImg = graphicImg;
	} else if (param == "ornam") {
		innerImg = ornamImg;
	} else if (param == "menu") {
		innerImg = menuImg;		
	} else {
		innerImg = defaultImg;
	}
	
	clrDiv('divSS');
	document.getElementById('divSS').innerHTML = "<img src=" + innerImg + ">";
}

function clrDiv(divName) {
	var divToClr = document.getElementById(divName);

	if ( divToClr.hasChildNodes() )	{
		while ( divToClr.childNodes.length >= 1 ) {
			divToClr.removeChild( divToClr.firstChild );       
		} 
	}

	divToClr.innerHTML = "";
}

function chkRefresh() {
	/*****
	- need to do this function to ensure page completely resets itself
	- was having issues before with most recently loaded document
	(instead of currenly selected document) loading into commonDiv
	after refreshing page with F5 or with Refresh button
	*****/	

	if( document.getElementById("visited").value == "" ) {
		// This is a fresh page load
		document.getElementById("visited").value = "1";
	} else	{
		window.location = "http://www.gretchenisland.com";
	}
}
