$(document).ready(function() {
    resetLiColors();

    var loc = window.location.pathname;

    //alert(loc);
    if (loc == "/default.aspx" || loc == "/" || loc =="/Default.aspx") {
        $("#breadcrumb").hide();
    }

    /******************************/
    /* RESET BRANDS LOGO          */
    /******************************/
    var brantxt = $.ajax({
        url: "http://www.mainlandskateandsurf.com/mainland/ajaxGetBrand.aspx",
        async: false
    }).responseText;

    $("#top_brands").html(brantxt);


    /******************************/
    /* TOP RATED LEFT SIDE      */
    /******************************/
    $("#tshirts").click(function(event) {
        ajaxCallTopRated("tshirts", 852, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#slippers").click(function(event) {
        ajaxCallTopRated("slippers", 1271, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#dressshirts").click(function(event) {
        ajaxCallTopRated("dressshirts", 857, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#tanks").click(function(event) {
        ajaxCallTopRated("tanks", 864, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#shorts").click(function(event) {
        ajaxCallTopRated("shorts", 859, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#pants").click(function(event) {
        ajaxCallTopRated("pants", 860, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#backpacks").click(function(event) {
        ajaxCallTopRated("backpacks", 1295, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#beltbuckles").click(function(event) {
        ajaxCallTopRated("beltbuckles", 1298, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#sweaters").click(function(event) {
        ajaxCallTopRated("sweaters", 865, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    /******************************/
    /* TOP RATED RIGHT SIDE      */
    /******************************/
    $("#longsleeves").click(function(event) {
        ajaxCallTopRated("longsleeves", 856, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#sweatshirts").click(function(event) {
        ajaxCallTopRated("sweatshirts", 899, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#jackets").click(function(event) {
        ajaxCallTopRated("jackets", 866, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#jerseys").click(function(event) {
        ajaxCallTopRated("jerseys", 863, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#boardshorts").click(function(event) {
        ajaxCallTopRated("boardshorts", 862, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#shoes").click(function(event) {
        ajaxCallTopRated("shoes", 880, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#sandals").click(function(event) {
        ajaxCallTopRated("sandals", 918, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#belts").click(function(event) {
        ajaxCallTopRated("belts", 871, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    $("#hats").click(function(event) {
        ajaxCallTopRated("hats", 873, "homeTopRated", "ajaxGetTopRated.aspx");
    });

    /******************************/
    /* BEST SELLER LEFT SIDE      */
    /******************************/
    $("#longboards").click(function(event) {
        ajaxCallTopRated("longboards", 1325, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#trucks").click(function(event) {
        ajaxCallTopRated("trucks", 1327, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#decks").click(function(event) {
        ajaxCallTopRated("decks", 1326, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#wheels").click(function(event) {
        ajaxCallTopRated("wheels", 1328, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#bearings").click(function(event) {
        ajaxCallTopRated("bearings", 1329, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#bushings").click(function(event) {
        ajaxCallTopRated("bushings", 1330, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#hardware").click(function(event) {
        ajaxCallTopRated("hardware", 1331, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    /******************************/
    /* BEST SELLER RIGHT SIDE     */
    /******************************/
    $("#sunglasses").click(function(event) {
        ajaxCallTopRated("sunglasses", 1293, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#watches").click(function(event) {
        ajaxCallTopRated("watches", 1306, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#backpacks2").click(function(event) {
        ajaxCallTopRated("backpacks2", 1307, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#guyshats").click(function(event) {
        ajaxCallTopRated("guyshats", 1290, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#girlshats").click(function(event) {
        ajaxCallTopRated("girlshats", 1302, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#purses").click(function(event) {
        ajaxCallTopRated("purses", 1308, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    $("#guyswallets").click(function(event) {
        ajaxCallTopRated("guyswallets", 1304, "homeBestSeller", "ajaxGetBestSeller.aspx");
    });

    function ajaxCallTopRated(idclick, catid, overwritediv, ajaxurl) {
        $("#" + overwritediv).html("<img href='http://www.mainlandskateandsurf.com/images/big_spinner.gif'/>");

        var txtsmp = $.ajax({
            url: "http://www.mainlandskateandsurf.com/mainland/" + ajaxurl + "?catid=" + catid,
            async: false
        }).responseText;

        $("#" + overwritediv).html(txtsmp);

        resetLiColors();
        $("#" + idclick).css("color", "#006699");
        $("#" + idclick).hover(
                      function() {
                          $(this).css("color", "#666666"); //mouseover
                      },
                      function() {
                          $(this).css({ color: '#006699' }); // mouseout
                      }
                  );
    }

    function resetLiColors() {
        /************************************/
        /* RESET CATEGORY LIST LEFT         */
        /************************************/
        $('#category_list_left').find("li").css("color", "#666666");
        $('#category_list_left').find("li").hover(
                        function() {
                            $(this).css("color", "#006699"); //mouseover
                        },
                        function() {
                            $(this).css({ color: '#666666' }); // mouseout
                        }
                    );
        $('#category_list_left').find("li").css("cursor", "pointer");

        /************************************/
        /* RESET CATEGORY LIST RIGHT        */
        /************************************/
        $('#category_list_right').find("li").css("color", "#666666");
        $('#category_list_right').find("li").hover(
                        function() {
                            $(this).css("color", "#006699"); //mouseover
                        },
                        function() {
                            $(this).css({ color: '#666666' }); // mouseout
                        }
                    );
        $('#category_list_right').find("li").css("cursor", "pointer");

        /************************************/
        /* RESET CATEGORY LIST BOTTOM LEFT  */
        /************************************/
        $('#category_list_bot_left').find("li").css("color", "#666666");
        $('#category_list_bot_left').find("li").hover(
                        function() {
                            $(this).css("color", "#006699"); //mouseover
                        },
                        function() {
                            $(this).css({ color: '#666666' }); // mouseout
                        }
                    );
        $('#category_list_bot_left').find("li").css("cursor", "pointer");

        /************************************/
        /* RESET CATEGORY LIST BOTTOM RIGHT */
        /************************************/
        $('#category_list_bot_right').find("li").css("color", "#666666");
        $('#category_list_bot_right').find("li").hover(
                        function() {
                            $(this).css("color", "#006699"); //mouseover
                        },
                        function() {
                            $(this).css({ color: '#666666' }); // mouseout
                        }
                    );
        $('#category_list_bot_right').find("li").css("cursor", "pointer");
    }
});

