var winW, numBottomTimerId, numPhotoHeight, numHideId, blnHidden, numTopTimerId;
blnHidden = true;

function setUpThumbs() {
	var i;
	for (i = 0; i < numTotalThumbs; i++) {
		document.getElementById("thumb" + i.toString()).style.background = "url(images/" + arrThumbs[i] + ")";
		document.getElementById("thumb" + i.toString()).style.backgroundPosition = "left bottom";
	} //for
} //setUpThumbs

function swapImages(numThumb) {
	clearTimeout(numTimerId);
	var i;
	numCurrentThumb = numThumb;
	for (i = 0; i < numTotalThumbs; i++) {
		document.getElementById("thumb" + i.toString()).style.backgroundPosition = "left bottom";
	} //for
	document.getElementById("thumb" + numThumb.toString()).style.backgroundPosition = "right top";
	document.getElementById("imageSrc").src = "images/" + arrImages[numThumb];
	document.getElementById("linkHref").href = arrLinks[numThumb];
	numTimerId = setTimeout("renderTimeRotation()", numTimerValue);
} //swapImages

function adjustPosition(blnRollOver, numThumb) {
	if (numCurrentThumb != numThumb) {
		if (blnRollOver) {
			document.getElementById("thumb" + numThumb.toString()).style.backgroundPosition = "right top";
		} else {
			document.getElementById("thumb" + numThumb.toString()).style.backgroundPosition = "left bottom";
		} //if
	} //if
} //adjustPosition

function renderTimeRotation() {
	if (numCurrentThumb + 1 < numTotalThumbs) {
		swapImages(numCurrentThumb + 1);
	} else {
		swapImages(0);
	} //if
} //renderTimeRotation

function highlightCell(strId, blnRollOver) {
	if (blnRollOver) {
		document.getElementById("cell" + strId).className = "colorCellOver";
	} else {
		document.getElementById("cell" + strId).className = "colorCell";
	} //if
} //highlightCell

function rollOverOut(strId, strNewImage, strNewWidth, strNewHeight, strTop) {
	document.getElementById(strId).src = strNewImage;
	document.getElementById(strId).width = strNewWidth;
	document.getElementById(strId).height = strNewHeight;
	if (strTop != "") {
		document.getElementById(strId).style.top = strTop;
	} //if
} //rollOverOut

function setUpMove(blnForward) {
	document.getElementById("leftArrow").style.visibility = "hidden";
	document.getElementById("rightArrow").style.visibility = "hidden";
	if (blnForward) {
		moveBeltForward();
	} else {
		moveBeltBackward();
	} //if
} //setUpMove

function moveBeltForward() {
	var numNewPosition = numCurrentPosition - numMoveIncrement;
	document.getElementById("photoContainer").style.left = numNewPosition.toString() + "px";
//	document.getElementById("colorContainer").style.left = numNewPosition.toString() + "px";
	numMoved = numMoved + numMoveIncrement;
	numCurrentPosition = numNewPosition;
	if (numMoved < 130) {
		numTimerId = setTimeout("moveBeltForward()", numTimerValue);
	} else {
		numCurrentSlot = numCurrentSlot + 1;
		document.getElementById("photoContainer").style.left = (-131 * numCurrentSlot).toString() + "px";
		document.getElementById("leftArrow").style.visibility = "visible";
		if (numCurrentSlot < numTotalSlots) {
			document.getElementById("rightArrow").style.visibility = "visible";
		} //if
		numMoved = 0;
	} //if
} //moveBeltForward

function moveBeltBackward() {
	var numNewPosition = numCurrentPosition + numMoveIncrement;
	document.getElementById("photoContainer").style.left = numNewPosition.toString() + "px";
//	document.getElementById("colorContainer").style.left = numNewPosition.toString() + "px";
	numMoved = numMoved + numMoveIncrement;
	numCurrentPosition = numNewPosition;
	if (numMoved < 130) {
		numTimerId = setTimeout("moveBeltBackward()", numTimerValue);
	} else {
		numCurrentSlot = numCurrentSlot - 1;
		document.getElementById("photoContainer").style.left = (-131 * numCurrentSlot).toString() + "px";
		document.getElementById("rightArrow").style.visibility = "visible";
		if (numCurrentSlot > 0) {
			document.getElementById("leftArrow").style.visibility = "visible";
		} //if
		numMoved = 0;
	} //if
} //moveBeltBackward

function adjustBottomBack() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  } //if
  if (myHeight - numMinHeight > 0) {
	  document.getElementById("bottomBack").style.height = (myHeight - numMinHeight).toString() + "px";
  } //if
//  window.alert( 'Width = ' + myWidth );
//  window.alert( 'Height = ' + myHeight );
} //adjustBottomBack

function loadXML(strXMLPath) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp = new XMLHttpRequest();
  	} else {// code for IE6, IE5
  		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  	} //if
	xmlhttp.open("GET", strXMLPath, false);
	xmlhttp.send();
	xmlDoc = xmlhttp.responseXML;
	alert(xmlDoc);
	alert(xmlDoc.getElementsByTagName("to")[0].nodeValue);

/*document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;

xmlDoc.documentElement.childNodes[0].attributes[0].nodeValue);
alert(updateItem.getAttribute("id"));
alert(updateItem.childNodes[0].nodeValue);

	*/
} //loadXML

function loadHttpDoc(strURL) {
	httpDoc = null;
	if (window.XMLHttpRequest) {
  		httpDoc = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
  		httpDoc = new ActiveXObject("Microsoft.XMLHTTP");
	} //if
	
	if (httpDoc != null) {
  		httpDoc.onreadystatechange = statusChange;
  		httpDoc.open("GET", strURL, true);
  		httpDoc.send(null);
  	} else {
  		alert("Your browser does not support HTTP request objects.");
  	} //if
} //loadHttpDoc

function statusChange() {
	var strFileText, strUpdateText, beginArea, endArea;
// if xmlhttp shows "loaded"
	if (httpDoc.readyState == 4) {
  // if "OK"
 		if ((httpDoc.status == 200) || (httpDoc.statusText == "OK")){
//  		alert("i'm here!");
//			strFileText = httpDoc.responseText;
			xmlDoc = httpDoc.responseXML;
			switch (numCurrentXMLDoc) {
				case 0:
					updateList = xmlDoc.getElementsByTagName("update");
					numUpdatesTotal = updateList.length;
					renderUpdate(0);
					break;
				case 1:
					quoteList = xmlDoc.getElementsByTagName("quote");
					numQuotesTotal = quoteList.length;
					if (blnAutoRotate) {
						setTimeout("doFadeOut()", 4000);
					} else {
						renderQuotes();
					} //if
					break;
				case 2:
					categoryList = xmlDoc.getElementsByTagName("category");
					numCategoriesTotal = categoryList.length;
					if (strPageType == "Portrait") {
						setUpPortraitMenu();
					} else if (strPageType == "Signature") {
						setUpSignatureMenu();
					} else if (strPageType == "Living") {
						setUpLivingMenu();
					} else if (strPageType == "Extreme") {
						setUpExtremeMenu();
					} else {
						randomList = xmlDoc.getElementsByTagName("random");
						numTotalSlots = numCategoriesTotal - numCatsShowing;
						setupBeltImages();
					} //if
					break;			
			} //switch
			numCurrentXMLDoc = numCurrentXMLDoc + 1;
			if (numCurrentXMLDoc < numTotalXMLDocs) {
				loadHttpDoc(arrXMLURLs[numCurrentXMLDoc]);
			} //if
//			alert(numUpdatesTotal);
//			document.getElementById("updateNumbers").innerHTML = "1 of " + numUpdatesTotal.toString();
//			alert(strFileText);
//			alert(updateList.length);
//			document.getElementById("update").innerHTML = strUpdateText;
  		} else {
  			alert("There was a problem retrieving the update file: " + httpDoc.statusText);
 		} //if
 	} //if
} //statusChange

function switchUpdates(blnForward) {
	var numNewUpdate;
	if (blnForward) {
		numNewUpdate = numCurrentUpdate + 1;
		if (numNewUpdate == numUpdatesTotal) {
			numNewUpdate = 0;
		} //if
	} else {
		numNewUpdate = numCurrentUpdate - 1;
		if (numNewUpdate < 0) {
			numNewUpdate = numUpdatesTotal - 1;
		} //if
	} //if
	renderUpdate(numNewUpdate);
} //switchUpdate

function renderUpdate(numNewUpdate) {
	var updateItem, strMainText, i;
	updateItem = updateList.item(numNewUpdate);
	for (i = 0; i < updateItem.childNodes.length; i++) {
//		alert(updateItem.childNodes[i].nodeName);
		switch (updateItem.childNodes[i].nodeName) {
			case "date":
				strMainText = "<p id=\"updateDate\" class=\"updateDate\">Updated " + updateItem.childNodes[i].childNodes[0].nodeValue + "</p><p id=\"storyHead\" class=\"storyHead\">";
				break;
			case "head":
				strMainText += updateItem.childNodes[i].childNodes[0].nodeValue + "</p>";
				break;
			case "text":
				strMainText += updateItem.childNodes[i].childNodes[0].nodeValue + "<div id=\"signature\"><img src=\"images/signature.png\" width=\"123\" height=\"63\" hspace=\"5\" align=\"right\" /></div>";
				break;
			case "image":
				document.getElementById("contentPhoto1").src = updateItem.childNodes[i].childNodes[0].nodeValue;
				break;
			case "caption":
				document.getElementById("contentPhotoCaption1").innerHTML = updateItem.childNodes[i].childNodes[0].nodeValue;
				break;
		} //switch
	} //for
	
/*	document.getElementById("contentPhoto1").src = updateItem.childNodes[3].childNodes[0].nodeValue;
	document.getElementById("contentPhotoCaption1").innerHTML = updateItem.childNodes[4].childNodes[0].nodeValue;
	strMainText = "<p id=\"updateDate\" class=\"updateDate\">Updated " + updateItem.childNodes[0].childNodes[0].nodeValue + "</p><p id=\"storyHead\" class=\"storyHead\">" + updateItem.childNodes[1].childNodes[0].nodeValue + "</p>" + updateItem.childNodes[2].childNodes[0].nodeValue + "<div id=\"signature\"><img src=\"images/signature.png\" width=\"123\" height=\"63\" hspace=\"5\" align=\"right\" /></div>";
	*/
	document.getElementById("mainText").innerHTML = strMainText;
	numCurrentUpdate = numNewUpdate;
	document.getElementById("updateNumbers").innerHTML = (numCurrentUpdate + 1).toString() + " of " + numUpdatesTotal.toString();
} //renderUpdate











function switchPhotos(blnForward) {
	var numNewPhoto;
	document.getElementById("loaderBox").style.display = "block";
	if (blnForward) {
		numNewPhoto = numCurrentPhoto + 1;
		if (numNewPhoto == numPhotosTotal) {
			numNewPhoto = 0;
		} //if
	} else {
		numNewPhoto = numCurrentPhoto - 1;
		if (numNewPhoto < 0) {
			numNewPhoto = numPhotosTotal - 1;
		} //if
	} //if
	renderPhoto(numNewPhoto);
} //switchPhotos

function renderPhoto(numNewPhoto) {
	var photoList, photoItem, i;
	photoList = categoryList.item(numCurrentLink).getElementsByTagName("image");
	numPhotosTotal = photoList.length;
	photoItem = photoList.item(numNewPhoto);
	
	document.getElementById("largeImage").src = photoItem.childNodes[0].nodeValue;
//	document.getElementById("largeImage").height = photoItem.getAttribute("height");

	numCurrentPhoto = numNewPhoto;
	document.getElementById("imageRotator").style.height = (parseInt(photoItem.getAttribute("height")) + 20).toString() + "px";
	numPhotoHeight = parseInt(photoItem.getAttribute("height"));
	document.getElementById("photoNumbers").innerHTML = (numCurrentPhoto + 1).toString() + " of " + numPhotosTotal.toString();
} //renderPhoto












function renderQuotes() {
	var quoteItem, i, numNewQuote;
	if (blnAutoRotate) {
		numNewQuote = numCurrentQuote + 1;
	} else {
		numNewQuote = Math.floor(Math.random() * quoteList.length);
	} //if
//	document.getElementById("quoteContainer").style.filter = "alpha(opacity=10)";
//	document.getElementById("quoteContainer").style = "opacity: .1;";
	if (numNewQuote == numQuotesTotal) {
		numNewQuote = 0;
	} //if
	quoteItem = quoteList.item(numNewQuote);
	for (i = 0; i < quoteItem.childNodes.length; i++) {
//		alert(updateItem.childNodes[i].nodeName);
		switch (quoteItem.childNodes[i].nodeName) {
			case "text":
				document.getElementById("quoteText").innerHTML = quoteItem.childNodes[i].childNodes[0].nodeValue;
				break;
			case "name":
				document.getElementById("quoteName").innerHTML = quoteItem.childNodes[i].childNodes[0].nodeValue;
				break;
		} //switch
	} //for
	if (blnAutoRotate) {
		numCurrentQuote = numNewQuote;
		numCurrentFadePart = 0;
		doFadeIn();
	} //if
} //renderQuotes

function doFadeOut() {
    var numFadeIE = 100 - ((numCurrentFadePart / numFadeParts) * 100);
	var numFadeFF = Math.round((1 - (numCurrentFadePart / numFadeParts)) * 10);
//	alert(numFadeFF);
	if (numCurrentFadePart <= numFadeParts) {
/*		head = document.getElementsByTagName("head")[0];
    	if (!head) { return; }
    	style = document.createElement("style");
		style.id = "tempStyle";
    	style.type = "text/css";
		var css = "#" + strFadeId + " { opacity: ." + numFad eFF.toString() + "; }";
		alert(css);
		if (css.indexOf(".10") != -1) {
			css = "#" + strFadeId + " { opacity: 1; }";
		} //if
		alert(css);
		if (document.getElementById("tempStyle")) {
			head.removeChild(document.getElementById("tempStyle"));
		} //if
    	head.appendChild(style);
    	style.innerHTML = css;
		*/
		if (numFadeFF == 10) {
			document.getElementById(strFadeId).style.opacity = "1";
		} else {
			document.getElementById(strFadeId).style.opacity = "." + numFadeFF.toString();
		} //if
		document.getElementById(strFadeId).style.filter = "alpha(opacity=" + numFadeIE.toString() + ")";
		numCurrentFadePart = numCurrentFadePart + 1;
		setTimeout("doFadeOut()", 100);
	} else {
		renderQuotes();
	} //if
} //doFadeOut

function doFadeIn() {
    var numFadeIE = 0 + ((numCurrentFadePart / numFadeParts) * 100);
	var numFadeFF = Math.round((0 + (numCurrentFadePart / numFadeParts)) * 10);
//	alert(numFadeFF);
	if (numCurrentFadePart <= numFadeParts) {
		if (numFadeFF == 10) {
			document.getElementById(strFadeId).style.opacity = "1";
		} else {
			document.getElementById(strFadeId).style.opacity = "." + numFadeFF.toString();
		} //if
		document.getElementById(strFadeId).style.filter = "alpha(opacity=" + numFadeIE.toString() + ")";
		numCurrentFadePart = numCurrentFadePart + 1;
		setTimeout("doFadeIn()", 100);
	} else {
		setTimeout("doFadeOut()", 4000);
		numCurrentFadePart = 0;
	} //if
} //doFadeIn

function setupBeltImages() {
	var i, imageList, imageItem, thumbList, thumbItem, colorList, colorItem, titleList, titleItem, linkList, linkItem, strTitle, strHTML;
	imageList = randomList.item(0).getElementsByTagName("image");
	imageItem = imageList.item(Math.floor(Math.random() * imageList.length));
//		alert(Math.floor(Math.random() * imageList.length));
//		document.getElementById("i" + i.toString()).src = imageItem.childNodes[0].nodeValue;
	document.getElementById("lpPhoto").src = imageItem.childNodes[0].nodeValue;
	strHTML = "";
	for (i = 0; i < numCategoriesTotal; i++) {
		thumbList = categoryList.item(i).getElementsByTagName("thumb");
		thumbItem = thumbList.item(0);
		titleList = categoryList.item(i).getElementsByTagName("title");
		titleItem = titleList.item(0);
		strTitle = titleItem.childNodes[0].nodeValue;
		linkList = categoryList.item(i).getElementsByTagName("link");
		linkItem = linkList.item(0);
		strHTML += "<div id=\"photo" + i.toString() + "\" class=\"photoCell\"><a href=\"" + linkItem.childNodes[0].nodeValue + "\"><img id=\"i" + i.toString() + "\" src=\"" + thumbItem.childNodes[0].nodeValue + "\" width=\"72\" height=\"44\" class=\"cellPhoto\" /></a><div id=\"text" + i.toString() + "\" class=\"photoText\">" + strTitle + "</div></div>";
	} //for
	document.getElementById("photoContainer").innerHTML = strHTML;
	for (i = 0; i < numCategoriesTotal; i++) {
		colorList = categoryList.item(i).getElementsByTagName("color");
		colorItem = colorList.item(0);
		document.getElementById("i" + i.toString()).style.borderColor = "#" + colorItem.childNodes[0].nodeValue;
		document.getElementById("photo" + i.toString()).style.left = (i * 131).toString() + "px";
	} //for
	document.getElementById("largePuppetPhoto").style.display = "block";
} //setupBeltImages

function renderMenuSelection(numMenuItem) {
	var i, captionList, captionItem, nameList, nameItem;
	if (!blnHidden) {
		document.getElementById("loaderBox").style.display = "block";		
	} else {
		blnHidden = false;
	} //if
	for (i = 0; i < numCategoriesTotal; i++) {
		document.getElementById("puppetName" + i.toString()).style.color = "#5f5f57";
		document.getElementById("menuBack" + i.toString()).style.visibility = "hidden";
		document.getElementById("whiteBox" + i.toString()).style.visibility = "hidden";
	} //for
	document.getElementById("puppetName" + numMenuItem.toString()).style.color = "#d1c9af";
	document.getElementById("menuBack" + numMenuItem.toString()).style.visibility = "visible";
	document.getElementById("whiteBox" + numMenuItem.toString()).style.visibility = "visible";

	nameList = categoryList.item(numMenuItem).getElementsByTagName("name");
	nameItem = nameList.item(0);
	document.getElementById("puppetNameHead").innerHTML = nameItem.childNodes[0].nodeValue;
	
	captionList = categoryList.item(numMenuItem).getElementsByTagName("caption");
	captionItem = captionList.item(0);
	document.getElementById("puppetNameChatter").innerHTML = captionItem.childNodes[0].nodeValue;
	
	numCurrentLink = numMenuItem;
	renderPhoto(0);
} //renderMenuSelection

function menuLinkRollover(blnRollover, numMenuItem) {
	if (numMenuItem != numCurrentLink) {
		if (blnRollover) {
			document.getElementById("puppetName" + numMenuItem.toString()).style.color = "#d1c9af";
		} else {
			document.getElementById("puppetName" + numMenuItem.toString()).style.color = "#5f5f57";
		} //if
	} //if
} //menuLinkRollover

function portraitMenuLinkRollover(blnRollover, numMenuItem) {
	if (numMenuItem != numCurrentLink) {
		if (blnRollover) {
			document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#241d28";
		} else {
			document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#000000";
		} //if
	} //if
} //protraitMenuLinkRollover

function renderPortraitMenuSelection(numMenuItem) {
	var i, imageList, imageItem, chatList, chatItem, sideList, sideItem, captionList, captionItem, xPosList, xPosItem, yPosList, yPosItem;
	if (!blnHidden) {
		document.getElementById("loaderBox").style.display = "block";		
	} else {
		blnHidden = false;
	} //if
	for (i = 0; i < numCategoriesTotal; i++) {
		document.getElementById("puppetName" + i.toString()).style.borderColor = "#000000";
	} //for
	document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#65516f";
	
	imageList = categoryList.item(numMenuItem).getElementsByTagName("image");
	imageItem = imageList.item(0);
	document.getElementById("largeImage").src = imageItem.childNodes[0].nodeValue;
	
	sideList = categoryList.item(numMenuItem).getElementsByTagName("side");
	sideItem = sideList.item(0);
//	document.getElementById("contentPhoto1").src = sideItem.childNodes[0].nodeValue;
	
	captionList = categoryList.item(numMenuItem).getElementsByTagName("caption");
	captionItem = captionList.item(0);
//	document.getElementById("contentPhotoCaption1").innerHTML = captionItem.childNodes[0].nodeValue;

	chatList = categoryList.item(numMenuItem).getElementsByTagName("chatter");
	chatItem = chatList.item(0);
	document.getElementById("chatContainer").innerHTML = chatItem.childNodes[0].nodeValue;
	
	xPosList = categoryList.item(numMenuItem).getElementsByTagName("chatX");
	xPosItem = xPosList.item(0);
	document.getElementById("chatContainer").style.left = xPosItem.childNodes[0].nodeValue + "px";

	yPosList = categoryList.item(numMenuItem).getElementsByTagName("chatY");
	yPosItem = yPosList.item(0);
	document.getElementById("chatContainer").style.top = (parseInt(yPosItem.childNodes[0].nodeValue) + 169).toString() + "px";

	numCurrentLink = numMenuItem;
} //renderPortraitMenuSelection

function setUpPortraitMenu() {
	var i, thumbList, thumbItem, strHTML;
	strHTML = "";
	for (i = 0; i < numCategoriesTotal; i++) {
		thumbList = categoryList.item(i).getElementsByTagName("thumb");
		thumbItem = thumbList.item(0);
		strHTML += "<div id=\"puppet" + i.toString() + "\" class=\"puppetMenuModule\"><div class=\"puppetNameBox\"><a href=\"jav" + "ascr" + "ipt: renderPortraitMenuSelection(" + i.toString() + ");\" onmouseover=\"portraitMenuLinkRollover(true, " + i.toString() + ")\" onmouseout=\"portraitMenuLinkRollover(false, " + i.toString() + ")\"><img id=\"puppetName" + i.toString() + "\" src=\"" + thumbItem.childNodes[0].nodeValue  + "\" width=\"65\" height=\"65\" border=\"0\" /></a></div></div>";
//		alert(thumbItem.childNodes[0].nodeValue);
	} //for
	document.getElementById("puppetMenu").innerHTML = strHTML;
	renderPortraitMenuSelection(0);
} //setUpPortraitMenu

function setUpLivingMenu() {
	var i, nameList, nameItem, strHTML, strQuery, numMenuSelection;
	strQuery = document.location.search;
	numMenuSelection = 0;
	strHTML = "";
	for (i = 0; i < numCategoriesTotal; i++) {
		nameList = categoryList.item(i).getElementsByTagName("name");
		nameItem = nameList.item(0);
		if (i < numCategoriesTotal - 1) {
			strHTML += "<div id=\"puppet" + i.toString() + "\" class=\"puppetMenuModule\"><div id=\"whiteBox" + i.toString() + "\" class=\"puppetWhiteBox\"></div><div class=\"puppetNameBox\"><a id=\"puppetName" + i.toString() + "\" href=\"jav" + "ascr" + "ipt: renderMenuSelection(" + i.toString() + ");\" onmouseover=\"menuLinkRollover(true, " + i.toString() + ")\" onmouseout=\"menuLinkRollover(false, " + i.toString() + ")\">" + nameItem.childNodes[0].nodeValue  + "</a></div><div id=\"menuBack" + i.toString() + "\" class=\"puppetNameBoxBack\"></div></div>";
		} else {
			strHTML += "<div id=\"puppet" + i.toString() + "\" class=\"puppetMenuModule\"><div id=\"whiteBox" + i.toString() + "\" class=\"puppetWhiteBox\"></div><div id=\"lastItem\" class=\"puppetNameBox\"><a id=\"puppetName" + i.toString() + "\" href=\"jav" + "ascr" + "ipt: renderMenuSelection(" + i.toString() + ");\" onmouseover=\"menuLinkRollover(true, " + i.toString() + ")\" onmouseout=\"menuLinkRollover(false, " + i.toString() + ")\">" + nameItem.childNodes[0].nodeValue  + "</a></div><div id=\"menuBack" + i.toString() + "\" class=\"puppetNameBoxBack\"></div></div>";
		} //if
		if (strQuery.indexOf(nameItem.childNodes[0].nodeValue) != -1) {
			numMenuSelection = i;
		} //if
//		alert(thumbItem.childNodes[0].nodeValue);
	} //for
	document.getElementById("puppetMenu").innerHTML = strHTML;
	renderMenuSelection(numMenuSelection);
} //setUpLivingMenu

/*function initWindow() {
	var numCenterOffSet;
	if (navigator.appName == "Microsoft Internet Explorer") {
		winW = document.body.offsetWidth;
	} else {
		winW = window.innerWidth - 20;
	} //if
	if (winW > 960) {
		numCenterOffSet = (winW - 960) / 2;
	} else {
		numCenterOffSet = 0;
	} //if
//	alert(winW);
	if ((document.getElementById("watermark")) && (winW < 1628)) {
//		alert(winW);
		document.getElementById("watermark").style.width = ((numWatermarkLeftOffset - numCenterOffSet ) + winW).toString() + "px";
	} else {
		document.getElementById("watermark").style.width = "1628px";
	} //if
} //initWindow

window.onresize = function() {initWindow();};
*/
function setBottomTimeout(strId) {
	numBottomTimerId = setTimeout("hideBottomMenu()", 300);
} //setBottomTimeout

function showBottomMenu(strId) {
	var i;
	clearTimeout(numBottomTimerId);
	for (i = 0; i < 3; i++) {
		document.getElementById("botmenu" + i.toString()).style.display = "none";
	} //for
	document.getElementById("botmenu" + strId).style.display = "block";	
} //showBottomMenu

function hideBottomMenu() {
	for (i = 0; i < 3; i++) {
		document.getElementById("botmenu" + i.toString()).style.display = "none";
	} //for
} //hideBottomMenu

var numAnimateId;
var blnButtonsShowing = false;
function showAnimateButtons() {
	clearTimeout(numAnimateId);
	document.getElementById("animateButtons").style.display = "block";
	if (Modernizr.touch) {
		if (blnButtonsShowing) {
			blnButtonsShowing = false;
			restoreAnimateDefault();
		} else {
			document.getElementById("animateButtons").style.display = "block";
			blnButtonsShowing = true;
		} //if
	} //if
} //showAnimateButtons

function swapAnimation(strId) {
	clearTimeout(numAnimateId);
	var i;
	for (i = 0; i < 12; i++) {
		document.getElementById("animateBtn" + i.toString()).style.background = "#6a4d4d";
	} //for
	document.getElementById("animateBtn" + strId).style.background = "#a78a8a";
	document.getElementById("contentPhoto1").src = "images/animate_images/animation" + strId + ".jpg";	
} //swapAnimation

function setAnimateTimeout() {
	numAnimateId = setTimeout("restoreAnimateDefault()", 500);
} //setAnimateTimeout

function restoreAnimateDefault() {
	var i;
	for (i = 0; i < 12; i++) {
		document.getElementById("animateBtn" + i.toString()).style.background = "#6a4d4d";
	} //for
	document.getElementById("contentPhoto1").src = "images/animate_images/animation.jpg";
	document.getElementById("animateButtons").style.display = "none";
} //restoreAnimateDefault

function signatureMenuLinkRollover(blnRollover, numMenuItem) {
	if (numMenuItem != numCurrentLink) {
		if (blnRollover) {
			document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#332a13";
		} else {
			document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#000000";
		} //if
	} //if
} //signatureMenuLinkRollover

function renderSignatureMenuSelection(numMenuItem) {
	var i, imageList, imageItem, chatList, chatItem, sideList, sideItem, captionList, captionItem, xPosList, xPosItem, yPosList, yPosItem;
	if (!blnHidden) {
		document.getElementById("loaderBox").style.display = "block";		
	} else {
		blnHidden = false;
	} //if
	for (i = 0; i < numCategoriesTotal; i++) {
		document.getElementById("puppetName" + i.toString()).style.borderColor = "#000000";
	} //for
	document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#967d3a";
	
	imageList = categoryList.item(numMenuItem).getElementsByTagName("image");
	imageItem = imageList.item(0);
	document.getElementById("largeImage").src = imageItem.childNodes[0].nodeValue;
	
	sideList = categoryList.item(numMenuItem).getElementsByTagName("side");
	sideItem = sideList.item(0);
//	document.getElementById("contentPhoto1").src = sideItem.childNodes[0].nodeValue;
	
	captionList = categoryList.item(numMenuItem).getElementsByTagName("caption");
	captionItem = captionList.item(0);
//	document.getElementById("contentPhotoCaption1").innerHTML = captionItem.childNodes[0].nodeValue;

	chatList = categoryList.item(numMenuItem).getElementsByTagName("chatter");
	chatItem = chatList.item(0);
	document.getElementById("chatContainer").innerHTML = chatItem.childNodes[0].nodeValue;
	
	xPosList = categoryList.item(numMenuItem).getElementsByTagName("chatX");
	xPosItem = xPosList.item(0);
	document.getElementById("chatContainer").style.left = xPosItem.childNodes[0].nodeValue + "px";

	yPosList = categoryList.item(numMenuItem).getElementsByTagName("chatY");
	yPosItem = yPosList.item(0);
	document.getElementById("chatContainer").style.top = (parseInt(yPosItem.childNodes[0].nodeValue) + 169).toString() + "px";

	numCurrentLink = numMenuItem;
} //renderSignatureMenuSelection

function setUpSignatureMenu() {
	var i, thumbList, thumbItem, strHTML;
	strHTML = "";
	for (i = 0; i < numCategoriesTotal; i++) {
		thumbList = categoryList.item(i).getElementsByTagName("thumb");
		thumbItem = thumbList.item(0);
		strHTML += "<div id=\"puppet" + i.toString() + "\" class=\"puppetMenuModule\"><div class=\"puppetNameBox\"><a href=\"jav" + "ascr" + "ipt: renderSignatureMenuSelection(" + i.toString() + ");\" onmouseover=\"signatureMenuLinkRollover(true, " + i.toString() + ")\" onmouseout=\"signatureMenuLinkRollover(false, " + i.toString() + ")\"><img id=\"puppetName" + i.toString() + "\" src=\"" + thumbItem.childNodes[0].nodeValue  + "\" width=\"65\" height=\"65\" border=\"0\" /></a></div></div>";
//		alert(thumbItem.childNodes[0].nodeValue);
	} //for
	document.getElementById("puppetMenu").innerHTML = strHTML;
	renderSignatureMenuSelection(0);
} //setUpSignatureMenu

function extremeMenuLinkRollover(blnRollover, numMenuItem) {
	if (numMenuItem != numCurrentLink) {
		if (blnRollover) {
			document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#4d0912";
		} else {
			document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#000000";
		} //if
	} //if
} //extremeMenuLinkRollover

function renderExtremeMenuSelection(numMenuItem) {
	var i, imageList, imageItem, chatList, chatItem, sideList, sideItem, captionList, captionItem, xPosList, xPosItem, yPosList, yPosItem;
	if (!blnHidden) {
		document.getElementById("loaderBox").style.display = "block";		
	} else {
		blnHidden = false;
	} //if
	for (i = 0; i < numCategoriesTotal; i++) {
		document.getElementById("puppetName" + i.toString()).style.borderColor = "#000000";
	} //for
	document.getElementById("puppetName" + numMenuItem.toString()).style.borderColor = "#862c34";
	
	imageList = categoryList.item(numMenuItem).getElementsByTagName("image");
	imageItem = imageList.item(0);
	document.getElementById("largeImage").src = imageItem.childNodes[0].nodeValue;
	
	sideList = categoryList.item(numMenuItem).getElementsByTagName("side");
	sideItem = sideList.item(0);
	document.getElementById("contentPhoto1").src = sideItem.childNodes[0].nodeValue;
	
	captionList = categoryList.item(numMenuItem).getElementsByTagName("caption");
	captionItem = captionList.item(0);
	document.getElementById("contentPhotoCaption1").innerHTML = captionItem.childNodes[0].nodeValue;

	chatList = categoryList.item(numMenuItem).getElementsByTagName("chatter");
	chatItem = chatList.item(0);
	document.getElementById("chatContainer").innerHTML = chatItem.childNodes[0].nodeValue;
	
	xPosList = categoryList.item(numMenuItem).getElementsByTagName("chatX");
	xPosItem = xPosList.item(0);
	document.getElementById("chatContainer").style.left = xPosItem.childNodes[0].nodeValue + "px";

	yPosList = categoryList.item(numMenuItem).getElementsByTagName("chatY");
	yPosItem = yPosList.item(0);
	document.getElementById("chatContainer").style.top = (parseInt(yPosItem.childNodes[0].nodeValue) + 169).toString() + "px";

	numCurrentLink = numMenuItem;
} //renderExtremeMenuSelection

function setUpExtremeMenu() {
	var i, thumbList, thumbItem, strHTML;
	strHTML = "";
	for (i = 0; i < numCategoriesTotal; i++) {
		thumbList = categoryList.item(i).getElementsByTagName("thumb");
		thumbItem = thumbList.item(0);
		strHTML += "<div id=\"puppet" + i.toString() + "\" class=\"puppetMenuModule\"><div class=\"puppetNameBox\"><a href=\"jav" + "ascr" + "ipt: renderExtremeMenuSelection(" + i.toString() + ");\" onmouseover=\"extremeMenuLinkRollover(true, " + i.toString() + ")\" onmouseout=\"extremeMenuLinkRollover(false, " + i.toString() + ")\"><img id=\"puppetName" + i.toString() + "\" src=\"" + thumbItem.childNodes[0].nodeValue  + "\" width=\"65\" height=\"65\" border=\"0\" /></a></div></div>";
//		alert(thumbItem.childNodes[0].nodeValue);
	} //for
	document.getElementById("puppetMenu").innerHTML = strHTML;
	renderExtremeMenuSelection(0);
} //setUpExtremeMenu

function showHideModal(blnShow) {
	if (blnShow) {
		document.getElementById("largePhotoModal").style.display = "block";
		if (document.getElementById("secretClip")) {
			document.getElementById("secretClip").Play();
		} //if
	} else {
		document.getElementById("largePhotoModal").style.display = "none";
		if (document.getElementById("secretClip")) {
			document.getElementById("secretClip").Stop();
		} //if
	} //if
} //showHideModal

function showHideSecondModal(blnShow) {
	if (blnShow) {
		document.getElementById("largePhotoModal1").style.display = "block";
	} else {
		document.getElementById("largePhotoModal1").style.display = "none";
	} //if
} //showHideSecondModal

function imageLoaded() {
	document.getElementById("loaderBox").style.display = "none";
	document.getElementById("loaderBox").style.height = (numPhotoHeight - 200).toString() + "px";
//	alert(document.getElementById("loaderBox").style.height);
} //imageLoaded

function setTopTimeout(strId) {
	numTopTimerId = setTimeout("hideTopMenu()", 300);
} //setTopTimeout

function showTopMenu(strId) {
	var i;
	clearTimeout(numTopTimerId);
	for (i = 0; i < 3; i++) {
		document.getElementById("topmenu" + i.toString()).style.display = "none";
	} //for
	document.getElementById("topmenu" + strId).style.display = "block";	
} //showTopMenu

function hideTopMenu() {
	for (i = 0; i < 3; i++) {
		document.getElementById("topmenu" + i.toString()).style.display = "none";
	} //for
} //hideTopMenu

function swapControlImages(strId, strImagePath) {
	document.getElementById(strId).src = strImagePath;
} //swapControlImages
