// Vladimir Kagan Couture 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;

//IE Exclusive StyleSheet Additions
	if (isIE) {
		document.write("<link rel='stylesheet' href='vkcStyle_IE.css' type='text/css' />");
		}

// Center Content on Screen
	function positionPresentation(page) {
	var viewWidth = 0, viewHeight = 0, contentWidth = 820, contentHeight = 580, 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 < 800) {
			posX = 0;
		}else{
			posX = Math.floor((viewWidth-contentWidth)/2);
			}
		if (viewHeight < 600) {
			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+550+"px";
		}

//	Scroll Board Functions
	var currentScroll;
	// 	Get Current Position and Ascertain Direction
		function scrollMenu(action, direction) {
			maxScroll = document.getElementById('collectionMenu').scrollHeight;
			currentScroll = document.getElementById('collectionMenu').scrollTop;
			if (direction == "down") {
				if (action == "go") {goDown = setInterval("scrollDown()", 10);}
				else {clearInterval(goDown); storeScrollPosition(currentScroll);}
				}
			if (direction == "up") {
				if (action == "go") {goUp = setInterval("scrollUp()", 10);}
				else {clearInterval(goUp); storeScrollPosition(currentScroll);}
				}
			}
		function scrollDown() {
			currentScroll=currentScroll+2;
			if (currentScroll > maxScroll) {
				currentScroll = maxScroll; clearInterval(goDown);
				}
			scroll();
			}
		function scrollUp() {
			currentScroll=currentScroll-2;
			if (currentScroll < 0) {currentScroll=0; clearInterval(goUp);}
			scroll();
			}
		function scroll() {
			document.getElementById('collectionMenu').scrollTop = currentScroll;
			}

// Menu Model Preview
	function menuPreview(model) {
		document.getElementById("modelPreview").src="images/vladimirKagan_"+model+"_preview.jpg";
		}

//	Launch PDF
	function launchPDF(pdfFile) {
		popUpWin=window.open("PDF/"+pdfFile+".pdf", pdfFile, "width=696px,height=500px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

//	Launch Join Mailing List Window	
	function launchMailReq() {	
		popUpWin=window.open("http://visitor.constantcontact.com/d.jsp?m=1102437386790&p=oi", "mailRequest", "width=580px,height=470px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=0,location=0");
		if (window.focus) {popUpWin.focus();}
		}

//	Launch Catalog Request Dialog
	function launchCatalogReq() {
		popUpWin=window.open("catalogRequest.php", "catalogRequest", "width=660px,height=500px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}
		

// 	Set Default Window.Status Message
	window.defaultStatus="Vladimir Kagan Couture";

// Current Menu Scroll Position Cookie Functions

	// Set Current Scroll Position Cookie Data
	function storeScrollPosition(currentScroll) {
		document.cookie = "lastScroll="+currentScroll;
		}

	// Retrieve Current Scroll Position Cookie Data
		function retrievePriorScrollPosition() {
		var allcookies = document.cookie;
		var pos=allcookies.indexOf("lastScroll=");
		if (pos != -1) {
			var start = pos + 11;
			var end = allcookies.indexOf(";", start);
			if (end == -1) end = allcookies.length;
			var value = allcookies.substring(start, end);
			currentScroll = Number(value);
			scroll();
 			}
		}