// 	JanosSpitzerFlooring.com 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;

//	Load in Internet Specific Styles
	if (isIE) {
		document.write("<link rel='stylesheet' href='Style_IE.css' type='text/css' />");
		}

//	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() {
	var viewHeight = 0, contentHeight = 640; thresholdHeight = 660;

	// 	Determine Available Window Size
  		if (isIE) {viewHeight = document.documentElement.clientHeight;}
		else{viewHeight = window.innerHeight;} 

	// 	Set Content Window Coordinates
		if (viewHeight < thresholdHeight) {
			document.getElementById('verticalPosition').style.top = ((contentHeight/2)+10)+"px";
			}

	//	Set Author Link Coordinates
		placement = (viewHeight < thresholdHeight) ? (contentHeight) : (contentHeight - 10 + ((viewHeight-thresholdHeight)/2));
		document.getElementById('authorLink').style.top = placement + "px";
		}


//	Home Page Slide Show
//	A PHP script has created a random set of 5 images

	//	Variables indicating image display status
		var currentDisplayedImage = 0;

	//	Slide Show Choreography

		//	Initializing Display
			function autoDisplay() {
				if (imageOptions>1) {
					executeShow=setInterval("flipSlide();", 4000);
					}
				}

		//  Execute Slide Display
			function flipSlide() {
				if (imageOptions > 1) {
					currentDisplayedImage++;
					if (currentDisplayedImage > (imageOptions - 1)) currentDisplayedImage = 0;
					setTimeout("fadeOut(600);", 0);
					showImage = imageOption[currentDisplayedImage];
					setTimeout("document.getElementById('triptychTeaser').src = showImage.src;", 600);
					setTimeout("fadeIn(800);", 600);		
					}
				}

		// 	Variably adjust Opacity Settings for an Element
			function fadeOut(millisec) {
				var speed = Math.round(millisec / 100);	var timer = 0;
				for (i = 100; i >= 0; i--) {
						setTimeout("changeOpac("+i+")", (timer * speed));
						timer++;
						}
					}

			function fadeIn(millisec) {
				var speed = Math.round(millisec / 100); var timer = 0;
				for (i = 0; i <= 100; i++) {
					setTimeout("changeOpac("+i+")", (timer * speed));
						timer++;
						}
					}

		// 	Apply Transparency Setting to an Object
			function changeOpac(opacity) {
				var object = document.getElementById('triptychTeaser').style;
				object.opacity = (opacity / 100);
				object.MozOpacity = (opacity / 100);
				object.KhtmlOpacity = (opacity / 100);
				object.filter = "alpha(opacity=" + opacity +")";
				}

//	Change Parquet Banner Image onClick
	function parquetBanner(imgRef) {
		document.getElementById('bannerImage').src = "images/triptych_"+imgRef+".jpg";
		}

// 	Pop Up Window Feature with Dynamically created content
	// Zeros (_) in text are globally (/g) converted to spaces (' ')
	// Assumes jpeg file type, if other include suffix in image variable value
	function createpopUpWin(imgRef,text) {
		if (imgRef.indexOf(".") < 1) imgType=".jpg";
		else {fileParts=imgRef.split("."); imgRef=fileParts[0]; imgType="."+fileParts[1];} 
		popUpWin=window.open("",text, "width=430px,height=580px,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,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='2011 Janos Spitzer Flooring' />\n\n<title>Janos Spitzer Flooring - "+text.replace(/_/g,' ')+"</title>\n\n";
		popUpCode+="<link rel='stylesheet' href='Style.css' type='text/css' />\n</head>\n\n";
		popUpCode+="<body>\n<div class='button'><a href='javascript: this.window.close();'>CLOSE THIS WINDOW</a></div>\n\n";
		popUpCode+="<div id='popUpContent'>\n<img src='images/"+imgRef+"_popUp"+imgType+"' alt='Image of "+text.replace(/_/g,' ')+".' />\n<br />";
		popUpCode+="<br />"+text.replace(/_/g,' ')+"\n</div><!-- End popUpContent -->\n";
		popUpCode+="</body></html>";
		popUpWin.document.write(popUpCode);
		popUpWin.document.close();
		}

//	Rating Sites Pop Up Window
	function launchSite(site) {
		if (site == "BBB") popUpSite=window.open("http://www.bbb.org/new-york-city/business-reviews/floor-materials-retail/janos-p-spitzer-flooring-company-inc-in-new-york-ny-53408/", "", "width=810px,height=580px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (site == "Franklin") popUpSite=window.open("http://www.franklinreport.com/RatingsCard.aspx?Id=3006", "", "width=830px,height=580px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (site == "NWFA") popUpSite=window.open("http://www.woodfloors.org/", "", "width=1010px,height=580px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (site == "CC") 	popUpSite=window.open("http://visitor.r20.constantcontact.com/d.jsp?llr=zq998mfab&p=oi&m=1105312180761", "", "width=700px,height=450px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=0,location=0");
		if (window.focus) {popUpSite.focus();}
		}

//	Launch A+D Invitation
	function launchInvite() {
		popUpWindow=window.open("A+D_Invite.html", "", "width=700px,height=450px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWindow.focus();}
		}

//	Launch Seminar Information
	function launchSeminar() {
		popUpWindow=window.open("seminar_popUp.php", "", "width=700px,height=450px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWindow.focus();}
		}

//	Google Map Pop Up Window
	function displayMap() {
		popUpMap=window.open("map.html", "", "width=430px,height=580px,toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,location=0");
		if (window.focus) {popUpMap.focus();}
		}
