$(function(){ $(window).scroll(function() { sortScroll(); }); function sortScroll(){ var win_top = $(document).scrollTop(); var menu_is_visible = $("#menu").is(':visible'); if (menu_is_visible) { var menu_top = $("#menu").offset().top+$("#menu ul").height(); if (win_top > menu_top) { $("#bin").addClass('fixed'); } else { $("#bin").removeClass('fixed'); } } } $(".num").keyup(function(){ id = $(this).parent().attr('id'); num = $(this).val(); $("#bin .info").html("загрузка"); $("#pr_price").html("0"); $.ajax({ type: "GET", url: "/ajax/index.php?id="+id+"&num="+num, success: function(msg) { var result = []; result = msg.split(','); $("#bin .info").html(result[0]); $("#pr_price").html(result[1]); } }); }); $("area.box").click(function(){ id = $(this).parent().parent().attr('id'); href = $(this).attr('href'); $("#bin .info").html("загрузка"); $("#pr_price").html("0"); $.ajax({ type: "GET", data: href, url: "/ajax/index.php", success: function(msg) { var result = []; result = msg.split(','); $("#a_"+id).val(result[0]); $("#bin .info").html(result[1]); $("#pr_price").html(result[2]); } }); return false; }); function overlay_hidden() { $("#overlay").animate( {opacity: '0'}, 300, function(){ $("#overlay").css( {display: 'none'}); }); $(".pre_order").addClass("none"); $(".pre_order").html(""); } function cat(cur_id, cur_href, cur_class) { $.ajax({ type: "GET", url: "/ajax/o_index.php?cmd="+cur_class+"&id="+cur_id+"&"+Math.random(), success: function(msg) { $(".eat-menu li."+cur_id+" input").val(msg); $(".order_table_std tr."+cur_id+" input").val(msg); prod_short_order_list(); pre_order_short_order_list(); } }); } function prod_short_order_list() { $.ajax({ type: "GET", url: "/ajax/o_index.php?cmd=prod_short_order_list&"+Math.random(), success: function(msg) { $("#bin .bg_green").html(msg); } }); } function pre_order_short_order_list() { $.ajax({ type: "GET", url: "/ajax/o_index.php?cmd=pre_order_short_order_list&"+Math.random(), success: function(msg) { $(".pre_order .order").html(msg); } }); } function prod_unset_all() { $.ajax({ type: "GET", url: "/ajax/o_index.php?cmd=prod_unset_all&"+Math.random(), success: function(msg) { $(".check .order").html(msg); a_list = $(".eat-menu input").get(); for (var i = 0; i < a_list.length; i++) { cur_el = $(a_list[i]).val(" "); } } }); } $(".r_menu .pre .ico a").live('click', function(){ prod_unset_all(); return false; }); $(".pre_order li area").live('click', function(){ cur_id = $(this).parent().parent().attr("class"); cur_href = $(this).attr("href"); cur_class = $(this).attr("class"); cat(cur_id, cur_href, cur_class); return false; }); $(".check li area").live('click', function(){ cur_id = $(this).parent().parent().attr("class"); cur_href = $(this).attr("href"); cur_class = $(this).attr("class"); cat(cur_id, cur_href, cur_class); return false; }); $(".order_table_std td area").live('click', function(){ cur_id = $(this).parent().parent().parent().parent().attr("class"); cur_href = $(this).attr("href"); cur_class = $(this).attr("class"); cat(cur_id, cur_href, cur_class); return false; }); $(".eat-menu li area").click(function(){ cur_id = $(this).parent().parent().parent().attr("class"); cur_href = $(this).attr("href"); cur_class = $(this).attr("class"); cat(cur_id, cur_href, cur_class); return false; }); $(".eat-menu li input").keyup(function(){ cur_id = $(this).parent().parent().attr("class"); cur_val = $(this).val(); $.ajax({ type: "GET", url: "/ajax/index.php?cmd=num&id="+cur_id+"&val="+cur_val+"&"+Math.random(), success: function(msg) { $("li."+cur_id+" input").val(msg); prod_short_order_list(); pre_order_short_order_list(); } }); return false; }); $(".i-main .add area").click(function(){ cur_id = $(this).attr("id"); cur_href = $(this).attr("href"); cur_class = $(this).attr("class"); cat(cur_id, cur_href, cur_class); return false; }); $(".bg_order .ico-cl a").live('click', function(){ overlay_hidden(); return false; }); $("#overlay").click(function(){ overlay_hidden(); }); $(".eat-menu div.big").click(function(){ $(this).addClass("none"); return false; }); $(".eat-menu a.big").click(function(){ cur_li = $(this).parent(); $("div.big", cur_li).removeClass("none"); return false; }); $("a.t").live('click', function(){ windowWidth=$('#sh').width(); windowHeight=$('#sh').height(); $("#overlay").css({display: 'inline', background: '#000000', opacity: '0', width: windowWidth, height: windowHeight}); $("#overlay").animate( {opacity: '0.8'}, 300); $(".pre_order").removeClass("none"); $.ajax({ type: "GET", url: "/ajax/order.php?"+Math.random(), success: function(msg) { $(".pre_order").html(msg); } }); return false; }); $(".pre_order .sam input:checkbox").live('click', function(){ if ($(".pre_order .sam input").attr("checked")) { $(".pre_order .sam .field").removeClass("none"); $(".pre_order .d_sam").addClass("none"); $.ajax({ type: "GET", url: "/ajax/o_index.php?cmd=pre_order_short_order_list&no_itogo=1&"+Math.random(), success: function(msg) { $(".pre_order .order").html(msg); } }); } else { $(".pre_order .sam .field").addClass("none"); $(".pre_order .d_sam").removeClass("none"); $.ajax({ type: "GET", url: "/ajax/o_index.php?cmd=pre_order_short_order_list&"+Math.random(), success: function(msg) { $(".pre_order .order").html(msg); } }); } }); $(".pre_order .city select").live('change', function(){ if ($(this).val() == 1) { $(".pre_order .fo_nk").removeClass("none"); $(".pre_order .fo_prk").addClass("none"); } else { $(".pre_order .fo_nk").addClass("none"); $(".pre_order .fo_prk").removeClass("none"); } }); }); function unblur() { this.blur(); } function blurLinks() { theLinks = document.getElementsByTagName("a"); for(i=0; iОтправка заказа..."); $.ajax({ type: "POST", url: "/ajax/order_send.php", data: req, success: function(msg){ $(".pre_order form .button").html(msg); } }); } function check_val(className, val) { cur_el = $("."+className); if (!cur_el.val()) { cur_el.val(val); } } function change_val(className, val) { cur_el = $("."+className); if (cur_el.val() == val) { cur_el.val(""); } }