    
    $(function() {
        $("#header-social img").hover(                    
            function(){this.src = this.src.replace(".gif","_blk.gif");}, 
            function(){this.src = this.src.replace("_blk.gif",".gif");            
        });
    });

    $(function() {
        $("#content-home img").hover(
            function(){this.src = this.src.replace(".jpg","_on.gif");}, 
            function(){this.src = this.src.replace("_on.gif",".jpg");
        });
    });
    
    function preload(arrayOfImages) {
        $(arrayOfImages).each(function(){
            $('<img/>')[0].src = this;
        });
    }

    function showSideTab(v) {
        if (v == 'press') {
            $('#contact-content-contact').hide();
            $('#contact-content-press').show();
        } else {
            $('#contact-content-press').hide();
            $('#contact-content-contact').show();
        }
        $('#contact-container').meerkat({
            background: 'url(\'/img/meerkat-right-bg.png\') repeat-y left top',
            height: '100%',
            width: '202px',
            position: 'right',
            close: '.contact-close',
            dontShowAgain: '.dont-show',
            animationIn: 'slide',
            animationSpeed: 500,
            removeCookie: '.reset'
            });
    }

    function submitMailingList() {
       var reg = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;
       var address = $("#header-social-input-email").val();
       if(reg.test(address) == false) {
           $("#header-social-message").html('<span class="messageError">Please enter a valid email address.</span>');
       } else {
           $.ajax({
               url: '/mailing',
               data: { a: address },
               dataType: 'json',
               success: function(data) {   
                   $("#header-social-message").html('Thank you, your email has been recorded.');
                   $("#header-social-input-email").val('');;
               }
           });
       }
    }
    
    function collectionNext() {
        var totalslides = $("#collection-totalslides").text();
        var currentslide = $("#collection-currentslide").text();
        $("#collection-controls-prev").show();
        if (parseInt(currentslide) == (parseInt(totalslides)-1)) {
            $("#collection-controls-next").hide();
        }
        divwidth = $("#collection-img-"+currentslide).width();
        $("#collection-slider").animate({
            'marginLeft' : "-=" + divwidth + "px"
        }, { duration: 600, easing: 'easeOutQuad'});
        var newslide = String(parseInt(currentslide)+1);
        collectionCaption(newslide);
        $("#collection-currentslide").text(newslide);
        $("#collection-passfocus").focus();
    }

    
    function collectionPrev() {
        var currentslide = $("#collection-currentslide").text();
        var moveslide = String(parseInt(currentslide) - 1);
        $("#collection-controls-next").show();
        if (currentslide == 2) {
            $("#collection-controls-prev").hide();
        }
        divwidth = $("#collection-img-"+moveslide).width();
        $("#collection-slider").animate({
            'marginLeft' : "+=" + divwidth + "px"
        }, { duration: 600, easing: 'easeOutQuad'});
        collectionCaption(moveslide);
        $("#collection-currentslide").text(moveslide);
        $("#collection-passfocus").focus();
    }
    
    function collectionCaption(id) {
        var display = $("#collection-caption-" + id).html();
        $("#collection-caption-display").html(display);
    }

    function shopUsDetails (st, pg) {
        $("#shop-details-int").slideUp(800);
        $("#shop-spacer-us").hide();
        var display = $("#shop-details-us-" + st + "-" + pg).html();
        $("#shop-details-us").html(display);
        $("#shop-details-us").slideDown(600);
        $(".shop-nav-links").addClass('black');
        $(".shop-nav-links").removeClass('red');
        $("#shop-region-us-" + st).removeClass('black');
        $("#shop-region-us-" + st).addClass('red');
        $("#shop-passfocus").focus();
    }

    function shopIntDetails (ctry, pg) {
        $("#shop-details-us").slideUp(800);
        $("#shop-spacer-us").show();
        var display = $("#shop-details-int-" + ctry + "-" + pg).html();
        $("#shop-details-int").html(display);
        $("#shop-details-int").slideDown(600);
        $(".shop-nav-links").addClass('black');
        $(".shop-nav-links").removeClass('red');
        $("#shop-region-int-" + ctry).removeClass('black');
        $("#shop-region-int-" + ctry).addClass('red');
        $("#shop-passfocus").focus();
    }

    sfHover = function() {
        var sfEls = document.getElementById("header-nav").getElementsByTagName("li");
        for (var i=0; i<sfEls.length; i++) {
            sfEls[i].onmouseover=function() {
                this.className+=" sfhover";
            }
            sfEls[i].onmouseout=function() {
                this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
            }
        }
    }
    if (window.attachEvent) window.attachEvent("onload", sfHover);
