/*--------------------------------------------------------------------------*
 * 
 * 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 = '(0) <span>$0.00</span>';
	}
	else if (items == null || total == null) {
		return;
	}
	else if(items == 0) {
		output = '(0) <span>$0.00</span>';
	}
	else {
		//Create string
		output = items + '';
		if (items > 1) {
			output = 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;}function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) { 
//Do not delete these comments. 
//Non-Obtrusive Image Swap Script V1.1 by Hesido.com 
//Attribution required on all accounts 
    if (typeof(elem) == 'string') elem = document.getElementById(elem); 
    if (elem == null) return; 
    var regg = /(.*)(_nm\.)([^\.]{3,4})$/ 
    var prel = new Array(), img, imgList, imgsrc, mtchd; 
    imgList = elem.getElementsByTagName('img'); 
    for (var i=0; img = imgList[i]; i++) { 
        if (!img.rolloverSet && img.src.match(regg)) { 
            mtchd = img.src.match(regg); 
            img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3]; 
            img.outSRC = img.src; 
            if (typeof(mouseOver) != 'undefined') { 
                img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false; 
                img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false; 
                img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false; 
                img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false; 
                } 
            if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;} 
            if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;} 
            if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;} 
            if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;} 
            img.rolloverSet = true; 
        } 
    } 
    function preLoadImg(imgSrc) { 
        prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc; 
    } 
} 
function imgHoverSwap() {this.src = this.hoverSRC;} 
function imgOutSwap() {this.src = this.outSRC;} 
function imgMouseDownSwap() {this.src = this.mdownSRC;} 
function imgMouseUpSwap() {this.src = this.mupSRC;}// JavaScript Document
// Pant Size Guide Pop-up Script

function popitup(url) {
	newwindow=window.open(url,'name','height=369,width=400');
	if (window.focus) {newwindow.focus()}
	return false;
}var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.fader=function(){
	function fade(n,p){this.n=n; this.init(p)}
	fade.prototype.init=function(p){
		var s=T$(p.id), u=this.u=T$$('li',s), l=u.length, i=this.l=this.c=this.z=0;
		if(p.navid&&p.activeclass){this.g=T$$('li',T$(p.navid)); this.s=p.activeclass}
		s.style.overflow='hidden'; this.a=p.auto||0; this.p=p.resume||0;
		for(i;i<l;i++){
			if(u[i].parentNode==s){
				u[i].style.position='absolute'; this.l++; u[i].o=p.visible?100:0;
				u[i].style.opacity=u[i].o/100; u[i].style.filter='alpha(opacity='+u[i].o+')'
			}
		}
		this.pos(p.position||0,this.a?1:0,p.visible)
	},
	fade.prototype.auto=function(){
		this.u.ai=setInterval(new Function(this.n+'.move(1,1)'),this.a*1000)
	},
	fade.prototype.move=function(d,a){
		var n=this.c+d, i=d==1?n==this.l?0:n:n<0?this.l-1:n; this.pos(i,a)
	},
	fade.prototype.pos=function(i,a,v){
		var p=this.u[i]; this.z++; p.style.zIndex=this.z;
		clearInterval(p.si); clearInterval(this.u.ai); this.u.ai=0; this.c=i;
		if(p.o>=100&&!v){p.o=0; p.style.opacity=0; p.style.filter='alpha(opacity=0)'}
		if(this.g){for(var x=0;x<this.l;x++){this.g[x].className=x==i?this.s:''}}
		p.si=setInterval(new Function(this.n+'.fade('+i+','+a+')'),20)
	},
	fade.prototype.fade=function(i,a){
		var p=this.u[i];
		if(p.o>=100){
			clearInterval(p.si); if((a||(this.a&&this.p))&&!this.u.ai){this.auto()}
		}else{
			p.o+=5; p.style.opacity=p.o/100; p.style.filter='alpha(opacity='+p.o+')'
		}
	};
	return{fade:fade}
}();
