// 	Vladimir Kagan 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 = 760, contentHeight = 500, 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 < 760) {document.getElementById('verticalPosition').style.left = 0+"px"; posX = 0;}
			else {posX = Math.floor((viewWidth-contentWidth)/2);}
		if (viewHeight < 500) {document.getElementById('verticalPosition').style.top = 250+"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";
		}

// 	Home Page Fade Routine
	function homeFade() {
		window.setTimeout("imageFade()",500);
		window.setTimeout("logoFade()", 2600);
		window.setTimeout("textFade()", 3300);
		window.setTimeout("hide_siteMenuMask()", 4800);
		}
	// 	Fade in Portrait Image
	function imageFade() {
		opacity('portrait', 0, 99, 2600);
		}
	// 	Fade in Portrait Image with Logo
	function logoFade() {
		opacity('portraitLogo', 0, 99, 2200);
		}
	// 	Fade in Links
	function textFade() {
		opacity('siteMenu_mask', 99, 0, 1500);
		opacity('contact', 0, 50, 1500);
		}

	function hide_siteMenuMask() {
		document.getElementById('siteMenu').style.zIndex = 100;
		}

//	Colorize Group Rollover Image
	function colorizeGroup(location, image) {
		groupObj = "groupItem" + location;
		document.getElementById(groupObj).src = imagePath+image+"_g_on.jpg";
		}
	function decolorizeGroup(location, image) {
		groupObj = "groupItem" + location;
		document.getElementById(groupObj).src = imagePath+image+"_g_off.jpg";
		}

//	Colorize Thumbnail Rollover Image
	function colorizeThumb(location) {
		thumbObj = "thumbnail" + location;
		document.getElementById(thumbObj).src = imagePath+"0"+location+"_t_on.jpg";
		}
	function decolorizeThumb(location) {
		thumbObj = "thumbnail" + location;
		document.getElementById(thumbObj).src = imagePath+"0"+location+"_t_off.jpg";
		}

//	Reveal Product Rollover Descriptions
	function changeDescription(item) {
		hideAll();
		if (item == "00") {document.getElementById('pageText').style.visibility = "visible";}
		else{document.getElementById('pageText').style.visibility = "hidden";
			descPanel = "description"+item;
			document.getElementById(descPanel).style.visibility = "visible";}
		}

//	Hide all Product Rollover Descriptions
	function hideAll() {
		for (i=1; i < 21; i++) {
			descPanel = "description"+i;
			document.getElementById(descPanel).style.visibility = "hidden";
			}
		}

//	Scroll Board Functions
	var currentScroll = 0;
	// 	Get Current Position and Ascertain Direction
		function scrollBoard(action, direction) {
			maxScroll = document.getElementById(boardObj).scrollHeight;
			currentScroll = document.getElementById(boardObj).scrollTop;
			if (direction == "down") {
				if (action == "go") {goDown = setInterval("scrollDown()", 20); document.getElementById('downArrow').src="images/downArrow_on.jpg";}
				else {clearInterval(goDown); document.getElementById('downArrow').src="images/downArrow_off.jpg";}
				}
			if (direction == "up") {
				if (action == "go") {goUp = setInterval("scrollUp()", 20); document.getElementById('upArrow').src="images/upArrow_on.jpg";}
				else {clearInterval(goUp); document.getElementById('upArrow').src="images/upArrow_off.jpg";}
				}
			}
		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(boardObj).scrollTop = currentScroll;
			}

//	Launch PDF Tear Sheets in pop-up Window
	function launchPDF(pdfFile) {
		popUpWin=window.open("PDF/"+pdfFile+".php5?itemName="+pdfFile, pdfFile, "width=660px,height=510px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

	function launchPDFSample() {
		popUpWin=window.open("PDF/2010_Kagan_Catalog.pdf", "catalogSample", "width=660px,height=510px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

// 	Launch Linked WebSites in pop-up Window
	function launchLink(urlAddress) {	
		popUpWin=window.open(urlAddress, "linkedSite", "width=930px,height=560px,toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,location=0");
		if (window.focus) {popUpWin.focus();}
		}

//	Change Product Key Image Display
	function keyImageSwap(key) {
		changeOpac(0, 'keyImage01');
		changeOpac(0, 'keyImage02');
		changeOpac(0, 'keyImage03');
		changeOpac(0, 'keyImage04');
		changeOpac(0, 'keyImage05');
		opacity(key, 0, 100, 300);
		}		

//	Opacity Transitions of Page Elements
	function transition(obj, state) {
		if (state == "on") {
			if (obj == "classicsMenu" && isIE ) document.getElementById('classicsMenu').style.height = "90px";
			if (obj == "contactMenu" && isIE ) document.getElementById('contactMenu').style.height = "90px";
			opacity(obj, 45, 99, 500);
			}
		if (state == "off") {
			if (obj == "classicsMenu" && isIE ) document.getElementById('classicsMenu').style.height = "15px"; // IE7 alpha:filter + overflow Work-around
			if (obj == "contactMenu" && isIE ) document.getElementById('contactMenu').style.height = "15px";
			opacity(obj, 99, 45, 500);
			}
		}

// 	Variably adjust Opacity Settings for an Element
	function opacity(obj, opacStart, opacEnd, millisec) {
		var speed = Math.round(millisec / 100);	var timer = 0;
		if (opacStart > opacEnd) {
			for (i = opacStart; i >= opacEnd; i--) {
				setTimeout("changeOpac("+i+",'"+obj+"')", (timer * speed));
				timer++;
				}
		} else { if (opacStart < opacEnd) {
			for (i = opacStart; i <= opacEnd; i++) {
				setTimeout("changeOpac("+i+",'"+obj+"')", (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 +")";
		}

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