var market_general={view_photo:function(a,c){var b='<img src="'+a+'" alt="" class="dlg_image" /><a href="#" class="close" title="Нажмите Esc для выхода">×</a>';jQuery.msgbox({bgcolor:"#000",opacity:0.8,inSpeed:0}).show({autoPosWhenScroll:false,showCaption:false,waitImage:true,moveHandle:".message",message:b},function(){if(c!=undefined){jQuery(".dlg_image").attr("title",c)}jQuery("#msgbox a.close").bind("click",function(){jQuery.msgbox().close();return false})})},get_img_id:function(a){return a.substr(a.lastIndexOf("/")+1,a.length)},add_goods_to_cart:function(c,a){a=a||0;jQuery.msgbox();function b(d){jQuery.msgbox.setButton({caption:"Закрыть"},function(){jQuery.msgbox.close()}).show({caption:"Товар успешно добавлен",message:'<br /><span class="small">Всего элементов в корзине <strong style="color:#444;">'+d.total_count+'</strong></span><br /><span class="small">Общая стоимость <strong style="color:#444;">'+d.total_price+'</strong></span><br /><br />Для управления списком заказанного товара/услуг и оформления заказа, перейдите <a href="http://market.'+TK_PUB_DOMAIN+'/orders.html">в корзину</a>',width:450});return true}jQuery.post(CLAjaxPreffix+"/market/cart/check/",{goods_id:c},function(d){if(d.auth){jQuery.msgbox.setButton({caption:"Добавить"},function(){jQuery.post(CLAjaxPreffix+"/market/cart/add/",{cart_item_id:a,goods_id:c},function(e){b(e)},"json")}).setButton({caption:"Отмена",xstyle:"color:#666;"},function(){jQuery.msgbox.close()});if(d.goods_count>0){jQuery.msgbox.show({caption:"Добавить товар в корзину",message:"Этого товара у вас уже <strong>"+d.goods_count+" шт.</strong><br /> <strong>Хотите добавить еще один?</strong>"})}else{jQuery.msgbox.show({caption:"Добавить товар в корзину",message:""})}}else{if(Loginpopup!=undefined&&Loginpopup){Loginpopup.Show()}}},"json");return false},remove_goods_from_cart:function(e,b){var d=jQuery("#item_"+e);var a=d.children(".name").children("strong").children("a").text();var c=d.children(".count").children("span").text();jQuery.msgbox().setButton({caption:"Удалить",xstyle:"color:#666;"},function(){var f=jQuery("#remove_items_count").attr("value");jQuery.post(CLAjaxPreffix+"/market/cart/remove/",{cart_item_id:e,goods_id:b,count:f},function(g){if(g.count_left>0){var h=c-f;d.children(".count").children("span").text((h<0?0:h))}else{d.remove();if(jQuery(".row").size()<=0){jQuery(".orders_table .operations").before('<div class="row"><p class="empty">Корзина пуста</p></div>')}}jQuery.msgbox.close()},"json")}).setButton({caption:"Отмена"},function(){jQuery.msgbox.close()}).show({caption:"Удалить товар из корзины",message:'<strong style="color:333">'+a+'</strong> в корзине <strong style="color:333">'+c+' шт.</strong><p style="margin-top:20px;">Сколько удалить?<br /> <input type="text" id="remove_items_count" value="1" /> шт.</p>',autoClose:30000})},inc_count:function(e,b){b=b||0;var d=jQuery("#item_"+e);var c=d.children(".count").children("span");var a=c.text();if(typeof a!=String){jQuery.post(CLAjaxPreffix+"/market/cart/add/",{cart_item_id:e,goods_id:b},function(f){a++;c.text(a);jQuery(".total_count_label").text(f.total_count);jQuery(".total_price_label").text(f.total_price)},"json")}},add_tab:function(c,a){var b=jQuery(".tabs .clearfix");b.children("a").children(".sel").removeClass("sel");b.append('<a href="#"><span class="tab sel '+a+'">'+c+"</span></a>");return false},remove_order:function(d,b){var a=jQuery(".orders_table").children("#item_"+d);var c=a.children(".order_date").text()||jQuery(".order_date_label").text();a.css({background:"#ddc8c8"});var b=b||0;jQuery.msgbox({afterClose:function(){a.removeAttr("style")}}).setButton({caption:"Удалить",xstyle:"color:#666;"},function(){jQuery.post(CLAjaxPreffix+"/market/history/remove/",{order_id:d},function(e){if(!b){a.slideUp(100,function(){a.remove();if(jQuery(".row").length<=0){jQuery(".orders_table").append('<div class="row"><p class="empty">Ни один заказ не был оформлен</p></div>')}var f=parseInt(jQuery(".total_order_count_label").text());f--;jQuery(".total_order_count_label").text(f);jQuery.msgbox.close()})}else{window.document.location.href="/orders/history.html"}},"json")}).setButton({caption:"Отмена"},function(){jQuery.msgbox.close()}).show({caption:"Удалить заказ",message:"<strong>Заказ №"+d+"</strong><br />Дата оформления: <strong>"+c+"</strong><br /><br /><p><strong>Обратите внимание.</strong> Продавцы уже уведомлены о вашем заказе. Удалить заказ из истории, не означает прекратить реализацию заказа.</p>",width:400})},empty_cart:function(){if(jQuery(".row .empty").length){jQuery.msgbox({animate:false,outSpeed:100}).setButton({caption:"Ясно"},function(){jQuery.msgbox.close()}).show({caption:"",showCaption:false,message:'<br /><p style="text-align:center;font-size:15pt;">Ой, корзина пуста!</p>',autoClose:3000});return false}jQuery.msgbox().setButton({caption:"Очистить",xstyle:"color:#666;"},function(){jQuery.post(CLAjaxPreffix+"/market/cart/empty/",{},function(a){jQuery(".orders_table").html('<div class="row"><p class="empty">Козина пуста</p></div>');jQuery(".total_count_label").text("0");jQuery(".total_price_label").text("0");jQuery.msgbox.close()},"json")}).setButton({caption:"Отмена"},function(){jQuery.msgbox.close()}).show({caption:"Очистить корзину?",message:"",autoClose:5000});return false},empty_history:function(){if(jQuery(".row .empty").length){jQuery.msgbox({animate:false,outSpeed:100}).setButton({caption:"Ясно"},function(){jQuery.msgbox.close()}).show({caption:"",showCaption:false,message:'<br /><p style="text-align:center;font-size:15pt;">Ой, история заказов пуста!</p>',autoClose:3000});return false}jQuery.msgbox().setButton({caption:"Очистить",xstyle:"color:#666;"},function(){jQuery.post(CLAjaxPreffix+"/market/history/empty/",{},function(a){jQuery(".orders_table").html('<div class="row"><p class="empty">Ни один заказ не был оформлен</p></div>');jQuery(".total_order_count_label").text("0");jQuery.msgbox.close()},"json")}).setButton({caption:"Отмена"},function(){jQuery.msgbox.close()}).show({caption:"Очистить историю заказов?",message:"<p><strong>Обратите внимание.</strong><br /> Если заказы, полностью истощены, т.е. товары, входящие в заказы, Вами получены, тогда смело очищайте историю заказов.</p>",width:400});return false},add_cat_request:function(){var a="";jQuery("#catsItems .market_cat").each(function(){a+=(jQuery(this).text()).replace(/[\×]+/g,"")+" -- "});jQuery.msgbox({inSpeed:0,outSpeed:0}).setButton("Отправить",{xstyle:"font-weight:bold;color:#CC3366"},function(){return market_general.send_add_cat_request(a)}).setButton("Отмена",function(){jQuery.msgbox.close();return false}).show("<h1>Запрос на добавление "+(a?"подкатегории":"новой категории")+"</h1><p>"+(a?"В ":"")+"<strong>"+a+'</strong></p><p><textarea id="add_cat_text" style="width:400px;height:200px;font-size:10pt;">Название категории: \n\nНазвание товара: \n\nОписание товара: \n</textarea></p>',{width:450});return false},send_add_cat_request:function(a){jQuery.post(CLAjaxPreffix+"/common/market_add_cat_request",{text:jQuery("#add_cat_text").val(),cats_path:a},function(b){jQuery.msgbox().setButton("Ясно",function(){jQuery.msgbox.close()}).show('<p style="text-align:center;">Ваше предложение будет рассмотрено, обдумано, и скорее всего принято.<br /> Скоро мы с Вами свяжемся! ;)</p>',{autoClose:5000})},"json");return false},complain:function(a){jQuery.msgbox().setButton("Пожаловаться",{xstyle:"color:#CC3366;font-weight:bold;width:200px;"},function(){jQuery.post(CLAjaxPreffix+"/common/market_complain",{goods_id:document.location.href,text:jQuery("#goods_complain_text").val()},function(b){if(b.good==1){jQuery.msgbox().setButton("Ясно",function(){jQuery.msgbox.close()}).show('<p style="text-align:center;">Ваша жалоба отправлена, будет рассмотрена, и скорее всего мы примем соответствующие меры! ;)</p>',{autoClose:6000})}else{if(b.good=-1){}else{if(b.good==0){}}}},"json")}).setButton("Отмена",function(){jQuery.msgbox.close()}).show('<h1>Пожаловаться на объявление</h1><p><span style="color:#666">Причина</span><br /><textarea style="width:450px;height:200px;" id="goods_complain_text"></textarea></p>');return false},view_all_images:function(){var a=jQuery("#view_all_goods_images");a.find("a").unbind("click");a.slideUp(200,function(){jQuery("#all_goods_images_list").slideDown(200);jQuery(this).remove()});return false},get_discount_dlg:function(e,b,d){var a=window.COMPANY_NAME;var c="";if(d!=undefined&&d){var c="http://"+jQuery("#est_subdomain_goods_"+d).attr("value")+TK_PUBLIC_DOMAIN+"/market/"+d+".html";var a=jQuery("#est_name_goods_"+d).attr("value")}jQuery.msgbox({bgcolor:"#000",opacity:0.6,inSpeed:0,beforeShow:function(){$m=jQuery("#msgbox");$m.addClass("get_discount_card_dlg");$m.find(".title").css({background:"none",color:"#222"});$m.find(".buttons").css({background:"none",border:"none"});$m.find(".wrap").css({background:"#eee",color:"#222"})}}).show("Получить купон на скидку",'<div><p><span class="num">1</span> Сохраните купон</p><p class="clearfix"><img src="'+CL_STAT_DOMAIN+'/discount_cards/market_discount_preview.gif" style="margin-left:23px;float:left" /><span class="discount_dlg_value">'+b+'%<br />скидка</span></p><p><span class="num">2</span> Распечатайте</p><p><span class="num">3</span> Предоставьте купон в заведении</p><p class="name">&laquo;'+a+'&raquo;</p><p style="margin-top:10px;"><span class="num">4</span> Получите скидку на товар/услугу</p><p class="name">&laquo;'+e+'&raquo;</p><div class="buttons" style="padding:0;display:block;text-align:left;margin-left:23px;"><span class="button" style="width:297px;text-align:center;"><a href="'+c+'?a=get_discount" target="_blank" onclick="jQuery.msgbox.close();" style="text-decoration:none;display:block;">Сохранить купон</a></span><span class="button" onclick="return jQuery.msgbox.close();">Отмена</span></div>',{autoPosWhenScroll:false,width:500,waitImage:true,afterClose:function(){jQuery("#msgbox").removeClass("get_discount_card_dlg")}});return false}};
