﻿//---------------------------------
//-- ON LOAD ----------------------
//---------------------------------
if (window.addEventListener)
	window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
	window.attachEvent("onload", do_onload)
else if (document.getElementById)
	window.onload=do_onload

//---------------------------------
function do_onload(){
	//Hide Return, Shipping, Pricing Policies
	if(uf_GetCustomerLevelID() > 1){
		if(document.getElementById("divShippingPolicy")){
			document.getElementById("divShippingPolicy").style.display = "none";
		}
		if(document.getElementById("divReturnPolicy")){
			document.getElementById("divReturnPolicy").style.display = "none";
		}
		if(document.getElementById("divPricingPolicy")){
			document.getElementById("divPricingPolicy").style.display = "none";
		}
		if(document.getElementById("laContactUs2")){
			document.getElementById("laContactUs2").href = "t-contact2.aspx";
		}
	}

	//Maru 01/22/2009 Start
	//Hide Free Shipping promo from wholesale customers
	if(uf_GetCustomerLevelID() > 1){
		if(document.getElementById("divFreeShipping1")){
			document.getElementById("divFreeShipping1").style.display = "none";
		}
		if(document.getElementById("divFreeShipping2")){
			document.getElementById("divFreeShipping2").style.display = "none";
		}
	}
	//Maru 01/22/2009 End

	//Set the current menu
	uf_SetCurrentMenu()
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
var lsPrevMenu = ""

//---------------------------------
function uf_SetMenu(asMenu){

	if(lsPrevMenu != ""){
		uf_ShowMenu(lsPrevMenu, 0)	
		uf_ShowSubMenu(lsPrevMenu, 0)
	}

	uf_ShowMenu(asMenu, 1)	
	uf_ShowSubMenu(asMenu, 1)

	lsPrevMenu = asMenu
}
//---------------------------------
function uf_ShowMenu(asMenu, abFlag){
	uf_ShowDiv("img" + asMenu + "1", !abFlag)
	uf_ShowDiv("img" + asMenu + "2", abFlag)
}

//---------------------------------
function uf_ShowSubMenu(asMenu, abFlag){
	uf_ShowDiv("divSub" + asMenu, abFlag)
}
//---------------------------------
function uf_ShowImg(asImgID, abFlag){
	if(document.getElementById(asImgID)){
		if(abFlag){document.getElementById(asImgID).style.display = "block"}
		else{document.getElementById(asImgID).style.display = "none"}
	}
}
//---------------------------------

function uf_ShowDiv(asDivID, abFlag){
	if(document.getElementById(asDivID)){
		if(abFlag){
			document.getElementById(asDivID).style.display = "block"
		}
		else{
			document.getElementById(asDivID).style.display = "none"
		}
	}
}
//---------------------------------
function uf_GetCustomerLevelID(){
	if(document.getElementById("hfCustomerLevelID"))
		return document.getElementById("hfCustomerLevelID").value
	else if(document.getElementById("_ctl0_hfCustomerLevelID"))
		return document.getElementById("_ctl0_hfCustomerLevelID").value
	else
		return '0'
}


//---------------------------------
function uf_TogglePic(asName, abFlag){
	uf_ShowDiv("div" + asName + "1", !abFlag)
	uf_ShowDiv("div" + asName + "2", abFlag)
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
function uf_SetCurrentMenu(){
	var NowIn = document.getElementById("spnNowIn").innerHTML
	var lsCustomerLevelID = uf_GetCustomerLevelID();

	//DETERMINE MENU TO SET
	//Categories for Retail
	if(lsCustomerLevelID == 0){
		if(NowIn.indexOf(">Just in<")!=-1){
			uf_SetMenu("JustIn")
		}
		else if(NowIn.indexOf(">Men<")!=-1 && NowIn.indexOf(">Clearance<")==-1){
			uf_SetMenu("Men")
		}
		else if(NowIn.indexOf(">Boys<")!=-1){
			uf_SetMenu("Kids")
		}
		else if(NowIn.indexOf(">Women<")!=-1 && NowIn.indexOf(">Clearance<")==-1){
			uf_SetMenu("Women")
		}
		else if(NowIn.indexOf(">Accessories<")!=-1 && NowIn.indexOf(">Clearance<")==-1){
			uf_SetMenu("Accessories")
		}
		else if(NowIn.indexOf(">Clearance<")!=-1){
			uf_SetMenu("Clearance")
		}
	}

	//Categories for WholeSale
	else if(lsCustomerLevelID > 1){
		if(NowIn.indexOf(">ws Just In<")!=-1){
			uf_SetMenu("WJustIn")
		}
		else if(NowIn.indexOf(">Men<")!=-1 && NowIn.indexOf(">Clearance<")==-1){
			uf_SetMenu("WMen")
		}
		else if(NowIn.indexOf(">Boys<")!=-1){
			uf_SetMenu("WKids")
		}
		else if(NowIn.indexOf(">Women<")!=-1 && NowIn.indexOf(">Clearance<")==-1){
			uf_SetMenu("WWomen")
		}
		else if(NowIn.indexOf(">Accessories<")!=-1 && NowIn.indexOf(">Clearance<")==-1){
			uf_SetMenu("Waccessories")
		}
		else if(NowIn.indexOf(">ws Clearance<")!=-1){
			uf_SetMenu("WClearance")
		}
		else if(NowIn.indexOf(">Catalog<")!=-1){
			uf_SetMenu("WCatalog")
		}
	}
}


//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
function uf_MouseOver(asID){
	var lsPic
	if(document.getElementById("img" + asID)){
		lsPic = document.getElementById("img" + asID).src
		lsPic = lsPic.substring(0,lsPic.length - 5)

		//document.getElementById("img" + asID).src = "skins/skin_3/images/joker/" + asID + "b.jpg"
		document.getElementById("img" + asID).src = lsPic + "b.jpg"
	}
}

//---------------------------------
function uf_MouseOut(asID){
	var lsPic
	if(document.getElementById("img" + asID)){
		lsPic = document.getElementById("img" + asID).src
		lsPic = lsPic.substring(0,lsPic.length - 5)
		//document.getElementById("img" + asID).src = "skins/skin_3/images/joker/" + asID + "a.jpg"
		document.getElementById("img" + asID).src = lsPic + "a.jpg"
	}
}

//---------------------------------
//-- SET IMAGE SOURCE -------------
//---------------------------------
function uf_SetImgSrc(asImgID, asImgName){
	var lsPath = "skins/skin_3/images/joker/"
	var loImg = document.getElementById(asImgID)
	
	if(loImg){
		loImg.src = lsPath + asImgName
	}
}

function uf_SetImgSrc2(aoImg, asImgName){
	var lsPath = "skins/skin_3/images/joker/"
	
	if(aoImg){
		aoImg.src = lsPath + asImgName
	}
}

//---------------------------------
//-- SET IMAGE HOVER --------------
//---------------------------------
function uf_PicHover(asDivID, asMouseOut){
	if(asMouseOut == 'True'){
		document.getElementById(asDivID + "a").style.display = "block"
		document.getElementById(asDivID + "b").style.display = "none"
	}
	else{
		document.getElementById(asDivID + "a").style.display = "none"
		document.getElementById(asDivID + "b").style.display = "block"
	}
}

//---------------------------------
//-- SET IMAGE SOURCE -------------
//---------------------------------
function uf_SetImgSrc(asImgID, asImgPath){
	var lsPath = "skins/skin_3/images/joker/"
	var loImg = document.getElementById(asImgID)
	
	if(loImg){
		loImg.src = asImgPath
	}
}

function uf_SetImgSrc2(aoImg, asImgPath){
	if(aoImg){
		aoImg.src = asImgPath
	}
}

//---------------------------------
//-- SET IMAGE SOURCE -------------
//---------------------------------
function uf_ChangeClass(aoObject, asCssClass){
	if(aoObject){
		aoObject.className = asCssClass
	}
}