/*--------------------------------------------------------------------------*
 * 
 * Copyright (C) 2008 Brand Labs LLC
 * 
 * Continue shopping which uses the referrer to redirect to
 * 
 * Version 1.0.2
 * 
 *--------------------------------------------------------------------------*/

function continueShopping(){var aa=null;var ba=null;var ca='/';var da=window.location.pathname;var ea=window.location.host;var fa=null;var ga;if(document.referrer){aa=document.referrer;}
try{fa=getProductHistoryURL();}
catch(e){fa=null;}
ca=(fa==null?ca:fa);if(aa==null||aa==''){window.location.href=ca;return;}
try{ga=aa.indexOf(ea);if(ga==-1){window.location.href=ca;return;}
ba=aa.substring((ga+ea.length));if(ba.toLowerCase().indexOf(da.toLowerCase())==0){window.location.href=ca;return;}
window.location.href=ba;return;}
catch(e){window.location.href=ca;return;}}
function getProductHistoryURL(){var ha='%2FHistory';var ia=null;var ja=null;var ka=null;var la=null;if(!document.cookie||document.cookie==null){return null;}
ia=document.cookie.split(';');for(index=0;index<ia.length;index++){ja=ia[index];while(ja.charAt(0)==' '){ja=ja.substring(1,ja.length);}
if(ja.indexOf(ha+'=')==0){ka=ja.substring(ha.length+1);if(ka==null||ka==''){return null;}
la=ka.split('%2C');return '/ProductDetails.asp?ProductCode='+la[0];}}
return null;}/*--------------------------------------------------------------------------*
 * 
 * Copyright (C) 2008 Brand Labs LLC
 * 
 *--------------------------------------------------------------------------*/
/**
 * Update header with cart items
 */
function updateHeaderCartSummary() {
	var element;
	var items;
	var output;
	
	element = document.getElementById('view_cart_text_right');
	
	if(element == null) {
		return;
	}
	
	items = getShoppingCartItems();
	total = getShoppingCartTotal();
	
	//No items or null
	if(isShoppingCartEmpty()) {
		output = '<span>$0.00</span>';
	}
	else if (items == null || total == null) {
		return;
	}
	else if(items == 0) {
		output = '<span>$0.00</span>';
	}
	else {
		//Create string
		output = items + '';
		if (items > 1) {
			output = output + '';
		}
		output = '<span>' + total + '</span>';
	}
	
	//Put data into field
	element.innerHTML = output;
}/*--------------------------------------------------------------------------*
 * 
 * Copyright (C) 2008 Brand Labs LLC
 * 
 * Shopping Cart Summary
 * 
 * Version 1.2.1
 * 
 *--------------------------------------------------------------------------*/

function getShoppingCartSummary(){var aa;var ba;aa=document.getElementById('display_cart_summary');if(aa==null){return null;}
return aa.innerHTML;}
function isShoppingCartEmpty(){var ca;ca=getShoppingCartSummary();if(ca==null){return null;}
if(ca.search('(Your shopping cart is empty)')!=-1){return true;}
return false;}
function getShoppingCartItems(){var da;var ea;da=getShoppingCartSummary();if(da==null){return null;}
ea=da.match(/\d+/);if(ea==null){return null;}
return ea[0];}
function getShoppingCartTotal(){var fa;var ga;var ha;var ia;fa=getShoppingCartSummary();if(fa==null){return null;}
ga=fa.match(/total\scost\sof\s.*\)/);ha=fa.match(/priced\sat\s.*\)/);if(ga==null&&ha==null){return null;}
if(ga!=null){if(ga[0]==null||ga[0].length<=15){return null;}
ia=ga[0].substr(14,ga[0].length-15);}
else{if(ha[0]==null||ha[0].length<=11){return null;}
ia=ha[0].substr(10,ha[0].length-11);}
return ia;}/*--------------------------------------------------------------------------*
 * 
 * Copyright (C) 2008 Brand Labs LLC
 * 
 * Default value temporary for user
 * 
 * Version 1.0.1
 * 
 *--------------------------------------------------------------------------*/

function inputTextClicked(aa,ba){if(aa.value==aa.defaultValue){aa.value='';aa.style.color=ba;}}
function inputTextBlurred(ca,da){if(ca.value!=''){return;}
ca.style.color=da;ca.value=ca.defaultValue;}
