// 	Avery Boardman General API(JavaScript)
// 	Author : EJFIIIWebDesign.com

//	Browser Brand Determination
	var isIE=false; var isNN=false; var isOP=false; isFF=false; 
	if (navigator.userAgent.indexOf("Opera")!=-1) isOP=true;
	if ((navigator.appName.indexOf("Microsoft")!=-1) && (navigator.userAgent.indexOf("Opera")==-1)) isIE=true;
	if (navigator.userAgent.indexOf("Firefox")!=-1) isFF=true;
	if ((navigator.appName.indexOf("Netscape")!=-1) && (navigator.userAgent.indexOf("Firefox")==-1)) isNN=true;

//	Reposition Content for Window Containers set Smaller than Content
// 	Necessary to prevent non-scrollable off screen content with negative margin style sheet centering method
	function checkVerticalPosition(page) {
	var viewWidth = 0, viewHeight = 0, contentWidth = 970, contentHeight = 600, posX = 0,  posY = 0;
	// 	Determine Available Window Size
  		if (isIE) {viewWidth = document.documentElement.clientWidth; viewHeight = document.documentElement.clientHeight;}
		else{viewWidth = window.innerWidth; viewHeight = window.innerHeight;} 
	// 	Set Content Window Coordinates
		if (viewWidth < 980) {document.getElementById('verticalPosition').style.left = 0+"px"; posX = 0;}
			else {posX = Math.floor((viewWidth-contentWidth)/2);}
		if (viewHeight < 600) {document.getElementById('verticalPosition').style.top = 310+"px"; posY = 0;}
			else {posY = Math.floor((viewHeight-contentHeight)/2);}
	// 	Apply New Window Coordinates
//		document.getElementById('content').style.left = posX+"px";
//		document.getElementById('content').style.top = posY+"px";
//		if (page != "home") document.getElementById('authorLink').style.top = posY+510+"px";
		}

//	Menu Hover Indications
	function hoverOn(position) {
		document.images[position].style.borderColor='#FFFFFF';
		}
	function hoverOff(position) {
		document.images[position].style.borderColor='#74CEDE';
		}

//	Launch PDF Pages in pop-up Window
	function launchPDF(pdfFile) {
		popUpWin=window.open("PDF/"+pdfFile+".pdf", pdfFile, "width=660px,height=510px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

//	Launch Catalog Request Dialog pop-up Window
	function launchCatalogRequest() {
		popUpWin=window.open("catalogRequest.html", "catalogRequest", "width=614px,height=510px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

//	Launch Showroom Links
	function launchLinks(urlAddress) {
		popUpWin=window.open(urlAddress, "linksWin", "width=880px,height=610px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=0,location=0");
		if (window.focus) {popUpWin.focus();}
		}

// 	Launch pop-up Window
	function launchStaticWin(fileName) {	
		popUpWin=window.open(fileName, "staticWin", "width=614px,height=560px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

//	Close any Pop Up Windows which loose focus
		function checkPopUps() {
		if (window.popUpWin) {window.popUpWin.close();}
		}

// Pop Up Window Feature with Dynamically created content
	// Pound Signs (#) in text are globally (g) converted to spaces (&nbsp;)
	function launchDynamicWin(image,text) {
		popUpWin=window.open("",image, "width=260px,height=230px,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,location=0");
		if (window.focus) {popUpWin.focus();}
		popUpCode="<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'\n'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n\n<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n<head>\n\n<meta http-equiv='content-type' content='text/html; charset=iso-8859-1' />\n<meta http-equiv='content-lauguage' content='en' />\n<meta http-equiv='imagetoolbar' content='no' />\n<meta name='author' content='EJFIII Web Design - JavaScript Created xHTML' />\n<meta name='copyright' content='2009 Avery Boardman' />\n\n<title>Avery Boardman - "+popUpTitle.replace(/#/g,'&nbsp;')+": "+text.replace(/#/g,'&nbsp;')+"</title>\n\n";
		popUpCode+="<style type='text/css'>\n\tbody\t{background-color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif;}\n\timg\t\t{border: 0px;}\n\t.title\t{text-align: center; font-size: 12px; font-weight: bold; color: #74CEDE;}\n</style>\n</head>\n\n";
		popUpCode+="<body>\n";
		popUpCode+="<table width='240px' cellspacing='0px' cellpadding='0px'>\n\t<tr>";
		popUpCode+="\n\t\t<td style='text-align: right;'><a href='javascript: window.close();' ><img id='button' src='images/webButtons/closeButton_off.jpg' width='100px' height='18px' alt='Close Window' onmouseover=document.getElementById('button').src='images/webButtons/closeButton_on.jpg' onmouseout=document.getElementById('button').src='images/webButtons/closeButton_off.jpg' /></a></td>\n\t</tr><tr>";
		popUpCode+="\n\t\t<td style='text-align: center;'><br /><img src='images/"+popUpPath+image+"_k.jpg' alt='"+popUpTitle.replace(/#/g,'&nbsp;')+": "+text.replace(/#/g,'&nbsp;')+"' /></td>\n\t";
		popUpCode+="</tr><tr>\n\t\t";
		popUpCode+="<td class='title'>"+popUpTitle.replace(/#/g,'&nbsp;')+":&nbsp;"+text.replace(/#/g,'&nbsp;')+"</td>\n\t";
		popUpCode+="</tr>\n</table>\n\n</body></html>\n";
		popUpWin.document.write(popUpCode);
		popUpWin.document.close();
		}

//	Flip Preview Image on Gallery Page
	function flipPreview(image) {
		document.getElementById('galleryPreview').src = "images/gallery/project"+image+"_p.jpg";
		if (image > 10) {
			project = "p"+image;
			document.getElementById(project).src = "images/gallery/project"+image+"_t.jpg";
			}
		}

//	Restore Gallery Faded Thumbnail Image
	function restoreThumb(image) {
			project = "p"+image;
			document.getElementById(project).src = "images/gallery/project"+image+"_to.jpg";
			}

//	Flip Key Image on Gallery Page
	function flipKey(image) {
		document.getElementById('galleryKey').src = "images/gallery/project"+image+"_k.jpg";
		hideAllGalleryDesc();
		desc = "galleryDesc"+image;
		document.getElementById(desc).style.visibility = "visible";
		}

//	Hide all Gallery Descriptions
		function hideAllGalleryDesc() {
		for (i=11; i < projectQty+1; i++) {
			desc = "galleryDesc"+i;
			document.getElementById(desc).style.visibility = "hidden";
			}
		}

//	Manage Button Highlighting
		function buttonHighlight(button, state) {
			button="button"+button;
			if (button.charAt(6) == "P") {
				document.getElementById(button).src="http://www.averyboardman.com/images/webButtons/printButton_"+state+".jpg";
			}else{
				document.getElementById(button).src="http://www.averyboardman.com/images/webButtons/closeButton_"+state+".jpg";
				}
			}			
			

// Set Default Window.Status Message
	window.defaultStatus="Avery Boardman - The Highest Expression of Custom Upholstery";
