// Contains custom objects for The WildSide.
// Written by Stephen Topsy of TopsyDesigns.com

// Global ---------------------------------------------------------- //
var itemBackgrounds = new Array
	itemBackgrounds["web00"] = "#804812"
	itemBackgrounds["web01"] = "#012117"
	itemBackgrounds["web02"] = "#746e27"
	itemBackgrounds["web03"] = "#ab2624"
	itemBackgrounds["web04"] = "#996633"
	itemBackgrounds["web05"] = "#270C28"
	itemBackgrounds["web06"] = "#d5bb3d"
	itemBackgrounds["web07"] = "#529aad"
	itemBackgrounds["web08"] = "#181c34"
	itemBackgrounds["web09"] = "#412800"
	itemBackgrounds["web10"] = "#b66060"
	itemBackgrounds["web11"] = "#4e421c"
	itemBackgrounds["web12"] = "#2E0303"
	itemBackgrounds["web13"] = "#f8e7d9"
	itemBackgrounds["web14"] = "#d8c6a1"
	itemBackgrounds["web15"] = "#f8f5d9"
	itemBackgrounds["web16"] = "#e2f8d9"
	itemBackgrounds["web17"] = "#d9eaf8"
	itemBackgrounds["web18"] = "#f8dad9"
	itemBackgrounds["web19"] = "#d9f8f3"
	itemBackgrounds["web20"] = "#e4d9f8"
	itemBackgrounds["web21"] = "#c9b4f2"
	itemBackgrounds["web22"] = "#f2b4d4"
	itemBackgrounds["web23"] = "#d0f2b4"
	itemBackgrounds["web24"] = "#b4e3f2"
	itemBackgrounds["standardThumbWhite"] = "#fff"
	itemBackgrounds["standardThumbBlack"] = "#000"
	itemBackgrounds["standardThumbGray"] = "#333"
	itemBackgrounds["standardThumbLightGray"] = "#CCC"

var itemTexture = new Array
	itemTexture["none"] = 'none'
	itemTexture["camo"] = 'url(/themes/wildsidegothic/images/fabric/fab_camouflage.png)'
	itemTexture["tiedye"] = 'url(/themes/wildsidegothic/images/fabric/fab_tiedye.png)'
	itemTexture["denim"] = 'url(/themes/wildsidegothic/images/fabric/fab_denim.png)'
		
var icon = new Array
	icon["warn"] = YAHOO.widget.SimpleDialog.ICON_WARN
	icon["help"] = YAHOO.widget.SimpleDialog.ICON_HELP
	icon["info"] = YAHOO.widget.SimpleDialog.ICON_INFO
	icon["alarm"] = YAHOO.widget.SimpleDialog.ICON_ALARM
	icon["tip"] = YAHOO.widget.SimpleDialog.ICON_TIP
	icon["block"] = YAHOO.widget.SimpleDialog.ICON_BLOCK
		
var itemDisplayDialogCancel = function() {
		if (document.getElementById('itemDisplayDialog')){
		  itemDisplayDialog.hide();
			  if (document.getElementById('videoPreview')){
					var vids = YAHOO.util.Cookie.get("vids");
					document.getElementById('videoPreview').innerHTML = vids;
					setupZoom();
					if (BrowserDetect.browser == "Explorer"){
						if (BrowserDetect.version <= 6){
						  YAHOO.util.Dom.setStyle('videoPreview', 'height', '0');
						}
					}
					YAHOO.util.Cookie.remove("vids", { expires: new Date("January 12, 2025"), path: "/" });
			  }
		}
		if (YAHOO.util.Cookie.get("itemDisplay")){
			YAHOO.util.Cookie.remove("itemDisplay", { expires: new Date("January 12, 2025"), path: "/" });
		}
		if (document.getElementById('moduleShirt')){
		  shirtPanel.hide();
		}
		YAHOO.util.Dom.setStyle('customSwatch_wrapper', 'visibility', 'hidden');
	}
	
var progressBar = "<img src='/themes/wildsidegothic/images/gui/progress/indeterminant.gif' />";
	

	
var notificationOkay = function(action) {
		notification.hide();
		return;
	}
	
var notificationStop = function() {
		notification.hide();
		return false;
	}
	
	
function notify(iconId, heading, message, position){
	
	notification = new YAHOO.widget.SimpleDialog("notification", { 
	width: "425px", 
	underlay: "matte",
	zIndex: 250,
	effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.3}, 
	modal: true,
    visible:false,
	fixedcenter: true,
	draggable:true });
	
	if (position != null){
		notification.cfg.setProperty("context",position);
		notification.cfg.setProperty("modal",false);
	}		  
	
	notification.setHeader(heading);
	notification.setBody(message);
	notification.cfg.setProperty("icon",icon[iconId]);
	notification.cfg.queueProperty("buttons", [ { text:"Okay", handler:notificationOkay, isDefault:true }]);
	
	//replace open notification. One instance of this object at a time!!
	if (document.getElementById('notification')){
		notification.hide();
	}
		
	notification.render(document.body);
	notification.show();
	}
	
	
function submitContact(username, userid){
		
		var contactDetails = {
				
			startTransaction:function() {
				
				YAHOO.util.Dom.setStyle('contactUs', 'visibility', 'visible');
				
				var companyName = document.contact.companyName.value;
				if (document.contact.yourName.value != ''){
					var yourName = document.contact.yourName.value;
					YAHOO.util.Dom.setStyle(document.contact.yourName, 'backgroundColor', '#FFF');
				}else{
					alert('What is your name?\r\nPlease provide your name before sending this form.');
					YAHOO.util.Dom.setStyle(document.contact.yourName, 'backgroundColor', '#FFCC66');
					document.contact.yourName.focus();
					return;
				}
				if (document.contact.email.value != ''){
					var email = document.contact.email.value;
						//validation
					   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
					   if(reg.test(email) == false) {
						  alert('Improper E-mail\r\nPlease enter a valid e-mail address. The WildSide does not send solicitations without your consent. We will not sell your email to a third party.');
						  YAHOO.util.Dom.setStyle(document.contact.email, 'backgroundColor', '#FFCC66');
						  document.contact.email.focus();
						  return false;
					   }
					YAHOO.util.Dom.setStyle(document.contact.email, 'backgroundColor', '#FFF');
				}else{
					alert('Missing E-mail\r\nPlease enter an e-mail address. The WildSide does not send solicitations without your consent. We will not sell your email to a third party.');
					YAHOO.util.Dom.setStyle(document.contact.email, 'backgroundColor', '#FFCC66');
					document.contact.email.focus();
					return;
				}
				if (document.contact.phone.value != ''){
					var phone = document.contact.phone.value;
					YAHOO.util.Dom.setStyle(document.contact.phone, 'backgroundColor', '#FFF');
				}else{
					alert('Missing Phone Number\r\nPlease enter a call-back number. We will not sell your phone number to a third party.');
					YAHOO.util.Dom.setStyle(document.contact.phone, 'backgroundColor', '#FFCC66');
					document.contact.phone.focus();
					return;
				}
				if (document.contact.question.value != ''){
					var question = document.contact.question.value;
					//replace breaks with newline chars
					function doublenewlines(question) { question = text.replace(/(\r\n|\r|\n)/g, '\n'); return question.replace(doublenewlinesRE, "$1\n\n$2"); }
					YAHOO.util.Dom.setStyle(document.contact.question, 'backgroundColor', '#FFF');
				}else{
					alert('What is your message?\r\nPlease provide questions or commentary before sending this form.');
					YAHOO.util.Dom.setStyle(document.contact.question, 'backgroundColor', '#FFCC66');
					document.contact.question.focus();
					return;
				}
				if (companyName != ''){
					var subject = "The WildSide: NEW MESSAGE from " + yourName + " of " + companyName;
				}else{
					var subject = "The WildSide: NEW MESSAGE from " + yourName;
				}
				var recip = "The WildSide <info@thewildside.com>";
				
				notify('info', 'Sending your message...', '<br />' + progressBar, 'okaycancel');
				notification.cfg.setProperty("modal", "true");
												
				YAHOO.util.Dom.setStyle('contactUs', 'cursor', 'wait');
				YAHOO.util.Connect.asyncRequest('GET', '/themes/wildsidegothic/templates/sendmail.php?username=' + username + '&userid=' + userid + '&recip=' + recip + '&subject=' + subject + '&question=' + question + '&email=' + email + '&phone=' + phone + '&name=' + yourName + '&company=' + companyName, callback, null);
				
				},
			  
			responseSuccess:function(o){
				
				notification.hide();
				
				YAHOO.util.Dom.setStyle('contactUs', 'visibility', 'hidden');
				changeSize('contactUs', '', '0', 1);
				
				YAHOO.util.Dom.setStyle('contactUs', 'cursor', 'auto');
				notify('info', 'Message Result', '<div style="background-color: #FFF; padding: 10px 20px; margin: 10px;">' + o.responseText +'</div>');
						
				},
			  
			responseFailure:function(o){
				
				YAHOO.util.Dom.setStyle('contactUs', 'cursor', 'auto');
				notify('alarm', 'Message Could Not Be Sent', 'Accept our apologies, we could not send your message. The server responded with:' + o.statusText +'    /    '+o.responseText);
				
				}
		}
		
		
		var callback =
		{
		  success:contactDetails.responseSuccess,
		  failure:contactDetails.responseFailure,
		  scope:contactDetails
		};
		
		
		contactDetails.startTransaction();
}

function submitOrder(){
	
	//validate form
	if (document.sendOrder.name.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.name, 'backgroundColor', '#FFF');
	}else{
		alert('What is your name?\r\nPlease provide your name before sending this order.');
		YAHOO.util.Dom.setStyle(document.sendOrder.name, 'backgroundColor', '#FFCC66');
		document.sendOrder.name.focus();
		return;
	}
	if (document.sendOrder.email.value != ''){
		var email = document.sendOrder.email.value;
			//validation
		   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		   if(reg.test(email) == false) {
			  alert('Improper E-mail\r\nPlease enter a valid e-mail address. The WildSide does not send solicitations without your consent. We will not sell your email to a third party.');
			  YAHOO.util.Dom.setStyle(document.sendOrder.email, 'backgroundColor', '#FFCC66');
			  document.sendOrder.email.focus();
			  return false;
		   }
		YAHOO.util.Dom.setStyle(document.sendOrder.email, 'backgroundColor', '#FFF');
	}else{
		alert('Missing E-mail\r\nPlease enter an e-mail address. The WildSide does not send solicitations without your consent. We will not sell your email to a third party.');
		YAHOO.util.Dom.setStyle(document.sendOrder.email, 'backgroundColor', '#FFCC66');
		document.sendOrder.email.focus();
		return;
	}
	if (document.sendOrder.phone.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.phone, 'backgroundColor', '#FFF');
	}else{
		alert('Missing Phone Number\r\nPlease enter a call-back number. We will not sell your phone number to a third party.');
		YAHOO.util.Dom.setStyle(document.sendOrder.phone, 'backgroundColor', '#FFCC66');
		document.sendOrder.phone.focus();
		return;
	}
	if (document.sendOrder.address.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.address, 'backgroundColor', '#FFF');
	}else{
		alert('Missing Billing Address\r\nPlease provide a billing address before sending this order.');
		YAHOO.util.Dom.setStyle(document.sendOrder.address, 'backgroundColor', '#FFCC66');
		document.sendOrder.address.focus();
		return;
	}
	if (document.sendOrder.shippingaddress.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.shippingaddress, 'backgroundColor', '#FFF');
	}else{
		alert('Missing Billing Address\r\nPlease provide a shipping address before sending this order or use "Same as billing".');
		YAHOO.util.Dom.setStyle(document.sendOrder.shippingaddress, 'backgroundColor', '#FFCC66');
		document.sendOrder.shippingaddress.focus();
		return;
	}
	if (document.sendOrder.city.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.city, 'backgroundColor', '#FFF');
	}else{
		alert('Missing Billing City/State and/or zip\r\nPlease provide a billing city and/or zip before sending this order. Residents of the US must also include the billing state.');
		YAHOO.util.Dom.setStyle(document.sendOrder.city, 'backgroundColor', '#FFCC66');
		document.sendOrder.city.focus();
		return;
	}
	if (document.sendOrder.country.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.country, 'backgroundColor', '#FFF');
	}else{
		alert('Missing Billing Country\r\nPlease provide a billing country before sending this order.');
		YAHOO.util.Dom.setStyle(document.sendOrder.country, 'backgroundColor', '#FFCC66');
		document.sendOrder.country.focus();
		return;
	}
	if (document.sendOrder.item_1.value != ''){
		YAHOO.util.Dom.setStyle(document.sendOrder.country, 'backgroundColor', '#FFF');
	}else{
		alert('Missing Stock ID\r\nPlease provide at least one stock ID before sending this order.');
		YAHOO.util.Dom.setStyle(document.sendOrder.item_1, 'backgroundColor', '#FFCC66');
		document.sendOrder.item_1.focus();
		return;
	}
	
	notify('info', 'Sending your message...', '<br />' + progressBar, 'okaycancel');
					
	document.sendOrder.submit();
}

var appendToCart = function(itemId, cartURL){
	
			
			var appendItem = {
				
			startTransaction:function() {
				
				YAHOO.util.Dom.setStyle('itemDisplayDialog', 'cursor', 'wait');
				if (document.getElementById('photoContainerShowOn')){
				  document.getElementById('photoContainerShowOn').innerHTML = "<div id='itemLoader'>"+progressBar+"</div>";
				}
				YAHOO.util.Connect.asyncRequest('GET', cartURL, callback, null);
				
				},
			  
			responseSuccess:function(o){
				
				YAHOO.util.Dom.setStyle('itemDisplayDialog', 'cursor', 'auto');
				notify('info', 'Added Successfully', '<p>This item has been added to your shopping cart. You will have a chance to specify a quantity or remove this item during checkout.</p>');
				
				YAHOO.util.Dom.setStyle('addToCart', 'display', 'none');
				document.getElementById('photoContainerShowOn').innerHTML = "";
				var x = document.getElementById('cartCountAlbum').innerHTML;
				if (x == 'zero'){
					x = 0;
				}
				x = (Number(x) + 1);
				document.getElementById('cartCountAlbum').innerHTML = x;
				
				if (x > 1){
				  document.getElementById('cartCountLabelAlbum').innerHTML = "items";
				}else if (x == 1){
				  document.getElementById('cartCountLabelAlbum').innerHTML = "item";
				}
					
				
				},
			  
			responseFailure:function(o){
				
				YAHOO.util.Dom.setStyle('itemDisplayDialog', 'cursor', 'auto');
				notify("warn", "I could not access your cart", "The server response was: <br />" + o.responseText);
					
				
				}
		}
		
		
		var callback =
		{
		  success:appendItem.responseSuccess,
		  failure:appendItem.responseFailure,
		  scope:appendItem
		};
		
		appendItem.startTransaction();
		

		
}
	
	

function removeFromCart(itemId, checked){

	alert(checked);
	YAHOO.util.Dom.setStyle('checkoutThumb_'+itemId, 'opacity', '50%');
	
}
	
	
	
	
	
	

// BrowserDetect ---------------------------------------------------------- //
// from Quirksmode. http://www.quirksmode.org/js/detect.html


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();





// Globals ---------------------------------------------------------- //


// global function used to change the size of any object with animation
// 'containerId' is the container's id, obviously
// 'newWidth' animate the container to this new width
// 'newHeight' animate the container to this new height
// 'time' duration in seconds until the animation completes
function changeSize(containerId, newWidth, newHeight, time){
	
	var currentWidth = YAHOO.util.Dom.getStyle(containerId, 'width');
		currentWidth = currentWidth.replace(/px/i, "");
	var currentHeight = YAHOO.util.Dom.getStyle(containerId, 'height');
		currentHeight = currentHeight.replace(/px/i, "");

	//animate to reveal new width
	if (newWidth != (null || '')){
		var changeWidth = new YAHOO.util.Anim(containerId, {width: { to: newWidth }}, time, YAHOO.util.Easing.easeBothStrong);
		changeWidth.animate();
	}else{
		var changeWidth = new YAHOO.util.Anim(containerId, {width: { to: currentWidth }}, time, YAHOO.util.Easing.easeBothStrong);
		changeWidth.animate();
	}

	//animate to reveal new height
	if (newHeight != (null || '')){
		var changeHeight = new YAHOO.util.Anim(containerId, {height: { to: newHeight }}, time, YAHOO.util.Easing.easeBothStrong);
		changeHeight.animate();
	}else{
		var changeHeight = new YAHOO.util.Anim(containerId, {height: { to: currentHeight }}, time, YAHOO.util.Easing.easeBothStrong);
		changeHeight.animate();
	}
}


function changeXY(containerId, newX, newY, time){
	var currentX = YAHOO.util.Dom.getX(containerId);
	var currentY = YAHOO.util.Dom.getY(containerId);
	if (newX == ''){
		newX = currentX;
	}
	if (newY == ''){
		newY = currentY;
	}
	
	if (time == ('' || null)){
		time = .4;
	}
	var photoOptionsAnim = new YAHOO.util.Motion(containerId, {points: { to: [newX, newY] }}, time, YAHOO.util.Easing.backOut);
	photoOptionsAnim.animate();
}


// Photo Page --------------------------------------------------------------- //


// Fabric Functions ---------------------------------------------------------- //
// changes current fabric background element
// 'itemTexture' denotes the png texture to be placed on top of the chosen color ('hexcolor'). Values are cotton, camo, plaid.

		

//button controls
function activeButton(button) {
	YAHOO.util.Dom.setStyle(button, 'backgroundPosition', '-316px');
	YAHOO.util.Dom.setStyle(button,  'textShadow', ' #none');
	YAHOO.util.Dom.setStyle(button,  'color', '#EEE');
	YAHOO.util.Dom.setStyle(button, 'display', 'block');
}

function resetButtons (){
	YAHOO.util.Dom.setStyle(['photoContainerButton_shirtdisable','photoContainerButton_teeMale','photoContainerButton_teeFemale','photoContainerButton_teeFemaleFit','photoContainerButton_teechild'], 'backgroundColor', 'transparent');
	YAHOO.util.Dom.setStyle(['photoContainerButton_shirtdisable','photoContainerButton_teeMale','photoContainerButton_teeFemale','photoContainerButton_teeFemaleFit','photoContainerButton_teechild'], 'backgroundPosition', '0');
	YAHOO.util.Dom.setStyle(['photoContainerButton_shirtdisable','photoContainerButton_teeMale','photoContainerButton_teeFemale','photoContainerButton_teeFemaleFit','photoContainerButton_teechild'], 'color', '#3b1c0f');
	YAHOO.util.Dom.setStyle(['photoContainerButton_shirtdisable','photoContainerButton_teeMale','photoContainerButton_teeFemale','photoContainerButton_teeFemaleFit','photoContainerButton_teechild'], 'textShadow', '#CCC 0 1px 1px');
	YAHOO.util.Dom.setStyle(['photoContainerButton_shirtdisable','photoContainerButton_teeMale','photoContainerButton_teeFemale','photoContainerButton_teeFemaleFit','photoContainerButton_teechild'], 'display', 'block');
}
	
//change textures
function changeItemTexture(itemTextureValue, itemContainer){
	
	if (itemContainer == null){
		itemContainer = 'photoContainerTexture';
	}
		
	YAHOO.util.Dom.setStyle(itemContainer, 'backgroundImage', itemTexture[itemTextureValue]);

}
	
//change color
function changeItemBgColor (itemBgColor, time){
	
	if (time == null){
		time = ".4";
	}
	
	var itemBgColorCheck = YAHOO.util.Cookie.get("itemBgColor");
	
	if (itemBgColor == "toggle"){
		if (itemBgColorCheck == "off"){
			YAHOO.util.Cookie.set("itemBgColor", "on", { expires: new Date("January 12, 2025"), path: "/" });
			YAHOO.util.Dom.setStyle('toggleColor', 'backgroundPosition', '0');
			itemBgColor = document.getElementById('cfv_StandardThumbBg').innerHTML;
				if (itemBgColor == "custom"){
				  itemBgColor = document.getElementById('cfv_CustomThumbBg').innerHTML;
				}else{
					itemBgColor = itemBackgrounds[itemBgColor];
				}
		}else if (itemBgColorCheck == "on"){
			YAHOO.util.Cookie.set("itemBgColor", "off", { expires: new Date("January 12, 2025"), path: "/" });
			YAHOO.util.Dom.setStyle('toggleColor', 'backgroundPosition', '-61px');
			itemBgColor = "#DDD";
		}else if (itemBgColorCheck == null){
			YAHOO.util.Cookie.set("itemBgColor", "off", { expires: new Date("January 12, 2025"), path: "/" });
			YAHOO.util.Dom.setStyle('toggleColor', 'backgroundPosition', '-61px');
			itemBgColor = "#DDD";
		}
		var changeBgColor = new YAHOO.util.ColorAnim('photoContainerTexture', {backgroundColor: { to: itemBgColor }}, .8);
		changeBgColor.animate();
			
	}else{
	
		if (itemBgColorCheck == "off"){
			itemBgColor = "#DDD";
			YAHOO.util.Dom.setStyle('toggleColor', 'backgroundPosition', '-61px');
		}else if  (itemBgColorCheck == "on"){
			YAHOO.util.Dom.setStyle('toggleColor', 'backgroundPosition', '0');
		}else if  (itemBgColorCheck == null){
			YAHOO.util.Cookie.set("itemBgColor", "on", { expires: new Date("January 12, 2025"), path: "/" });
			YAHOO.util.Dom.setStyle('toggleColor', 'backgroundPosition', '0');
		}
		var changeBgColor = new YAHOO.util.ColorAnim('photoContainerTexture', {backgroundColor: { to: itemBgColor }}, time);
		changeBgColor.animate();
	}
	
}

// we may scroll any container that has overflow. 'Math' is either '-' or '+'.
// 'leftscroll' and 'topscroll' values must be a number or one of the folowing: 'left', or 'top'
function scrollThis(containerId, leftscroll, topscroll, math, maxscroll){
	
	//we get the current scroll values of 'containerId'
	var currentScroll = YAHOO.util.Cookie.get("scrollThis" + containerId);
	
	//if the cookies do not exist, set the current values to 0, else updates values based on cookie
	if (currentScroll != null){
		currentScroll = currentScroll.split(":");
		var currentScrollLeft = currentScroll[0];
		var currentScrollTop = currentScroll[1];
	}else{
		var currentScrollLeft = 0;
		var currentScrollTop = 0;
	}
	
	//determines whether to scroll to a positive or negative value
	if (math == '+'){
		leftscroll = Number(leftscroll)+Number(currentScrollLeft);
		if (leftscroll > maxscroll){
			alert('You are at the end.');
			return;
		}
		topscroll = Number(topscroll)+Number(currentScrollTop);
		if (topscroll > maxscroll){
			alert('You are at the end.');
			return;
		}
	}else if (math == '-'){
		leftscroll = Number(currentScrollLeft)-Number(leftscroll);
		if (leftscroll < 0){
			alert('You are at the beginning.');
			return;
		}
		topscroll = Number(currentScrollTop)-Number(topscroll);
		if (topscroll < 0){
			alert('You are at the beginning.');
			return;
		}
	}
		
	//set the new scroll value in the cookie
	YAHOO.util.Cookie.set("scrollThis" + containerId, leftscroll+':'+topscroll, { expires: new Date("January 12, 2025"), path: "/" });
	
	//initiate the scroll
	var element = document.getElementById(containerId);
	var scrollAnim = new YAHOO.util.Scroll(element, {
	   scroll: { to: [leftscroll, topscroll] } 
	});
	
	scrollAnim.method = YAHOO.util.Easing.easeBoth;
	scrollAnim.animate();
}


//change texture, shirt, and color
function changeDisplayOptions(itemBgColor, itemShowOn, itemTexture){
	
	if (itemBgColor == 'clear'){
		YAHOO.util.Dom.setStyle('photoContainerButton_reset', 'display', 'none');
		document.getElementById('teeModuleNotice').innerHTML = '<div style="padding:4px;"><strong>Show this on a shirt</strong><div>choose a size bellow:</div></div>';
		YAHOO.util.Dom.setStyle('photoContainerShowOn', 'backgroundImage', 'none');
		photoPosition('0','0');
		itemDimensions = YAHOO.util.Cookie.get("itemDimensions");
		itemDimensions = itemDimensions.split("x");
		changeSize("photoTransfer", itemDimensions[0], itemDimensions[1], .3);
	}
	
	if (itemBgColor != null){
	  changeItemBgColor(itemBgColor);
	}
	if (itemShowOn != null){
	  photoSize(null, itemShowOn);
	}
	if (itemTexture != null){
	  changeItemTexture(itemTexture);
	}
}

function photoSize(info, itemShowOn, originalSize){
	
	  //Set shirt
	  YAHOO.util.Dom.setStyle('photoContainerShowOn', 'backgroundImage', 'url(/themes/wildsidegothic/images/fabric/'+itemShowOn+'.png)');
		
	  if (originalSize){
		
		var toggle = document.getElementById('photoContainerSwatchButton_shirt_options').innerHTML;
		if (toggle == 'show on shirt'){
			document.getElementById('photoContainerSwatchButton_shirt_options').innerHTML = 'hide shirt';
			loadItem(info);
			return;
		}
		var origSize = YAHOO.util.Cookie.get("itemDimensions");
		origSize = origSize.split("x");
		changeSize("photoTransfer", origSize[0], origSize[1], .3);
		var marginx = (325 - origSize[0]) / 2;
		var marginy = (325 - origSize[1]) / 2;
		YAHOO.util.Dom.setStyle('photoTransfer', 'margin', marginy + 'px ' + marginx +'px');
		document.getElementById('photoContainerSwatchButton_shirt_options').innerHTML = 'show on shirt';
		  
	  }else{

			var currentWidth = YAHOO.util.Dom.getStyle("photoTransfer", "width");
				currentWidth = currentWidth.replace(/px/i, "");
			var currentHeight = YAHOO.util.Dom.getStyle("photoTransfer", "height");
				currentHeight = currentHeight.replace(/px/i, "");
			YAHOO.util.Cookie.set("itemDimensions", currentWidth + "x" + currentHeight, { expires: new Date("January 12, 2025"), path: "/" });
	
			if (info != 'full'){
				  
				
				//base is the distance between armpits on a small male or female tee.
				var base = 20;
				
				if (itemShowOn == 'teeFemale'){
					base = 18;
				} else if (itemShowOn == 'teeBaby'){
					base = 12;
				} else if (itemShowOn == 'teeChild'){
					base = 18;
				}
				
					  
				  //get shirt dimension from meta data
				  info = info.split(" - ");
				  var dimensions = info[0];
				  var description = info[1];
				  
				  dimensions = dimensions.split("x");
				  
				  var width = dimensions[0];
				  if (dimensions[1]){
					  var height = dimensions[1];
				  }else{
					  var height = dimensions[0];
				  }
					  
				  
				  //325 is the default image size (in pixels) for products in the database.
				  var newWidth = (width * 325) / base; 
				  var newHeight = (height * 325) / base;
				  
				  var y = (325 - newHeight) / 2;
				  var x = (325 - newWidth) / 2;
				  
				  //by default, set a minimal y position so that art doesnt draw on the neck (overridden by ShiftY in meta data)
				  if (y < 44){
					  y = 44;
				  }
				  
				  
				  
				  var x1 = (Number(x));
				  var x2 = (Number(x));
				  var y1 = (Number(y));
				  var y2 = 0;
				  
				  //auto-positioning. depending on shirt, make default adjustments to ensure art is centered on shirt
				  if (itemShowOn == 'teeBaby'){
					  y1 = y1 - 30;
				  } else if (itemShowOn == 'teeChild'){
					  y1 = y1 - 20;
				  }
				  
				  
				  
				  if (document.getElementById('cfv_ShiftX')){
					  var xShift = document.getElementById('cfv_ShiftX').innerHTML;
						  x1 = x - (Number(xShift));
						  x2 = x + (Number(xShift));
				  }
				  
				  if (document.getElementById('cfv_ShiftY')){
					  var yShift = document.getElementById('cfv_ShiftY').innerHTML;
					  y1 = y + (Number(yShift));
				  }
							  
				  YAHOO.util.Dom.setStyle('photoTransfer', 'margin', y1 + 'px ' + x1 +'px ' + y2 +'px ' + x2 + 'px');
				  
			  }else{
				  
				  var y = (325 - currentHeight) / 2;
				  YAHOO.util.Dom.setStyle('photoTransfer', 'margin', y + 'px auto');
				  
			  }
	  }
				
		//if item is pocket, show at full size.
		if ((width <= 4) && (height <= 4)){
			
			var y = (325 - currentHeight) / 2;
			YAHOO.util.Dom.setStyle('photoTransfer', 'margin', y + 'px auto');
			//YAHOO.util.Dom.setStyle('photoTransfer', 'margin', '0 auto');
			
			return;
		}
		
		//set shirt size, unless disabled in meta data
		if (info != 'full'){
		changeSize("photoTransfer", newWidth, newHeight, .3);
		}
	
			
		
		
	}





// Page scripts ---------------------------------------------------------- //

						  
function pageData(){
			if (document.getElementById('stockId')){
				var stockId = document.getElementById('stockId').innerHTML;
				pageDisplayDialog.setHeader("<h3 id='newStockId'>"+stockId+"</h3>");
			}else{
				pageDisplayDialog.setHeader("<h3 id='newStockId'>Catalog Page is null</h3>");
			}
			
			YAHOO.util.Dom.setStyle('photoContainerTexture', 'display', 'none');
			YAHOO.util.Dom.setStyle('stockIdModule', 'display', 'none');
			YAHOO.util.Dom.setStyle('moduleShirt', 'display', 'none');
			YAHOO.util.Dom.setStyle('photoContainerOptions', 'width', '150px');
			YAHOO.util.Dom.setStyle('photoContainerOptions', 'text-align', 'left');
			YAHOO.util.Dom.setStyle('photoContainerPhoto', 'text-align', 'left');
			YAHOO.util.Dom.setStyle('photoContainerPhoto', 'width', '325px');
			YAHOO.util.Dom.setStyle('photoContainerShowOn', 'backgroundImage', 'url(/themes/wildsidegothic/images/fabric/nothing.png)');
			
			window.document.getElementById('photoContainerOptions').innerHTML = "<a href='http://thewildside.com/main.php?g2_view=html.HtmlPage' target='_blank' title='Order Form' id='orderform_link'>&nbsp;</a><h3 style='border-bottom: 1px solid #CCC'>Pricing</h3><ul><li>Oversize (P17 +): $0.35</li><li>Adult (P9 - P16): $0.25</li><li>Youth (P8 - P6): $0.15</li><li>Pocket (P5 -): $0.05</li></ul><h3 style='border-bottom: 1px solid #CCC; margin-top: 10px;'>To Order</h3><p>To purchase, use our write-in order-form or call <span style='white-space: nowrap;'>(800) 421-3130</span> or <span style='white-space: nowrap;'>(818) 837-5000.</span></p><p>Minimum order of 100 dozen for above pricing.";
			
			var vpHeight = YAHOO.util.Dom.getViewportHeight();
			if (vpHeight < 600){
				vpHeight = vpHeight - 40;
				pageDisplayDialog.cfg.setProperty("height", vpHeight+"px");
				vpHeight = vpHeight - 100;
				YAHOO.util.Dom.setStyle('photoContainerPhoto', 'height', vpHeight+"px");
				YAHOO.util.Dom.setStyle('photoContainerPhoto', 'overflow', 'scroll');
			}else{
				YAHOO.util.Dom.setStyle('photoContainerPhoto', 'height', YAHOO.util.Dom.getStyle('photoTransfer', 'height')	);
			}
			
			YAHOO.util.Dom.setStyle('photoContainerOrderInfo', 'margin', YAHOO.util.Dom.getStyle('photoContainerPhoto', 'height') + ' 0 0 0');
			YAHOO.util.Dom.setStyle('photoContainerOrderInfo', 'width', YAHOO.util.Dom.getStyle('photoContainerPhoto', 'width'));
			
			if (BrowserDetect.browser == "Explorer"){
				  pageDisplayDialog.cfg.setProperty("fixedcenter", "true");
				if (BrowserDetect.version <= 6){
				  //remove stock id module
				  var x = document.getElementById('photoContainer');
				  var y = document.getElementById('photoContainerOptions');
				  x.removeChild(y);
				}
			}
}


function itemData(itemId, userId){
	
				
			//Favorite Item check
			if (document.getElementById('favoritesModule')){
				if (userId){
					
					//Add To Favorites Button
					var favBadgeOBJ = document.getElementById('favBadge');
					var favBadgeURL = favBadgeOBJ.getAttribute('href');
					favBadgeOBJ.setAttribute('href', '#');
					var oFavBadge = new YAHOO.widget.Button('favBadge');
					
					var onFavBadgeClick = function (e) {
					 
						addFavorite(itemId, favBadgeURL, 'add');
					 
					};
					oFavBadge.on("click", onFavBadgeClick);
					
					//Remove From Favorites Button
					var favBadgeRemoveOBJ = document.getElementById('favBadgeRemove');
					var favBadgeRemoveURL = favBadgeRemoveOBJ.getAttribute('href');
					favBadgeRemoveOBJ.setAttribute('href', '#');
					var oFavBadgeRemove = new YAHOO.widget.Button('favBadgeRemove');
					
					var onFavBadgeRemoveClick = function (e) {
					 
						addFavorite(itemId, favBadgeRemoveURL, 'remove');
					 
					};
					oFavBadgeRemove.on("click", onFavBadgeRemoveClick);
				
					
				  var  myFavsVerify = {
						  
					  startTransaction:function() {
						  
						  YAHOO.util.Connect.asyncRequest('GET', '/themes/wildsidegothic/templates/myFavsVerify.php?userId=' + userId +'&itemId=' + itemId, favsCallback, null);
						  YAHOO.util.Dom.setStyle(document.getElementById('favoritesModule'), 'display', 'block');
						  
						  },
						
					  responseSuccess:function(o){
						  
						  var favs = o.responseText;
						  if (favs.match(itemId)){
							  YAHOO.util.Dom.setStyle(document.getElementById('favBadge'), 'display', 'none');
							  YAHOO.util.Dom.setStyle(document.getElementById('favBadgeRemove'), 'display', 'block');
						  }else{
							  YAHOO.util.Dom.setStyle(document.getElementById('favBadge'), 'display', 'block');
							  YAHOO.util.Dom.setStyle(document.getElementById('favBadgeRemove'), 'display', 'none');
						  }
								  
						  },
						
					  responseFailure:function(o){
								
							  YAHOO.util.Dom.setStyle(itemDisplayButtons[0], 'display', 'none');
						  
						  }
				  }
				  
				  
				  var favsCallback =
						  {
							success:myFavsVerify.responseSuccess,
							failure:myFavsVerify.responseFailure,
							scope:myFavsVerify
						  };
				  
				  
				  myFavsVerify.startTransaction();
	
				}else{
					YAHOO.util.Dom.setStyle(document.getElementById('favoritesModule'), 'display', 'none');
				}
			}
			
	
			//make cart buttons
			//Add To Cart Button
			if (document.getElementById('addToCartButton')){
				var cartOBJ = document.getElementById('addToCartButton');
				var cartURL = cartOBJ.getAttribute('href');
				cartOBJ.setAttribute('href', '#');
				var oAddToCartButton = new YAHOO.widget.Button("addToCartButton");
				
				var onAddToCartButtonClick = function (e) {
				 
					appendToCart(itemId, cartURL);
				 
				};
				oAddToCartButton.on("click", onAddToCartButtonClick);
								
				//View Cart Button
				var oViewCartButton = new YAHOO.widget.Button("viewCartButton");
				
				var onViewCartButtonClick = function (e) {
					
					itemDisplayDialogCancel();
					notify("none", "Open Cart", "Please wait while your cart is loaded...<br /><br />"+ progressBar);
				 
				};
				 
				oViewCartButton.on("click", onViewCartButtonClick);
			}
							
			
			//set stock id title
			if (document.getElementById('stockId')){
			  var stockId = document.getElementById('stockId').innerHTML;
				if (stockId != null){
				itemDisplayDialog.setHeader("<h3 id='newStockId'>"+stockId+"</h3>");
				}else{
				itemDisplayDialog.setHeader("<h3 id='newStockId'>Item</h3>");
				}
			}
				
			
			//get other meta data
			if (document.getElementById('cfv_AllowPrice')){
				var prices = YAHOO.util.Dom.getElementsByClassName('itemPrice', 'div'); 
				YAHOO.util.Dom.setStyle(prices, 'display', 'block');
			}
			
			if (document.getElementById('cfv_ShowOn')){
				var itemShowOn = document.getElementById('cfv_ShowOn').innerHTML;
			}else{
				var itemShowOn = "nothing";
	  
				if (itemShowOn == 'nothing'){
				  YAHOO.util.Dom.setStyle('photoContainerSwatchButton_shirt_options', 'display', 'none');
				}
			}
			
			if (document.getElementById('cfv_PressOn')){
				var itemPressOn = document.getElementById('cfv_PressOn').innerHTML;
			}else{
				var itemPressOn = null;
			}
			
			if (document.getElementById('cfv_Texture')){
				var itemTexture = document.getElementById('cfv_Texture').innerHTML;
				changeItemTexture(itemTexture);
			}else{
				YAHOO.util.Dom.setStyle('photoContainerTexture', 'backgroundImage', 'none');
			}
			
			 if (document.getElementById('cfv_TransferType')){
				var transferType = document.getElementById('cfv_TransferType').innerHTML;
				if (transferType == 'sleeves'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This item is a set of <strong>SLEEVES</strong>.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
				}else if (transferType == 'pocket'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This item is a <strong>POCKET</strong>.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
					YAHOO.util.Dom.setStyle('naviBlock', 'display', 'none');
				}else if (transferType == 'included_pocket'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This <strong>FREE POCKET</strong> is included with the purchase of specific transfers. This item cannot be purchased seperately.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
					YAHOO.util.Dom.setStyle('addToCartButton', 'display', 'none');
					YAHOO.util.Dom.setStyle('favoritesModule', 'display', 'none');
					YAHOO.util.Dom.setStyle('naviBlock', 'display', 'none');
				}else if (transferType == 'cut-a-part'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This is a <br /><strong>CUT-A-PART</strong> sheet, containing several designs on each transfer.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
				}else if (transferType == 'child'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This item is sized for <strong>CHILDREN</strong>.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
				}else if (transferType == 'oversize'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This item is <strong>OVERSIZED</strong>.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
				}else if (transferType == 'namedrop'){
					document.getElementById('teeModuleNotice').innerHTML = '<p class="smallNotice">This item is a <strong>NAME DROP</strong>.</p>';
					var stockId = document.getElementById('newStockId').innerHTML;
					document.getElementById('newStockId').innerHTML = stockId;
				}
			} 
			
			if (document.getElementById('cfv_StandardThumbBg')){
				var itemStandardBgColor = document.getElementById('cfv_StandardThumbBg').innerHTML;
			}else{
				var itemStandardBgColor = '#AAA';
			}
			if (document.getElementById('cfv_CustomThumbBg')){
				itemBgColor = document.getElementById('cfv_CustomThumbBg').innerHTML;
			}else{
				itemBgColor = itemBackgrounds[itemStandardBgColor];
			}
			
			//change bg color
			changeItemBgColor(itemBgColor);	
				
			if (document.getElementById('cfv_DefaultSize')){
				var itemDefaultSize = document.getElementById('cfv_DefaultSize').innerHTML;
			}else{
				var itemDefaultSize = "full";
			}
			
			//append bg color to new style sheet... prevents 'flicker' when running loadItem()
			/*var sheet = YAHOO.util.StyleSheet(YAHOO.util.Selector.query('style',null,true)); 
			var css = "#photoContainerTexture { background-color: "+ itemBgColor +"; }";
			sheet = new YAHOO.util.StyleSheet(css);
			alert('here');*/
			
			
			photoSize(itemDefaultSize, itemShowOn);
			
			
			//Lights or Darks check. Not used, needs to be fixed so that colors change dynamically when going from Lights Only to Lights and Darks.
			if (document.getElementById('cfv_PressOn')){
			var itemPressOn = document.getElementById('cfv_PressOn').innerHTML;
				if (itemPressOn == "LightsOnly"){
					var x = YAHOO.util.Selector.query('#swatches .dark');
					YAHOO.util.Dom.setStyle(x, 'display', 'none');
					YAHOO.util.Dom.setStyle('photoContainerSwatchButton_custom_wrapper', 'display', 'none');
				}else if (itemPressOn == "DarksOnly"){
					var x = YAHOO.util.Selector.query('#swatches .light');
					YAHOO.util.Dom.setStyle(x, 'display', 'none');
					YAHOO.util.Dom.setStyle('photoContainerSwatchButton_custom_wrapper', 'display', 'none');
				}else if (itemPressOn == "BlackOnly"){
					YAHOO.util.Dom.setStyle('swatches' , 'display', 'none');
					YAHOO.util.Dom.setStyle('photoContainerSwatchButton_custom_wrapper', 'display', 'none');
				}else{
					YAHOO.util.Dom.setStyle('photoContainerSwatchButton_custom_wrapper', 'display', 'block');
					var x = YAHOO.util.Selector.query('#swatches .light');
					var y = YAHOO.util.Selector.query('#swatches .dark');
					YAHOO.util.Dom.setStyle(x, 'display', 'block');
					YAHOO.util.Dom.setStyle(y, 'display', 'block');
				}
					
			}
			 
}

function loadItem(itemId, userId){
	
	changeItemBgColor ('#000');
	
	var loadItemDetails = {
			
		startTransaction:function() {
			
			YAHOO.util.Dom.setStyle('photoContainerTexture', 'backgroundImage', 'none');
							  
			YAHOO.util.Connect.asyncRequest('GET', '/main.php?g2_itemId=' + itemId, callback, null);
			document.getElementById('photoContainerShowOn').innerHTML = "<div id='itemLoader'>"+progressBar+"</div>";
			
			},
		  
		responseSuccess:function(o){
			
			document.getElementById('photoWrapper').innerHTML = o.responseText;
					  
						  
			if (document.getElementById('cfv_FullPage')){
				pageData();
			}else{
				if (userId){
				  itemData(itemId, userId);
				}else{
				  itemData(itemId);
				}
			}
			
			
			},
		  
		responseFailure:function(o){
			
			notify('warn', o.statusText, o.responseText);
			
			
			}
	}
	
	var callback =
	{
	  success:loadItemDetails.responseSuccess,
	  failure:loadItemDetails.responseFailure,
	  scope:loadItemDetails
	};
	
	
	loadItemDetails.startTransaction();
}

function printThis(container){

var printItems = YAHOO.util.Dom.getElementsByClassName('printLink', 'div');
	if (window.print){
				
		for (var i=0;i<printItems.length;i++)	{
			YAHOO.util.Dom.setStyle(printItems[i], 'display', 'none');
		}
		
		var divToPrint=document.getElementById(container);
		newWin= window.open("printPae");
		
		if (newWin.document.write(divToPrint.outerHTML)){
		newWin.document.write(divToPrint.outerHTML);
		newWin.print();
		}else{
			alert("Print function not supported with your browser at this time. We are working to solve this.");
			return;
		}
				
		for (var i=0;i<printItems.length;i++)	{
			YAHOO.util.Dom.setStyle(printItems[i], 'display', 'block');
		}
		newWin.close();
		
	}else{
		
		alert("The print function is not compatible with your browser");
		for (var i=0;i<printItems.length;i++)	{
			YAHOO.util.Dom.setStyle(printItems[i], 'display', 'none');
		}
	}
}

function getBg(itemId, itemContainer){
	
var imageBlockImageDetails = {
			
		startTransaction:function() {
			
			YAHOO.util.Connect.asyncRequest('GET', '/themes/wildsidegothic/templates/getBg.php?itemId=' +itemId, callback, null);
			
			},
		  
		responseSuccess:function(o){
			
			if (itemContainer == null){
				itemContainer = 'imageBlockImage_'+itemId;
			}
			
			var data = o.responseText.split(", ");
				if (data[1] != null){
				  var items = YAHOO.util.Dom.getElementsByClassName(itemContainer, 'li');
							  
				  for (var i=0;i<items.length;i++)	{
					  YAHOO.util.Dom.setStyle(items[i], 'backgroundColor', data[1]);
				  }
				  
				}
				if (data[0] != "custom"){
				  if (data[0] != null){
					data = data[0];
					for (var i=0;i<items.length;i++)	{
					  YAHOO.util.Dom.setStyle(items[i], 'backgroundColor', itemBackgrounds[data]);
					}
				  }
				}
				if (data[2] != null){
				  changeItemTexture(data[2], itemContainer);
				}
					
			},
		  
		responseFailure:function(o){
			
			return;
			
			}
	}
	
	
	var callback =
	{
	  success:imageBlockImageDetails.responseSuccess,
	  failure:imageBlockImageDetails.responseFailure,
	  scope:imageBlockImageDetails
	};
	
	
	imageBlockImageDetails.startTransaction();
	
}

function pageDefaults (userId){

if (YAHOO.util.Cookie.get("itemDisplay")){
var itemId = YAHOO.util.Cookie.get("itemDisplay");
  if (itemId != 'skip'){
	  if (BrowserDetect.browser == 'Explorer'){
		if (BrowserDetect.version <= '6'){
		  return;
		}else{
		  itemDisplay(itemId);
		}
	  }else{
		  itemDisplay(itemId);
	  }
  }
YAHOO.util.Cookie.remove("itemDisplay", { expires: new Date("January 12, 2025"), path: "/" });
}
	

if (document.getElementById('membersOnline')){
	var parent = document.getElementById('membersOnline');
	var onlineCount = parent.getElementsByTagName('span').length;
	document.getElementById('onlineCount').innerHTML = onlineCount;
}
	

var  myFavsCount = {
			
		startTransaction:function() {
			
			YAHOO.util.Connect.asyncRequest('GET', '/themes/wildsidegothic/templates/myFavsCount.php?userId=' +userId, callback, null);
			
			},
		  
		responseSuccess:function(o){
			
			var favs = o.responseText;
			if (document.getElementById('favItemCount')){
			  document.getElementById('favItemCount').innerHTML = favs;
			  if (favs == '1'){
			  document.getElementById('favItemLabel').innerHTML = 'item';
			  }else{
			  document.getElementById('favItemLabel').innerHTML = 'items';
			}
			}
					
			},
		  
		responseFailure:function(o){
			
			return;
			
			}
	}
	
	
	var callback =
	{
	  success:myFavsCount.responseSuccess,
	  failure:myFavsCount.responseFailure,
	  scope:myFavsCount
	};
	
	
	myFavsCount.startTransaction();

}