			$(document).ready(function(){
				
				var e = window.location.pathname;
                var ul = $("#navigation");

				
				if (e == "/"){
                    ul.find("li:first a").addClass("active");
					box_count = $(".group li").size();
					box_size = (Math.ceil(box_count/3))*181+210;
					$(".main").children().css('height', box_size+'px');
					

					
                }
				
                else {
					
					
					
					$('.main').equalheight();
					/*$(".main").children().css('height', $('#middle_frame').css("height"));*/
					
					
                    $.each(ul.find("li a"), function(){
                        if ("/"+$(this).attr("href")==e) {
                            $(this).addClass("active");
                        }
                    });
                };
				
				
				$('.pill-buy-button').hover(function () {
					$(this).toggleClass("on_hover");
				  });
				
				/*alert(box_size);*/
				
				
				var zIndexNumber = 10000;
				$('div').each(function() {
					if($(this).attr('id').substring(0,5)=='fancy'){}else{
					$(this).css('zIndex', zIndexNumber);
					zIndexNumber -= 10;}
				});
				
				$('div[class^="separ"]').css('zIndex', 0);
				$('.bgr-closer').css('zIndex', -1);
				
				/*$(".main").equalheight();*/

				
				/**index boxes Open Close**/

				
				/*base.html.resetNavbar('navigation');*/
				/*$('#navigation_top').css("display","block");*/
               
				var e = window.location.pathname;
			    if( e == "/")  {
			        $(".main_content").removeClass("background_and_border");
			    }
                $(".popupzoom").fancybox({
                    "transitionIn"   :	"elastic",
                    "transitionOut":  "elastic",
                    "speedIn"	     :	400,
                    "speedOut"	   :   200
                });
				



					$("#tool_contr").click(function() {
						toolbar_control(this);						
					});
					
				  $("li.items").hover(function () {
					$(this).toggleClass("on_hover");
				  });
				  
				  $("li.sub_items").hover(function () {
					$(this).toggleClass("sub_on_hover");
				  });
				  
				
				/*Products_table default selct row*/
				
				/*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");
					}
				});
		

				
				/********/
				
			});

			function toolbar_control(toolbr){
				if ($("#toolbar").css('top') == '-70px'){
				$("#toolbar").animate({top:"0px"},500);
				}else{$("#toolbar").animate({top:"-70px"},500);}
				$("#toolbar").toggleClass("tool-open");
				return false;	
			}
			
			
			
			jQuery.fn.equalheight = function() {
				jQuery(this).each(function(){
					var currentTallest = 0; //create currentTallest var
					
					//go through every child of the mother div
					jQuery(this).children().each(function(i){
						//keep checking every child's height and get the height of the tallest div											  
						if (jQuery(this).height() > currentTallest) { currentTallest = jQuery(this).height(); }
						
					});
					
					//set currentTallest as pixels
					currentTallest = currentTallest+"px";
					
					//If browser is Microsoft Internet explorer, then use css "height: yypx"
					if (jQuery.browser.msie && jQuery.browser.version == 6.0) { jQuery(this).children().css({'height': currentTallest}); }
					
					//use css "min-height: yypx"
					jQuery(this).children().css({'min-height': currentTallest}); 
				});
				return this;
			};
					
			function popup_window(url,the_height,the_width)
				{
				 newwindow=window.open(url,'','height='+the_height+',width='+the_width+'');
				 if (window.focus) {newwindow.focus()}
				 return false;
				}

