<!--

function createCookie(name,value,days) {
	var expires;
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	else {
		expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') {c = c.substring(1,c.length);}
		if (c.indexOf(nameEQ) == 0) {return c.substring(nameEQ.length,c.length);}
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function CheckTab(){
	if(document.cookie){
		var CookieValues = readCookie("Tab");
		if(CookieValues == "Brand"){
			ShowBrandNav();
		}
		else if(CookieValues == "Celeb"){
			ShowCelebNav();
		}
		else{
			ShowDepartmentNav();
		}
	}
	else{
		ShowDepartmentNav();
	}
}

function HideAllNav(){

	document.getElementById("DepartmentTab").style.display="none";
	document.getElementById("DepartmentTabHeader").style.background="#F5F5F5";
	document.getElementById("DepartmentTabHeaderLink").style.color="#1B1F4B";

	document.getElementById("BrandTab").style.display="none";
	document.getElementById("BrandTabHeader").style.background="#F5F5F5";
	document.getElementById("BrandTabHeaderLink").style.color="#1B1F4B";

	document.getElementById("CelebTab").style.display="none";
	document.getElementById("CelebTabHeader").style.background="#F5F5F5";
	document.getElementById("CelebTabHeaderLink").style.color="#1B1F4B";

}


function ShowDepartmentNav(){
	HideAllNav()
	createCookie("Tab","Department",0);
	document.getElementById("DepartmentTab").style.display="block";
//	document.getElementById("BrandTab").style.display="none";
	document.getElementById("DepartmentTabHeader").style.background="#1B1F4B";
	document.getElementById("DepartmentTabHeaderLink").style.color="#FFEEA8";
//	document.getElementById("BrandTabHeader").style.background="#F5F5F5";
//	document.getElementById("BrandTabHeaderLink").style.color="#1B1F4B";
}

function ShowBrandNav(){
	HideAllNav()
	createCookie("Tab","Brand",0);
//	document.getElementById("DepartmentTab").style.display="none";
	document.getElementById("BrandTab").style.display="block";
//	document.getElementById("DepartmentTabHeader").style.background="#F5F5F5";
//	document.getElementById("DepartmentTabHeaderLink").style.color="#1B1F4B";
	document.getElementById("BrandTabHeader").style.background="#1B1F4B";
	document.getElementById("BrandTabHeaderLink").style.color="#FFEEA8";
}


function ShowCelebNav(){
	HideAllNav()
	createCookie("Tab","Celeb",0);
//	document.getElementById("DepartmentTab").style.display="none";
	document.getElementById("CelebTab").style.display="block";
//	document.getElementById("DepartmentTabHeader").style.background="#F5F5F5";
//	document.getElementById("DepartmentTabHeaderLink").style.color="#1B1F4B";
	document.getElementById("CelebTabHeader").style.background="#1B1F4B";
	document.getElementById("CelebTabHeaderLink").style.color="#FFEEA8";
}

function SelectedBrand(BrandID){
	createCookie("BrandVal",BrandID,0);
}
function SelectedCeleb(ThemeID){
	createCookie("CelebVal",ThemeID,0);
}

// ----------------------------------------------------------------------------
// creates anchor links for each Select->Option present in each (of the two)
// dropdowns with an ID of search_form.field_product_brand
// ----------------------------------------------------------------------------
// The arguments passed are
// x           = the offset in the list
// CookieVal   = the offset of the link last selected (to enable highlighting of the selected link)
// strLinkType = whether we are creating an brand or celeb link (brand or theme)
// ----------------------------------------------------------------------------
function CreateLink(x,CookieVal, strLinkType){
	var LinkTag;
	var strCssClass;
	// --------------------------------------------------------------------------
	// Determine if the link requested is the current page and set strCssClass
	// accordingly
	// --------------------------------------------------------------------------
	if(CookieVal == x){
		strCssClass = 'link-department-select';
	}
	else{
		strCssClass = 'link-department';
	}

	// --------------------------------------------------------------------------
	// Determine if the link requested is a brand or celeb link and create the
	// anchor tag accordingly
	// --------------------------------------------------------------------------
	if(strLinkType == 'Brand'){
		LinkTag = "<p><a class='" + strCssClass + "' href='/store/search/brand/" + document.search_form.field_product_brand.options[x].value.replace(/\-/g, "%97").replace(/ /g, "-") + "/' onClick='SelectedBrand(" + x + ")'>" + document.search_form.field_product_brand.options[x].value +"</a></p>";
	}
	else if(strLinkType == 'Celeb'){
		LinkTag = "<p><a class='" + strCssClass + "' href='/store/search/theme/" + document.search_form.theme_dropdown.options[x].value.replace(/\-/g, "%97").replace(/ /g, "-") + "/' onClick='SelectedCeleb(" + x + ")'>" + document.search_form.theme_dropdown.options[x].value +"</a></p>";
	}
	// --------------------------------------------------------------------------
	// this default case left in during transition to new script and can be
	// deleted after the new celeb menu is seen to be working correctly
	// --------------------------------------------------------------------------
	else{
		LinkTag = "<p><a class='" + strCssClass + "' href='/store/search/brand/" + document.search_form.field_product_brand.options[x].value.replace(/\-/g, "%97").replace(/ /g, "-") + "/' onClick='SelectedBrand(" + x + ")'>" + document.search_form.field_product_brand.options[x].value +"</a></p>";
	}
	return LinkTag;
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

