keywordsclicked = 0;
UpdateUnsubclicked = 0;
var shopLink = "";
var bannerNavHover = false;
var isFM = false;
/* Product slide window starting height */
	var sliderHeight = "240";

function validateSearch(form) {
	if ((form.queryText.value == "") || (form.queryText.value.toLowerCase() == "search site")) {
		alert('Please enter a search word or phrase');
		return false;
	}
}

function keywordsDown(){
	if (keywordsclicked==0){
		keywordsclicked = 1;
		UpdateUnsubclicked = 0;
		toggleVisibility("most_popular_keywords_slide","show","visible","visible");
		toggleVisibility("update_unsubscribe_details","hidden","hidden","hidden");
		toggleVisibility("update_unsubscribe_button","hidden","hidden","hidden");
	} else {
		keywordsclicked = 0;
		toggleVisibility("most_popular_keywords_slide","hidden","hidden","hidden");
	}
}

if (document.images) 
{
	tabOnLeft = new Image(); tabOnLeft.src = "/shopping/images/tmpl/tab_images/left_tab_on.gif"; 
	tabOnRight = new Image(); tabOnRight.src = "/shopping/images/tmpl/tab_images/right_tab_on.gif"; 
	tabOffLeft = new Image(); tabOffLeft.src = "/shopping/images/tmpl/tab_images/left_tab_off.gif"; 
	tabOffRight = new Image(); tabOffRight.src = "/shopping/images/tmpl/tab_images/right_tab_off.gif"; 
}
function swapTab(whichImages, on)
{
	if (on)
	{
		document.images[whichImages+"_left"].src=tabOnLeft.src;
		document.images[whichImages+"_right"].src=tabOnRight.src;
	}
	else
	{
		document.images[whichImages+"_left"].src=tabOffLeft.src;
		document.images[whichImages+"_right"].src=tabOffRight.src;
	}
}

function toggleVisibility(id, NStype, IEtype, WC3type) {
	if (document.getElementById) {
		eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
	}
	else if (document.layers) {
		document.layers[id].visibility = NStype;
	} else {
		if (document.all) {
			eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
		}
	}
}

function toggleUpdateUnsub(){
	if (UpdateUnsubclicked==0){
		UpdateUnsubclicked = 1;
		keywordsclicked = 0;
		toggleVisibility("update_unsubscribe_details","show","visible","visible");
		toggleVisibility("update_unsubscribe_button","show","visible","visible");
		toggleVisibility("most_popular_keywords_slide","hidden","hidden","hidden");
	} else {
		UpdateUnsubclicked = 0;
		toggleVisibility("update_unsubscribe_details","hidden","hidden","hidden");
		toggleVisibility("update_unsubscribe_button","hidden","hidden","hidden");
	}
}

function getRadioValue(whichForm, whichFormField)
{
	valueSelected = false;
	if (whichForm)
	{
		if (whichFormField.length) 
		{
			for (i=0; i< whichFormField.length; i++)
			{
				if (whichFormField[i].checked || (whichFormField.selectedIndex && whichFormField.options[i].selected && i>0)) {
					valueSelected=true;
					return true;
				}
			}
		}
		
		//if radio array only has 1 element, then it will return "undefined"
		//for the length property, so you must check for a field value
		//to see if it has been checked.
		else if (null!=whichFormField.value && ""!=whichFormField.value)
		{
			if (whichFormField.checked || whichFormField.selected)
			{
				return true;
			}
		}
	}
	return valueSelected;
}

function getFMPattern(whichForm, whichFormField) {

}


function validateOptionsSelected(pSelect1, pSelect2)
{
	//select1 is driver value
	//select2 is filtered value
	var alertType =  "";
	if ( isFM && document.getElementById("select1") && ( document.SkuSelector.driverValue.value == '' || document.SkuSelector.driverValue.value == null ) ) {
	    document.getElementById("select1Text").style.color="red";
		document.getElementById("select1Indicator").style.display="block";
		alertType += pSelect1;
	}
	else if (!isFM && pSelect1 && document.getElementById("select1") && !getRadioValue(document.SkuSelector, document.SkuSelector.driverValue)) {
		document.getElementById("select1Text").style.color="red";
		document.getElementById("select1Indicator").style.display="block";
		alertType += pSelect1; 
	} 
	else if (pSelect2 && document.getElementById("select2") && !getRadioValue(document.Skus, document.Skus.skuid)) {
		document.getElementById("select2Text").style.color="red";
		document.getElementById("select2Indicator").style.display="block";
		if (""!=alertType) { alertType += " and "; }
		alertType += pSelect2; 	
	}
	else if (!(document.getElementById("formSubmit")))
	{
		return false;
	}
	if (alertType)
	{
		document.getElementById("alertMessage").innerHTML = "Please select a " +alertType+ " before adding this item to your cart."; 
		document.getElementById("alertMessage").style.display = "block"; 
		return false; 
	}
	else
	{
		var thisForm = document.getElementById("skuPurchase");
		if (thisForm) return validatePurchase(thisForm, false);
	}
}


function reloadDiv2 (pUrl, pDivId, pCallback) {
	if (document.getElementById(pDivId))
	{
		$.ajax({
			url: pUrl,
			type: "GET",
			dataType: "html",
			cache: false,
			success: function(html) {
			    var newHTML = "";
			    if ( rd ) {
			    	newHTML = "<div class='inner-product-desc' style='position:relative;'>" + html + "</div><div class='product-slider-menu' id='product-slider-menu-id'></div>";
			    	document.getElementById(pDivId).innerHTML = newHTML;
			    	$(".inner-product-desc").css("position", "relative");  	
			    	setProductSlider();
			    	keepShopping();
			    } else {
			    	newHTML = html;
			    	document.getElementById(pDivId).innerHTML = newHTML;
			    	keepShopping();
			    }
				
			}
		});
	}
}

function keepShopping() {
	if ( document.getElementById("keepShopSpan") && shopLink != "" ) {
		document.getElementById("keepShopSpan").innerHTML = shopLink;  
	}
}


// AJAX call to reload divs.
function reloadDiv (pUrl, pDivId, pCallback) {
	if (document.getElementById(pDivId))
	{
	    var xmlhttp;
	    // create the request
	    xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	    // callback to update specified div
	    xmlhttp.onreadystatechange = function () {
	        if (xmlhttp.readyState == 4) {
	            //alert ("x updating: " + pDivId + "\nURL: "+pUrl+"\nstatus: " + xmlhttp.status);
	            var newHTML = xmlhttp.responseText;
	            document.getElementById(pDivId).innerHTML = newHTML;
	            if (typeof(pCallback) == "function")
	            {
	            	pCallback();
	            }
	            if ( isFM ) {
	              setQtyPos();
	            }
	        }
	    }
	    // submit request
	    xmlhttp.open("get", pUrl, true);
	    xmlhttp.send(null);
	
		
	 }
}



// AJAX call to reload divs.
function getDynamicContent (pUrl, pCallback) {
    var xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("get", pUrl, false);
    xmlhttp.send(null);
	return xmlhttp.responseText;
}

   function makePOSTRequest(pUrl, pFormParameters, pTargetDiv, pCallback) {
      var http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('An error has occurred.  Please try again.\n\nIf this error continues, please contact webmaster@franklincovey.com for assistance.');
         var hidePage = document.getElementById("hidePage");
         if (hidePage) hidePage.style.display="none";
         return false;
      }
      http_request.onreadystatechange = function () {
	        if (http_request.readyState == 4) {
	            // alert ("x updating: " + pDivId + "\nURL: "+pUrl+"\nstatus: " + xmlhttp.status);
	            var newHTML = http_request.responseText;
	            if (document.getElementById(pTargetDiv))
	            	document.getElementById(pTargetDiv).innerHTML = "<br style='line-height:0px !important;' />"+newHTML;
	            	evaluateJs(pTargetDiv, newHTML);
	            if (typeof(pCallback) == "function")
	            {
	            	pCallback();
	            }
	        }
	    }
      http_request.open('POST', pUrl, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", pFormParameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(pFormParameters);
   }

	// {{{ __evaluateJs()
    /**
     * Evaluate Javascript in the inserted content
     *
     * @private
     */	
	function evaluateJs(pObj, pCode)
	{
		var obj = document.getElementById(pObj);
		if (obj)
		{
			var scriptTags = obj.getElementsByTagName('SCRIPT');
			var string = '';
			var jsCode = '';
			for(var no=0;no<scriptTags.length;no++){	
				if(scriptTags[no].src){
			        var head = document.getElementsByTagName("head")[0];
			        var scriptObj = document.createElement("script");
			        scriptObj.setAttribute("type", "text/javascript");
			        scriptObj.setAttribute("src", scriptTags[no].src);  	
			        head.appendChild(scriptObj);
				}else{
					if(window.opera){
						jsCode = jsCode + scriptTags[no].text + '\n';
					}
					else
					{
						jsCode = jsCode + scriptTags[no].innerHTML;	
					}
				}			
			}
			if(jsCode)installScript(jsCode);
		}
	}

	function installScript( script )
	{		
		try {
		    if (!script)
		        return;	
		    if (eval.call){
		    	eval.call(window,script);
		    }else if (window.execScript){ 
	        	window.execScript(script)
	        }else if(navigator.vendor.indexOf("Apple")!=-1){
	            window.setTimeout(script,0);
	        }else{        	
	            window.setTimeout( script, 0 );
	        } 
		}catch(e){
			alert(e);
		}
	}	

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } 
}

    function changeDivDisplay (whichDivs, newStyle)
	{
		if (document.getElementById)
		{
			for (i=0; i<whichDivs.length; i++)
			{
				if (document.getElementById(whichDivs[i]))
				{
					document.getElementById(whichDivs[i]).style.display=newStyle;
				}
			}
		}
	}


//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 


function submitAjaxForm(pFormId, pFormAction, pDivToReplace, pDivToFade, pCallback, pAjaxSubmit)
{
	if (document.getElementById(pFormId))
	{
		if (null==pFormAction) pFormAction=document.getElementById(pFormId).action;
		if (!pAjaxSubmit) document.getElementById(pFormId).submit();
		else 
		{
			var params=getValuesAsArray(pFormId);
			//make params into string
			var paramsString = "";
			for(var prop in params){
				paramsString+=escape(prop)+"="+escape(params[prop])+"&";			
			}		
			paramsString = paramsString.replace(/&$/, "");
			makePOSTRequest(pFormAction, paramsString, pDivToReplace, pCallback);
		}
	}
	else
	{
		alert('An error has occurred.  Please try again.\n\nIf this error continues, please contact webmaster@franklincovey.com for assistance.');
	}
}

function validatePurchase(pForm, pIsNameplate)
{
	var submitForm = true;
	if (pIsNameplate)
	{
		var nameplateValue = document.getElementById('nameplateValue');
		if (nameplateValue)
		{
			if (nameplateValue.value == "" || -1!=nameplateValue.value.indexOf("30 Character Limit"))
			{
				alert('Please specify the name and exact spelling that you want\non your nameplate in the "Step 1" text field.');
				submitForm=false;
			}
		}
	}
	if (submitForm)
	{
		var hidePage = document.getElementById('hidePage');
		try
		{
			submitAjaxForm('skuPurchase', pForm.action, 'cartConfirm', null, showAddToCart, true);
			if (hidePage)
			{
				hidePage.style.display="block";	
			}
		}
		catch(e)
		{
			hidePage.style.display="none";
		}
	}
	return false;
}

function showAddToCart()
{
	var cartConfirm = document.getElementById('cartConfirm');
	var hidePage = document.getElementById("hidePage");
	var fc_qv=document.getElementById('FC_QV');
	var cartSummary = document.getElementById('cartSummary-A');
	var cartSummaryRd = document.getElementById('cartSummary-rd');

	if (cartConfirm)
	{
		try {
			if (hidePage) { hidePage.style.height=getPageHeight(); }
			cartConfirm.style.top=getScrollAmt()*1+100+"px";
			if (cartSummaryRd) cartConfirm.style.left=(getPageWidth()*1-500*1)/2+"px";
			changeDivDisplay(['hidePage', 'cartConfirm'], 'block');
			if (fc_qv)
			{
				fc_qv.style.display = "none";
			}
		} catch(e) {
			changeDivDisplay(['hidePage'], 'none');
		}
	}
	
	if (cartSummaryRd)
	{
		reloadDiv ('/shopping/common/cartsummary_rd.jsp', 'cartSummary-rd');
	}
	else if (cartSummary)
	{
		reloadDiv ('/shopping/common/cartsummary_a.jsp', 'cartSummary-A');
	}
	slideRelatedProducts();
}

function slideRelatedProducts()
{
	var relatedProducts=document.getElementById('product-related-addcart');
	var addToCartSummary=document.getElementById('cartConfirmOuter');
	var slideSpeed = 10;	// Higher value = faster
	var timer = 13;	// Lower value = faster
	
	var objectIdToSlideDown = false;
	var activeId = false;
	var slideInProgress = false;

	if (addToCartSummary && relatedProducts) 
	{ 
		relatedProducts.style.top="0px";
		setTimeout("slideContent('"+slideSpeed+"', '"+timer+"')", 1000);
	}
}

function closeRelated()
{
	slideContent('-10', '13');
}

function slideContent(pDirection, pTimer)
{
	var prodSum =document.getElementById('cartConfirmOuter');
	var relatedProducts = document.getElementById('product-related-addcart');
	var newTop=getDivHeight(prodSum);
	var currentTop=0;
	currentTop=parseInt(relatedProducts.style.top, 10);
	if (isNaN(currentTop) || null==currentTop) 
	{
		currentTop=getDivHeight(prodSum);
	}
	else
	{
		currentTop=currentTop+(pDirection*1);
	}
	rerunFunction = true;
	if(currentTop>=getDivHeight(prodSum)){
		currentTop = getDivHeight(prodSum);
		rerunFunction = false;
	}
	if(currentTop<=1){
		currentTop = 1;
		rerunFunction = false;
	}
	relatedProducts.style.top = currentTop+'px';
	if(rerunFunction){
		setTimeout("slideContent('" + pDirection + "', '"+pTimer+"')", pTimer);
	}
}

function moveDiv(pDivName, pMoveAmount)
{
	var pDivRef = document.getElementById(pDivName);
	pDivRef.style.top=pMoveAmount+'px';
	return parseInt(pDivRef.style.top);
}


function closeCartWin()
{
	var cartConfirm = document.getElementById('cartConfirm');
	var hidePage = document.getElementById("hidePage");
	if (cartConfirm && hidePage)
	{
		changeDivDisplay(['hidePage', 'cartConfirm'], 'none');
		cartConfirm.innerHTML="";
	}
}


function reloadShoppingBag()
{	
	if (!document.getElementById('submissionError')) reloadDiv ('/shopping/checkout/cartitemsCheckout.jsp?redirectLink='+escape(document.location.href), 'shoppingBag');
}

function getValuesAsArray(formRef)
{
	var retArray = new Object();
	if (document.getElementById(formRef))
	{
		formRef = document.getElementById(formRef);
		var els = formRef.elements;
		for(var no=0;no<els.length;no++){
			if(els[no].disabled)continue;
			var tag = els[no].tagName.toLowerCase();
			switch(tag){
				case "input": 
					var type = els[no].type.toLowerCase();
					if(!type)type='text';
					switch(type){
						case "text":
						case "image":
						case "hidden":
						case "password":
							retArray[els[no].name] = els[no].value;
							break;
						case "checkbox":
							/*var boxes = this.getFamily(els[no],formRef);
							if(boxes.length>1){
								retArray[els[no].name] = new Array();
								for(var no2=0;no2<boxes.length;no2++){
									if(boxes[no2].checked){
										var index = retArray[els[no].name].length;
										retArray[els[no].name][index] = boxes[no2].value;
									}
								}								
							}else{*/
								if(els[no].checked)retArray[els[no].name] = els[no].value;
							//}
							break;	
						case "radio":
							if(els[no].checked)retArray[els[no].name] = els[no].value;
							break;		
						
					}	
					break;	
				case "select":
					var string = '';			
					var mult = els[no].getAttribute('multiple');
					if(mult || mult==''){
						retArray[els[no].name] = new Array();
						for(var no2=0;no2<els[no].options.length;no2++){
							var index = retArray[els[no].name].length;
							if(els[no].options[no2].selected)retArray[els[no].name][index] = els[no].options[no2].value;	
						}
					}else{
						retArray[els[no].name] = els[no].options[els[no].selectedIndex].value;
					}
					break;	
				case "textarea":
					retArray[els[no].name] = els[no].value;
					break;					
			}			
		}
	}
	return retArray;		
}



function reloadSkuOptionsDiv (pUrl, pDivId, pSkusFormName, pSkusElementName,pProdId, pDriverValue, pDisplaySelectedProduct, pProductDetailsTab, pSelect2, pQuickView) {
	if (pDriverValue==null||pDriverValue=="")
	{
		//window.location.reload();
		return;
	} 
	else
	{
		/*alert(
			'----------------------------------'+"\n"+
			'reloadSkuOptionsDiv'+"\n"+
			'----------------------------------'+"\n"+
			'pUrl='+pUrl+"\n"+
			'pDivId='+pDivId+"\n"+
			'pSkusFormName='+pSkusFormName+"\n"+
			'pSkusElementName='+pSkusElementName+"\n"+
			'pProdId='+pProdId+"\n"+
			'pDriverValue='+pDriverValue+"\n"+
			'pDisplaySelectedProduct='+pDisplaySelectedProduct+"\n"+
			'pProductDetailsTab='+pProductDetailsTab+"\n"+
			'pSelect2='+pSelect2+"\n"
		);*/
	    var skuId = getSelectedFormElementValue(pSkusFormName,pSkusElementName);
		var hidePurchase = false;
	    if (document.getElementById("select2")) hidePurchase = true;
	    var paramString = "?";
	    if (-1!=pUrl.indexOf("?")) paramString="&";
	    paramString += "id="+pProdId+"&driverValue="+pDriverValue+"&displaySelectedProduct="+pDisplaySelectedProduct+"&productDetailsTab="+pProductDetailsTab+"&quickView="+pQuickView;
	    paramString = paramString+"&testSkuId=";
	    if (skuId) {
	       paramString = paramString+skuId;
	    }
	    var xmlhttp;
	    // create the request
	    xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	    // callback to update specified div
	    xmlhttp.onreadystatechange = function () {
	        if (xmlhttp.readyState == 4) {
	            //alert ("x updating: " + pDivId + "\nURL: "+pUrl+paramString+"\nstatus: " + xmlhttp.status);
	            document.getElementById(pDivId).innerHTML = xmlhttp.responseText;
	            skuId = getSelectedFormElementValue(pSkusFormName,pSkusElementName);
	            /*if (!skuId) {
	                //skuId = selectFirstFormElementValue(pSkusFormName,pSkusElementName);
	            }*/
	            if (!skuId) {
	                skuId = getFormElementValue(pSkusFormName,"defaultSKU");
	            }
	            if (document.getElementById("select1Text"))
	            {
					document.getElementById("select1Text").style.color="";
					document.getElementById("select1Indicator").style.display="none";
	            }
	            reloadProductDivs(pProdId, skuId, pDriverValue, pDisplaySelectedProduct, pProductDetailsTab, pQuickView, hidePurchase, pSelect2);
	        }
	    }
	    // submit request
	    xmlhttp.open("get", getPageURLPrefix("/catalog/") + pUrl+paramString);
	    xmlhttp.send(null);
	   }
}

function show_props(obj, obj_name) { 
    var result = "" 
    for (var i in obj) 
        result += obj_name + "." + i + " = " + obj[i] + "\n" 
    return result; 
} 

function reloadSkuOptionsDivViewCart (pItemId, pUrl, pDivId, pSkusFormName, pSkusElementName,pProdId, pDriverValue, pDisplaySelectedProduct, pProductDetailsTab, pSelect2, pCheckout) {
	if (pDriverValue==null||pDriverValue=="")
	{
		window.location.reload();
	} 
	else
	{
	    var skuId = getSelectedFormElementValue(pSkusFormName,pSkusElementName);
		var hidePurchase = false;
	    if (document.getElementById("select2")) hidePurchase = true;
	    var paramString = "?";
	    if (-1!=pUrl.indexOf("?")) paramString="&";
	    paramString += "id="+pProdId+"&driverValue="+pDriverValue+"&displaySelectedProduct="+pDisplaySelectedProduct+"&productDetailsTab="+pProductDetailsTab+"&checkout="+pCheckout;
	    paramString = paramString+"&testSkuId=";
	    if (skuId) {
	       paramString = paramString+skuId;
	    }
	    var xmlhttp;
	    // create the request
	    xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	    // callback to update specified div
	    xmlhttp.onreadystatechange = function () {
	        if (xmlhttp.readyState == 4) {
	            //alert ("x updating: " + pDivId + "\nURL: "+pUrl+paramString+"\nstatus: " + xmlhttp.status);
	            document.getElementById(pDivId).innerHTML = xmlhttp.responseText;
	            skuId = getSelectedFormElementValue(pSkusFormName,pSkusElementName);
	            if (!skuId) skuId = getFormElementValue(pSkusFormName,"defaultSKU");
   	            if (!skuId && document.getElementById('defaultSku-'+pItemId)) skuId=document.getElementById('defaultSku-'+pItemId).value;
				if (!skuId)
				{
					var skuIdArry = document.getElementById(pDivId);
					for (var item = skuIdArry.firstChild; item; item = item.nextSibling) 
					{ 
				        if (item.name=="skuid") skuId=item.value;
					} 
				}
	            if (document.getElementById("select1Text"))
	            {
					document.getElementById("select1Text").style.color="";
					document.getElementById("select1Indicator").style.display="none";
	            }
	            if (skuId) reloadCommItemDivs(pProdId, pItemId, skuId, pDriverValue, null, pCheckout);	            
	        }
	    }
	    // submit request
	    xmlhttp.open("get", getPageURLPrefix("/catalog/") + pUrl+paramString);
	    xmlhttp.send(null);
	   }
}


function opProductPurchaseReload()
{
	return;
}

function qvRedraw() {
	if (typeof(QV_display) != 'undefined')
		QV_display.redrawQV();
}

function validateRelated()
{
	var driverForm = document.getElementById('skuSelectorPO');
	var secondaryForm = document.getElementById('Skus-related');
	var submitForm=true;
	
	if (driverForm)
	{
		var driverText = document.getElementById('select1Text-related')
		if (driverForm.elements['driverValue'] && ""==driverForm.elements['driverValue'].value && driverText)
		{
			driverText.style.color="red";
			submitForm=false;
		}
	}
	if (secondaryForm)
	{
		var secondaryText = document.getElementById('select2Text-related')
		if (secondaryForm.elements['skuid'] && secondaryForm.elements['skuid'].length && secondaryForm.elements['skuid'].length>1)
		{
			var found=false;
			for (var i=0; i<secondaryForm.elements['skuid'].length; i++)
			{
				if (secondaryForm.elements['skuid'][i].checked || (secondaryForm.elements['skuid'][i].selected && secondaryForm.elements['skuid'][i].value!=""))
				{
					found=true;
					break;
				}
			}
			if (!found)
			{
				secondaryText.style.color="red";
				submitForm=false;
			}
		}
		else if (secondaryForm.elements['skuid'] && ""==secondaryForm.elements['skuid'].value && secondaryText)
		{
			secondaryText.style.color="red";
			submitForm=false;
		}
	}
	if (submitForm)
	{
		submitAjaxForm('product-form-related', null, 'cartConfirm', null, showAddToCart, true);
	}
}

var clickOnceCount = 0;
function updateItem(pItemId)
{
	var elemValue;
	var submit=true;
	
	var hider = document.getElementById("hider");
	var slider = document.getElementById(pItemId+"_slider");
	var master = document.getElementById("cart-items-chk");
	
	var editTable = document.getElementById(pItemId+"_edit");
	
	var secondaryForm = document.getElementById("product-form-"+pItemId);
	var secondaryDiv = document.getElementById("product-secondary-options-"+pItemId);
	if (secondaryDiv)
	{
		var nodes = getNodeElementsByName("skuid",secondaryDiv);
		if (nodes && nodes.length==1)
		{
			if (nodes[0].value=="") 
			{
				submit=false;
			}
			//if radio array only has 1 element, then it will return "undefined"
			//for the length property, so you must check for a field value
			//to see if it has been checked.
			else if (null!=nodes[0].value)
			{
				var tagType=nodes[0].tagName.toLowerCase();
				if (tagType=="select" && !nodes[0].selected) 
				{
					var thisSelect = document.getElementById('skuid_'+pItemId);
					if (thisSelect && thisSelect.length > 1 && thisSelect.selectedIndex > 0) { submit=true }
					else submit=false;
				}
				else if (tagType=="input" && nodes[0].type.toLowerCase()=="radio" && !nodes[0].checked) submit=false;
			}
		}
		else if (nodes && nodes.length>1)
		{
			for (var i=0; i<nodes.length; i++)
			{
				switch(nodes[i].tagName.toLowerCase())
				{
					case "input": 
						var type = nodes[i].type.toLowerCase();
						if(!type)type='text';
						switch(type)
						{
							case "text":
							case "image":
							case "hidden":
							case "password":
								elemValue = nodes[i].value;
								break;
							case "checkbox":
								if(nodes[i].checked) elemValue = nodes[i].value;
								break;	
							case "radio":
								if(nodes[i].checked) elemValue = nodes[i].value;
								break;		
						}	
						break;	
					case "select":
						elemValue = nodes[i].options[nodes[i].selectedIndex].value;
						break;	
					case "textarea":
						elemValue = nodes[i].value;
						break;	
				}				
			}
			if (!elemValue || ""==elemValue)
				submit=false;
		}
		if (submit==false)
		{
			var alertCopy = document.getElementById('select2Text-'+pItemId);
			var alertCopy2 = document.getElementById('select2Indicator-'+pItemId);
			if (alertCopy)
				alertCopy.style.color="red";
			if (alertCopy2)
			{
				alertCopy2.style.color="red";
				alertCopy2.innerHTML="<b>Please select</b>";
				alertCopy2.display="block";
			}
			submit=false;
		}
	}
	if (submit && secondaryForm && clickOnceCount < 1)
	{
		if (hider && slider && master)
		{
			var masterTableHeight=getDivHeight(master);
			var masterTableWidth=getDivWidth(master);
			var editTableHeight=getDivHeight(editTable);
			hider.style.width=masterTableWidth+"px";
			hider.style.height=masterTableHeight+"px";
			slider.style.height=editTableHeight+"px";
			slider.innerHTML='<table width="100%" height="100%"><tr><td class="middle"><img src="/shopping/images/checkout/grn/slider.gif" alt="Please wait..." id="sliderImg"></td></tr></table>';
			slider.style.display="block";
			hider.style.display="block";
		}
		clickOnceCount++;
		secondaryForm.submit();
		var sliderImg = document.getElementById('sliderImg');
		if (silderImg) sliderImg.src=sliderImg.src;
	}
	else if (clickOnceCount>=1)
	{
		alert('Please wait... Your updated shopping cart will be displayed shortly.');
	}
}

function reloadDiv3()
{
//do nothing
}

function reloadCommItemDivs(pProdId, pItemId, pSkuId, pDriverValue, pSelect2, pCheckout) {
	if (pDriverValue==null||pDriverValue=="") {
		window.location.reload();
	}
	else
	{
		if ("related"==pItemId && pSkuId&& pSkuId!="")
		{
		    var urlPrefix = getPageURLPrefix("/catalog/");
		    reloadDiv(urlPrefix+"catalog/skuPriceRelatedWrapper.jsp?skuID="+pSkuId+"&prodID="+pProdId,"skuPriceRelated");
		    //get the form qty
		    var qty=1;
		    if (document.getElementById("product-form-"+pItemId))
		    {
		    	qty=document.getElementById("product-form-"+pItemId).quantity.value;
		    }
		    reloadDiv(urlPrefix+"catalog/skupurchaserelatedwrapper.jsp?prodId="+pProdId+"&skuID="+pSkuId+"&ciID=related&qty="+qty,"skuPurchRelated");
		}
		else
		{
			/*alert(
				'----------------------------------'+"\n"+
				'reloadProductDivs'+"\n"+
				'----------------------------------'+"\n"+
				'pProdId: '+pProdId+"\n"+
				'pItemId: '+pItemId+"\n"+
				'pSkuId: '+pSkuId+"\n"+
				'pDriverValue: '+pDriverValue+"\n"+
				'pSelect2: '+pSelect2+"\n"
			);*/
			if (!pSkuId)
			{
				pSkuId="";
			}
		    var urlPrefix = getPageURLPrefix("/catalog/");
		    //var paramString = "?prodId="+pProdId+"&skuId="+pSkuId+"&driverValue="+pDriverValue+"&disableOnFirstDisplay="+pDisableOnFirstDisplay+'&select2Desc='+pSelect2+'&optButtonOnState='+optButtonOnState+'&optButtonOffState='+optButtonOffState;
		    
		    if (pCheckout!="true") reloadDiv(urlPrefix+"catalog/skuImageWrapper.jsp?skuID="+pSkuId,"skuImg-"+pItemId);
			    else  reloadDiv(urlPrefix+"catalog/skuImageWrapper.jsp?skuID="+pSkuId+"&imageSize=medium", "skuImg-"+pItemId);
			var hideDetails = "";
			if (pCheckout=="true") hideDetails = "true";			
		    reloadDiv(urlPrefix+"catalog/skuDescriptionWrapper.jsp?skuID="+pSkuId+"&id="+pProdId+"&hideDetails="+hideDetails,"skuDesc-"+pItemId);
		    //get the form qty
		    var qty=1;
		    if (document.getElementById("product-form-"+pItemId))
		    {
		    	qty=document.getElementById("product-form-"+pItemId).quantity.value;
		    }
		    if (window.XMLHttpRequest) reloadDiv(urlPrefix+"catalog/skupurchaseviewcartwrapper.jsp?prodId="+pProdId+"&skuID="+pSkuId+"&ciID="+pItemId+"&qty="+qty+"&checkout="+pCheckout,"skuPurch-"+pItemId);
		    else reloadDiv(urlPrefix+"catalog/skupurchasegenericformwrapper.jsp?prodId="+pProdId+"&skuID="+pSkuId+"&ciID="+pItemId+"&qty="+qty,"skuPurchaseForm-"+pItemId);
		    
		    var priceWrapper = "skuPriceWrapper.jsp";
		    if (pCheckout=="true") priceWrapper = "skuPrice2Wrapper.jsp";
		    
		    reloadDiv(urlPrefix+"catalog/"+priceWrapper+"?skuID="+pSkuId+"&commerceID="+pItemId+"&qty="+qty,"skuPrice-"+pItemId);
	   }
	}	
}


function reloadProductDivs(pProdId, pSkuId, pDriverValue, pDisplaySelectedProduct, pProductDetailsTab, pQuickView, pDisableOnFirstDisplay, pSelect2) {
	if (pDriverValue==null||pDriverValue=="") {
		window.location.reload();
	}
	else
	{
		/*alert(
			'----------------------------------'+"\n"+
			'reloadProductDivs'+"\n"+
			'----------------------------------'+"\n"+
			'pProdId: '+pProdId+"\n"+
			'pSkuId: '+pSkuId+"\n"+
			'pDriverValue: '+pDriverValue+"\n"+
			'pDisplaySelectedProduct: '+pDisplaySelectedProduct+"\n"+
			'pProductDetailsTab: '+pProductDetailsTab+"\n"+
			'pDisableOnFirstDisplay: '+pDisableOnFirstDisplay+"\n"+
			'pSelect2: '+pSelect2+"\n"
		);*/
		if ( !pSkuId && fm_skus ) {
		  // Get the first undisabled sku id from the radios.
		  var skus = document.Skus.skuid;
		  if ( fm_skus == 'radio' ) {		    
		    for (i = 0; i <skus.length; i++) {
		      if ( skus[i].value != '' ) {
		        pSkuId = skus[i].value;
		        break;
		      }
		    }
		  } else if ( fm_skus == 'select' ) {
		    for (i = 0; i <skus.options.length; i++) {
		       if ( skus.options[i].value != '' ) {
		        pSkuId = skus.options[i].value;
		        break;
		      }
		    }
		  }
		  if ( !pSkuId ) {
		    pSkuId="";
			return;
		  }		  
		} else if (!pSkuId)
		{
			pSkuId="";
			return;
		}
	    var urlPrefix = getPageURLPrefix("/catalog/");
	    if (typeof(optButtonOnState) == 'undefined') optButtonOnState = "";
	    if (typeof(optButtonOffState) == 'undefined') optButtonOffState = "";
	    var paramString = "?prodId="+pProdId+"&skuId="+pSkuId+"&driverValue="+pDriverValue+"&disableOnFirstDisplay="+pDisableOnFirstDisplay+'&select2Desc='+pSelect2+'&optButtonOnState='+optButtonOnState+'&optButtonOffState='+optButtonOffState+'&quickView='+pQuickView;
	    reloadDiv(urlPrefix+"catalog/productnamewrapper.jspf"+paramString+"&displaySelectedProduct="+pDisplaySelectedProduct,"product-name");
	    if ( isFM ) {
	      reloadDiv(urlPrefix+"catalog/productfmpurchasewrapper.jspf"+paramString,"product-purchase");
	      reloadDiv(urlPrefix+"catalog/productfmmainimagewrapper.jspf"+paramString,"product-image");
	    } else {
	      reloadDiv(urlPrefix+"catalog/productpurchasewrapper.jspf"+paramString,"product-purchase");
	      reloadDiv(urlPrefix+"catalog/productmainimagewrapper.jspf"+paramString,"product-image");
	    }
	    
	    if (document.getElementById('product-slider-menu-id'))
	    {
	        
			reloadProductDetailDiv2(pProdId, pSkuId, pProductDetailsTab, null);
	    }
	    else
	    {
		    reloadDiv(urlPrefix+"catalog/productdetailstabwrapper.jspf"+paramString+"&productDetailsTab="+pProductDetailsTab,"product-details",qvRedraw);
	    }
	    if (document.getElementById("select2Text"))
	    {
			document.getElementById("select2Text").style.color="";
			document.getElementById("select2Indicator").style.display="none";
	    }	    
	}	
}

function reloadProductDetailDiv(pProdId, pSkuId, pProductDetailsTab, pTabIndentifier) {
    var paramString = "?prodId="+pProdId+"&skuId="+pSkuId+"&productDetailsTab="+pProductDetailsTab+"&tabIndentifier="+pTabIndentifier;
    reloadDiv(getPageURLPrefix("/catalog/") + "catalog/productdetailstabwrapper.jspf"+paramString,"product-details");
}
function reloadProductDetailDiv2(pProdId, pSkuId, pProductDetailsTab, pTabIndentifier) {
    
    var paramString = "?prodId="+pProdId+"&skuId="+pSkuId+"&productDetailsTab="+pProductDetailsTab+"&tabIndentifier="+pTabIndentifier;
    if (document.getElementById('qvProduct')) {
        reloadDiv(getPageURLPrefix("/catalog/") + "catalog/productdetailstabwrapper.jspf"+paramString,"product-details");
	} else {
	    reloadDiv2(getPageURLPrefix("/catalog/") + "catalog/productdetailstabwrapper.jspf"+paramString,"product-details");
	}
    
}

function getFormElementValue(pFormName, pElementName) {
    var value;
    var form=document.getElementById(pFormName);
    if (!form) {
        return value;
    }
    var element = form.elements[pElementName];
    if (!element) {
        return value;
    }
    value = element.value
    return value;
}

function getSelectedFormElementValue(pFormName, pElementName) {
    var checkedValue;
    var form=document.getElementById(pFormName);
    if (!form) {
        return checkedValue;
    }
    var options = form.elements[pElementName];
    if ( !options ) {
        return checkedValue;
    }
    if (options.length) {
		if (options.nodeName && options.nodeName.toLowerCase()=="select")
		{
			checkedValue = options[options.selectedIndex].value;
		}
		else
		{
	        for (i=0;  (!checkedValue) && (i<options.length); i++) {
	            if (options[i].checked) {
	                checkedValue = options[i].value;
	            }
	        }
		}
    }
    else {
        if (options.checked) {
            checkedValue = options.value;
        }
    }
    return checkedValue;
}

function selectFirstFormElementValue(pFormName, pElementName) {
    var checkedValue;
    var form=document.getElementById(pFormName);
    if (!form) {
        return checkedValue;
    }
    var options = form.elements[pElementName];
    if ( !options ) {
        return checkedValue;
    }
    if (options.length) {
        for (i=0; (!checkedValue) && (i<options.length); i++) {
            if (!options[i].disabled) {
                options[i].checked = true;
                checkedValue = options[i].value;
            }
        }
    }
    else {
        if (!options.disabled) {
            options.checked = true;
            checkedValue = options.value;
        }
    }
    return checkedValue;
}

function getPageURLPrefix(pBefore) {
    var requestURL = location.href;
    if (-1!=requestURL.indexOf("checkout")) pBefore = "/checkout/";
    var endIndex = requestURL.indexOf(pBefore);
    truncated = requestURL.substring(0, endIndex+1);
    return truncated;
}

function cancelCreateEdit(whichDiv)
{
	continueBtn = document.getElementById("continueSection");
	if (document.getElementById(whichDiv))
	{
		document.getElementById(whichDiv).innerHTML="";
		changeDivDisplay([whichDiv], 'none');
	}
	if ("true"!=gup('displayBilling') && whichDiv=="createEdit")
	{
		changeDivDisplay(['hidePage'], 'none');
	}
	if (continueBtn) { continueBtn.style.display="block"; }
		
}

function cancelBilling(whichDiv)
{
	if (document.getElementById(whichDiv))
	{
		changeDivDisplay([whichDiv, 'hidePage'], 'none');
	}
}


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if (els[i].className && els[i].className.match(pattern)) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function getNodeElementsByName(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if (els[i].name && els[i].name.match(pattern)) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


function getPageHeight()
{ 
	if( window.innerHeight && window.scrollMaxY ) // Firefox 
	{
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body && (document.body.scrollHeight > document.body.offsetHeight)) // all but Explorer Mac
	{
		pageHeight = document.body.scrollHeight;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{ 
		pageHeight = document.body.offsetHeight + document.body.offsetTop; 
	}
	return pageHeight;
}

function getPageWidth()
{ 
	if( window.innerWidth && window.scrollMaxX ) // Firefox 
	{
		pageWidth = window.innerWidth + window.scrollMaxX;
	}
	else if( document.body && (document.body.scrollWidth > document.body.offsetWidth)) // all but Explorer Mac
	{
		pageWidth = document.body.scrollWidth;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{ 
		pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
	}
	return pageWidth;
}



function getScrollAmt()
{
	var scroll=0;
	if (document.body.scrollTop)
	{
		scroll=document.body.scrollTop;
	}
	else if (window.pageYOffset)
	{
		scroll=window.pageYOffset;
	}
	return scroll;
}

function getDivHeight(pNode)
{ 
	return pNode.innerHeight?pNode.innerHeight:pNode.offsetHeight+document.body.offsetTop; 
}
function getDivWidth(pNode)
{ 
	return pNode.innerWidth?pNode.innerWidth:pNode.offsetWidth; 
}


function dumpProps(obj, parent) {
   for (var i in obj) {
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      if (!confirm(msg)) { return; }
      if (typeof obj[i] == "object") {
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}
function showShadows(whichDiv) 
{
	var selectedSpace = document.getElementById(whichDiv);
	var shadowTop = document.getElementById(whichDiv+"ShadowTop");
	var shadowBottom = document.getElementById(whichDiv+"ShadowBottom");
	var shadowLeft = document.getElementById(whichDiv+"ShadowLeft");
	var shadowBottomLeft = document.getElementById(whichDiv+"ShadowBottomLeft");
	var shadowRight = document.getElementById(whichDiv+"ShadowRight");
	if (selectedSpace) // && shadowTop && shadowBottom && shadowLeft && shadowRight)
	{
		var top = findPosY(selectedSpace);
		var left = findPosX(selectedSpace);
		var width = getDivWidth(selectedSpace);
		var height = getDivHeight(selectedSpace);
		if (width>0 && height>0)
		{
		
			var divWidth=width*1-16;
			//var divWidth2=left+width;
			var divHeight=height*1-16;
			//var divTop=top-8;
			//var divTop2 = top*1+8;
			//var divLeft=left*1+8; 
			//var divLeft2 = divLeft-16;
			//var divBottom=top+height;

			shadowTop.style.width=divWidth+"px";
			alert(shadowTop.style.width);
			//shadowTop.style.top=divTop+"px";
			//shadowTop.style.left=divLeft+"px";

			//shadowBottom.style.left=divLeft+"px";
			shadowBottom.style.width=divWidth+"px";
			//shadowBottom.style.top=divBottom+"px";
			
			//shadowLeft.style.left=divLeft2+"px";
			shadowLeft.style.height=divHeight+"px";
			//shadowLeft.style.top=divTop2+"px";
			
			//shadowRight.style.left=divWidth2+"px";
			//shadowRight.style.top=divTop2+"px";
			shadowRight.style.height=divHeight+"px";
			
			//shadowBottomLeft.style.top=divBottom-8+"px";
			//shadowBottomLeft.style.left=divLeft2+"px";
		}
	
	
	}
}


function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

function openContentWin(pURL)
{
	openWinRequired(pURL,'contentWin','scrollbars=yes,toolbar=yes,directories=yes,menubar=yes,resizable=yes,status=yes,width=1024,height=450');
}


		// Get the cookie!
		function getCookie(name)
		{
		    var re=new RegExp("(^"+name+"|;\\s?"+name+")=[^;]+", "i");
		    if (document.cookie.match(re)) // if cookie found
		      return document.cookie.match(re)[0].split("=")[1];
		    return null;
		}

		// Set the cookie
		function setCookie(name, value, expires, path, domain, secure) 
		{
			document.cookie = name + "=" + escape(value) +
			((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
			((path == null) ? "" : "; path=" + path) +
			((domain == null) ? "" : "; domain=" + domain) +
			((secure == null) ? "" : "; secure");
		}
		
		function gup(name)
		{
			var regexS = "[\\?\\&\\;]"+name+"=([^&#]*)";
		  	var regex = new RegExp( regexS );
		  	var tmpURL = window.location.href.replace(/amp;/g, "");
			
		  	var results = regex.exec( tmpURL );
		  	if( results == null )
		    	return "";
		  	else
		    	return results[1];
		}

		function getBaseDomain()
		{
			
			var currDomain = document.domain;
			var subDomain = null;
			if (null!=currDomain && ""!=currDomain)
			{
				subDomains = currDomain.split(".");
				var section = 1-subDomains.length;
			    if (subDomains.length > 2) 
			    {
			        subDomain = "."+subDomains.slice(section).join(".");
			    }
			}
			return subDomain;
		}	
	
    function setProductSlider() {

		if (document.getElementById('product-slider-menu-id'))
		{
	    	rd = true;
			var theHeight = 0;
	    	$('.inner-product-desc').each(function () {
						var current = $(this);
						current.attr("box_h", current.height());
						theHeight = current.height();
					}
			 );	
			var pctDiff = sliderHeight/theHeight;		
			if ( pctDiff < .80 ) {
				$(".inner-product-desc").css("height", sliderHeight);
				$(".inner-product-desc").css("overflow", "hidden");
				$(".product-slider-menu").html('<a href="#">Read More</a>');
				$(".product-slider-menu a").click(function() { openProductSlider() });
			} else {
				$(".inner-product-desc").css("height", "auto");
			}
		}
    }
      
	function openProductSlider()
	{
		var open_height = $(".inner-product-desc").attr("box_h") + "px";
		$(".inner-product-desc").animate({"height": open_height}, {duration: "slow" });
		
		$(".product-slider-menu").html('<a href="#">Close</a>');
		$(".product-slider-menu a").click(function() { closeProductSlider() })
	}
	
	function closeProductSlider()
	{
		$(".inner-product-desc").animate({"height": sliderHeight}, {duration: "slow" });
		
		$(".product-slider-menu").html('<a href="#">Read More</a>');
		$(".product-slider-menu a").click(function() { openProductSlider() })
	}	
	
function cycleBanners(startSlide,slideCount,store) {
    // Default randomize billboards.
    var rndm = 1;
    /************************************************************************
    * Banner randomizing defaults to true unless there are only 2 banners
    * or the store has an override define in the storeRandomBillboard array
    *************************************************************************/
    var storeRandom = new Array();
    storeRandom['franklincovey'] = false;

    /* Do not randomize if there are only 2 billboards.
     * The "Next" button stops working */
    if ( slideCount == 2 ) {
      rndm = 0;
    } else if ( storeRandom[store] == false) {
      rndm = 0;
    }
    // Force no random until the next button issue is resolved.
    rndm = 0;
      
   /*********************************************
    * Define banner rotation speed
    * Default to 4000 ms unless there is a store 
    * override in the storeDelays array.
    ********************************************/
   var delay = 4000; 
   var storeDelays = new Array();
   storeDelays['franklincovey'] = 6000;
   if ( storeDelays[store] ) { delay = storeDelays[store]; }

   $('#mainBanner').cycle({ 
				  timeout: delay,
				  random: rndm,
				  fx: 'fade', 
				  speed: 400,
				  prev : '#prev_banner_btn',
				  next : '#next_banner_btn',
				  after : onAfter,
				  startingSlide: startSlide
	});
}

function onAfter(curr, next, opts) {
  var index = $(this).parent().children().index(this);
  
  $('#prev_banner_btn')[index == 0 ? 'show' : 'show']();
  $('#next_banner_btn')[index == opts.slideCount - 1 ? 'show' : 'show']();
}
function toggleBannerNav(which,toggle) {
  if ( document[which + "_banner"] ) {
    document[which + "_banner"].src = "/shopping/images/shop_template/" + which + "_nav_" + toggle + ".gif"; 
  }
}	

function pmi_get_url_param( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function pmi_setup_panel()
{
   if (typeof(pmiGlobals) != "undefined")
   {
      if (typeof(pmiGlobals.setupPanel) != "undefined")
      {
         pmiGlobals.setupPanel();
      }
      else
      {
         setTimeout(pmi_setup_panel,100);
      }
   }
}

/*if ("true" == pmi_get_url_param("fromInfluencer") )
{
   pmi_setup_panel();
}*/
