$(document).ready( function() {
	// PNG;
	$("#plashka").css('opacity', 0.5 );

/*
$(".sortir").mouseover( function() {
$(this).css({ color: "#ffffff" } );

});

$(".sortir").mouseout( function() {
$(this).css({ color: "#7b6e63" } );

});
*/


	$('.b-news2 UL').jcarousel({ scroll: 1 });
	$('.b-news1 UL').jcarousel({ scroll: 1 });
  $("#main-menu div.main-menu").hover(
    function() {
      $(this).css("background-position","50% 100%");
    }, function() {
      $(this).css("background-position","50% 0%");
  });
  function order_button() {
  $("div.order-button").hover(
    function() {
      $(this).css("background-position","0% 50%");
    }, function() {
      $(this).css("background-position","0% 0%");
  });    
  $("#order_info_button").hover(
    function() {
      $(this).css("background-position","0% 50%");
    }, function() {
      $(this).css("background-position","0% 0%");
  });
  }
  order_button();
	//$("div.menugroups-item a").hide();
    function menuajax() {
		$("div.menugroups-item a").bind("click", function () {
			$("div.menugroups div").addClass("menugroups-item").removeClass("menugroups-item-select");
			//$(this).parent("div").addClass("menugroups-item-select");
			$("#order-load").show();
			$("#menu-all").load($(this).attr("href") + " #menu-all", {}, function() { menuajax(); order_button(); $("#order-load").hide(); } );
			return false;
		});
	}
	menuajax();

	// Flash;
/*	$("#flash1").flash({
		src: "/templates/flash/euromed_1.swf",
		width: "670",
		height: "300",
		wmode: "transparent"
	});

		$("#flash2").flash({
		src: "/templates/flash/euromed.swf",
		width: "500",
		height: "700",
		wmode: "transparent"
	});
*/
	$("#logo").flash({
		src: "/templates/flash/logo.swf",
		width: "280",
		height: "160",
		wmode: "transparent"
	});


	$("#shat").flash({
		src: "/templates/flash/shatun2.swf",
		width: "800",
		height: "750",
		wmode: "transparent"
	});



	$("#light").flash({
		src: "/templates/flash/light.swf",
		width: "400",
		height: "400",
		wmode: "transparent"
	});

	$("#light2").flash({
		src: "/templates/flash/light2.swf",
		width: "400",
		height: "400",
		wmode: "transparent"
	});


	$("#menu").flash({
		src: "/templates/flash/menu.swf",
		width: "780",
		height: "170",
		wmode: "transparent"
	});

	$("#bron").flash({
		src: "/templates/flash/bron.swf",
		width: "300",
		height: "250",
		wmode: "transparent"
	});

$(".mapi").mouseover( function() {

$("#lasa").css({ background: "url(/templates/images/service_red.png) right no-repeat" } );
$("#map_mini").css({ border: "1px #860501 solid" } );

});

$(".mapi").mouseout( function() {

$("#lasa").css({ background: "none" } );
$("#map_mini").css({ border: "1px #291d15 solid" } );

});



$(".block" ).mouseover( function() {
$(".ssilkafoto",this).show();
});

$(".block" ).mouseout( function() {
$(".ssilkafoto",this).hide();

});





});
var qwqw = 0;
var y = 0;
function vacancy(x) {
	if (x == y){
		$('#'+x).slideToggle('normal');
	}
	else {
		$('.vacan').slideUp('normal');
		$('#'+x).slideDown('normal');
		}
	y = x;
}

// Количество;
function order_plus(id) {
	var value = Number($('#count'+id).val());
	if (value < 99) $('#count'+id).val(value+1); else $('#count'+id).val(99);
}
function order_minus(id) {
	var value = Number($('#count'+id).val());
	if (value > 1) $('#count'+id).val(value-1); else $('#count'+id).val(1);
}
function order_plus2(id) {
	$("#order-load").show();
	var incount = Number($("div","#basket-in-count"+id).html());
	$.post('/units/php/_order.php', { 'id': id, 'count': 1 }, function() {
		$("#basket-all").load("/delivery/menu/ #basket-all", { }, function() {
        	$("div","#basket-in-count"+id).html(incount+1);
			$("#order-load").hide();
		});
	});
}
function order_plus3(id) {
	$("#order-load").show();
	var incount = Number($("div","#basket-in-count"+id).html());
	$.post('/units/php/_order.php', { 'id': id, 'count': 1 }, function() {
		$("#basket-all").load("/delivery/menu/order/ #basket-all", { }, function() {
        	$("div","#basket-in-count"+id).html(incount+1);
			$("#order-load").hide();
		});
	});
}
function order_minus2(id) {
	$("#order-load").show();
	var incount = Number($("div","#basket-in-count"+id).html());
	$.post('/units/php/_order.php', { 'id': id, 'count': -1 }, function() {
		$("#basket-all").load("/delivery/menu/ #basket-all", { }, function() {
        	if (incount==1) $("#basket-in-count"+id).hide();
        	$("div","#basket-in-count"+id).html(incount-1);
			$("#order-load").hide();
		});
	});
}
function order_minus3(id) {
	$("#order-load").show();
	var incount = Number($("div","#basket-in-count"+id).html());
	$.post('/units/php/_order.php', { 'id': id, 'count': -1 }, function() {
		$("#basket-all").load("/delivery/menu/order/ #basket-all", { }, function() {
        	if (incount==1) $("#basket-in-count"+id).hide();
        	$("div","#basket-in-count"+id).html(incount-1);
			$("#order-load").hide();
		});
	});
}
function order_minus4(id) {
	$("#order-load").show();
	var incount = Number($("div","#basket-in-count"+id).html());
	$.post('/units/php/_order.php', { 'id': id, 'count': -1 }, function() {
		$("#basket-all").load("/delivery/menu/order/ #basket-all", { }, function() {
        	if (incount==1) $("#basket-in-count"+id).hide();
        	$("div","#basket-in-count"+id).html(incount-1);
        	document.location.href = '/delivery/menu/';
			$("#order-load").hide();
		});
	});
}
// Удалить из корзины;
function order_delete2(id) {
	$("#order-load").show();
	$.post('/units/php/_order.php', { 'id': id, 'delete': true }, function() {
		$("#basket-all").load("/delivery/menu/ #basket-all", { }, function() {
        	$("#basket-in-count"+id).hide();
        	$("div","#basket-in-count"+id).html(0);
			$("#order-load").hide();
		});
	});
}
function order_delete3(id) {
	$("#order-load").show();
	$.post('/units/php/_order.php', { 'id': id, 'delete': true }, function() {
		$("#basket-all").load("/delivery/menu/order/ #basket-all", { }, function() {
        	$("#basket-in-count"+id).hide();
        	$("div","#basket-in-count"+id).html(0);
			$("#order-load").hide();
		});
	});
}
function order_delete4(id) {
	$("#order-load").show();
	$.post('/units/php/_order.php', { 'id': id, 'delete_all': true }, function() {
		$("#order-load").hide();
    //document.location.href = '/delivery/menu/';
    document.location.reload();
	});
}
// Оформление заказа;
function order_ok(region) {
	$("#order-load").show();
	var name = $("#ordername").val();
	var phone = $("#orderphone").val();
	if (name != '' && phone != '' && region==1) {
	$("#black-message-content").load("/delivery/menu/order/ #black-message-content", { 'ok': true, 'name': name, 'phone': phone }, function() {
	  $("#order_info_button").css("background-position","0% 100%");
	  $("#order_info_text").hide();
    $("#order-load").hide();
    message();
	});
	} else {
	$("#order_ok").load("/delivery/menu/order/ #order_ok", { 'ok': true, 'name': name, 'phone': phone }, function() {
	  $("#order_info_button").hover(
    function() {
      $("#order_info_button").css("background-position","0% 50%");
    }, function() {
      $("#order_info_button").css("background-position","0% 0%");
    });
    $("#order-load").hide();
	});
	}
}
// Добавление в корзину;
function order(id) {
	var count = Number($("#count"+id).val());
	var incount = Number($("div","#basket-in-count"+id).html());
	$("#order-load").show();
	$.post('/units/php/_order.php', { 'id': id, 'count': count }, function() {
		$("#basket-all").load("/delivery/menu/ #basket-all", { }, function() {
       	    $("div","#basket-in-count"+id).html(incount+count);
    	    $("#basket-in-count"+id).show();
			$("#order-load").hide();
		});
	});
	$("#count"+id).val(1);
}
// Выбор района;
function setRegion(id) {
	$("#order-load").show();
	$.post('/units/php/_region.php', { 'id': id }, function() {
    	$("#basket-all").load("/delivery/menu/ #basket-all", {}, function() {
    		$("#order-load").hide();
    	});
	});
}
function setRegion2(id) {
	$("#order-load").show();
	$.post('/units/php/_region.php', { 'id': id }, function() {
    	$("#basket-all").load("/delivery/menu/order/ #basket-all", {}, function() {
    		$("#order_info_button").load("/delivery/menu/order/ #order_info_button", {}, function() {
    		  $("#order-load").hide();
    	 });
    	});
	});
}


// Сортировка блюд по подтипам;
function sortir(type2) {
  $(".sortir").css({ borderBottom: "2px dashed"});
  $("#iden"+type2).css({ borderBottom: "0px  dashed"});



  $(".menu-item-fon").hide();	
  $(".class"+type2).show();
  
}


// Сообщение;
function message() {
  $("#black").show();
  $("#black").width($("#main").width());
  $("#black").height($("#main").height());
}
function message_close() {
  $("#black").hide();
}
// info;
function info(i) {
	$("#order-load").show();
	var flag = 0;
	if ($("#sc"+i).is(":checked")) flag = i;
  $("#basket-all").load("/delivery/menu/order/ #basket-all", { 'info': true, 'i': i, '_flag': flag }, function() {
    if (flag>0) $("#order_sc_info").show(); else $("#order_sc_info").hide();
//    $("#sc"+i+"-info").show();
    $("#order-load").hide();
	});
}
