function preloadAllImages() {
	MM_preloadImages('images/header/Faith_dot_com_o.gif','images/header/mailing_list_o.gif','images/header/your_account_o.gif','images/nav_glob/womanswear_o.gif','images/nav_glob/menswear_o.gif','images/nav_glob/accessories_o.gif','images/nav_glob/beauty_fragrance_o.gif','images/nav_glob/model_shots_o.gif');
}

function goBack() {
	history.go(-1);
}

//used by the dropdown lists
function JumpToUrl(ClientID)
{
	var ddl = document.getElementById(ClientID);
	//alert(ddl);
	var url = ddl.options[ddl.selectedIndex].value;
	//alert(url);
	window.location.href = url;
}   

function showProductQuantity() {
  var i,p,v,obj,args=showProductQuantity.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; d=args[i+3];
    if (obj.style) { 
	 	obj=obj.style; 
		v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
		d=(d=='block')?'block':(d=='none')?'none':d; 
	}
    obj.visibility=v;
	 obj.display=d;
	 }ss
}

function hideItemDetails(ItemId)
{
	var product_item = document.getElementById(ItemId);
	product_item.className = "product-item hide-item-details";
}

function showItemDetails(ItemId)
{
	var product_item = document.getElementById(ItemId);
	product_item.className = "product-item show-item-details";
}

function crossBrowserLinkClick(element) {
	if (element.click) {
		element.click();
	} else {
		var href = element.href;
		//strip off the leading 'javascript:'
		var func;
		
		if (href.indexOf('javascript:') > -1) {
			func = href.substr(11);
		} else
			func = href;
			
		//strip the space off (encoded as %20)
		if (func.substr(0, 3) == '%20')
			func = func.substr(3);	

		//run the function
		eval(func);
	}
}

function updateInfoBox(txtHolder, newTxt){
	if (document.getElementById(txtHolder)) {
		document.getElementById(txtHolder).innerHTML = newTxt;
	}
}

function validateControl(controlToValidate,regex,txtHolder,errorMsg)
{
	if (document.getElementById(txtHolder))
	{
		document.getElementById(txtHolder).innerHTML = '';
		
		if (document.getElementById(controlToValidate))
		{	
			document.getElementById(controlToValidate).className = 'textInput';
			document.getElementById(txtHolder).className = 'AccessInvisible';
			
			var text = trim(document.getElementById(controlToValidate).value);
		
			if (!text.match(regex))
			{	
				document.getElementById(txtHolder).innerHTML = errorMsg;
				document.getElementById(controlToValidate).className = 'ErrorInput textInput';
				document.getElementById(txtHolder).className = 'AccessVisible';
			}
		}
	}
}

function compareControls(controlToValidate1,controlToValidate2,txtHolder,errorMsg)
{
	if (document.getElementById(txtHolder))
	{
		document.getElementById(txtHolder).innerHTML = '';
		
		if (document.getElementById(controlToValidate1) && document.getElementById(controlToValidate2))
		{	
			document.getElementById(controlToValidate1).className = 'textInput';
			document.getElementById(controlToValidate2).className = 'textInput';
			
			document.getElementById(txtHolder).className = 'AccessInvisible';
			
			var text = trim(document.getElementById(controlToValidate1).value);
			var text2 = trim(document.getElementById(controlToValidate2).value);
		
			if (!text.match(text2) || text.length != text2.length)
			{	
				document.getElementById(txtHolder).innerHTML = errorMsg;
				
				document.getElementById(controlToValidate1).className = 'ErrorInput textInput';
				document.getElementById(controlToValidate2).className = 'ErrorInput textInput';
				
				document.getElementById(txtHolder).className = 'AccessVisible';
			}
		}
	}
}

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '')
}


function setVariantID(strClientID, ProductID, VariantID , ID, strImgTopDirectory)
{
		var sizeImg = document.getElementsByTagName("img");
		var selectedSrc = "images/" + strImgTopDirectory + "/site/buttons/icons/size_" + ID + "_on.gif";

		for (i = 0; i < sizeImg.length; i++) {
			if (document.getElementById(strClientID + "_image" + i)){
				var currentImg = document.getElementById(strClientID + "_image" + i);
				if (currentImg.getAttribute("src").indexOf("_on.gif") != -1 && currentImg.getAttribute("src").indexOf("size_") != -1) {
					currentImg.setAttribute("src", "images/" + strImgTopDirectory + "/site/buttons/icons/size_" + i + ".gif");
				}
			
			}
		}
	//var path = "images/" + strImgTopDirectory + "/site/buttons/icons/size_" + ID + "_on.gif";

	// set the source for the current Variant Selected Variant only
	document.getElementById(strClientID + "_image" + ID).setAttribute("src", selectedSrc);
	document.getElementById(strClientID + '_txtVariantID').value = VariantID;
	document.getElementById(strClientID + '_txtProductID').value = ProductID;
	
	// enable the Add To basket button
	document.images.imgAddToBasket.src='images/' + strImgTopDirectory + '/site/buttons/add_to_basket.gif';
}

/* ***********************************
	Scroller
 *********************************** */	
 
 function insertAfter(targetElement, newElement) {
	// Get the top element
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}

function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else 
      window.onload = fnc;
  }
}

function disableCRB(e)
{
	if(e && document.getElementById('page-blanket'))
	{
		var elem = document.getElementById('page-blanket');
		elem.style.display = 'block';
		var winH = 0;
		var winW = 0;
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
				winH = window.innerHeight;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight;
			}
		}
		elem.style.height = winH;
	}
	document.getElementById("divLoading").style.display = 'block';
}
function adjustCCOptions(e)
{
	if(e)
	{
		var obj = document.getElementById("ssOptions");
		if(obj)
		{
			if(e.options[e.selectedIndex].value.toUpper() == "SOLO" || e.options[e.selectedIndex].value.toUpper() == "SWITCH")
			{
				/*show start date and issue number options*/
				obj.style.display = 'block';
			}
			else
			{
				/*hidestart date and issue number options*/
				obj.style.display = 'hidden';
			}
		}
	}
}
function checkCCOptions()
{
	var obj = document.getElementById("ctrlPaymentDetails:ddlCards");
	if(obj)
	{
		adjustCCOptions(obj);
	}
}
/*
	This function should be overloaded in the page if you want to 
	validate a text box
*/
function validate(txtbox)
{
	return true;
}

function navigateProductList(url)
{
	var _cid = "";
	
	
	if(document.location.pathname.indexOf("ProductList.aspx") != -1 && url.indexOf("cid") != -1)
	{
		var arrURL = url.split("cid=");
		if(arrURL[1].indexOf("&") == -1)
		{
			_cid = arrURL[1];
		}
		else
		{
			_cid = (arrURL[1].split("&"))[0];
		}
		
		if(document.getElementById("cid"))
			document.getElementById("cid").value = _cid;
		
		window.document.forms[0].submit();
	}
	else
		window.document.location = url;
	

}


