$(document).ready(function(){
    if($.browser.safari && $.browser.version.substr(0, 3) == '523' ) {

        $('div.colors,div.gallery').css({
            top: -321
            //,position: 'relative'
        });
    }
});

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

function isIE(){
    return $.browser.msie;
}
function isIE7(){
    return $.browser.msie && $.browser.version == 7;
}
function isIE6(){
    return $.browser.msie && $.browser.version == 6;
}
function toggleInterested(s){
    with($('#interested')){
        s ? hide() : show();
    }
}

$(document).ready(function() {
    //$('ul.submenu').bgiframe({opacity:true, width: 'auto', src:'javascript:false'});

    var athleteHoverIn = function(){
        var sm = $(this).parents('#interested-luxury').length > 0;
        if(sm){
            $(this).prevAll('a').each(function(){
                $(this).css('border', '2px solid #e48200');
            });
            return;
        }
        if($.browser.msie) {
            $(this).css('margin', '-2px');
            $(this).css('border','2px solid #EF8200');
        } else {
            $(this).css('margin', '-2px');
            $(this).css('border','2px solid #EF8200');
        }
    };
    var athleteHoverOut = function(){
        var sm = $(this).parents('#interested-luxury').length > 0;
        if(sm){
            $(this).prevAll('a').each(function(){
                $(this).css('border', 'none');
            });
        }
        $(this).css('border','none');
        if($.browser.msie){
            $(this).css('margin', '0');
        } else {
            $(this).css('margin', '0');
        }
    };

  if($('#featured-athletes') || $('#interested-luxury') ){

      $('#featured-athletes img').hover(athleteHoverIn, athleteHoverOut);
      /*
      $('#featured-athletes div.athletes-cont span.athletes strong.athletes-name').hover(
        function(){$(this).siblings('a').children('img').each(athleteHoverIn);},
        function(){$(this).siblings('a').children('img').each(athleteHoverOut);}
      );
      */
      $('strong.athletes-name').click(function(){
        $(this).siblings('a').each(function(){
            window.location = $(this).attr('href');
        });
      });

    $('div.athletes-cont').each(function(){
        $(this).css('cursor', 'pointer');
        $(this).click(function(){
            $(this).children('span.athletes').each(function(){
                $(this).children('a').each(function(){
                    window.location = $(this).attr('href');
                });
            });
        });
    });


  }
  // apply to all png images
  $('img[@src=.png], .close').ifixpng();
  //$('img[@src$=.png], #filter li, .filterlayer').ifixpng();
  //$('img[@src$=.png], #filter li, .filterlayer').ifixpng();

  //$('img').ifixpng();// fix png transp. to NEW icon
    $("#filter li a").click(function(){
    return false; //remove link action from FILTER menu
    });



    // NOTICE LAYER
    /*
        var blockCookie = readCookie("block");
        if (blockCookie != "true"){

            //createCookie("block","true",1);
            createCookie("block","true",0); // without '1' expires on browser close
            $("#notice-layer")
            .animate({opacity: 1.0}, 3000) // hold for 3 seconds
            .animate({"height": "hide"}, 1000); // slideup
        } else {
            $("#notice-layer").hide();
        }
       */


    $(".start-over").click( function() {
    return false;
    });


    // PRODUCT GUIDE
    $(".produtc-guide-tab a").click( function() {

        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker0").height($(document).height() - 198 + "px");

        $(".blocker0").toggle();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).parent().toggleClass('produtc-guide-tab-on');

         $("#product-guide-layer").slideToggle("slow", function(){
            with($("#product-guide-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });
    });


    $(".produtc-guide-tab").click( function() {

        $("#filtercontainer > div:eq(1) ").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker0").toggle();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).toggleClass('produtc-guide-tab-on');

         $("#product-guide-layer").slideToggle("slow", function(){
            with($("#product-guide-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });
    });



  $(".blockers").click(function(){// remove dark layer and gender tab active
    $(this).hide();
    $("#filter li").removeClass("produtc-guide-tab-on");
    $("#filter li").removeClass("gender-tab-on");
    $("#filter li").removeClass("fit-tab-on");
    $("#filter li").removeClass("sport-tab-on");
    $("#filter li").removeClass("region-tab-on");
    $("#filtercontainer > div:eq(0)").hide();
    $("#filtercontainer > div:eq(1)").hide();
    $("#filtercontainer > div:eq(2)").hide();
    $("#filtercontainer > div:eq(3)").hide();
    $("#filtercontainer > div:eq(4)").hide();
  });


    // GENDER
    $(".gender-tab a").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker1").height($(document).height() - 198 + "px");

        $(".blocker0").hide();
        $(".blocker1").toggle();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").hide();/**/
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).parent().toggleClass('gender-tab-on');

         $("#gender-layer").slideToggle("slow", function(){
            with($("#gender-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

    $(".gender-tab").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker0").hide();
        $(".blocker1").toggle();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).toggleClass('gender-tab-on');

         $("#gender-layer").slideToggle("slow", function(){
            with($("#gender-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

    $("#product-guide-layer a.next").click( function() {


        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker1").height($(document).height() - 198 + "px");

        $(".blocker0").hide();
        $(".blocker1").toggle();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").hide();/**/
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");


        $("#filter > li:eq(1)").toggleClass('gender-tab-on');
         $("#gender-layer").slideToggle("slow", function(){
            with($("#gender-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });


    });



    // FIT
    $(".fit-tab a").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker2").height($(document).height() - 198 + "px");

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").toggle();
        $(".blocker3").hide();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).parent().toggleClass('fit-tab-on');
         $("#fit-layer").slideToggle("slow", function(){
            with($("#fit-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });


    $(".fit-tab").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").toggle();
        $(".blocker3").hide();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).toggleClass('fit-tab-on');
         $("#fit-layer").slideToggle("slow", function(){
            with($("#fit-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });


    $("#gender-layer a.next").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(3)").hide();
        $("#filtercontainer > div:eq(4)").hide();
        /*
        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").show();
        $(".blocker3").hide();
        $(".blocker4").hide();
        $("#notice-layer").hide();
        */
        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $("#filter > li:eq(2)").toggleClass('fit-tab-on');
         $("#fit-layer").slideToggle("slow", function(){
            with($("#fit-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

    // SPORT
    $(".sport-tab a").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker3").height($(document).height() - 198 + "px");

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").toggle();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).parent().toggleClass('sport-tab-on');
         $("#sport-layer").slideToggle("slow", function(){
            with($("#sport-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

    $(".sport-tab").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").toggle();
        $(".blocker4").hide();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $(this).toggleClass('sport-tab-on');
         $("#sport-layer").slideToggle("slow", function(){
            with($("#sport-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });


    $("#fit-layer a.next").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(4)").hide();

        /*
        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").toggle();
        $(".blocker4").hide();
        $("#notice-layer").hide();
        */

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".relative").css("display","none");

        $("#filter > li:eq(3)").toggleClass('sport-tab-on');
         $("#sport-layer").slideToggle("slow", function(){
            with($("#sport-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

    // REGION
    $(".region-tab a").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();

        $(".blocker4").height($(document).height() - 198 + "px");

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").toggle();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("fit-tab-on");

        $(".relative").css("display","none");

        $(this).parent().toggleClass('region-tab-on');
         $("#region-layer").slideToggle("slow", function(){
            with($("#region-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

    $(".region-tab").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").toggle();
        $("#notice-layer").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("fit-tab-on");

        $(".relative").css("display","none");

        $(this).toggleClass('region-tab-on');
         $("#region-layer").slideToggle("slow", function(){
            with($("#region-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });

     $("#sport-layer a.next").click( function() {

        $("#filtercontainer > div:eq(0)").hide();
        $("#filtercontainer > div:eq(1)").hide();
        $("#filtercontainer > div:eq(2)").hide();
        $("#filtercontainer > div:eq(3)").hide();

        /*
        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").toggle();
        $("#notice-layer").hide();
        */

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("fit-tab-on");

        $(".relative").css("display","none");

        $("#filter > li:eq(4)").toggleClass('region-tab-on');
         $("#region-layer").slideToggle("slow", function(){
            with($("#region-layer .relative")){
                isIE() ? show() : animate({ opacity: 'toggle'},"fast");
            }
         });

    });









    var closeLayer = function() {
        //$(".filterlayer").slideUp("slow");
        //$(".produtc-guide-tab").removeClass('produtc-guide-tab-on');
        with($(this).parent().parent()){
            isIE() ? toggle() : slideToggle("slow");
        }
        with($(this).parent()){
            isIE() ? toggle() : animate({ opacity: 'toggle'},"slow");
        }
        $(".blocker").hide();

        $("#filter li").removeClass("produtc-guide-tab-on");
        $("#filter li").removeClass("gender-tab-on");
        $("#filter li").removeClass("fit-tab-on");
        $("#filter li").removeClass("sport-tab-on");
        $("#filter li").removeClass("region-tab-on");

        $(".blocker0").hide();
        $(".blocker1").hide();
        $(".blocker2").hide();
        $(".blocker3").hide();
        $(".blocker4").hide();
    };

    //Close LAYER
    $("a.close").click(closeLayer);
    $('a.view-result').click(function(){
        sendFilter();
        closeLayer.apply(this);
    });

    initProductZooms();


    $(".filterlayer li a").click(function(){
        $(this).toggleClass("on");
    });

    initTextBox('.search', 'PRODUCT SEARCH');
    initTextBox('input#blog-search', 'SEARCH BLOG');
    initTextBox('#dealer_city', 'ENTER CITY');
    initTextBox('#dealer_zip', 'ENTER ZIP');

    // learn more
    $(".learn-more li a.spec").click( function(){
        $(this).parent().next(".learn-more-item").slideToggle().siblings(".learn-more-item").slideUp();
        $(".learn-more li a").not($(this)).removeClass("less");
        $(this).toggleClass("less");
        return false;
    });

    // learn more2
    $(".learn-more2 li a.spec").click( function(){
        $(this).parent().next(".learn-more-item").slideToggle().siblings(".learn-more-item").slideUp();
        $(".learn-more2 li a").not($(this)).removeClass("less");
        $(this).toggleClass("less");
        return false;
    });

    // luxury performance
    $("#athletes-01 a").click( function(){
        //$(this).parent().next(".learn-more-item").slideToggle().siblings(".learn-more-item").slideUp();
        //$(".learn-more2 li a").not($(this)).removeClass("less");
        $(this).siblings().removeClass("athletes-sub-active");
        $(this).addClass("athletes-sub-active");
        $("#athletes-02").empty().hide();

        $("#athletes-02").load($(this).attr("href"));
        $("#athletes-02").fadeIn();
        $('#athletes-02').each(function(){
            //$(this).css('height', $(this).height());
        });
        return false;
    });

});

//FIXING IE6 AND SAFARI BUG FOR MENU ITEM "SELECTED" CLASS
function fixNav(){

    /*
    #menu li.products{width:7em;}
    #menu li.polarization{width:9em;}
    #menu li.performance{width:9em;}
    #menu li.technology{width:13em;}
    #menu li.luxury{width:10em;}
    #menu li.rx{width:2em;}
    #menu li.store{width:4em;}
    */

    $("li.products").css("width","7em");
    $("li.polarization").css("width","9em");
    $("li.performance").css("width","9em");
    $("li.luxury").css("width","7em");
    $("li.technology").css("width","13em");
    $("li.rx").css("width","2em");
    $("li.store").css("width","4em");
    $("li.news").each(function(){
        $(this).css('width',80);
    });
    $("li.dealer").each(function(){
        $(this).css('width', 100);
    });
    //$("li.topnav").css("padding-top","3px");
    //$("li.topnav").css("padding-bottom","3px");

    $('li.selected').css('padding-top', '1px');
    $('li.selected').css('padding-bottom', '1px');

    //$('li.selected').css('margin-top', '0px');


    /*
    //$(this).css('padding-top', '1px');
    $(this).height($(this).height()-1);
    $(this).css('top', '-1px');
    $("li").css("padding-top","3px");
    $("li").css("padding-bottom","3px");
    $(this).corner("3px");
    */

    $(".selected").each(function(){
        $(this).css('width', $(this).width() + 1);
        $(this).corner('3px');
    });
};

$(document).ready(function(){

    fixNav();

});

function initTextBox(strSelector, strDef){
    //clear search field default value
    $(strSelector).each(function(){
        var v = this.value;
        if(typeof(v) == 'undefined') v = strDef;
        $(this).css('color', v == strDef ? '#CCCCCC' : '#333333');

    });
    $(strSelector).focus(function() {
        if( this.value == strDef ) {
            this.value = "";
        }
        $(this).css("color","#333333");
    }).blur(function() {
        if( !this.value.length ) {
            this.value = strDef;
            $(this).css("color","#ccc");
        }

    });
}

function initProductZooms(){
    $('thumb').each(function(){
        $(this).mouseover = null;
    });
    // SHOW HIDE ZOOM PICS  - counting 24 itens per page, to increase is necessary change on HTML, JS and CSS (here below)
    $(".thumb-1").mouseover(function() { $(".zoomcontainer").hide(); $("#zoom-1").show(); });
    $("#zoom-1").mouseout(function() { $("#zoom-1").hide(); });
    $(".thumb-2").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-2").show(); });
    $("#zoom-2").mouseout(function() { $("#zoom-2").hide(); });
    $(".thumb-3").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-3").show(); });
    $("#zoom-3").mouseout(function() { $("#zoom-3").hide(); });
    $(".thumb-4").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-4").show(); });
    $("#zoom-4").mouseout(function() { $("#zoom-4").hide(); });
    $(".thumb-5").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-5").show(); });
    $("#zoom-5").mouseout(function() { $("#zoom-5").hide(); });
    $(".thumb-6").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-6").show(); });
    $("#zoom-6").mouseout(function() { $("#zoom-6").hide(); });
    $(".thumb-7").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-7").show(); });
    $("#zoom-7").mouseout(function() { $("#zoom-7").hide(); });
    $(".thumb-8").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-8").show(); });
    $("#zoom-8").mouseout(function() { $("#zoom-8").hide(); });
    $(".thumb-9").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-9").show(); });
    $("#zoom-9").mouseout(function() { $("#zoom-9").hide(); });
    $(".thumb-10").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-10").show(); });
    $("#zoom-10").mouseout(function() { $("#zoom-10").hide(); });

    $(".thumb-11").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-11").show(); });
    $("#zoom-11").mouseout(function() { $("#zoom-11").hide(); });
    $(".thumb-12").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-12").show(); });
    $("#zoom-12").mouseout(function() { $("#zoom-12").hide(); });
    $(".thumb-13").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-13").show(); });
    $("#zoom-13").mouseout(function() { $("#zoom-13").hide(); });
    $(".thumb-14").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-14").show(); });
    $("#zoom-14").mouseout(function() { $("#zoom-14").hide(); });
    $(".thumb-15").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-15").show(); });
    $("#zoom-15").mouseout(function() { $("#zoom-15").hide(); });
    $(".thumb-16").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-16").show(); });
    $("#zoom-16").mouseout(function() { $("#zoom-16").hide(); });
    $(".thumb-17").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-17").show(); });
    $("#zoom-17").mouseout(function() { $("#zoom-17").hide(); });
    $(".thumb-18").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-18").show(); });
    $("#zoom-18").mouseout(function() { $("#zoom-18").hide(); });
    $(".thumb-19").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-19").show(); });
    $("#zoom-19").mouseout(function() { $("#zoom-19").hide(); });
    $(".thumb-20").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-20").show(); });
    $("#zoom-20").mouseout(function() { $("#zoom-20").hide(); });

    $(".thumb-21").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-21").show(); });
    $("#zoom-21").mouseout(function() { $("#zoom-21").hide(); });
    $(".thumb-22").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-22").show(); });
    $("#zoom-22").mouseout(function() { $("#zoom-22").hide(); });
    $(".thumb-23").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-23").show(); });
    $("#zoom-23").mouseout(function() { $("#zoom-23").hide(); });
    $(".thumb-24").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-24").show(); });
    $("#zoom-24").mouseout(function() { $("#zoom-24").hide(); });

    $(".thumb-25").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-25").show(); });
    $("#zoom-25").mouseout(function() { $("#zoom-25").hide(); });

    $(".thumb-26").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-26").show(); });
    $("#zoom-26").mouseout(function() { $("#zoom-26").hide(); });
    $(".thumb-27").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-27").show(); });
    $("#zoom-27").mouseout(function() { $("#zoom-27").hide(); });
    $(".thumb-28").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-28").show(); });
    $("#zoom-28").mouseout(function() { $("#zoom-28").hide(); });

    $(".thumb-29").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-29").show(); });
    $("#zoom-29").mouseout(function() { $("#zoom-29").hide(); });
    $(".thumb-30").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-30").show(); });
    $("#zoom-30").mouseout(function() { $("#zoom-30").hide(); });
    $(".thumb-31").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-31").show(); });
    $("#zoom-31").mouseout(function() { $("#zoom-31").hide(); });
    $(".thumb-32").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-32").show(); });
    $("#zoom-32").mouseout(function() { $("#zoom-32").hide(); });
    $(".thumb-33").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-33").show(); });
    $("#zoom-33").mouseout(function() { $("#zoom-33").hide(); });
    $(".thumb-34").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-34").show(); });
    $("#zoom-34").mouseout(function() { $("#zoom-34").hide(); });
    $(".thumb-36").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-36").show(); });
    $("#zoom-36").mouseout(function() { $("#zoom-36").hide(); });

    $(".thumb-37").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-37").show(); });
    $("#zoom-37").mouseout(function() { $("#zoom-37").hide(); });

    $(".thumb-38").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-38").show(); });
    $("#zoom-38").mouseout(function() { $("#zoom-38").hide(); });

    $(".thumb-39").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-39").show(); });
    $("#zoom-39").mouseout(function() { $("#zoom-39").hide(); });

    $(".thumb-40").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-40").show(); });
    $("#zoom-40").mouseout(function() { $("#zoom-40").hide(); });

    $(".thumb-41").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-41").show(); });
    $("#zoom-41").mouseout(function() { $("#zoom-41").hide(); });

    $(".thumb-42").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-42").show(); });
    $("#zoom-42").mouseout(function() { $("#zoom-42").hide(); });

    $(".thumb-43").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-43").show(); });
    $("#zoom-43").mouseout(function() { $("#zoom-43").hide(); });

    $(".thumb-44").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-44").show(); });
    $("#zoom-44").mouseout(function() { $("#zoom-44").hide(); });

    $(".thumb-45").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-45").show(); });
    $("#zoom-45").mouseout(function() { $("#zoom-45").hide(); });

    $(".thumb-46").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-46").show(); });
    $("#zoom-46").mouseout(function() { $("#zoom-46").hide(); });

    $(".thumb-47").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-47").show(); });
    $("#zoom-47").mouseout(function() { $("#zoom-47").hide(); });

    $(".thumb-48").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-48").show(); });
    $("#zoom-48").mouseout(function() { $("#zoom-48").hide(); });

    $(".thumb-49").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-49").show(); });
    $("#zoom-49").mouseout(function() { $("#zoom-49").hide(); });

    $(".thumb-50").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-50").show(); });
    $("#zoom-50").mouseout(function() { $("#zoom-50").hide(); });

    $(".thumb-51").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-51").show(); });
    $("#zoom-51").mouseout(function() { $("#zoom-51").hide(); });

    $(".thumb-52").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-52").show(); });
    $("#zoom-52").mouseout(function() { $("#zoom-52").hide(); });

    $(".thumb-53").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-53").show(); });
    $("#zoom-53").mouseout(function() { $("#zoom-53").hide(); });

    $(".thumb-54").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-54").show(); });
    $("#zoom-54").mouseout(function() { $("#zoom-54").hide(); });

    $(".thumb-55").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-55").show(); });
    $("#zoom-55").mouseout(function() { $("#zoom-55").hide(); });

    $(".thumb-56").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-56").show(); });
    $("#zoom-56").mouseout(function() { $("#zoom-56").hide(); });

    $(".thumb-57").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-57").show(); });
    $("#zoom-57").mouseout(function() { $("#zoom-57").hide(); });

    $(".thumb-58").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-58").show(); });
    $("#zoom-58").mouseout(function() { $("#zoom-58").hide(); });

    $(".thumb-59").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-59").show(); });
    $("#zoom-59").mouseout(function() { $("#zoom-59").hide(); });

    $(".thumb-60").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-60").show(); });
    $("#zoom-60").mouseout(function() { $("#zoom-60").hide(); });

    $(".thumb-61").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-61").show(); });
    $("#zoom-61").mouseout(function() { $("#zoom-61").hide(); });

    $(".thumb-62").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-62").show(); });
    $("#zoom-62").mouseout(function() { $("#zoom-62").hide(); });

    $(".thumb-63").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-63").show(); });
    $("#zoom-63").mouseout(function() { $("#zoom-63").hide(); });

    $(".thumb-64").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-64").show(); });
    $("#zoom-64").mouseout(function() { $("#zoom-64").hide(); });

    $(".thumb-65").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-65").show(); });
    $("#zoom-65").mouseout(function() { $("#zoom-65").hide(); });

    $(".thumb-66").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-66").show(); });
    $("#zoom-66").mouseout(function() { $("#zoom-66").hide(); });

    $(".thumb-67").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-67").show(); });
    $("#zoom-67").mouseout(function() { $("#zoom-67").hide(); });

    $(".thumb-68").mouseover(function() { $(".zoomcontainer").hide();$("#zoom-68").show(); });
    $("#zoom-68").mouseout(function() { $("#zoom-68").hide(); });

}

function GroupFilter(name) {
    this.lengthName = 15;
    this.name       = name;
    this.codes      = new Array();
    this.codeNames  = new Array();
}

GroupFilter.prototype.editCode = function(code,codeName) {
        var exist = false;
        for (var i = 0; i < this.codes.length; i++)
            if (this.codes[i] == code){
                exist = true;
                var index = i;
            }

        if (exist){
            this.codes.splice(index,1);
            this.codeNames.splice(index,1);
        } else {
            this.codes.push(code);
            this.codeNames.push(codeName);
        }
}

GroupFilter.prototype.getCode = function(){
    return this.codes;
}

GroupFilter.prototype.getName = function() {
    return this.name;
}

GroupFilter.prototype.getCodeNames = function() {
    var namesOut="";
    for (var i = 0; i < this.codeNames.length; i++) {
        namesOut +=this.codeNames[i];
        if (i != this.codeNames.length-1)
            namesOut +=", ";
        else
            namesOut +=".";
    }

    if (namesOut.length > this.lengthName)
        namesOut = namesOut.substr(0,this.lengthName)+"...";

    if (namesOut == "")
        return "ALL";
    else
        return namesOut;
}

function GroupsFilter () {
    this.gender     = new GroupFilter("gender"  );
    this.fit        = new GroupFilter("fit"     );
    this.sport      = new GroupFilter("sport"   );
    this.region     = new GroupFilter("region"  );
    this.environment = new GroupFilter('environment');
}

GroupsFilter.prototype.getObjFilter = function(mode) {
    switch (mode) {
        case 'gender' :{
            return this.gender;
            break;
        }
        case 'fit' :{
            return this.fit;
            break;
        }
        case 'sport' :{
            return this.sport;
            break;
        }
        case 'region' :{
            return this.region;
            break;
        }
        case 'environment' : return this.environment;
    }
}

GroupsFilter.prototype.getFilter = function() {
    var gender  = this.gender.getName();
    var fit     = this.fit.getName();
    var sport   = this.sport.getName();
    var region  = this.region.getName();
    var environment = this.environment.getName();

    return {
        gender: this.gender.getCode(),
        fit: this.fit.getCode(),
        sport:this.sport.getCode(),
        region: this.region.getCode(),
        environment: this.environment.getCode()
    };
}

objGroupsFilter = new GroupsFilter();

function addFilter(mode,code,objHtml){
    var objHtml = $(objHtml);
    obj = objGroupsFilter.getObjFilter(mode);
    obj.editCode(code,objHtml.html());
    $("#sp_"+mode).html(obj.getCodeNames());
    sendFilter();
}

function sendFilter() {
    var filter = objGroupsFilter.getFilter();
    var opts = [];
    for(var k in filter){
        for(var i in filter[k]){
            opts.push('type[' + k + '][]=' + filter[k][i]);
        }
    }
    apply_filter('?' + opts.join('&'));
}

function clearSearch(hideGuide){
    var hideGuide = hideGuide || false;
    objGroupsFilter = new GroupsFilter();
    $("#sp_gender").html("");
    $("#sp_fit").html("");
    $("#sp_sport").html("");
    $("#sp_region").html("");
    $(".on").attr("class","off");
    if(!hideGuide) $(".produtc-guide-tab a").click();
    sendFilter();
    return false;
}

function disabledMenu(div,menu){
    $(div).hide();

    $("#product-guide-layer").hide();
    $("#gender-layer").hide();
    $("#fit-layer").hide();
    $("#sport-layer").hide();
    $("#region-layer").hide();
    $("#menu_"+menu).attr("class",menu+"-tab");
}

