
// this code fixes the IE6 flicker bug 
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch (err) { }
// end IE6 flicker bug fix

/*Superfish v1.3.1  - jQuery menu widget Copyright (c) 2007 Joel Birch */
/* Custom settings used for delay and speed.   delay: 500, speed: 400*/

(function ($) {
    $.fn.superfish = function (o) {
        var $sf = this,
			defaults = {
			    hoverClass: 'sfHover',
			    pathClass: 'overideThisToUse',
			    delay: 500,
			    animation: { opacity: 'show' },
			    speed: 400
			},
		over = function () {
		    clearTimeout(this.sfTimer);
		    clearTimeout($sf[0].sfTimer);
		    $(this)
				.showSuperfishUl()
				.siblings()
				.hideSuperfishUl();
		},
		out = function () {
		    var $$ = $(this);
		    if (!$$.is('.' + o.bcClass)) {
		        this.sfTimer = setTimeout(function () {
		            $$.hideSuperfishUl();
		            if (!$('.' + o.hoverClass, $sf).length) {
		                over.call($currents.hideSuperfishUl());
		            }
		        }, o.delay);
		    }
		};
        $.fn.extend({
            hideSuperfishUl: function () {
                return this
					.removeClass(o.hoverClass)
					.find('ul:visible')
						.hide()
					.end();
            },
            showSuperfishUl: function () {
                return this
					.addClass(o.hoverClass)
					.find('>ul:hidden')
						.animate(o.animation, o.speed)
					.end();
            },
            applySuperfishHovers: function () {
                return this[($.fn.hoverIntent) ? 'hoverIntent' : 'hover'](over, out);
            }
        });
        o = $.extend({ bcClass: 'sfbreadcrumb' }, defaults, o || {});
        var $currents = $('li:has(ul)', this).filter('.' + o.pathClass);
        if ($currents.length) {
            $currents.each(function () {
                $(this).removeClass(o.pathClass).addClass(o.hoverClass + ' ' + o.bcClass);
            });
        }
        var $sfHovAr = $('li:has(ul)', this)
			.applySuperfishHovers(over, out)
        /* commented out .find('a').each(superfishFocusBlur) for performance - glowney & tguffee 6/08 */
        /*			.find('a')
        .each(superfishFocusBlur)
        */.end()
			.not('.' + o.bcClass)
				.hideSuperfishUl()
			.end();
        $(window).unload(function () {
            $sfHovAr.unbind('mouseover').unbind('mouseout');
        });
        return this.addClass('superfish').blur(function () {
            out.call(this);
        });
    };

    function superfishFocusBlur() {
        var $a = $(this), $li = $a.parents('li');
        $a.focus(superfishOverCall).blur(superfishRemoveClass);
    }
    function superfishOverCall() {
        over.call($li);
        return false;
    }
    function superfishRemoveClass() {
        $li.removeClass(o.hoverClass);
    }

    /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
    * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
    * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
    *
    * @name bgiframe
    * @type jQuery
    * @cat Plugins/bgiframe
    *
    * Version 2.1.1
    * Custom settings used for $.extend. REI  5/28/08 top:'-1px',left:'0px',width:'180px' 
    */
    $.fn.bgIframe = $.fn.bgiframe = function (s) { if ($.browser.msie && /6.0/.test(navigator.userAgent)) { s = $.extend({ top: '-1px', left: '0px', width: '180px', height: 'auto', opacity: true, src: 'javascript:false;' }, s || {}); var prop = function (n) { return n && n.constructor == Number ? n + 'px' : n; }, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' + 'style="display:block;position:absolute;z-index:-1;' + (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') + 'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' + 'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' + 'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' + 'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' + '"/>'; return this.each(function () { if ($('> iframe.bgiframe', this).length == 0) this.insertBefore(document.createElement(html), this.firstChild); }); } return this; };

//    /**
//    * hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
//    * <http://cherne.net/brian/resources/jquery.hoverIntent.html>
//    * 
//    * @param  f  onMouseOver function || An object with configuration options
//    * @param  g  onMouseOut function  || Nothing (use configuration options object)
//    * @author    Brian Cherne <brian@cherne.net>
//    * Custom settings used for sensitivity setting. REI  5/28/08 sensitivity:6 
//    */
//    $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 6, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); };

})(jQuery);

// old deprecated code
function init() { }
(function ($) {
    /* rei namespace
    * setup, jmontgo Dec 2010
    */
    if (window.rei) return;

    var rei;
    window.rei = rei = {
        error: [],
        analytics: [],
        re: { // RegExp cache
            cleanUrlChars: /[;'<>=()]/gm
        },
        perf: { start: window.perf_start || (new Date()).getTime(), ready: 0, load: 0 },
        util: {
            randomID: function (size) {
                var chars = "0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
                var str = '', i = 0;
                while (i++ < size) {
                    // get random character in range
                    str += chars.substr(Math.floor(Math.random() * 62), 1);
                }
                return str;
            }
        },
        ready: function () {
//            window.rei.perf.ready = (new Date()).getTime();

//            // storeId setup in unvHeader
//            if (storeId == 8000 && storeClass.toLowerCase() == 'outlet') { storeId = 8001; }
//            if (document.getElementById('unvHeader')) { hdrObj.init(); }

            // overwrite any thickbox instances
            if (window.tb_bootstrap) {
                tb_bootstrap = function () { };
                tb_bootstrap.override = true;
            };
        }, // ready()
        load: function () {
//            var perf = window.rei.perf;
//            perf.load = (new Date()).getTime();

            // jquery-ui autocomplete
//            $(document.getElementById('headerQuery')).autocomplete({
//                appendTo: document.getElementById('autocomplete'),
//                source: ''.concat(
//			(location.protocol == "https:" ? "https:" : "http:"),
//			"//content.atomz.com/autocomplete/sp10/04/6f/84",
//			((document.getElementById("sp_staged") && document.getElementById("sp_staged").value) ? "-stage/" : "/")
//		)
//            });

            setTimeout(function () {
                // priority items

                // was findAStore.js
                // TODO find and test this zip feature
//                function checkZip() {
//                    var zip = parseInt($(document.getElementById('findAStoreZip')).val() || '', 10);
//                    if (isNaN(zip) || (zip < 1)) { alert("Please enter a valid ZIP code."); return false; };
//                    window.location = "/map/store#" + zip;
//                };
//                $(document.getElementById('findAStoreZip')).focus(function () { $(this).val(""); }).keydown(function (event) {
//                    if (event.keyCode == "13") checkZip();
//                })
//                $(document.getElementById('findAStoreClick')).click(checkZip);

                // drowDown init
                var hunt3 = $(document.getElementById('hunt3'));
                hunt3.superfish({
                    animation: { opacity: "show", height: "show" }
                });
                if ($.browser.msie) {
                    var li_with = hunt3.children("li:has(ul)");
                    li_with.mouseover(function () {
                        $("ul", this).bgIframe({ opacity: false });
                    }).find("a").focus(function () {
                        li_with.find("ul").bgIframe({ opacity: false });
                    });
                }
                // dropDown()

                //from mbox.js
//                $('.recommendations6').jcarousel({ scroll: 6 });
//                $('.recommendations5').jcarousel({ scroll: 5 });
//                $('.recommendations4').jcarousel({ scroll: 4 });
//                $(document.getElementById('recommendationsVertical')).jcarousel({ vertical: true });

                // setup (replace) thickbox with fancybox
//                if (!window.tb_bootstrap || (window.tb_bootstrap && tb_bootstrap.override)) {
//                    TB_remove = $.fancybox.close;
//                    var url, w, h, wRE = /width=([0-9]+)/, hRE = /height=([0-9]+)/, l, item, items = document.querySelectorAll ? document.querySelectorAll('.thickbox') : $('.thickbox');
//                    l = items.length;
//                    while (l && (item = items[--l])) {
//                        url = item.href || item.alt;
//                        w = url.match(wRE),
//				h = url.match(hRE);
//                        w = (w && w.length > 0) ? (w[1] * 1) : 1,
//				h = (h && h.length > 0) ? (h[1] * 1) : 1;
//                        w = w < 560 ? 560 : w,
//				h = h < 340 ? 340 : h;
//                        $(item).fancybox({ type: 'iframe', width: w, height: h });
//                    }
//                };

//                minicart = new Minicart()
            }, 0);
            setTimeout(function () {
                // deferred items
                // load analytics
                //var js = document.createElement('script');
                //js.type = 'text/javascript';
                //js.async = true;
                //js.id = 'analyticsjs';
                //js.src = '/javascript/analytics.js';
                //document.getElementsByTagName('script')[0].parentNode.appendChild(js);
                /* TODO does this work with the smart-buttons?
                * esp on: /help/index.html
                * */
                //$(document.getElementById('unvHeader')).append('<img src="'.concat(
                //	location.protocol, '//admin.instantservice.com/resources/smartbutton/5514/15502/available.gif?',
                //	Math.floor(Math.random()*10001), '" style="width:0px;height:0px;visibility:hidden;position:absolute;" width="0" height="0" onLoad="hdrObj.liveChatOn();" onError="hdrObj.liveChatOff();"/>'
                //) );
                //		var img = new Image();
                //		img.src = '/pix/common/pixel.gif?perf:r'.concat( (perf.ready - perf.start).toString(),',l',(perf.load - perf.start).toString(),',',(window.perf_start ? 'y,':'n,'),location.href);
                //		document.body.appendChild(img);

            }, 100);
        } // load()
    };

//    $(rei.ready);
    $(window).load(rei.load);

//    /* COREMETRICS deprecated content;
//    * most used: cmSpFromCmRE, cmCreateManualLinkClickTag, cmCreatePageviewTag
//    */
//    var item, fn = function () {
//        if (!document.body) return;
//        //	var img = new Image();
//        //	img.src = '/pix/common/pixel.gif?cm_='.concat(location.href);
//        //	document.body.appendChild(img);
//    }, cm_ = 'initToken,cmSpFromCmRE,makeOneCmSp,makeCmRe,getABString,cmCreateConversionEventTag,cmCreatePageElementTag,cmCreateProductElementTag,cmCreateManualLinkClickTag,cmCreateManualImpressionTag,cmCreateManualPageviewTag,cmErrorTag,cmCreateTechPropsTag,cmCreateDefaultPageviewTag,cmCreateProductviewTag,cmAddShop,cmCreateShopAction5Tag,cmCreateShopAction9Tag,cmDisplayShop5s,cmDisplayShop9s,cmCalcSKUString,cmCreateOrderTag,cmCreateRegistrationTag,cmCreateErrorTag,cmReportLoadTime,cmGetDefaultPageID,cmCreateApplicationStepTag,cmIndexOfParameter,cmExtractParameter,cmRemoveParameter,cmCheckCMEM,cmSafeZero,myNormalizeURL,cmSendFormFieldTag,cmCreatePageviewTag,cmMultipleOnChange,cmCheckForOnChange,cmSetupFormFieldTags,cmMakeTag,cmCreateFormFieldTag'.split(',');
//    while (item = cm_.shift()) {
//        window[item] = fn;
//    };
//    /*
//    window.onerror = function(err,url,line){
//    var o = {'error':err,'url':url,'line':line};
//    rei.error.push(o);
//    if(window.console && console.log) console.log('error!',o);
//    if(!document.body) return true;
//    var img = new Image();
//    img.src = '/pix/common/pixel.gif?err='.concat(location.href,'&line=',line,'&url=',encodeURIComponent(url),'&err=',encodeURIComponent(err));
//    document.body.appendChild(img);
//    return true;
//    };
//    */

})(jQuery);


