// Sun Decor Fabrics JavaScript
// Author : 2007/EJFIII Web Design

// Browser Brand Determination
	var isOP=false; var isIE=false; var isFF=false; var isNN=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;

// Determine Available Screen Resolution
	function availWindow() {
		if (isIE) {
			viewWidth = document.documentElement.clientWidth;
  		}else{
   			viewWidth = window.innerWidth;
  			}
		return viewWidth;
		}

// Center Content on Screen
	function positionPresentation() {
		availWindow();
		posX = Math.floor((viewWidth-755)/2);
		document.getElementById("screenPresentation").style.left = posX+"px";
		}

// Teaser Slide Show
	function teaserShow() {
		window.setTimeout("showSlide(2,1)", 4000);
		window.setTimeout("showSlide(3,2)", 8000);
		window.setTimeout("showSlide(4,3)", 12000);
		window.setTimeout("showSlide(5,4)", 16000);
		window.setTimeout("showSlide(6,5)", 20000);
		window.setTimeout("showSlide(1,6)", 24000);
		window.setTimeout("teaserShow()", 24000);
		}

	function showSlide(showSlide, hideSlide) {
		hideTeaserSlide = "teaserSlide"+hideSlide;
		opacity(0, hideTeaserSlide);
		document.getElementById(hideTeaserSlide).style.zIndex = 98;
		showTeaserSlide = "teaserSlide"+showSlide;
		document.getElementById(showTeaserSlide).style.zIndex = 99;
		opacity(100, showTeaserSlide);
		}

// 	Variably adjust Opacity Settings for an Element
	function opacity(opacity, slide) {
		var speed = 10;	var timer = 0;
		if (opacity == 100) {
			for (i = 0; i <= 100; i++) {
				setTimeout("changeOpac("+i+",'"+slide+"')", (timer * speed));
				timer++;
				}
			}
		else {
			for (i = 100; i >= 0; i--) {
				setTimeout("changeOpac("+i+",'"+slide+"')", (timer * speed));
				timer++;
				}
			}
		}

// 	Apply Transparency Setting to an Object
	function changeOpac(opacity, obj) {
		var object = document.getElementById(obj).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity +")";
		}

// Pop Up Window Feature with Dynamically created content
	// Zeros (0) in text are globally (/g) converted to spaces (&nbsp;)
	// Assumes jpeg file type, if other include suffix in image variable value
	function createpopUpWin(image,text) {
		if (image.indexOf(".") < 1) imgType=".jpg";
		else {fileParts=image.split("."); image=fileParts[0]; imgType="."+fileParts[1];} 
		popUpWin=window.open("",text, "width=518px,height=400px,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='2008 Sun Decor Fabrics' />\n\n<title>Sun Decor Fabrics - "+text.replace(/0/g,'&nbsp;')+" "+category.replace(/0/g,'&nbsp;')+"</title>\n\n";
		popUpCode+="<link rel='stylesheet' href='sdfPopUpStyle.css' type='text/css' />\n</head>\n\n";
		popUpCode+="<body>\n<div id='popUpShell'>\n<a href='javascript: this.window.close();'><img id='sdfSideMast' src='images/sdfMastGN_popUp2.jpg' width='98px' height='380px' alt='Close this Window' /></a>\n\n";
		popUpCode+="<div id='popUpContent'>\n<img src='images/"+popUpPath+image+"_pop"+imgType+"' alt='Image of "+text.replace(/0/g,'&nbsp;')+" "+category.replace(/0/g,'&nbsp;')+".' />\n<br />";
		popUpCode+="<br /><b>"+category.replace(/0/g,'&nbsp;')+" Style : "+text.replace(/0/g,'&nbsp;')+"</b><br />\n</div><!-- End popUpContent -->\n";
		popUpCode+="\n<address><br /><br />Sun Decor Fabrics &nbsp;&nbsp;&nbsp; 200 Lexington Avenue  Suite 417a &nbsp;&nbsp;&nbsp; New York  New York  10016<br />";
		popUpCode+="Tel 212 213 2703 &nbsp;&nbsp;&nbsp; Fax 212 213 2708 &nbsp;&nbsp;&nbsp; WebSite: www.sundecorfabrics.com</address>\n</div><!-- End popUpShell -->\n</body></html>";
		popUpWin.document.write(popUpCode);
		popUpWin.document.close();
		}

// 	Launch Linked WebSites in pop-up Window
	function launchLink(urlAddress) {	
		popUpWin=window.open(urlAddress, "linkedSite", "width=920px,height=560px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

// Pop Up Hardware Finish Codes
	function finishCodes(event,action) {
  		availWindow();
		if (action == "1") {
			document.getElementById("finishCodes").style.left = Math.floor(event.clientX - (viewWidth * 0.1)) + "px";
			document.getElementById("finishCodes").style.top = event.clientY + document.documentElement.scrollTop + "px";
			document.getElementById("finishCodes").style.visibility = "visible";
		}else if (action == "2") {
			document.getElementById("finishCodes").style.left = Math.floor(event.clientX - (viewWidth * 0.45)) + "px";
			document.getElementById("finishCodes").style.top = event.clientY + document.documentElement.scrollTop + "px";
			document.getElementById("finishCodes").style.visibility = "visible";
		}else{
			document.getElementById("finishCodes").style.visibility = "hidden";
			}
		}

// Set Default Window Status Message
	window.status=("Sun Decor Fabrics - Window Treatments and Fabrics");