			$(document).ready(function(){
				/**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");
				  });
				  
				  $("li.r1").hover(function () {
					$(this).toggleClass("r2");
				  });
				
				 $(".product_boxes li").hover(function () {
					$(this).toggleClass("on_hover");
				  });
				  
				  
				groupname =$(".category a").html().substr(0, 1).toUpperCase() + $(".category a").html().substr(1).toLowerCase();
				$("h2#boxes_h").html("<span class='h-vi'></span>"+groupname);
				
				/*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");
					}
				});
		
				
				
				/********/
				

    

				$("#submit").click(function(){
					valid_t = isValidEmailAddress($("#email").val());
					if (valid_t) {
						hash = calcMD5($("#email").val());
						cupon_val = hash.substr(0,10);
						$("#cupon").text( cupon_val );
						change_cupon();
						return false;
					}
					else{
						alert('Please insert valid email','Alert' );
					}
				});
					
				  $("#email").toggleVal();

			});

			function isValidEmailAddress(emailAddress) {
				var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
				return pattern.test(emailAddress);
			}

			function change_cupon(){
				$("#take_cupon").show();
				$("#get_cupon").hide();
			}
			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;
				}

