function go(form){window.location=form.range.options[form.range.selectedIndex].value;}
function goID(id){window.location=document.getElementById(id).value;}
function preload_images(){var d=document;if(!d.imgs){d.imgs=new Array();}
var j=d.imgs.length,args=preload_images.arguments,i;for(i=0;i<args.length;i++){d.imgs[j]=new Image;d.imgs[j].src=args[i];j++;}}
function bookmark(title){var urlAddress=location.href;var pageName=title;var browser=navigator.appName;if(browser=='Microsoft Internet Explorer'){window.external.AddFavorite(urlAddress,pageName)}else if(browser=='Netscape'){alert("Your browser does not support this feature.  Use CTRL-D to bookmark this page");}else{alert("Your browser does not support this feature.");}}
function getCookie(Name){var search=Name+"=";var returnvalue="";if(document.cookie.length>0){offset=document.cookie.indexOf(search)
if(offset!=-1){offset+=search.length}
end=document.cookie.indexOf(";",offset);if(end==-1){end=document.cookie.length;}
returnvalue=unescape(document.cookie.substring(offset,end))}
return returnvalue;}
function setCookie(name,num){document.cookie=name+"="+num;}
function isCookied(name,num){if(getCookie(name)!=num){return true;}else{return false;}}
function checkMinQty(id,min_qty,type){qty=document.getElementById(id);curr_qty=qty.value;if(curr_qty!=0&&min_qty!='0'&&min_qty!='1'){if(type=='interactive'){curr_qty--;}
if(Number(curr_qty)<Number(min_qty)){alert('You must add at least '+min_qty+' of that item before continuing.');qty.value=min_qty;return false;}}
return true;}
function checkMinQtySubs(name,qty,price){var names=name.split(",");var qtys=qty.split(",");var prices=price.split(",");for(var n in names){if(names[n]!=''&&!checkMinQty('qty_'+names[n],qtys[n],'')){priceChange(names[n],'dynamic',prices[n]);return false;}}
return true;}
function priceChange(id,oper,num){if(num==''){num=document.getElementById('hidden_price_'+id).value;}
if(oper=='dynamic'){var num2=0;var qty=document.getElementById('qty_'+id).value;if(qty<1||qty==''){document.getElementById('price_'+id).value='$'+num;}else{num2=num.replace(',','')*document.getElementById('qty_'+id).value;document.getElementById('price_'+id).value='$'+num2.toFixed(2);}}
if(oper=='add'){++document.getElementById('qty_'+id).value;var qty=document.getElementById('qty_'+id).value;if(qty<1){document.getElementById('qty_'+id).value='1';document.getElementById('price_'+id).value='$'+num;}else{num2=num.replace(',','')*document.getElementById('qty_'+id).value;document.getElementById('price_'+id).value='$'+num2.toFixed(2);}}
if(oper=='sub'){--document.getElementById('qty_'+id).value;var qty=document.getElementById('qty_'+id).value;if(qty<1){document.getElementById('qty_'+id).value='1';document.getElementById('price_'+id).value='$'+num;}else{num2=num.replace(',','')*document.getElementById('qty_'+id).value;}}
if(oper=='dropdown'){var qty=document.getElementById('qty_'+id).value;if(qty<1){document.getElementById('qty_'+id).value='1';document.getElementById('price_'+id).value='$'+num;}else{num2=num.replace(',','')*document.getElementById('qty_'+id).value;}}
if(num2!=''){if(!isNaN(num2)){document.getElementById('price_'+id).value='$'+num2.toFixed(2);}else{document.getElementById('price_'+id).value='$'+num;document.getElementById('qty_'+id).value='';}}}
function cartChange(id,num,qty,total,name){var num2=0;var qty2=document.getElementById('qty_'+id).value;if(isNaN(qty2)){document.getElementById('qty_'+id).value='';qty2='';}
var num3=document.getElementById('price_'+id).value.split("$");var num3=num3[1].replace(',','');if(qty!='0'||!qty){var rPrice=num.replace(',','')/qty;}else{document.getElementById('price_'+id).value='$0.00';}
num2=(rPrice*qty2);document.getElementById('price_'+id).value='$'+num2.toFixed(2);if(total==document.getElementById('total').value){total=total-num3;total=total+num2;document.getElementById('total').value='$'+total.toFixed(2);}else{var fake_total=document.getElementById('total').value.split("$");fake_total=fake_total[1].replace(',','');total=fake_total-num3;total=total+num2;document.getElementById('total').value='$'+total.toFixed(2);}
var nQty=getCookie(name);arQty=nQty.split('|');cntQty=arQty.length-1;for(i=0;i<cntQty;i++){arID=arQty[i].split(',');if(document.getElementById('qty_'+arID[0]).value==arID[1]){document.getElementById('hasUpdated').value='1';document.getElementById('update_msg').style.color='#000';continue;}else{document.getElementById('hasUpdated').value='0';document.getElementById('update_msg').style.color='#F00';break;}}}
function hasUpdated(){if(typeof document.getElementById('hasUpdated')!='undefined'){var hUpdated=document.getElementById('hasUpdated').value;if(hUpdated!='1'){alert('You have not updated your cart since last changing your quantities.\nPlease press the \'Update Cart\' button before continuing.');return false;}}}
function verifyRecipients(theForm){var intLength=theForm.length;var firstStep=1,shipTos=new Array();for(var i=0;i<intLength;i++){if(firstStep&&theForm.elements[i].name.substr(0,4)=='recp'){var numShipTos=+theForm.elements[i].options.length-1;firstStep=0;}
if(theForm.elements[i].name.substr(0,4)=='recp'&&theForm.elements[i].value==''){alert('You must choose a recipient for each of the products you are purchasing.');return false;}else if(theForm.elements[i].name.substr(0,4)=='recp'){var shipTo=theForm.elements[i].selectedIndex;if(!in_array(shipTo,shipTos)){var stLen=shipTos.length;shipTos.push(shipTo);}}}
if(shipTos.length!=numShipTos){var verifyShipTos=confirm("Some of your shipping address do not have products assigned to them.\n\nDo you wish to continue anyway?");if(verifyShipTos){return true;}else{return false;}}
return true;}
function in_array(needle,haystack){if(typeof needle==undefined){alert("Needle is undefined.\nError: in_array");return false;}else if(typeof haystack==undefined){alert("Needle is undefined.\nError: in_array");return false;}
for(i=0,n=haystack.length;i<n;i++){if(haystack[i]==needle){return true;}}
return false;}
function noHammer(theForm){if(typeof theForm.submit!='undefined'){theForm.submit.disabled=true;theForm.submit.value='Wait...';return true;}}
function validateForgotForm(theForm){var theEmail=theForm.email;var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if((theEmail.value==null)||(theEmail.value=="")){document.getElementById('errorMsg').innerHTML="<br />Please enter a valid e-mail address before continuing.";theEmail.focus();return false;}else{if(!filter.test(theEmail.value)){document.getElementById('errorMsg').innerHTML="<br />Please enter a valid e-mail address before continuing.";theEmail.value="";theEmail.focus();return false;}}
return true;}
function hideShowCalc(recip){recip=(recip!='')?'_'+recip:'';if(document.getElementById('cart_ship_estimator'+recip)!=null&&typeof document.getElementById('cart_ship_estimator'+recip)!='undefined'){var div=document.getElementById('cart_ship_estimator'+recip);var link=document.getElementById('hideShowCalc'+recip);}else{return false;}
div.style.display=(div.style.display=='block')?'none':'block';link.innerHTML=(div.style.display=='block')?'Hide Details':'Show Details';}
function suggestedSearchField(value,typ){if(typ=='out'){value.className='suggestion';}else if(typ=='over'){value.className='suggestion_hover';}else if(typ=='click'){document.getElementById('search_keyword').value=value.innerHTML;document.getElementById('suggestions').innerHTML='';document.getElementById('suggestions').className='';}}
var suggested_val=null;function suggestedSearchSniff(e,typ,theclass,func,params){if(e.keyCode==40){if(suggested_val==null){suggested_val=0;}else{document.getElementById('suggestion_'+suggested_val).className='suggestion';suggested_val++;}
if(document.getElementById('suggestion_'+suggested_val)!=undefined){fld=document.getElementById('suggestion_'+suggested_val);document.getElementById('search_keyword').value=fld.innerHTML;fld.className='suggestion_hover';}else{suggested_val=null;}}else if(e.keyCode==38){if(suggested_val!=null&&suggested_val!=0){document.getElementById('suggestion_'+suggested_val).className='suggestion';suggested_val--;if(document.getElementById('suggestion_'+suggested_val)!=undefined){fld=document.getElementById('suggestion_'+suggested_val);document.getElementById('search_keyword').value=fld.innerHTML;fld.className='suggestion_hover';}else if(document.getElementById('suggestion_0')!=undefined){fld=document.getElementById('suggestion_0');document.getElementById('search_keyword').value=fld.innerHTML;fld.className='suggestion_hover';suggested_val=0;}else{suggested_val=null;}}else if(suggested_val==0){document.getElementById('suggestion_0').className='suggestion';suggested_val=null;}}else{suggested_val=null;getInfo(typ,theclass,func,params);}}
function toggleBlock(test_id,change_id,change_val,display_val){if(document.getElementById(test_id).value==change_val){var set_display=display_val;}else{var set_display=(display_val=='block')?'none':'block';}
document.getElementById(change_id).style.display=set_display;return false;}
function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}
function MM_swapImgRestore(){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_findObj(n,d){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(){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];}}
function bookmarksite(title,url){if(window.sidebar)
window.sidebar.addPanel(title,url,"");else if(window.opera&&window.print){var elem=document.createElement('a');elem.setAttribute('href',url);elem.setAttribute('title',title);elem.setAttribute('rel','sidebar');elem.click();}
else if(document.all)
window.external.AddFavorite(url,title);}
function show(id){var object=document.getElementById(id);object.style.display='block';}
function hide(id){var object=document.getElementById(id);object.style.display='none';}
var arTabs=new Array('tab1','tab2','tab3');function tabOn(id){for(var i=0,n=arTabs.length;i<n;i++){if(document.getElementById(arTabs[i])!=null&&typeof document.getElementById(arTabs[i])!='undefined'){if(arTabs[i]==id){var item=document.getElementById(arTabs[i]);var tab=document.getElementById(arTabs[i]+'_tab');tab.style.backgroundImage=tab.style.backgroundImage.replace('off','on');tab.className=tab.className.replace('off','on');item.style.display='block';}else{var item=document.getElementById(arTabs[i]);var tab=document.getElementById(arTabs[i]+'_tab');tab.style.backgroundImage=tab.style.backgroundImage.replace('on','off');tab.className=tab.className.replace('on','off');item.style.display='none';}}}}
function calcBusinessDays(dDate1,dDate2){var iWeeks,iDateDiff,iAdjust=0;if(dDate2<dDate1)return-1;var iWeekday1=dDate1.getDay();var iWeekday2=dDate2.getDay();iWeekday1=(iWeekday1==0)?7:iWeekday1;iWeekday2=(iWeekday2==0)?7:iWeekday2;if((iWeekday1>5)&&(iWeekday2>5))iAdjust=1;iWeekday1=(iWeekday1>5)?5:iWeekday1;iWeekday2=(iWeekday2>5)?5:iWeekday2;iWeeks=Math.floor((dDate2.getTime()-dDate1.getTime())/604800000)
if(iWeekday1<iWeekday2){iDateDiff=(iWeeks*5)+(iWeekday2-iWeekday1)}else{iDateDiff=((iWeeks+1)*5)-(iWeekday1-iWeekday2)}
iDateDiff-=iAdjust
return(iDateDiff+1);}
var current_count=0;var max_count=200;function textCounter(field,target){if(field.value.length>max_count){field.value=field.value.substring(0,max_count);}else{current_count=max_count-field.value.length;target.value=current_count;}}
function disableEnterKey(e){var key;if(window.event)
key=window.event.keyCode;else
key=e.which;return(key!=13);}

/*!
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008-2011 M. Alsup
 * Version: 1.3.1 (07-OCT-2011)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.3.2 or later
 */
;(function($) {

var ver = 'Lite-1.3';

$.fn.cycle = function(options) {
    return this.each(function() {
        options = options || {};
        
        if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
        this.cycleTimeout = 0;
        this.cyclePause = 0;
        
        var $cont = $(this);
        var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
        var els = $slides.get();
        if (els.length < 2) {
            window.console && console.log('terminating; too few slides: ' + els.length);
            return; // don't bother
        }

        // support metadata plugin (v1.0 and v2.0)
        var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
		var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
		if (meta)
			opts = $.extend(opts, meta);
            
        opts.before = opts.before ? [opts.before] : [];
        opts.after = opts.after ? [opts.after] : [];
        opts.after.unshift(function(){ opts.busy=0; });
            
        // allow shorthand overrides of width, height and timeout
        var cls = this.className;
        opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width;
        opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height;
        opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1]) || opts.timeout;

        if ($cont.css('position') == 'static') 
            $cont.css('position', 'relative');
        if (opts.width) 
            $cont.width(opts.width);
        if (opts.height && opts.height != 'auto') 
            $cont.height(opts.height);

        var first = 0;
        $slides.css({position: 'absolute', top:0, left:0}).each(function(i) { 
            $(this).css('z-index', els.length-i) 
        });
        
        $(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
        if ($.browser.msie) els[first].style.removeAttribute('filter');

        if (opts.fit && opts.width) 
            $slides.width(opts.width);
        if (opts.fit && opts.height && opts.height != 'auto') 
            $slides.height(opts.height);
        if (opts.pause) 
            $cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});

        var txFn = $.fn.cycle.transitions[opts.fx];
		txFn && txFn($cont, $slides, opts);
        
        $slides.each(function() {
            var $el = $(this);
            this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
            this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
        });

        if (opts.cssFirst)
            $($slides[first]).css(opts.cssFirst);

        if (opts.timeout) {
            // ensure that timeout and speed settings are sane
            if (opts.speed.constructor == String)
                opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
            if (!opts.sync)
                opts.speed = opts.speed / 2;
            while((opts.timeout - opts.speed) < 250)
                opts.timeout += opts.speed;
        }
        opts.speedIn = opts.speed;
        opts.speedOut = opts.speed;

 		opts.slideCount = els.length;
        opts.currSlide = first;
        opts.nextSlide = 1;

        // fire artificial events
        var e0 = $slides[first];
        if (opts.before.length)
            opts.before[0].apply(e0, [e0, e0, opts, true]);
        if (opts.after.length > 1)
            opts.after[1].apply(e0, [e0, e0, opts, true]);
        
        if (opts.click && !opts.next)
            opts.next = opts.click;
        if (opts.next)
            $(opts.next).bind('click', function(){return advance(els,opts,opts.rev?-1:1)});
        if (opts.prev)
            $(opts.prev).bind('click', function(){return advance(els,opts,opts.rev?1:-1)});

        if (opts.timeout)
            this.cycleTimeout = setTimeout(function() {
                go(els,opts,0,!opts.rev)
            }, opts.timeout + (opts.delay||0));
    });
};

function go(els, opts, manual, fwd) {
    if (opts.busy) return;
    var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
    if (p.cycleTimeout === 0 && !manual) 
        return;

    if (manual || !p.cyclePause) {
        if (opts.before.length)
            $.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
        var after = function() {
            if ($.browser.msie)
                this.style.removeAttribute('filter');
            $.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
            queueNext();
        };

        if (opts.nextSlide != opts.currSlide) {
            opts.busy = 1;
            $.fn.cycle.custom(curr, next, opts, after);
        }
        var roll = (opts.nextSlide + 1) == els.length;
        opts.nextSlide = roll ? 0 : opts.nextSlide+1;
        opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
    }
    
    function queueNext() {
        if (opts.timeout)
            p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev) }, opts.timeout);
    }
};

// advance slide forward or back
function advance(els, opts, val) {
    var p = els[0].parentNode, timeout = p.cycleTimeout;
    if (timeout) {
        clearTimeout(timeout);
        p.cycleTimeout = 0;
    }
    opts.nextSlide = opts.currSlide + val;
    if (opts.nextSlide < 0) {
        opts.nextSlide = els.length - 1;
    }
    else if (opts.nextSlide >= els.length) {
        opts.nextSlide = 0;
    }
    go(els, opts, 1, val>=0);
    return false;
};

$.fn.cycle.custom = function(curr, next, opts, cb) {
    var $l = $(curr), $n = $(next);
    $n.css(opts.cssBefore);
    var fn = function() {$n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb)};
    $l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
        $l.css(opts.cssAfter);
        if (!opts.sync) fn();
    });
    if (opts.sync) fn();
};

$.fn.cycle.transitions = {
    fade: function($cont, $slides, opts) {
		$slides.not(':eq(0)').hide();
		opts.cssBefore = { opacity: 0, display: 'block' };
		opts.cssAfter  = { display: 'none' };
		opts.animOut = { opacity: 0 };
		opts.animIn = { opacity: 1 };
    },
    fadeout: function($cont, $slides, opts) {
		opts.before.push(function(curr,next,opts,fwd) {
			$(curr).css('zIndex',opts.slideCount + (fwd === true ? 1 : 0));
			$(next).css('zIndex',opts.slideCount + (fwd === true ? 0 : 1));
		});
		$slides.not(':eq(0)').hide();
		opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
		opts.cssAfter  = { display: 'none', zIndex: 0 };
		opts.animOut = { opacity: 0 };
    }
};

$.fn.cycle.ver = function() { return ver; };

// @see: http://malsup.com/jquery/cycle/lite/
$.fn.cycle.defaults = {
	animIn:        {},
	animOut:       {},
	fx:           'fade',
    after:         null, 
    before:        null, 
	cssBefore:     {},
	cssAfter:      {},
    delay:         0,    
    fit:           0,    
    height:       'auto',
	metaAttr:     'cycle',
    next:          null, 
    pause:         0,    
    prev:          null, 
    speed:         1000, 
    slideExpr:     null,
    sync:          1,    
    timeout:       4000 
};

})(jQuery);


