/*
 * menuExpandable2.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (dave@gazingus.org)
 */


if (!document.getElementById) {
    document.getElementById = function() { return null; }
}


var previousItemId = null;
var productsVisitedCookie = "productsVisited";
var productIdsCookie = "productIds";
var previousMenu = new Array();
var mainTitle = "Fox Racing Inc.";
var windowAlert = null;
function winAlert(string)
{
	if(windowAlert == null)
	{
		return;
		//windowAlert = window.open("web/pages/blank.html");

	}
	windowAlert.document.write(string+"<br>");
}

function goToHome()
{
	setCookie("selectedItem","");
	setCookie("menuState","");
	window.location = "AutoForward.do?forward=home.pagedef";
}

// ************************   METHODS FOR LEFT MENU BEHAVIOUR     *******************************

function expandMenus(loadItemPage)
{
    var nurl = window.location;
    var menuOpenString = getCookie("menuState");
    var queryString = new String(nurl).substring(new String(nurl).indexOf("?")+1);
    if(queryString == "forward=home.pagedef&home=home"){
	setCookie("selectedItem","");
	setCookie("menuState","");
        return;
    }
    if(menuOpenString == null || menuOpenString == "") return;
    //alert("menuOpenString: "+menuOpenString);
    var menuOpenArray = menuOpenString.split(",");
    for(var i=0; i<menuOpenArray.length; i++)
    {
		// get the gateway page
		showMenu(menuOpenArray[i], i);
	}
	winAlert("menuOpenArray.length = "+menuOpenArray.length+", previousMenu.length = "+previousMenu.length);
	for(var j=menuOpenArray.length; j<previousMenu.length; j++)
	{
		// close the other open menus
		hideMenu(previousMenu[j], j);
	}
	// show the last product page
	var itemIdSelected = getCookie("selectedItem");
	//alert("itemId is:"+itemIdSelected);
	selectItemOnMenu(itemIdSelected);
	//alert("item id selected: "+itemIdSelected);
	if(loadItemPage == null)
		showItemPage(itemIdSelected);
}

function selectItemOnMenu(itemId)
{
	//alert("select item:"+itemId);
	if(itemId == null || itemId == "") return;
	if(previousItemId != null && $(previousItemId) != null)
		$(previousItemId).className = "itemDeSelected";
	//alert("item id:"+itemId);
	var menuItem = itemKeys[itemId].split(",")[2];
	//alert("Menu item is:"+$(menuItem));
	if(menuItem != null && $(menuItem) != null){
        $(menuItem).className = "itemSelected";
        //alert("Menu item class is :"+$(menuItem).className);
        previousItemId = menuItem;
	}

}

function showItemPage(itemString)
{
	if(itemString == null || itemString == "") return;
	//alert("showItemPage("+itemString+")");
	var argArray = new Array();
	//argArray = itemString.split(",");
	argArray = itemKeys[itemString].split(",");
	callCategoryFromMenu(argArray[0], argArray[1], argArray[2], argArray[3]);
}

function showMenu(menuId, level, unSetProduct)
{
	//alert("showMenu(menuId="+menuId+", level="+level+")");
	var tabId = menuId+"Actuator";
	var menuName = menuId+"Menu";
	winAlert("tabId is: "+tabId+", menuName: "+menuName);
	//alert("previous menu"+previousMenu[level]+"Actuator");
	if(previousMenu[level] != null)
	{
		if($(previousMenu[level]+"Actuator") && $(previousMenu[level]+"Actuator")!=null && ((previousMenu[level]+"Actuator")=="Clearance@@@70008Actuator" || (previousMenu[level]+"Actuator")== "Holiday Sale@@@70008Actuator" || (previousMenu[level]+"Actuator")== "Holiday_Sale@@@70008Actuator"  )) {
			 //alert("into clearance");
                        $(previousMenu[level]+"Actuator").className = "clearance";
		}else {
			//alert("into not clearance");
			$(previousMenu[level]+"Actuator").className = "topTabDeSelected";
		}
		//winAlert("previousMenu["+level+"] = "+previousMenu[level]);

		if($(previousMenu[level]+"Menu") && $(previousMenu[level]+"Menu")!=null )
			$(previousMenu[level]+"Menu").style.display = "none";
	}
	//alert("select/deselct:"+$(tabId));
	if($(tabId) != null && menuId != 'Holiday_Sale@@@70008') {
                $(tabId).className = "topTabSelected";
        }else {
                 $(tabId).className = "clearance";

        }
	if($(menuName)!=null)
		$(menuName).style.display = "block";
	if(previousItemId) $(previousItemId).className = "itemDeSelected";
	previousMenu[level] = menuId;
	if(unSetProduct != null)
	{
		setCookie("selectedItem", "");
	}
	setMenuStateCookie(menuId, level);

}

function hideMenu(menuId, level)
{
	//alert("hideMenu('"+menuId+"', "+level+")");
	var tabId = menuId+"Actuator";
	var menuName = menuId+"Menu";
	if($(tabId) == null || $(menuName) == null  )return;
	if( (previousMenu[level]+"Actuator")!='Clearance@@@70008Actuator' || ((previousMenu[level]+"Actuator")!= "Holiday Sale@@@70008Actuator" || (previousMenu[level]+"Actuator")!= "Holiday_Sale@@@70008Actuator" )){
		//alert("into not clearance"); 
		$(tabId).className = "topTabDeSelected";
	}else{
		//alert("into clearance ");
		$(tabId).className = "clearance";
	}
	$(menuName).style.display = "none";
}

function setProductPageMenu(itemId)
{
	winAlert("menu State is:"+menuStates[itemId]);
	setCookie("menuState", menuStates[itemId]);
	setCookie("selectedItem", itemId);
	expandMenus(false);
}

function setMainMenu(menuString)
{
	setCookie("menuState", menuString);
	setCookie("selectedItem", "");
	expandMenus(false);

}
function setMenuLevel(level)
{
	winAlert("setMenuLevel:"+level);
	if(level == null) return;
	var cookieText = "";
	for(var i=0; previousMenu[i] != null && i<=level; i++)
	{

		cookieText += previousMenu[i]
		if(i<level) cookieText += ",";
	}
	// unset the later levels
	for(var j=level+1; previousMenu[j] != null && previousMenu != "" && j< previousMenu.length; j++)
	{
		//alert("unset #"+j+": "+previousMenu[j]);
		if($(previousMenu[j]+"Actuator") == null) return;
		$(previousMenu[j]+"Actuator").className = "topTabDeSelected";
		$(previousMenu[j]+"Menu").style.display = "none";
		previousMenu[j] = null;

	}
	setCookie("menuState", cookieText);
}


function setMenuStateCookie(menuId, level)
{
	//previousMenu
	winAlert("setMenuCookieState("+menuId+", "+level+")");
	var cookieText = "";
	if(level==0) cookieText = menuId;

	for(var i=0; i<=level && level > 0; i++)
	{
		winAlert("#"+i+":"+previousMenu[i]);
		cookieText += previousMenu[i]
		if(i<level) cookieText += ",";
	}
	setCookie("menuState", cookieText);
}

//show root category pages
function showMainTab(url, menuId)
{
	showMenu(menuId, 0);
	get(url);
	setCookie("selectedItem", "");

}
// show sub category pages
function callCategoryFromMenu(cname, catid, itemid, itemLevel) {
		var id = catid;
        cname = cname.replace("&" , "_AND_");
        setMenuLevel(itemLevel);
		if(previousItemId) $(previousItemId).className = "itemDeSelected";
		//winAlert("item id:"+itemid);
		selectItemOnMenu(catid);
        setCookie("selectedItem", catid);
        get("CatalogForward.do?aforward=asyn&cname="+cname+"&cid="+catid+"&itemId="+itemid+"&menuLevel="+itemLevel);
}

var divisionName = "contentArea"; var getFlag="";
function get(url, divName, noSetHash)
{
		if(!document.all || isOpera) // not IE
		{
			getAjax(url, divName, noSetHash);
			return;
		}
	    if(divName == null) divName = 'contentArea';
       	getFlag = "get";
		getURL = url;
		divisionName = divName;
		window.contentFrame.location = url;
}

function getAjax(url, divName, noSetHash)
{

	//alert("getAjax:"+url);
	if(new String(window.location).indexOf(url) < 0 && noSetHash == null)
	{
		//alert("url = window.location");
		//currentHash = url
		setFragmentIdentifier(url);
	}
	if(divName == null) divName = 'contentArea';
	//alert("content Area is:"+$("contentArea"));
	url += "&noHash=true";
	var getAjaxVar = new Ajax.Updater(
				divName,
				url,
				{
					method: 'get',
					evalScripts: true,
					onComplete: showDiv
				});
	//alert("gotAjax");
}

function showDiv()
{
	//alert("showing div: ");
	$(divisionName).style.visibility = "visible";
}

//  back/front button
function showHistoryMenu()
{
		// copy the content first
		$(divisionName).innerHTML = window.frames["contentFrame"].document.documentElement.innerHTML
		winAlert("showHistoryMenu");

		if($("topMenu") != null)
		{
			winAlert("Top tab is: "+$("topMenu"));
			// set this top tab and unset the previous menu item
			if(previousItemId) $(previousItemId).className = "itemDeSelected";

			// set the top tab
			var previousActuator = previousMenu[0]+"Actuator";
			if($("topMenu").innerHTML != previousActuator)
			{
				showMenu($("topMenu").innerHTML, 0);
			}

			return;
		}

		if($("itemId") == null) return;
		//winAlert("itemTabs are: "+getCookie("itemTabs"+$("itemId").innerHTML));
		setCookie("menuState", menuStates[$("itemId").innerHTML]);
		//setCookie("selectedItem", $("selectedItemCookieString").innerHTML);
		setCookie("selectedItem", $("itemId").innerHTML);
		expandMenus(false);

		/*var itemString = $("itemString").innerHTML;
		if(previousItemId) $(previousItemId).className = "itemDeSelected";
        $(itemString).className = "itemSelected";
		previousItemId = itemString;*/
}

// copies the content to iframe
function copyContent()
{
	if(new String(window.frames["contentFrame"].document.location).indexOf("blank.html")>0) return;
	divName = divisionName;
	var contentSize;
	if(getFlag == "" ) // Back/forward
	{
		showHistoryMenu();
		return;
	}
	if($(divName) == null && divName == "contentArea")
	{
		setTimeout("copyContent()", 300);
		return;
	}

	if($(divName))
	{
		$(divName).innerHTML = window.frames["contentFrame"].document.documentElement.innerHTML
		$(divName).style.visibility = "visible";
	}
	getFlag = "";
	//hideWaiting()
}

//********************** END OF LEFT MENU BEHAVIOUR METHODS         ***********************




// PRODUCT PAGE CODE

function changeOnSize() {
	var selectedSizeIndex = document.productForm.sizeSelect.selectedIndex;
	if (selectedSizeIndex == 0)	{
		selectedSizeIndex = 1;
	}
	var selectedSize = document.productForm.sizeSelect.options[selectedSizeIndex].value;
	var newColorsForSizeIndex = 0;
	var newColorsForSize = new Array();
	for(var forLoop=0; forLoop < allSizesArray.length; forLoop++) {
		if (allSizesArray[forLoop] == selectedSize) {
			if (newColorsForSizeIndex == 0) {
				newColorsForSize[newColorsForSizeIndex] = allColorsArray[forLoop];
				priceArray[newColorsForSizeIndex] = allPriceArray[forLoop];
				imageArray[newColorsForSizeIndex] = allImagesArray[forLoop];
				imageTArray[newColorsForSizeIndex] = allImagesTArray[forLoop];
				idsForSize[newColorsForSizeIndex] = allItemIdsArray[forLoop];
				salePriceArray[newColorsForSizeIndex] = allSalePriceArray[forLoop];
				onSaleArray[newColorsForSizeIndex] = allOnSaleArray[forLoop];
				newColorsForSizeIndex++;
			} else {
				var status = 0;
				for (var iforLoop = 0; iforLoop < newColorsForSize.length; iforLoop++)
				{
						if(newColorsForSize[iforLoop] == allColorsArray[forLoop])
						{
								status = 1;
						}
					}
				if(status == 0)
				{
					newColorsForSize[newColorsForSizeIndex] = allColorsArray[forLoop];
					priceArray[newColorsForSizeIndex] = allPriceArray[forLoop];
					imageArray[newColorsForSizeIndex] = allImagesArray[forLoop];
					imageTArray[newColorsForSizeIndex] = allImagesTArray[forLoop];
					idsForSize[newColorsForSizeIndex] = allItemIdsArray[forLoop];
					salePriceArray[newColorsForSizeIndex] = allSalePriceArray[forLoop];
					onSaleArray[newColorsForSizeIndex] = allOnSaleArray[forLoop];
					newColorsForSizeIndex++;
				}
			}
		}
	}
	for(var i=0; i<newColorsForSize.length; i++)
	{
		var minValueIndex = i;
		for(var j=i+1; j<newColorsForSize.length; j++)
		{
			if(newColorsForSize[i].toLowerCase() > newColorsForSize[j].toLowerCase())
			{ minValueIndex = j; }
		}
		if(minValueIndex != i)
		{
			var colorTemp = newColorsForSize[i];
			newColorsForSize[i] = newColorsForSize[minValueIndex];
			newColorsForSize[minValueIndex] = colorTemp;
			var priceTemp = priceArray[i];
			priceArray[i] = priceArray[minValueIndex];
			priceArray[minValueIndex] = priceTemp;
			var imageTemp = imageArray[i];
			imageArray[i] = imageArray[minValueIndex];
			imageArray[minValueIndex] = imageTemp;
			var imageTTemp = imageTArray[i];
			imageTArray[i] = imageTArray[minValueIndex];
			imageTArray[minValueIndex] = imageTTemp;
			var idTemp = idsForSize[i];
			idsForSize[i] = idsForSize[minValueIndex];
			idsForSize[minValueIndex] = idTemp;
			var salePriceTemp = salePriceArray[i];
			salePriceArray[i] = salePriceArray[minValueIndex];
			salePriceArray[minValueIndex] = salePriceTemp;
			var onSaleTemp = onSaleArray[i];
			onSaleArray[i] = onSaleArray[minValueIndex];
			onSaleArray[minValueIndex] = onSaleTemp;
		}
	}
	var colorSltTdee = "<select name='colorSelect' onChange='changeOnColor();'>";
	colorSltTdee = colorSltTdee + "<option value='notselected'>";
	if(formatOrColor == 1){ colorSltTdee = colorSltTdee + "Format"; }
	else { colorSltTdee = colorSltTdee + "Color"; }
	for(var forLoop=0; forLoop < newColorsForSize.length; forLoop++)
	{
		if(COLOR == newColorsForSize[forLoop])
		{
			colorSltTdee = colorSltTdee + "<option value='" + newColorsForSize[forLoop] + "' selected>" + newColorsForSize[forLoop];
			COLOR = "";
		}
		else
		{
			colorSltTdee = colorSltTdee + "<option value='" + newColorsForSize[forLoop] + "'>" + newColorsForSize[forLoop];
		}

	}
	colorSltTdee = colorSltTdee + "</select>";
	document.getElementById("colorSltTd").innerHTML = colorSltTdee;
	winAlert("  selected color "+  colorSltTdee);
	}

function changeOnColor() {
	if (sizeArrayLength != 0 && document.productForm.sizeSelect.value == "notselected")
	{
		document.productForm.colorSelect[0].selected=true;
		alert("Please select a Size First!!");
		document.productForm.sizeSelect.focus();
	}
	else {
	var selectedColorIndex = document.productForm.colorSelect.selectedIndex;
	if(selectedColorIndex == 0)
	{
		selectedColorIndex = 1;
	}
	var imageTdee = "";
	var priceTdee = "";
	imageTdee = "<img src='http://images.foxracing.com/" + imageArray[selectedColorIndex-1] + "' border='0'>";
    document.getElementById("imageTd").innerHTML = imageTdee;
	if((priceArray[selectedColorIndex-1] != salePriceArray[selectedColorIndex-1]) || (onSaleArray[selectedColorIndex-1] == "true"))
	{
		priceTdee = "<strike>$&nbsp;"+priceArray[selectedColorIndex-1]+"</strike>&nbsp;";
		priceTdee = priceTdee + "<font color=red><b>$&nbsp;" + salePriceArray[selectedColorIndex-1]  + "</b></font>";
	}
	else
	{
		priceTdee = "<b>$&nbsp;" + priceArray[selectedColorIndex-1]  + "</b>";
	}
	document.getElementById("priceTd").innerHTML = priceTdee;
	addToShoppingCartTdee = "<a href=\"javascript:addToShoppingCart('"+ idsForSize[selectedColorIndex-1] +"');\"><img src=\"web/images/add_to_cart1.gif\" border='0' alt=''></a>";
	document.getElementById("addToShoppingCartTd").innerHTML = addToShoppingCartTdee;
	addToWishListTdee = "<a href=\"javascript:addToWishList('"+ idsForSize[selectedColorIndex-1] +"');\"><img src=\"web/images/add_wish_list.gif\" border='0' alt=''></a>";
	document.getElementById("addToWishListTd").innerHTML = addToWishListTdee;

	itemId = idsForSize[selectedColorIndex-1];
	for(var i=0; i<allItemIdsArray.length; i++)
	{
		if(itemId == allItemIdsArray[i])
		{
			itemDetail = allItemDetailArray[i];
			break;
		}
	}
	if(itemDetail != null && itemDetail != "")
	{
		productDetailTdMain = "<a href='javascript:switchLayers(\"productDetailLayer\");'>PRODUCT DETAIL</a>";
		document.getElementById("productDetailTdMain").innerHTML = productDetailTdMain;
		productDetailLayer = "<TABLE width='100%' align='left'><TR><TD align='left' width='20%' class='normalText'><FONT color='blue'> <b>PRODUCT DETAIL :: &nbsp;</b></FONT></TD><TD align='left' class='normalText' width='80%'>"+itemDetail+"</TD></TR></TABLE>";
		document.getElementById("productDetailLayer").innerHTML = productDetailLayer;
	}
	}
}

function addToShoppingCart(itemId) {
	var quantity = document.productForm.quantity.value;
	if (sizeArrayLength != 0 &&
	    document.productForm.sizeSelect.value == "notselected") {
		alert("Please select a Size");
	} else if (colorsForSizeLength != 0 &&
	    document.productForm.colorSelect.value == "notselected")	{
		alert("Please select Color");
	} else if (quantity == "") {
		alert("Please select Quantity");
	} else {
		var categoryId= document.forms["productForm"].categoryId.value;
		var productId= document.forms["productForm"].productId.value;
		get("AddToShoppingCart.do?aforward=asyn&itemId="+ itemId +"&quantity="+ quantity +"&catId="+categoryId+"&proId="+productId+"&addToShoppingCart=yes");
	}
}

function addToWishList(itemId) {
	var quantity = document.productForm.quantity.value;

	if (sizeArrayLength != 0 &&
	    document.productForm.sizeSelect.value == "notselected")	{
		alert("Please select a Size");
	} else if (colorsForSizeLength != 0 &&
	           document.productForm.colorSelect.value == "notselected")	{
		alert("Please select Color");
	} else if (quantity == "") {
		alert("Please select Quantity");
	} else {
		var checkSignOnb = document.forms["productForm"].checkSignOn.value;
		var userName = document.forms["productForm"].userName.value;
		var categoryId= document.forms["productForm"].categoryId.value;
		var productId= document.forms["productForm"].productId.value;
		if (checkSignOnb == 'false' && userName == 'null') {
			//alert(" into login screen ");
			window.location = "AutoForward.do?forward=login.test&wishlist_itemId="+ itemId +"&wishlist_catId="+categoryId+"&wishlist_proId="+productId+"&toWishList=yes";
		} else {
			//alert("  into else ");
			window.location = "AddToWishList.do?wishlist_itemId="+ itemId +"&wishlist_catId="+categoryId+"&wishlist_proId="+productId;
		}
	}
}

function showShoppingCart() {
	window.location = "AutoForward.do?forward=shoppingcart.pagedef";
}

function openImage(largeImage, detailImage, backImage, standardImage)
{
	var pageURL = "web/pages/productimagedetailview.jsp?large="+largeImage+"&detail="+detailImage+"&back="+backImage+"&standard="+standardImage;
	window.open(pageURL, "", "alwaysRaised=yes,dependent=yes,width=520,height=530,left=0,top=0,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,fullscreen=no");
}


function checkQuantity(elmnt,content) {
	var ValidChars = "0123456789";
	var Char;
	var clength = content.length;
	for (i = 0; i<clength; i++)	{
		Char = content.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			content = content.substring(0, i);
			break;
        }
    }
	document.productForm.quantity.value = content;
	document.productForm.quantity.focus();
}

function ShowWindowSatisfaction() {
	objwin = window.open("http://www.foxracing.com/customer_service/return_exchange.html","ReturnExchange","height=350,width=695,top=150,left=200,resize=yes,scrollbars=yes");
	if (objwin != null) {
	    objwin.focus();
	}
}

function ShowWindowSizeCharts() {
	objwin = window.open("http://www.foxracing.com/customer_service/sizing.html","SizeCharts","height=400,width=700,top=150,left=200,resize=yes,scrollbars=yes");
	if (objwin != null) {
	    objwin.focus();
	}
}

function ShowWindowWarranty() {
	objwin = window.open("http://www.foxracing.com/customer_service/warranties.html","Warranties","height=400,width=700,top=150,left=200,resize=yes,scrollbars=yes ");
	if (objwin != null) {
	    objwin.focus();
	}
}

function ShowWindowContact() {
	objwin = window.open("http://www.foxracing.com/customer_service/contact.html","Contact","height=500,width=700,top=150,left=200,resize=yes,scrollbars=yes ");
	if (objwin != null) {
	    objwin.focus();
	}
}

function switchLayers( layerName, frame ) {
	var doc = window.document;
	if(frame != null) doc = window.contentFrame.document;
	//if($("productDetailLayer")==null) return;
	$("productDetailLayer").style.display = 'none';
	$("productImagesLayer").style.display = 'none';
	$("productReviewLayer").style.display = 'none';
	$("emptyLayer").style.display = 'none';

	switch(layerName) {
		case "productDetailLayer":
		  $("productDetailLayer").style.display = 'block';
		  break;
		case "productImagesLayer":
		  $("productImagesLayer").style.display = 'block';
		  break;
		case "productReviewLayer":
		  $("productReviewLayer").style.display = 'block';
		  break;
		case "emptyLayer":
		  $("emptyLayer").style.display = 'block';
		  break;
	} // switch

}

// LIST MENU FUNCTIONS
function ShowWindowSchedule() {
    objwin=window.open("web/pages/delivery_schedule.html","DeliverySchedule","height=700,width=420,top=150,left=200,resize=no,scrollbars=yes");
    if (objwin != null) {
        objwin.focus();
    }
}

function changeCSS(nr) {
	if (document.getElementsByTagName) {
		x = document.getElementsByTagName('link');
	} else if (document.all) {
		x = document.all.tags('link');
	} else {
		alert('This script does not work in your browser');
		return;
	}
	nr--;
	for (var i=0;i<x.length;i++) {
		dis = !(i == nr);
		x[i].disabled = dis;
	}
}

function callProductPage(proId,proName,cid,cname,proNumber,imgName, fromSearchPage)
{
	winAlert("callProductPage(proId = "+proId+")");
	var productIsThere = false;
	var productIds = getCookie(productIdsCookie);
	if(productIds != null)
	{
		if(productIds.indexOf(proId) == -1)
		{
			setCookie(productIdsCookie,productIds + "," +proId);
			productIsThere = true;
		}
	}
	else
	{
		setCookie(productIdsCookie,proId);
		productIsThere = true;
	}
	if(productIsThere)
	{

		var productsVisited = getCookie(productsVisitedCookie);
		if(productsVisited != null )
		{

			var lastVisitedArray = new Array();
			if(productsVisited.indexOf("###") != -1)
			{
				lastVisitedArray = productsVisited.split("###");

				var arrayLength = lastVisitedArray.length;
				if(arrayLength == 5)
				{
					for(var i=0; i<4; i++)
					{
						lastVisitedArray[i] = lastVisitedArray[i+1];
					}
					lastVisitedArray[4] = proId + "&&&" + proName + "&&&" + cid + "&&&" + cname + "&&&" + proNumber + "&&&" + imgName;

				}
				else
				{
					lastVisitedArray[arrayLength] =  proId + "&&&" + proName + "&&&" + cid + "&&&" + cname + "&&&" + proNumber + "&&&" + imgName;

				}
			}
			else
			{
				lastVisitedArray[0] = productsVisited;
				lastVisitedArray[1] = proId + "&&&" + proName + "&&&" + cid + "&&&" + cname + "&&&" + proNumber + "&&&" + imgName;

			}

			var lastVisitedArrayStr = "";


			for(var i=0; i<lastVisitedArray.length; i++)
			{
				if(i==0)
				{
					lastVisitedArrayStr = lastVisitedArray[i];

				}
				else
				{
					lastVisitedArrayStr = lastVisitedArrayStr + "###" + lastVisitedArray[i];

				}
			}

			setCookie(productsVisitedCookie,lastVisitedArrayStr);

		}
		else
		{
			setCookie(productsVisitedCookie, proId + "&&&" + proName + "&&&" + cid + "&&&" + cname + "&&&" + proNumber + "&&&" + imgName);

		}
	}

	cname = cname.replace("&","_AND_");
	if(fromSearchPage == 'true') {
		window.location = "ProductForward.do?noExpand=true&forward=product.pagedef&proId="+proId+"&cid="+cid+"&cname="+cname+"&proNumber="+proNumber+"&imgName="+imgName;

	} else {
		get('ProductForward.do?aforward=asyn&proId='+proId+'&cid='+cid+'&cname='+cname+'&proNumber='+proNumber+'&imgName='+imgName);
	}
}


var previousVisitedActuator = null;


function callVisitedProductPage(proId,proName,cid,cname,proNumber,imgName)
{
	cname = cname.replace("&","_AND_");
	get('ProductForward.do?aforward=asyn&proId='+proId+'&cid='+cid+'&cname='+cname+'&proNumber='+proNumber+'&imgName='+imgName+"&loadMenu=true");
}


function swapImage(proId,image) {
        document.getElementById(proId).src= "http://images.foxracing.com/"+image;
}


function ShowRequestCatalog() {
       objwin = window.open("AutoForward.do?forward=requestCatalog","Catalog","height=600,width=720,top=150,left=100,resize=yes,scrollbars=yes ");
       if (objwin != null) {
			ojwin.focus();

        }

}


// =========================================================================
//                          Cookie functions
// =========================================================================
/* This function is used to set cookies */
function setCookie(name,value,expires,path,domain,secure) {
	if(name == null || value == null) return;
	winAlert("setCookie("+name+", "+value+")");
  	document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

/* This function is used to get cookies */
function getCookie(name) {
        var prefix = name + "="
        var start = document.cookie.indexOf(prefix)

        if (start==-1) {
                return null;
        }

        var end = document.cookie.indexOf(";", start+prefix.length)
        if (end==-1) {
                end=document.cookie.length;
        }

        var value=document.cookie.substring(start+prefix.length, end)
        winAlert("getCookie("+name+") = "+unescape(value));
        return unescape(value);
}

/* This function is used to delete cookies */
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}




// END COOKIES

function showVisitedProducts()
{
	var lvpCk = getCookie("productsVisited");
	if (lvpCk ==  null  || lvpCk == "" ) return;

	var lastVisitedProductsTd = "<table border='0' width='200'><tr><td width='190' class='back' class='normaltext'><img border='0' src='web/images/lastvisited.gif' width='195'></td></tr>";
	if (lvpCk.indexOf("###") != -1)
	{

		productArray = lvpCk.split("###");
		for (var i = productArray.length; i > 0; i--)
		{
			var index = i-1;
			parameterArray = productArray[i-1].split("&&&");
			lastVisitedProductsTd = lastVisitedProductsTd + "<tr><td width='205' class='normalTextm'><a href=\"JavaScript:callVisitedProductPage("+parameterArray[0]+",'"+parameterArray[1]+"',"+parameterArray[2]+",'"+parameterArray[3]+"','"+parameterArray[4]+"','"+parameterArray[5]+"',"+index+");\">"+parameterArray[1]+"</a></td></tr>";
		}
	} else {
		parameterArray = lvpCk.split("&&&");
		lastVisitedProductsTd = lastVisitedProductsTd + "<tr><td width='205' class='normalTextm'><a href=\"JavaScript:callVisitedProductPage("+parameterArray[0]+",'"+parameterArray[1]+"',"+parameterArray[2]+",'"+parameterArray[3]+"','"+parameterArray[4]+"','"+parameterArray[5]+"',"+0+");\">"+parameterArray[1]+"</a></td></tr>";
	}
	lastVisitedProductsTd = lastVisitedProductsTd + "</table>";
	$("lastVisitedProductsTd").innerHTML = lastVisitedProductsTd;

}

function showWaiting()
{
	//window.status = "Loading page. Please wait ..."
	var waitDivHeight = window.document.body.clientHeight - 80
	var waitDivWidth = window.document.body.clientWidth
	if(window.document.body.scrollHeight > window.document.body.clientHeight)
		waitDivHeight = window.document.body.scrollHeight - 50
	if(window.document.body.scrollWidth > window.document.body.clientWidth)
		waitDivWidth = window.document.body.scrollWidth

	if(window.document.getElementById("waitDiv") != null)
	{
		window.document.getElementById("waitDiv").style.height = waitDivHeight;
		window.document.getElementById("waitDiv").style.width = waitDivWidth;
		window.document.getElementById("waitDiv").style.display = "block"
	}
}

function hideWaiting()
{
	if(window.document.getElementById("waitDiv") != null)
		window.document.getElementById("waitDiv").style.display = "none";
}

function initializeMenu(menuId, actuatorId)
{
	//winAlert("into initializemenu"+menuId);
	var menu = document.getElementById(menuId);
	var actuator = document.getElementById(actuatorId);
	var actualLink = actuator.href;
	if (menu == null || actuator == null || actualLink.indexOf("javascript")!=-1 )
	return;
}

// Bookmarks
var currentHash = "";
	function Bookmark(hashString, useAjax)
	{
		//alert("Bookmark:"+hashString);
		hashString = hashString.substring(1);
		this.urlString = hashString;
		var nvStrings = hashString.split("&");
		for(var i=0; i<nvStrings.length; i++)
		{
			//alert("nv string #"+(i+1)+": "+nvStrings[i]);
			var nvPair = nvStrings[i].split("=");
			//alert("NV Pair is:"+nvPair[0]+" = "+nvPair[1]);
			this[nvPair[0]] = nvPair[1];
		}
		if(this["itemId"] != null && this["proId"] == null ) this.urlString = "CatalogForward.do?"+this.urlString;
		if(this["proId"] != null && this["itemId"] ==null) this.urlString = "ProductForward.do?"+this.urlString;
		if(this["itemId"] != null && this["proId"] != null) 
				this.urlString = "AddToShoppingCart.do?"+this.urlString;
		
		
		setCookie("menuState", menuStates[this["cid"]]);
		setCookie("selectedItem", this["cid"]);

		if(this["actuatorId"] != null)
		{
			this.urlString = "AutoForward.do?"+this.urlString;
			setCookie("selectedItem", "");
		}
		//alert("userAjax is:"+useAjax);
		if(useAjax == null)	get(this.urlString);
		else getAjax(this.urlString);//+"&noHash=true");
		expandMenus(false);
	}

	function goToBookmark(expandCategory, useAjax)
	{
		//alert("goToBookmark");
		bookmarkString = window.location.hash;
		//alert("bookmark is:"+bookmarkString);
		if(bookmarkString.length == "")
		{
			$("contentArea").style.visibility = "visible";
			//get("AutoForward.do?aforward=asyn&noHash=true", "contentArea", true);
			if(expandCategory == null)	expandMenus();
			else expandMenus(false);
			return;
		}
		var bkmark = new Bookmark(bookmarkString, useAjax);
	} // goToBookmark


var hashPatterns = new Array();
hashPatterns[0] = "#itemId=";
hashPatterns[1] = "#aforward=";
function checkPage()
{
	//alert("checkPage");
	if(document.all && !isOpera) // check title in IE
	{
		// playing an swf causes the hash to append to window title!
		winTitle = new String(window.document.title);
		for(var i=0; i<hashPatterns.length; i++)
		{
			if(winTitle.indexOf(hashPatterns[i])>0)
			{
				//alert("title:"+winTitle+" contains "+hashPatterns[i]);
				winTitle = winTitle.substring(0, winTitle.indexOf(hashPatterns[i]));
				//alert("setting title:"+winTitle);
				window.document.title = winTitle;
			} // pattern matches
		}// list patterns
	}
	else // check hash in mozilla
	{	// hash doesent load page from history
		var urlHash = new String(window.location.hash);
		if(urlHash != null && urlHash.length > 1)
		{
			urlHash = urlHash.substring(1);
			if(urlHash != currentHash)
			{
				//alert("previous hash:"+currentHash+", urlHash = "+urlHash);
				//checkInHistory();
				//alert("history.go(-1)");//"+urlHash+")");
				//history.go(urlHash);
				//window.contentFrame.history.go(-2);
				goToBookmark(null, true);
				currentHash = urlHash;
			}
		}
	}
	setTimeout(checkPage, 300);
}

var isOpera = false;
function initPage()
{
	//alert("initPage - timeout =1000");
	//alert(navigator.appName);
	if(navigator.appName == "Opera")
		isOpera = true;
	if(document.all)
	{
		;//alert("MSIE");
	}
	else
	{
		;//alert("Netscape");
	}
	checkPage();
}

function setProductHash(url)
{
	//alert("set product hash");
	setFragmentIdentifier(url);
	//alert("url is:"+new String(url).indexOf("?"));
	// set the product title
}
function setMenuHash(url)
{
	//alert("setMenuHash:"+url+", window location:"+window.location);
	setFragmentIdentifier(url);
	//alert("url is:"+new String(url).indexOf("?"));
	// set the product title
}

function setFragmentIdentifier(url)
{
	if(url == null) return;
	if(url == window.location) return;
	var queryString = new String(url).substring(new String(url).indexOf("?")+1);
	//alert("query string = "+queryString+", hash is:"+window.location.hash);
	if(window.location.hash != "#"+queryString)
		window.location.hash = queryString;
	currentHash = queryString;
}

function setItemPageHash(url, itemName)
{
	//alert("setItemPageHash");
	setFragmentIdentifier(url);
	window.document.title = mainTitle+" - "+itemName;

}

// Product page
var loopForAll;
function initializeProductArray()
{
	parent.allSizesArray = new Array();
	parent.allSizeSequenceArray = new Array();
	parent.allColorsArray = new Array();
	parent.allPriceArray = new Array();
	parent.allSalePriceArray = new Array();
	parent.allOnSaleArray = new Array();
	parent.allImagesArray = new Array();
	parent.allLargeImagesArray = new Array();
	parent.allDetailImagesArray = new Array();
	parent.allBackImagesArray = new Array();
	parent.allImagesTArray = new Array();
	parent.allItemIdsArray = new Array();
	parent.allItemDetailArray = new Array();
	parent.loopForAll = 0;

}
function addItemToArray(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13)
{
	//alert("addItemToArray("+loopForAll+")");
	parent.allItemIdsArray[parent.loopForAll] = arg1;//"<%=item.getItemId()%>";
	parent.allSizesArray[parent.loopForAll] = arg2;//"<%=itemSize.getName()%>";
	parent.allSizeSequenceArray[parent.loopForAll] = arg3;//"<%=itemSize.getSequence()%>";
	parent.allColorsArray[parent.loopForAll] = arg4;//"<%=itemColor.getName()%>";
	parent.allPriceArray[parent.loopForAll] = arg5;//"<%=regPriceString%>";
	parent.allSalePriceArray[parent.loopForAll] = arg6;//"<%=salePriceString%>";
	parent.allOnSaleArray[parent.loopForAll] = arg7;//"<%=item.getOnSale()%>";
	parent.allImagesArray[parent.loopForAll] = arg8;//"<%=itemImageName%>";
	parent.allLargeImagesArray[parent.loopForAll] = arg9;//"<%=itemLargeImageName%>";
	parent.allDetailImagesArray[parent.loopForAll] = arg10;//"<%=itemDetailImageName%>";
	parent.allBackImagesArray[parent.loopForAll] = arg11;//"<%=itemBackImageName%>";
	parent.allImagesTArray[parent.loopForAll] = arg12;//"<%=itemImageNameT%>";
	parent.allItemDetailArray[parent.loopForAll] = arg13;//"<%=itemDetail%>";
	parent.loopForAll++;
}

var sizeArray = new Array();
var sizeSequenceArray = new Array();
var productTImagesArray = new Array();
var productImagesArray = new Array();
var productLargeImagesArray = new Array();
var productDetailImagesArray = new Array();
var productBackImagesArray = new Array();

function setProductInfo()
{
		parent.sizeArray = new Array();
		parent.sizeSequenceArray = new Array();
		parent.productTImagesArray = new Array();
		parent.productImagesArray = new Array();
		parent.productLargeImagesArray = new Array();
		parent.productDetailImagesArray = new Array();
		parent.productBackImagesArray = new Array();
		sizeArrayIndex = 0;
		for (forLoop = 0; forLoop < parent.allSizesArray.length; forLoop++) {
			if (forLoop == 0) {
				parent.sizeArray[sizeArrayIndex] = parent.allSizesArray[forLoop];
				parent.sizeSequenceArray[sizeArrayIndex] = parent.allSizeSequenceArray[forLoop];
				sizeArrayIndex++;
			} else {
				var status = 0;
				for (var iforLoop = 0; iforLoop < parent.sizeArray.length; iforLoop++) {
					if (parent.sizeArray[iforLoop] == parent.allSizesArray[forLoop]) {
							status = 1;
					}
				}
				if (status == 0) {
					parent.sizeArray[sizeArrayIndex] = parent.allSizesArray[forLoop];
					parent.sizeSequenceArray[sizeArrayIndex] = parent.allSizeSequenceArray[forLoop];
					sizeArrayIndex++;
				}
			}
		}

		var productTImagesArrayIndex = 0;
		for (var forLoop = 0; forLoop < parent.allImagesTArray.length; forLoop++) {
			if (forLoop == 0) {
				parent.productTImagesArray[productTImagesArrayIndex] = parent.allImagesTArray[forLoop];
				parent.productImagesArray[productTImagesArrayIndex] = parent.allImagesArray[forLoop];
				parent.productLargeImagesArray[productTImagesArrayIndex] = parent.allLargeImagesArray[forLoop];
				parent.productDetailImagesArray[productTImagesArrayIndex] = parent.allDetailImagesArray[forLoop];
				parent.productBackImagesArray[productTImagesArrayIndex] = parent.allBackImagesArray[forLoop];
				productTImagesArrayIndex++;
			} else {
				var status = 0;
				for (var iforLoop = 0; iforLoop < parent.productTImagesArray.length; iforLoop++) {
					if (parent.productTImagesArray[iforLoop] == parent.allImagesTArray[forLoop]) {
						status = 1;
					}
				}
				if (status == 0) {
					parent.productTImagesArray[productTImagesArrayIndex] = parent.allImagesTArray[forLoop];
					parent.productImagesArray[productTImagesArrayIndex] = parent.allImagesArray[forLoop];
					parent.productLargeImagesArray[productTImagesArrayIndex] = parent.allLargeImagesArray[forLoop];
					parent.productDetailImagesArray[productTImagesArrayIndex] = parent.allDetailImagesArray[forLoop];
					parent.productBackImagesArray[productTImagesArrayIndex] = parent.allBackImagesArray[forLoop];
					productTImagesArrayIndex++;
				}
			}
		}

		for (var i=0; i<parent.sizeSequenceArray.length; i++) {
			var minValueIndex = i;
			for (var j=i+1; j<parent.sizeSequenceArray.length; j++) {
				if (parseInt(parent.sizeSequenceArray[minValueIndex]) > parseInt(parent.sizeSequenceArray[j]))
				{ minValueIndex = j; }
			}
			if(minValueIndex != i)
			{
				var temp = parent.sizeSequenceArray[i];
				parent.sizeSequenceArray[i] = parent.sizeSequenceArray[minValueIndex];
				parent.sizeSequenceArray[minValueIndex] = temp;
				var sizeTemp = parent.sizeArray[i];
				parent.sizeArray[i] = parent.sizeArray[minValueIndex];
				parent.sizeArray[minValueIndex] = sizeTemp;
			}
		}

		parent.sizeArrayLength = parent.sizeArray.length;
		if((parent.sizeArray[0] == "") && (parent.sizeArrayLength == 1))
		{
			parent.sizeArrayLength = 0;
		}
} // function setProductInfo

function setProductInfo1(productImageName, itemId)
{
	var productDocument = window.contentFrame.document;
	if(productDocument.getElementById("sizeSltTd") == null)
		productDocument = window.document;

	parent.formatOrColor = 0;
	for(var i=0; i<parent.allColorsArray.length; i++)
	{
		if(parent.allColorsArray[i] == "DVD" || parent.allColorsArray[i] == "dvd" || parent.allColorsArray[i] == "VHS" || parent.allColorsArray[i] == "vhs")
		{
			parent.formatOrColor = 1;
			break;
		}
	}

	if(parent.sizeArrayLength != 0)
	{
		var sizeSltTd = "<select name='sizeSelect' onChange='changeOnSize();'>";
		sizeSltTd = sizeSltTd + "<option value='notselected'> Size";
		for(var forLoop=0; forLoop < parent.sizeArray.length; forLoop++)
		{
				if(parent.SIZE == parent.sizeArray[forLoop])
				{
					sizeSltTd = sizeSltTd + "<option value='" + parent.sizeArray[forLoop] + "' selected>" + parent.sizeArray[forLoop];
				}
				else
				{
					sizeSltTd = sizeSltTd + "<option value='" + parent.sizeArray[forLoop] + "'>" + parent.sizeArray[forLoop];
				}
		}
		sizeSltTd = sizeSltTd + "</select>";
		productDocument.getElementById("sizeSltTd").innerHTML = sizeSltTd;
		productDocument.getElementById("sizeNameTd").innerHTML = "Size:";
		//document.getElementById("sizeWarningTd").innerHTML = "<FONT color='red'>*Please select Size first because not all colors are always available in all sizes.</FONT>";
	}


	var firstSize = parent.sizeArray[0];
	parent.colorsForSize = new Array();
	parent.idsForSize = new Array();
	parent.priceArray = new Array();
	parent.imageArray = new Array();
	parent.imageTArray = new Array();
	parent.salePriceArray = new Array();
	parent.onSaleArray = new Array();
	var itemDetail = "";
	//var itemId = "";

	var colorsForSizeIndex = 0;
	for(var forLoop=0; forLoop < parent.allSizesArray.length; forLoop++)
	{
		if(parent.allSizesArray[forLoop] == firstSize)
		{
			if(colorsForSizeIndex == 0)
			{
				parent.colorsForSize[colorsForSizeIndex] = parent.allColorsArray[forLoop];
				parent.priceArray[colorsForSizeIndex] = parent.allPriceArray[forLoop];
				parent.imageArray[colorsForSizeIndex] = parent.allImagesArray[forLoop];
				parent.imageTArray[colorsForSizeIndex] = parent.allImagesTArray[forLoop];
				parent.idsForSize[colorsForSizeIndex] = parent.allItemIdsArray[forLoop];
				parent.salePriceArray[colorsForSizeIndex] = parent.allSalePriceArray[forLoop];
				parent.onSaleArray[colorsForSizeIndex] = parent.allOnSaleArray[forLoop];
				colorsForSizeIndex++;
			}
			else
			{
				var status = 0;
				for(var iforLoop = 0; iforLoop < parent.colorsForSize.length; iforLoop++)
				{
					if(parent.colorsForSize[iforLoop] == parent.allColorsArray[forLoop])
					{
						status = 1;
					}
				}
				if(status == 0)
				{
					parent.colorsForSize[colorsForSizeIndex] = parent.allColorsArray[forLoop];
					parent.priceArray[colorsForSizeIndex] = parent.allPriceArray[forLoop];
					parent.imageArray[colorsForSizeIndex] = parent.allImagesArray[forLoop];
					parent.imageTArray[colorsForSizeIndex] = parent.allImagesTArray[forLoop];
					parent.idsForSize[colorsForSizeIndex] = parent.allItemIdsArray[forLoop];
					parent.salePriceArray[colorsForSizeIndex] = parent.allSalePriceArray[forLoop];
					parent.onSaleArray[colorsForSizeIndex] = parent.allOnSaleArray[forLoop];
					colorsForSizeIndex++;
				}
			}
		}
	}

	if(parent.idsForSize.length == 0) { parent.idsForSize = parent.allItemIdsArray; }
	if(parent.colorsForSize.length == 0) { parent.colorsForSize = parent.allColorsArray; }
	if(parent.priceArray.length == 0) { parent.priceArray = parent.allPriceArray; }
	if(parent.imageTArray.length == 0) { parent.imageTArray = parent.allImagesTArray; }
	if(parent.imageArray.length == 0) { parent.imageArray = parent.allImagesArray; }
	if(parent.priceArray.length == 0) { parent.priceArray = parent.allPriceArray; }
	if(parent.salePriceArray.length == 0) { parent.salePriceArray = parent.allSalePriceArray; }
	if(parent.onSaleArray.length == 0) { parent.onSaleArray = parent.allOnSaleArray; }

	for (var i = 0; i < parent.colorsForSize.length; i++) {
		var minValueIndex = i;
		for (var j = i+1; j < parent.colorsForSize.length; j++) {
			if(parent.colorsForSize[i].toLowerCase() > parent.colorsForSize[j].toLowerCase()) 	{
				minValueIndex = j;
			}
		}
		if (minValueIndex != i)	{
			var colorTemp = parent.colorsForSize[i];
			parent.colorsForSize[i] = parent.colorsForSize[minValueIndex];
			parent.colorsForSize[minValueIndex] = colorTemp;
			var priceTemp = parent.priceArray[i];
			parent.priceArray[i] = parent.priceArray[minValueIndex];
			parent.priceArray[minValueIndex] = priceTemp;
			var imageTemp = parent.imageArray[i];
			parent.imageArray[i] = parent.imageArray[minValueIndex];
			parent.imageArray[minValueIndex] = imageTemp;
			var imageTTemp = parent.imageTArray[i];
			parent.imageTArray[i] = parent.imageTArray[minValueIndex];
			parent.imageTArray[minValueIndex] = imageTTemp;
			var idTemp = parent.idsForSize[i];
			parent.idsForSize[i] = parent.idsForSize[minValueIndex];
			parent.idsForSize[minValueIndex] = idTemp;
			var salePriceTemp = parent.salePriceArray[i];
			parent.salePriceArray[i] = parent.salePriceArray[minValueIndex];
			parent.salePriceArray[minValueIndex] = salePriceTemp;
			var onSaleTemp = parent.onSaleArray[i];
			parent.onSaleArray[i] = parent.onSaleArray[minValueIndex];
			parent.onSaleArray[minValueIndex] = onSaleTemp;
		}
	}

	parent.colorsForSizeLength = parent.colorsForSize.length;
	if((parent.colorsForSize[0] == "") && (parent.colorsForSizeLength == 1))
	{
		parent.colorsForSizeLength = 0;
	}
	var colorSltTd = "";
	var colorNameTd = "";
	if(parent.colorsForSizeLength != 0)
	{
		if(parent.formatOrColor == 1)
		{ colorNameTd = "Format:"; }
		else
		{ colorNameTd = "Color:"; }
		productDocument.getElementById("colorNameTd").innerHTML = colorNameTd;
		colorSltTd = "<select name=\"colorSelect\" onChange=\"changeOnColor();\">";
		colorSltTd = colorSltTd + "<option value='notselected'>";
		if(parent.formatOrColor == 1){ colorSltTd = colorSltTd + "Format"; }
		else { colorSltTd = colorSltTd + "Color"; }
		for(var forLoop=0; forLoop < parent.colorsForSize.length; forLoop++)
		{
			if(parent.COLOR == parent.colorsForSize[forLoop])
			{
				colorSltTd = colorSltTd + "<option value='" + parent.colorsForSize[forLoop] + "' selected>" + parent.colorsForSize[forLoop];
				parent.COLOR = "";
			}
			else
			{
				colorSltTd = colorSltTd + "<option value='" + parent.colorsForSize[forLoop] + "'>" + parent.colorsForSize[forLoop];
			}
		}
	}
	colorSltTd = colorSltTd + "</select>";
	productDocument.getElementById("colorSltTd").innerHTML = colorSltTd;


	var imageTd = "<img src='http://images.foxracing.com/"+productImageName+"' border='0' bgcolor='blue'>";
	productDocument.getElementById("imageTd").innerHTML = imageTd;

	var itemParam = idsForSize[0];
	if(itemId != null && itemId !="") itemParam = itemId;
	//var addToShoppingCartTd = "<a href=\"javascript:addToShoppingCart('"+ <%if(itemId != 0) {%><%=itemId%><%} else {%> parent.idsForSize[0] <%}%> +"');\"><img src=\"web/images/add_to_cart1.gif\" border='0' alt=''></a>";
	var addToShoppingCartTd = "<a href=\"javascript:addToShoppingCart('"+ itemParam +"');\"><img src=\"web/images/add_to_cart1.gif\" border='0' alt=''></a>";
	productDocument.getElementById("addToShoppingCartTd").innerHTML = addToShoppingCartTd;

	//var addToWishListTd = "<a href=\"javascript:addToWishList('"+ <%if(itemId != 0) {%><%=itemId%><%} else {%> parent.idsForSize[0] <%}%> +"');\"><img src=\"web/images/add_wish_list.gif\" border='0' alt=''></a>";
	var addToWishListTd = "<a href=\"javascript:addToWishList('"+ itemParam +"');\"><img src=\"web/images/add_wish_list.gif\" border='0' alt=''></a>";
	productDocument.getElementById("addToWishListTd").innerHTML = addToWishListTd;

	//itemId = <%if(itemId != 0) {%><%=itemId%><%} else {%> parent.idsForSize[0] <%}%>;
	for(var i=0; i<parent.allItemIdsArray.length; i++)
	{
		//if(itemId == parent.allItemIdsArray[i])
		if(itemParam == parent.allItemIdsArray[i])
		{
			itemDetail = parent.allItemDetailArray[i];
			break;
		}
	}
	if(itemDetail != null && itemDetail != "")
	{
		productDetailTdMain = "<a href='javascript:switchLayers(\"productDetailLayer\");'>PRODUCT DETAIL</a>";
		productDocument.getElementById("productDetailTdMain").innerHTML = productDetailTdMain;
		productDetailLayer = "<TABLE width='100%' align='left'><TR><TD align='left'  width='20%' class='normalText'><FONT color='blue'> <b>PRODUCT DETAIL :: &nbsp;</b></FONT></TD><TD align='left'  width='80%' class='normalText'>"+itemDetail+"</TD></TR></TABLE>";
		productDocument.getElementById("productDetailLayer").innerHTML = productDetailLayer;
	}

} // set product info 1

function getProductImages()
{
				var productImagesTd="<TABLE>";
				for(var i=1; i<=parent.productTImagesArray.length; i++)
				{
					if((i%5) == 1)
					{
						productImagesTd = productImagesTd + "<TR>";
					}
					var imageTURL = "http://images.foxracing.com/";
					var imageURL = "http://images.foxracing.com/";
					imageTURL = imageTURL + parent.productTImagesArray[i-1];
					imageURL = imageURL + parent.productImagesArray[i-1];
					var standardImage = parent.productImagesArray[i-1];
					var largeImage = parent.productLargeImagesArray[i-1];
					var detailImage = parent.productDetailImagesArray[i-1];
					var backImage = parent.productBackImagesArray[i-1];

					if(largeImage=="no_image_availablef.gif" && detailImage=="no_image_availablef.gif" && backImage=="no_image_availablef.gif")
					{
						productImagesTd = productImagesTd + "<td align='left'><a href='javascript:openImage(\""+ largeImage +"\",\""+ detailImage +"\",\""+ backImage +"\",\""+ standardImage +"\");'><img src='"+ imageTURL + "' border='0' alt='Click here to view large image!!'></a></td>";
					}
					else if(largeImage=="+ imageURL + " && detailImage=="no_image_availablef.gif" && backImage=="no_image_availablef.gif")
					{
						productImagesTd = productImagesTd + "<td align='left'><img src='"+ imageTURL + "' border='0' alt=''></td>";
					}
					else
					{
						productImagesTd = productImagesTd + "<td align='left'><a href='javascript:openImage(\""+ largeImage +"\",\""+ detailImage +"\",\""+ backImage +"\",\""+ standardImage +"\");'><img src='"+ imageTURL + "' border='0' alt='Click here to view large image!!'></a></td>";
					}

					if((i==parent.productTImagesArray.length || (i%5) == 0))
					{
						productImagesTd = productImagesTd + "</TR>";
					}
				}
				productImagesTd = productImagesTd + "</TABLE>";
				return productImagesTd;

}

