$(document).ready(function(){

      /* base.html.resetNavbar("navigation");
        base.html.resetNavbar("multi_category_navigation");*/
		
        $.localScroll();

        base.html.welcomeMsg.show({visible:'{/literal}{wa_mod_isenabled module="welcome_msg"}{literal}'});

        $(".popupzoom").fancybox({
            "transitionIn"   :	"elastic",
            "transitionOut":  "elastic",
            "speedIn"	     :	400,
            "speedOut"	   :   200,
            "width"        :  600,
            "height"       :  265
        });

        if ( $(".phone_banner").length == 0 || $(".live_chat").length == 0  ) {
            $(".contact_tab").css("width","380px");
        }
        else { $(".contact_tab").css("width","555px"); }

        if ( $(".phone_banner").length == 0 && $(".live_chat").length == 0  ) {
            $(".contact_tab").css("display","none");
        }

         $(function(){

            $("div.top_seller_list").carousel({ dispItems: 5, combinedClasses: true });

         });

         $(".carousel-wrap li").hover(function() {
            $(this).addClass("hover");
                        }, function() {
            $(this).removeClass("hover");
         })

        $(".product_boxes li:nth-child(3n)").addClass("no_margin");
        $(".product_boxes li:nth-child(3n+1)").addClass("first");


        var e = window.location.pathname;
        var ul = $("#navigation");

        if (e == "/") {
            ul.find("li:first a").addClass("active");
        }
        else {
            $.each(ul.find("li a"), function(){
                if ("/"+$(this).attr("href")==e) {
                    $(this).addClass("active");
                }
            });
        }


		/*OnClick changes selected row*/
		$(".products_table tbody tr.in-stock").click(function (){
			var ter=$(this).parent();
			$(this).find("input:radio").attr("checked","checked");
			$(ter).find("tr.selected-row").removeClass("selected-row");
			$(this).addClass("selected-row");
		});
		
		/*on each Products_table:
			If there RadioButton selcted from smarty (.dif-ch) adds class ".selected-row" to TR.
			If no ".selcted_row" class in hole table (".Products_table" )
				looks for last TR with ".in-stosk" class and add to this class ".selcted_row"
				
		  var tr_lect = TR which contens radio button (".dif-ch"), selected by smarty
		  var def_row = total TRs with class ".selected-row", to check if smarty have selected any row*/
		  
		$(".products_table").each(function(i){
			var tr_lect = $(this).find(".dif-ch").closest("tr");
			$(tr_lect).addClass("selected-row");
			
			var def_row = $(this).find(".selected-row").size();
			if (!def_row){
				var tr_def_row = $(this).find(".in-stock:last");
				$(tr_def_row).find("input:radio").attr("checked","checked");
				$(tr_def_row).addClass("selected-row");
			}
		});
		
		
});






