//original file: util.js----------------------------------------------------------
	function addLoadListener(fn) {

		if (typeof window.addEventListener != 'undefined') {
			window.addEventListener('load', fn, false);
		} else if (typeof document.addEventListener != 'undefined') {
			document.addEventListener('load', fn, false);
		} else if (typeof window.attachEvent != 'undefined') {
			window.attachEvent('onload', fn);
		} else {
			var oldfn = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = fn;
			} else {
				window.onload = function() {
					oldfn();
					fn();
				};
			}
		}
	}


	function attachEventListener(target, eventType, functionRef, capture) {
		if (typeof target.addEventListener != "undefined") {
			target.addEventListener(eventType, functionRef, capture);
		} else if (typeof target.attachEvent != "undefined") {
			target.attachEvent("on" + eventType, functionRef);
		} else {
			eventType = "on" + eventType;
			if (typeof target[eventType] == "function") {
				var oldListener = target[eventType];
				target[eventType] = function() {
					oldListener();
					return functionRef();
				}
			} else {
				target[eventType] = functionRef;
			}
		}
		return true;
	}


	function getElementsByAttribute(attribute, attributeValue)
	{
		var elementArray = new Array();
		var matchedArray = new Array();

		if (document.all) {
			elementArray = document.all;
		} else {
			elementArray = document.getElementsByTagName("*");
		}

		for (var i = 0; i < elementArray.length; i++) {
			if (attribute == "class") {
				var pattern = new RegExp("(^| )" + attributeValue + "( |$)");
				if (elementArray[i].className.match(pattern)) {
					matchedArray[matchedArray.length] = elementArray[i];
				}
			} else if (attribute == "for") {
				if (elementArray[i].getAttribute("htmlFor") || elementArray[i].getAttribute("for")) {
					if (elementArray[i].htmlFor == attributeValue) {
						matchedArray[matchedArray.length] = elementArray[i];
					}
				}
			} else if (elementArray[i].getAttribute(attribute) == attributeValue) {
				matchedArray[matchedArray.length] = elementArray[i];
			}
		}
		return matchedArray;
	}

	function preloadImage(src, protocolDomain){
        if(protocolDomain){
                src = protocolDomain+src;
        }
        var image = new Image();
        image.src = src;

    }

	function preload_cart_images(prefix) {

		/* images from cart_info.jsp */
		var image1 = new Image();
		image1.src = prefix + '/images/logo_alt.gif';
		var image2 = new Image();
		image2.src = prefix + '/images/checkout.gif';
		var image3 = new Image();
		image3.src = prefix + '/images/sign_in_pop.gif';
		var image4 = new Image();
		image4.src = prefix + '/images/close.gif';
		var image5 = new Image();
		image5.src = prefix + '/images/keep_shopping_txt.gif';
		var image6 = new Image();
		image6.src = prefix + '/images/hackersafe-2.gif';

		/* images from css */
		var image7 = new Image();
		image7.src = prefix + '/images/3.gif';
		var image8 = new Image();
		image8.src = prefix + '/images/fade.png';
		var image9 = new Image();
		image9.src = prefix + '/images/cart_top3.gif';
		var image10 = new Image();
		image10.src = prefix + '/images/cart_shade_tile.png';
		var image11 = new Image();
		image11.src = prefix + '/images/gradient_4.gif';
		var image12 = new Image();
		image12.src = prefix + '/images/cart_bottom.png';

		var image13 = new Image();
		image13.src = prefix + '/images/logo.png';
		var image14 = new Image();
		image14.src = prefix + '/images/checkout.png';
		var image15 = new Image();
		image15.src = prefix + '/images/bg.gif';
		var image16 = new Image();
		image16.src = prefix + '/images/cart_shade_tile2.gif';
		var image17 = new Image();
		image17.src = prefix + '/images/utility_nav_bg.gif';
		var image18 = new Image();
		image18.src = prefix + '/images/sign_in.gif';
		var image19 = new Image();
		image19.src = prefix + '/images/close_2.gif';
		var image20 = new Image();
		image20.src = prefix + '/images/submit2.gif';
		var image21 = new Image();
		image21.src = prefix + '/images/international.gif';
		var image22 = new Image();
		image22.src = prefix + '/images/back.gif';
		var image23 = new Image();
		image23.src = prefix + '/images/continue_2.gif';

		/*nav*/
		var image24 = new Image();
		image24.src = prefix + '/images/nav_bg.gif';
		var image25 = new Image();
		image25.src = prefix + '/images/nav.gif';
		var image26 = new Image();
		image26.src = prefix + '/images/nav_corner_r.png';
		var image27 = new Image();
		image27.src = prefix + '/images/main_bg.gif';
		var image28 = new Image();
		image28.src = prefix + '/images/shadow.png';
		var image29 = new Image();
		image29.src = prefix + '/images/top_shade.png';

		var image30 = new Image();
		image30.src = prefix + '/images/styles_bg.gif';
		var image31 = new Image();
		image31.src = prefix + '/images/delete_x.png';
		var image31 = new Image();
		image31.src = prefix + '/images/item_slot_blink.gif';
		var image32 = new Image();
		image32.src = prefix + '/images/up.gif';
		var image33 = new Image();
		image33.src = prefix + '/images/down.gif';
		var image34 = new Image();
		image34.src = prefix + '/images/foot_go.gif';
		var image35 = new Image();
		image35.src = prefix + '/images/close_x.gif';
		var image36 = new Image();
		image36.src = prefix + '/images/thawte.gif';
		var image37 = new Image();
		image37.src = prefix + '/images/gradient_2.gif';
		var image38 = new Image();
		image38.src = prefix + '/images/cart_bg.gif';
		var image39 = new Image();
		image39.src = prefix + '/images/cart_bg.gif';
		var image40 = new Image();
		image40.src = prefix + '/images/empty_bg.gif';



	}

	function preload_cat_overlay(prefix) {
		var image1 = new Image();
		image1.src = prefix + '/images/popup_bg.png';
	}

	function preload_atc(prefix) {
		var image1 = new Image();
		image1.src = prefix + '/images/add_to_cart_over.gif';
	}

	function preload_ajax_loader(prefix) {
		var image1 = new Image();
		image1.src = prefix + '/images/fade.png';
	}

//original file: cart_scrolling.js----------------------------------------------------------

	function cart_scrolling(){

		var scrollId = document.getElementById('scroll');
		var cartItems = document.getElementById('cartitems');

		if (!cartItems) { return; }

		/* there should be at least 3 */
		var sets = cartItems.getElementsByTagName('ul');


		// this is to hide all but the last three
		if (sets.length > 3) {
			for (i = sets.length - 3; i--; i >= 0) {
				sets[i].style.display = "none";
			}
		}

		// this is hide all but the first three
		//for (i=3; i<sets.length; i++) {
		//	sets[i].style.display = "none"; // initially, hide all uls except the first three
		//}





		// use this if you are hiding all but the first three =====================
		//var pageup = document.getElementById('pageup');
		//pageup.style.display = "none";

		//if (sets.length > 3) {
		//	scrollId.style.display = "block"; 	/* display paging arrows */

		//	var pageup = document.getElementById('pageup');
		//	var pagedown = document.getElementById('pagedown');

		//	attachEventListener(pageup, "click", scrollUp, false);
		//	attachEventListener(pagedown, "click", scrollDown, false);
		//}
		// =========================================================================



		// use this if you are hiding all but the last three ==========================
		var pagedown = document.getElementById('pagedown');
		pagedown.style.display = "none";
		if (sets.length > 3) {
			scrollId.style.display = "block"; 	/* display paging arrows */

			var pageup = document.getElementById('pageup');
			var pagedown = document.getElementById('pagedown');

			attachEventListener(pageup, "click", scrollUp, false);
			attachEventListener(pagedown, "click", scrollDown, false);
		}
	}

	/* use this if you are hiding all but the first three rows */
	/*
	function scrollDown() {
		var current = document.getElementById('current');
		var currentInt = parseInt(current.value);
		var firstBatch = document.getElementById('batch' + currentInt);
		firstBatch.style.display = "none";
		var counter = (currentInt) + 3;
		var nextVisible = document.getElementById('batch' + counter);
		nextVisible.style.display = "block";
		current.value = currentInt + 1;
		var pageup = document.getElementById('pageup');
		pageup.style.display = "block";
		var pagedown = document.getElementById('pagedown');
		var nextPossibleValue = (currentInt) + 4;
		var nextPossibleList = document.getElementById('batch' + nextPossibleValue);

		if (!nextPossibleList) {
			pagedown.style.display = "none";
		}
	}
	*/

	/* use this if you are hiding all but the first three rows */
	/*
	function scrollUp() {
		var current = document.getElementById('current');
		var currentInt = parseInt(current.value);
		var counterLastRow = (currentInt) +  2;
		var firstBatch = document.getElementById('batch' + counterLastRow);
		firstBatch.style.display = "none";
		var counter = (currentInt) - 1;
		var nextVisible = document.getElementById('batch' + counter);
		nextVisible.style.display = "block";
		current.value = currentInt - 1;
		var pagedown = document.getElementById('pagedown');
		pagedown.style.display = "block";
		var pageup = document.getElementById('pageup');
		var nextPossibleValue = (currentInt) + 4;
		var nextPossibleList = document.getElementById('batch' + nextPossibleValue);

		if (counter == 1) {
			pageup.style.display = "none";
		}
	}
	*/

	/* use this if you are hiding all but the last three rows */
	function scrollDown() {

		/* last row */
		var bottom = document.getElementById('current');
		var bottomInt = parseInt(bottom.value);

		var topRow = document.getElementById('batch' + (bottomInt - 2));

		var nextBottomRow = bottomInt + 1;
		var bottomRow = document.getElementById('batch' + nextBottomRow);

		if (bottomRow) {

			/* hide top row */
			topRow.style.display = 'none';

			/* show next bottom hidden row */
			bottomRow.style.display = 'block';
		}

		var nextNextBottomRow = document.getElementById('batch' + (nextBottomRow + 1));

		if (!nextNextBottomRow) {

			/* no more bottom rows to show */
			var pagedown = document.getElementById('pagedown');
			pagedown.style.display = "none";
		}

		var pageup = document.getElementById('pageup');
		pageup.style.display = 'block';
		bottom.value = bottomInt + 1;
	}

	/* use this if you are hiding all but the last three rows */
	function scrollUp() {

		/* last row */
		var bottom = document.getElementById('current');
		var bottomInt = parseInt(bottom.value);

		/* hide bottom row */
		var bottomRow = document.getElementById('batch' + bottomInt);
		bottomRow.style.display = 'none';

		/* show next top hidden row */
		var nextTopRow = (bottomInt) - 3;
		var topRow = document.getElementById('batch' + nextTopRow);
		topRow.style.display = 'block';

		if (nextTopRow == 1) {
			var pageup = document.getElementById('pageup');
			pageup.style.display = "none";
		}

		var pagedown = document.getElementById('pagedown');
		pagedown.style.display = 'block';
		bottom.value = bottomInt - 1;
	}

//original file: cart.js----------------------------------------------------------

	addLoadListener(hoverCheckout);
	addLoadListener(hoverDelete);

	/*on detail page when you hover over the atc button */
	addLoadListener(addCartHover);

	/*show a different color when they hover over arrow when their is more than 9 products in the cart */
	addLoadListener(hoverArrow);

	/* product detail page, a new image is shown when customer hover over different views */
	addLoadListener(viewHover);


	   /**
	    * Update the cart status that is shown on the static page
	    */
		function updateCart(response, arg) {

			asyncGet(arg.context + '/templates/cart_info.jsp', 'updateCartDisplay', {'elementId': arg.elementId});

		}

		function updateCartDisplay(response, arg) {

			document.getElementById(arg.elementId).innerHTML= response;

			//show up and down arrow if necessary
			cart_scrolling();



			/* Fix IE png transparency issue, we need timeout because we need the checkout.png image to
			 * be downloaded FIRST before we pngfix it, or IE6 will be stuck on downloading checkout.png
			 */
 			var arVersion = navigator.appVersion.split("MSIE")
			var version = parseFloat(arVersion[1])
			if ((version < 7) && (document.body.filters)){
				pngfixer(document.getElementById('checkout'), '');
				hoverCheckout();
			}

			hoverDelete();

			setHeight();

			load_javascript(staticPath+"/scripts/size_chart.js");

			/* Alternate IE solution...
			if ((version < 7) && (document.body.filters))
			{
				setTimeout("pngfixer(document.getElementById('checkout'), '');", 500);
				setTimeout("hoverCheckout()", 750);
			}
			*/
		}

		/**
		 * Updates the layer(popup) div contain the checkout page.
		*/
		function updateCOPage(response, arg) {

			var pos = response.indexOf("Thank You for Your Order");

			if(pos >=0) {
				location.href = arg.success_url;

			} else {
				document.getElementById(arg.elementId).innerHTML= response;
				//close the ajax loader
				closeAjaxLoader();
			}

			myregexp = new RegExp("<!--current_page:(.*)-->");
            mymatch = myregexp.exec(response);

            if(mymatch){
                current_co = mymatch[1];

                yahoo_tracking();
                google_tracking();
            }

		}




		function multiShipment(vf, context) {

 			var step = document.getElementById("STEP");
 			step.value = "10";

 			var successMultiShipCheckout = document.getElementById("successMultiShipCheckout");

 			//alert('the value for success multi co is ' + successMultiShipCheckout.value);

 			var successCheckout = document.getElementById("successCheckout");

 			successCheckout.value = successMultiShipCheckout.value;

 			var field = document.createElement("input");
			field.setAttribute("type","hidden");
			field.setAttribute("value","");
			field.setAttribute("name","goto_multiship");
			vf.appendChild(field);
 			asyncPost(context + '/servlet/Cart', vf, 'updateCOPage', {'elementId': 'co_top'});

         }


         /*
         *  We could not using quotes in the jsonString (issue with escaping).  Instead, we used "::", so we need to search and replace.
	     */

         function onShippingMethodChangeUpdateTotalDiv(jsonString) {

			jsonString = jsonString.replace(/::/g, '"');
			var shippingJSONObject = eval( '(' + jsonString + ')' );
			var totalPrice = document.getElementById('totalPrice');
			var taxAmount = document.getElementById('taxAmount');
			var shippingDiscount = document.getElementById('shippingDiscount');
			var shippingMethod = document.getElementById('shipping_method_id');

			//alert('the selected in is ' + shippingMethod.selectedIndex);

			for(sm in shippingJSONObject.totalPrice) {

				if(shippingMethod.options[shippingMethod.selectedIndex].value == sm) {

					totalPrice.innerHTML = shippingJSONObject.totalPrice[sm];
				}

			}

			for(sm in shippingJSONObject.tax) {

				if(shippingMethod.options[shippingMethod.selectedIndex].value == sm) {
					taxAmount.innerHTML = shippingJSONObject.tax[sm]
				}

			}

			if(shippingDiscount) {
				for(sm in shippingJSONObject.shippingDiscount) {

					if(shippingMethod.options[shippingMethod.selectedIndex].value == sm) {
						shippingDiscount.innerHTML = shippingJSONObject.shippingDiscount[sm];
					}
				}
			}

		}



		function giftWrapStatus() {

 			var addGiftWrapping = document.getElementById("add_gift_wrapping");
 			var giftMessage = document.getElementById("gift_message_span");

 			if(addGiftWrapping.checked) {

 				giftMessage.style.visibility = 'visible';

 			} else {

 				giftMessage.style.visibility = 'hidden';
 				giftMessage.value= '';
 			}

 		}

 		function giftWrapStatus(k) {

			var addGiftWrapping = k.length > 0 ? document.getElementById("add_gift_wrapping_" + k) : document.getElementById("add_gift_wrapping");
			var giftMessage = k.length > 0 ? document.getElementById("gift_message_span_" + k) : document.getElementById("gift_message_span");

			if(addGiftWrapping.checked) {

				giftMessage.style.visibility = 'visible';

			} else {

				giftMessage.style.visibility = 'hidden';
				giftMessage.value= '';
			}

		}

		function handle_login_out(response, arg){
			document.getElementById(arg.elementId).innerHTML=response;
		}


		/*
		*	When a user select a color on the product detail page.
		* 1. we update the images
		* 2. update hidden form field choiceName_1 with the selected color value.
		* 3. update size dropdown options and deselect previous selected size if any
		* 4. change css class of selected color to indicate to user and deselect any other selected color option
		* 5. change the sku color in the product description to match the selected sku
		*
		*/
		function updateProductImageColorDetails(context, color_choice_value_id, color_name, product_id, imageJSON, sku_id) {

			/*Step 1 */

			//we need to substitute all "::" with quotes
			imageJSON = imageJSON.replace(/::/g, "\"");

			var imageJSONObj = eval('(' + imageJSON + ')');

			var main_view = document.getElementById('main_view');
			//thumbnail 3
			if(imageJSONObj.images[2].pv_3_m) {
				change_mouseover_image_ie6("view3", "product_main_image", imageJSONObj.images[2].pv_3_m, '', 'main_view');
				//main_view.className = "product";
				//swap_image("product_main_image", imageJSONObj.images[2].pv_3_m);
				 var imagePV3 = new Image();
                imagePV3.src = imageJSONObj.images[2].pv_3_m;
				//main_view.src= imagePV3.src;
				preloadImage(imageJSONObj.images[2].pv_3_m, secureProtocolDomain);
			}

			//thumbnail 1
			if(imageJSONObj.images[0].pv_1_m) {
				change_mouseover_image_ie6("view1", "product_main_image", imageJSONObj.images[0].pv_1_m, '', 'main_view');
				//main_view.className = "product";
				//swap_image("product_main_image", imageJSONObj.images[0].pv_1_m);
				var imagePV1 = new Image();
                imagePV1.src = imageJSONObj.images[0].pv_1_m;
				//main_view.src= imagePV1.src;
				preloadImage(imageJSONObj.images[0].pv_1_m, secureProtocolDomain);
			}


			//thumbnail 2
			if(imageJSONObj.images[1].pv_2_m) {
				change_mouseover_image_ie6("view2", "product_main_image", imageJSONObj.images[1].pv_2_m, '', 'main_view');
				//main_view.className = "product";
				//swap_image("product_main_image", imageJSONObj.images[1].pv_2_m);
				var imagePV2 = new Image();
                imagePV2.src = imageJSONObj.images[1].pv_2_m;
				main_view.src= imagePV2.src;
				preloadImage(imageJSONObj.images[1].pv_2_m, secureProtocolDomain);
			}

			var arVersion = navigator.appVersion.split("MSIE");
			var version = parseFloat(arVersion[1]);
			if (version < 7){
				//After a main image was swapped, run this once for IE6 browser for png transparency fix
				pngfixerproduct(main_view, '', '234', '282', '');
			}



			/*Step 2*/
			document.product_form.choiceName_1.value = color_choice_value_id;

			/*Step 3*/
			document.product_form.choiceName_2.value = '';
			var sizeInfo = document.getElementById('shoesize');
			if(sizeInfo)
				sizeInfo.innerHTML = 'Size';
			displayAddToCartButton(staticPath, context, '2', '1');

			document.getElementById("sizechart").innerHTML="<table cellspacing=\"0\" class=\"sizetable\"><tbody><tr><td colpan=\"4\" style=\"height:10px;\">please wait...</td></tr></tbody></table>";

			asyncGet(context + '/product/product_size.jsp', 'copyToElementInnerHtml', {'elementId': 'sizechart'}, 'product_id=' + product_id + '&color_choice_value_id=' + color_choice_value_id);

			/*Step 4*/
			var productColorOptionUL = document.getElementById('product_color_options');
			var sets = productColorOptionUL.getElementsByTagName('ul');

			for (i=0; i<sets.length; i++) {
				sets[i].getElementsByTagName('li')[0].className = "";
			}

			var selectProductColorLI = document.getElementById('color_' + color_choice_value_id);
			if(selectProductColorLI)
				selectProductColorLI.className = 'currentstyle';

			/*Step 5*/
			var skuColorInProductDescription = document.getElementById('sku_color');
			if(skuColorInProductDescription)
				skuColorInProductDescription.innerHTML = color_name;

			recentlyViewedSku(context, sku_id);

			scrollTo(0,0);
		}

		/*
		*	When a user select a size on the product detail page
		*	1. update hidden form field choiceName_2 with the selected size value.
		*   2. hide the size dropdown element.
		* 	3. update size info element with selected size value
		*/
		function updateProductSizeDetails(size_choice_value_id, size_choice_name, sizeElement) {
			document.product_form.choiceName_2.value = size_choice_value_id;
			hideElement(sizeElement);

			var sizeInfo = document.getElementById('shoesize');
			if(sizeInfo)
				sizeInfo.innerHTML = size_choice_name;
		}

		// calls updateProductSizeDetails(size_choice_value_id, size_choice_name, sizeElement)
		// and also the function to display the correct "add to cart" button
		function updateProductSizeDetailsShowCartButton(staticPath, contextPath, sizeChoiceNameId, colorChoiceNameId, size_choice_value_id, size_choice_name, sizeElement) {
			updateProductSizeDetails(size_choice_value_id, size_choice_name, sizeElement);
			displayAddToCartButton(staticPath, contextPath, sizeChoiceNameId, colorChoiceNameId);
		}


		/*
		*	Same as above, but for popups. We need a different name than 'shoesize'
		*   to distinguish parent window and children window elements. Currently
		*   specifically used by out of stock popup.
		*/
		function updateProductSizeDetailsPopup(size_choice_value_id, size_choice_name, sizeElement) {
			document.outofstockform.choiceName_2.value = size_choice_value_id;
			hideElement(sizeElement);

			var sizeInfo = document.getElementById('shoesize_popup');
			if(sizeInfo)
				sizeInfo.innerHTML = size_choice_name;

			/* update hidden param as well, this is what the form actually needs to process */

		}




		/*
		*	When a user select a size on the product cat all page
		*	1. update hidden form field choiceName_2 with the selected size value.
		*   2. hide the size dropdown element.
		* 	3. update size info element with selected size value
		*/
		function updateCatProductSizeDetails(key_id, size_choice_value_id, size_choice_name) {
			var sizeChoice = eval('document.form_' + key_id + '.choiceName_2');
			sizeChoice.value = size_choice_value_id;
			hideElement('sizechart_' + key_id);

			var sizeInfo = document.getElementById('shoesize_' + key_id);
			if(sizeInfo)
				sizeInfo.innerHTML = size_choice_name;
			var img = document.getElementById('shoeimg_' + key_id);
            if(img){
                    img.src=staticPath+'/images/add.gif';
            }
		}


		function showSizeElement(d) {
			if(!document.product_form.choiceName_1.value) {alert('Please select a color/style first.');	return false; }
			showElement(d);
		}


		/* HOVER DELETE BUTTONS IN SHOPPING CART */

		function hoverDelete() {
			var buttons = getElementsByAttribute('class', 'delete');
			if (!buttons) { return; }

			for (i=0; i<buttons.length; i++) {
				attachEventListener(buttons[i], "mouseover", showDel, false);
				attachEventListener(buttons[i], "mouseout", hideDel, false);
			}

		}

		function showDel(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture;
			if(typeof staticPath == 'undefined'){
		        picture = "../images/delete_x_over.gif";
		    }else{
		        picture = staticPath+"/images/delete_x_over.gif";
		    }
			element.src = picture;
			//alert ('me');
		}

		function hideDel(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture;

			if(typeof staticPath == 'undefined'){
		        picture = "../images/delete_x.gif";
		    }else{
		        picture = staticPath+"/images/delete_x.gif";
		    }

			element.src = picture;
			//alert ('me');
		}





		/* HOVER CHECKOUT BUTTON */

	function hoverCheckout() {
		var checkout = document.getElementById('checkout');
		if (!checkout) { return; }

			attachEventListener(checkout, "mouseover", checkHover, false);
			attachEventListener(checkout, "mouseout", checkNormal, false);
	}

	function checkHover(event) {
		if (typeof event == "undefined") {
			event = window.event;
		}
		var element = getEventTarget(event);
		var picture = "//www.havaianasus.com/images/checkout_over.png";
		element.src = picture;

		var arVersion = navigator.appVersion.split("MSIE");
		var version = parseFloat(arVersion[1]);
		if (version < 7){
			// Fix png for IE
			pngfixer(element, " onmouseout=\"checkNormal()\" ");
		}
	}

	function checkNormal(event) {
		if (typeof event == "undefined") {
			event = window.event;
		}
		var element = getEventTarget(event);
		var picture = "//www.havaianasus.com/images/checkout.png";
		element.src = picture;

		var arVersion = navigator.appVersion.split("MSIE");
		var version = parseFloat(arVersion[1]);
		if (version < 7){
			// Fix png for IE
			pngfixer(element, " onmouseover=\"checkHover()\" ");
		}
	}

	/* FOR IE TO HOVER SIDEBAR SHOPPING ITEMS */
	function hoverLi(){
		var cartItems = document.getElementById('cartitems');
		if (!cartItems) { return; }
		var lis = cartItems.getElementsByTagName('li');

		for (i=0; i<lis.length; i++) {
			attachEventListener(lis[i], "mouseover", hoverProduct, false);
			attachEventListener(lis[i], "mouseout", normalProduct, false);
		}
	}


	/*extends the grey bg for popup cart page */
	function setHeight(){

            var container = document.getElementById('container');

            if (!container) { return; };

            var pixelHeight = container.offsetWidth;

            var co = document.getElementById('co_top');

            if (!co) { return; };

            co.style.height = pixelHeight + "px";

}






		/* ADD TO CART HOVER */
		function addCartHover() {
			var thisID = document.getElementById('addtocart');
			if (!thisID) { return; }
			attachEventListener(thisID, "mouseover", cartHover, false);
			attachEventListener(thisID, "mouseout", cartNormal, false);
		}

		function cartHover(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/add_to_cart_over.gif";
			element.src = picture;
		}

		function cartNormal(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/add_to_cart.gif";
			element.src = picture;
		}

		function displayAddToCartButton(staticPath, contextPath, sizeChoiceNameId, colorChoiceNameId) {
			var cart = document.getElementById('cart');

			if (cart) {
				var sizeVal = eval('document.product_form.choiceName_' + sizeChoiceNameId + '.value');
				var colorVal = eval('document.product_form.choiceName_' + colorChoiceNameId + '.value');

				if (sizeVal == '' || colorVal == '') {
					cart.style.background = 'url(' + staticPath + '/images/3_dimmed.gif)';
					cart.style.backgroundRepeat = 'no-repeat';
					cart.innerHTML = '<input type="image" src="' + staticPath + '/images/add_to_cart_out.gif" alt="Add to cart" class="submit" onclick="return false;">';
				} else {
					cart.style.background = 'url(' + staticPath + '/images/3.gif)';
					cart.style.backgroundRepeat = 'no-repeat';
					cart.innerHTML = '<input type="image" src="' + staticPath + '/images/add_to_cart.gif" id="addtocart" alt="Add to cart" class="submit" onclick="showBlinkingCartItem(); asyncPost(\'' + contextPath + '/servlet/Cart\', this.form, \'updateCart\', {\'elementId\': \'cart_info\', \'context\' : \'' + contextPath + '\'}); return false;" />';
				}
			}
		}












		/* PAGING ARROWS HOVER */
		function hoverArrow(){
				var pageup = document.getElementById('pageup');
				var pagedown = document.getElementById('pagedown');
				if (!pageup) { return };
				if (!pagedown) { return };

				attachEventListener(pageup, "mouseover", hoverUpArrow, false);
				attachEventListener(pageup, "mouseout", unHoverUpArrow, false);
				attachEventListener(pagedown, "mouseover", hoverDownArrow, false);
				attachEventListener(pagedown, "mouseout", unHoverDownArrow, false);
		}

		function hoverDownArrow(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/down_over.gif";
			element.src = picture;
		}

		function unHoverDownArrow(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/down.gif";
			element.src = picture;
		}

		function hoverUpArrow(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/up_over.gif";
			element.src = picture;
		}

		function unHoverUpArrow(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/up.gif";
			element.src = picture;
		}





		/* VIEW DETAIL HOVERS */
		function viewHover(){
				var view1 = document.getElementById('view1');
				var view2 = document.getElementById('view2');
				var view3 = document.getElementById('view3');
				if (!view1) { return };
				if (!view2) { return };
				if (!view3) { return };

				attachEventListener(view1, "mouseover", hoverView1, false);
				attachEventListener(view1, "mouseout", unHoverView1, false);
				attachEventListener(view2, "mouseover", hoverView2, false);
				attachEventListener(view2, "mouseout", unHoverView2, false);
				attachEventListener(view3, "mouseover", hoverView3, false);
				attachEventListener(view3, "mouseout", unHoverView3, false);
		}

		function hoverView1(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/view1_over.gif";
			element.src = picture;
		}

		function unHoverView1(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/view1.gif";
			element.src = picture;
		}

		function hoverView2(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/view2_over.gif";
			element.src = picture;
		}

		function unHoverView2(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/view2.gif";
			element.src = picture;
		}

		function hoverView3(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/view3_over.gif";
			element.src = picture;
		}

		function unHoverView3(event) {
			if (typeof event == "undefined") {
				event = window.event;
			}
			var element = getEventTarget(event);
			var picture = "../images/view3.gif";
			element.src = picture;
		}


	function closeSizeChart(element) {
		element.style.display = 'none';
	}

	function mouseLeaves (element, evt) {
		if (typeof evt.toElement != 'undefined' && typeof element.contains != 'undefined') {
			return !element.contains(evt.toElement);
		} else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
			return !contains(element, evt.relatedTarget);
		}
	}

	function contains (container, containee) {
		while (containee) {
			if (container == containee) {
				return true;
			}
			containee = containee.parentNode;
		}
		return false;
	}

	/* blink the next cart item slot where the item will be added to */
	function showBlinkingCartItem() {
		var nextCartItem = document.getElementById('empty_item_slot');
		nextCartItem.style.visibility = 'visible';
	}

	/* hover effect for header sign in, this is put in place to allow IE6 browsers to maintain hover
	 * effect WITHOUT putting a value in href because action for sign-in link is a popup */
	function hoverHeaderSignin(){
		document.getElementById('header_signin').style.backgroundPosition = '-265px  62px';
	}
	function normalHeaderSignin(){
		document.getElementById('header_signin').style.backgroundPosition = '-265px 0';
		document.getElementById('header_signin').style.left = '265px';
	}

	/* call this to cookie the customer that he/she left the cart - used to determine whether to display product detail flash */
	function setJustLeftCart() {
		createCookie('just_left_cart','true');
	}

	/* call this to determine if the customer just left the cart - this also optionally removes the cookie */
	function justLeftCart(remove) {
		var val = readCookie('just_left_cart');
		if (remove) {
			eraseCookie('just_left_cart');
		}
		return val == 'true';
	}

//original file: login.js---------------------------------------------------------
addLoadListener(userLogin);

/* LOGIN */

function userLogin() {
	var login = document.getElementById('login');
	var closeLogin = document.getElementById('closelog');
	attachEventListener(closeLogin, "mouseover", hoverCloseLogin, false);
	attachEventListener(closeLogin, "mouseout", unHoverCloseLogin, false);
	attachEventListener(login, "click", showLogIn, false);
	attachEventListener(closeLogin, "click", hideLogIn, false);
}

function showLogIn() {
	var logdiv = document.getElementById('logincontain');
	var login = document.getElementById('login');

	/* We need to disable the display of login form when user is already signed in */
	if (logdiv != "" && login.className != "signedin") {
 		logdiv.style.display = "block";
	};
}

function hideLogIn() {
	var logdiv = document.getElementById('logincontain');
	var login = document.getElementById('login');

	/* We need to disable the display of login form when user is already signed in */
	if (logdiv != "" && login.className != "signedin") {
 		logdiv.style.display = "none";
	};
}

function hoverCloseLogin(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);
	var picture;
	if(typeof staticPath == 'undefined'){
        picture = "../images/close_2_over.gif";
    }else{
        picture = staticPath+"/images/close_2_over.gif";
    }
	element.src = picture;
}

function unHoverCloseLogin(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);
	var picture;
	if(typeof staticPath == 'undefined'){
        picture = "../images/close_2.gif";
    }else{
        picture = staticPath+"/images/close_2.gif";
    }
	element.src = picture;
}

//original file: nav.js-----------------------------------------------------------

	addLoadListener(showSubnav);

	/* DISPLAY SUBNAVIGATION */

function showSubnav() {
	var community = document.getElementById('community');
	var subNav = document.getElementById('subnav');
	if (!community) { return; }

	attachEventListener(community, "mouseover", displayNav, false);
	attachEventListener(community, "mouseout", hideNav, false);
	attachEventListener(subNav, "mouseover", displayNav, false);
	attachEventListener(subNav, "mouseout", hideNav, false);

}

function displayNav(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);

	var subNav = document.getElementById('subnav');
	if (!subNav) { return; }
	subNav.style.display = "block";
}

function hideNav(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);

	var subNav = document.getElementById('subnav');
	if (!subNav) { return; }
	subNav.style.display = "none";
}

function getEventTarget(event) {
	var targetElement = null;

	if (typeof event.target != "undefined") {
		targetElement = event.target;
	} else {
		targetElement = event.srcElement;
	}

	while (targetElement.nodeType == 3 && targetElement.parentNode != null) {
		targetElement = targetElement.parentNode;
	}

	return targetElement;
}

//original file: country.js-----------------------------------------------------------
	addLoadListener(countryDropdown);


	/* INTERNATIONAL DROPDOWN */

	function countryDropdown() {
		var countryDiv = document.getElementById('international');
		var closeCountry = document.getElementById('closecountry');

		attachEventListener(closeCountry, "mouseover", hoverCloseCountries, false);
		attachEventListener(closeCountry, "mouseout", unHoverCloseCountries, false);
		attachEventListener(countryDiv, "click", showCountries, false);
		attachEventListener(closeCountry, "click", hideCountries, false);
	}

	function showCountries() {
		var countryDiv = document.getElementById('countrycontain');
		if (countryDiv) {
	 		countryDiv.style.display = "block";
		}
	}

	function hideCountries() {
		var countryDiv = document.getElementById('countrycontain');
		if (countryDiv) {
	 		countryDiv.style.display = "none";
		}
	}

function hoverCloseCountries(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);
	var picture;

	if(typeof staticPath == 'undefined'){
        picture = "../images/close_2_over.gif";
    }else{
        picture = staticPath+"/images/close_2_over.gif";
    }
	element.src = picture;
}

function unHoverCloseCountries(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);

	var picture;
	if(typeof staticPath == 'undefined'){
        picture = "../images/close_2.gif";
    }else{
        picture = staticPath+"/images/close_2.gif";
    }
	element.src = picture;
}

//original file: sizing.js-----------------------------------------------------------
addLoadListener(goSizeHover);

/* GO SIZE HOVER */
function goSizeHover() {
	var thisID = document.getElementById('gobutton');
	if (!thisID) { return; }
	attachEventListener(thisID, "mouseover", goHover, false);
	attachEventListener(thisID, "mouseout", goNormal, false);
}

function goHover(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);
	var picture = "../images/foot_go_over.gif";
	element.src = picture;
}

function goNormal(event) {
	if (typeof event == "undefined") {
		event = window.event;
	}
	var element = getEventTarget(event);
	var picture = "../images/foot_go.gif";
	element.src = picture;
}

//original file: url.js-----------------------------------------------------------
/* any javascript functions that manipulate URLs should be placed here */

/*
	pass in the protocol and domain and it will swap it into the _current_ location.
	you can use this to swap the current protocol and domain with a secure version.
*/
function swapProtocolDomain(protocolDomain) {

	/* no need to swap if they aren't different */
	var matchingIndex = window.location.href.indexOf(protocolDomain);
	if (matchingIndex > -1) {
		return window.location.href;
	}

	/* we'll search after the 7th char assuming "http://" */
	var slashIndex = window.location.href.indexOf('/', 7);

	/* if current protocol is "https://", we readjust to cater that instead */
	if(window.location.href.indexOf('https') > -1){
		slashIndex = window.location.href.indexOf('/', 8);
	}

	if (slashIndex > -1) {
		var swapOut = window.location.href.substr(0, slashIndex);
		var keep = window.location.href.substr(slashIndex);
		return protocolDomain + keep;
	} else {
		return protocolDomain;
	}
}

function gotoSwapProtocolDomain(protocolDomain){
        var resultURL = swapProtocolDomain(protocolDomain);
        if(window.location.href != resultURL){
                document.location=resultURL;
        }

}
