$(document).ready(function(){
	
	//	dropdown on mainpage
	$(".vizuals li").hover(function() {
          $('.sec-lev-menu', this).show();
        }, function() {
          $('.sec-lev-menu', this).hide();
        });	
        
    $("#xmenu li").hover(function() {
          $('.level-2', this).show();
        }, function() {
          $('.level-2', this).hide();
        });	
        
    $(".product-in-list2 a").fancybox({
 		'overlayShow' : true,
 		'zoomSpeedIn' : 300,
 		'zoomSpeedOut' : 300
 		});
 		
 	//	shop handlers
	$(".order").live("click",function(){
		var selector = $(this);
		var href = selector.attr("href");
		$(".cart").load($(this).attr("href"),function(data){
			//	done
			if(selector.hasClass("to_cart")){
				//	заказываем
				selector.removeClass("to_cart");
				selector.addClass("in_cart");
				selector.attr("href",href.replace("add","del"));
				
				$.gritter.add({
				// (string | mandatory) the heading of the notification
				title: 'Добавлено в корзину!',
				// (string | mandatory) the text inside the notification
				text: 'Товар добавлен в корзину.<br><a href="/bin/">Перейти к оформлению заказа</a>.'
				}); 
			} else {
				//	отменяем заказ
				selector.removeClass("in_cart").removeClass("can_cart");
				selector.addClass("to_cart");
				selector.attr("href",href.replace("del","add"));
				
				$.gritter.add({
				// (string | mandatory) the heading of the notification
				title: 'Удалено из корзины!',
				// (string | mandatory) the text inside the notification
				text: 'Товар удален из корзины.'
				}); 
			}
		});
	});
	
		//	hover
	$(".order").hover(function(){
		//	waiting for jquery 1.4 stable :(
		if($(this).hasClass("in_cart")){
		//	over
			$(this).removeClass("in_cart");
			$(this).addClass("can_cart");
		}	
	},function(){
		//	out
		if($(this).hasClass("can_cart")){
			$(this).addClass("in_cart");
			$(this).removeClass("can_cart");
		}
	});
	
	$("#getOrder").click(function(){
		$("#orderButtons").hide();
		$(".order_form").slideToggle();
		return false;
	});
	
	$(".counter").keypress(function(e)
	{
		 //Enter keycode
		var code = (e.keyCode ? e.keyCode : e.which);
		if((code < 58 && code>47) || (code==8) || (code==13))
		{
			return true;
		}
		return false;
	});
});
