var curmenucell=null;
var overmenu=null;
var path_prefix;

function subscribe_me() {
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<img src="img/progress/21-1.gif" width="32" height="32" />');
	$.post('/cbk_subscribe.php',{ semail:$("#t_email_subscr").val() } , function(data) { $("#panel_bottom_div").html(data);} );
	}

function card_add(trgt) {
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding-right:10px" valign="top"><img src="img/progress/21-1.gif" width="32" height="32" /></td><td valign="top"><div style="font-size:16px">Открытие окна...</div><div style="font-size:12px">Подождите, сейчас будет открыта форма ввода дисконта.</div></td></tr></table>');
	$.post('/card.php',{ trgt:trgt} , function(data) { $("#panel_bottom_div").html(data);  } );
	}
function card_post() {
	$.post('/card.php', $("#card_form").serialize(), function(data) { $("#panel_bottom_div").html(data);  } );
	}

function cabdet(oid) {
	$("#dlg").dialog({ height: 550, width: 1000, modal: true }); 
	$.post('/cabinet_viewgoods.php', {id:oid} , function(data) { $("#dlg").html(data);   } );
	}

function getCount() { 
	$.post('/search.php?se[set][only_count]=1', $("#search_form_post").serialize() , function(data) { $("#count_div").html(data);   } );
	}
function chat() {
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding-right:10px" valign="top"><img src="img/progress/21-1.gif" width="32" height="32" /></td><td valign="top"><div style="font-size:16px">Открытие чата...</div><div style="font-size:12px">Подождите, сейчас будет открыта форма чата.</div></td></tr></table>');
	$.post('/chat_form.php',{ } , function(data) { $("#panel_bottom_div").html(data); chat_wd(); } );
	}
function chat_post() {
	$.post('/chat_post.php', $("#chat_form").serialize(), function(data) { $("#chat_dummy").html(data); $('#chat_text').val(''); chat_dmn(); } );
	}
function chat_dmn() {
	if ($("#chat_dummy").html()!="") { 
	$("#chat_list").html(  $("#chat_dummy").html()+$("#chat_list").html()  ); $("#chat_dummy").html('');
	$("#chat_list").scrollTop(0);
	}
	}
function chat_wd() { 
	if (document.getElementById('chat_list')) {
	$.post('/chat_post.php', {act:'listen'}, function(data) { 
		$("#chat_dummy").html(data); 
		chat_dmn();  
		setTimeout(chat_wd, 1000);
		} );
	}}
	
function panel_close() {
	$('#panel_bottom').hide();
	$("#panel_bottom_div").html('');
	$.post('/chat_post.php', {act:'close'}, function(data) { $("#chat_dummy").html(data); chat_dmn(); } );
	}

function menu_h(trgt, sender, ppref) {
	if(curmenucell!=trgt){
			setTimeout(function(){ 
			$("#f_text").val(overmenu);
			if ( overmenu==1) { 
			$("#menu_h_maindiv").show();
			$("#menu_h_div").show();
			$(".menu_h_span").css("border-bottom","1px solid grey");
			$(".menu_h_cell").css("border-bottom","1px solid grey");
			$("#menu_h_div").addClass("menu_h_div");
			$(sender).css("border-bottom","none");
			$(".menu_h_cell").removeClass("menu_h_cellhover");
			$(sender).addClass("menu_h_cellhover");
			$("#menu_h_div").css("width", $("#menu_h").outerWidth()-2+"px");
			$.post('/inc_menu_'+trgt+'.php', {} , function(data) { $("#menu_h_div").html(data); } );
			}
			}, overmenu!=1?250:0); 
		}
	curmenucell=trgt;
	overmenu=1;
	}
function menu_out() { 
	$("#menu_h_maindiv").hide();
	$(".menu_h_cell").removeClass("menu_h_cellhover");
	$(".menu_h_span").css("border-bottom","1px solid white");
	$(".menu_h_cell").css("border-bottom","1px solid white");
	$("#menu_h_div").hide();
	curmenucell=null; overmenu=null;
	}

function sf_chcat(sender, ppref, show_adv_sets) {  
	$.post('/search_form.php',{ for_folder:$(sender).val(), show_adv_sets:show_adv_sets } , function(data) { $("#search_form").html(data); } );
	}
function waiter(cont) {
	$(cont).html('<div style="padding:50px" align="center"><img src="img/progress/24-1.gif" width="24" height="24" /></div>');
	}
function basket_add(bid, amount, ppref) { 
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding-right:10px" valign="top"><img src="img/progress/21-1.gif" width="32" height="32" /></td><td valign="top"><div style="font-size:16px">Добавлем товар в корзину...</div><div style="font-size:12px">Подождите, сейчас выбранный Вами товар будет добавлен в корзину.</div></td></tr></table>');
	$.post('/cbk_add_to_basket.php',{ bid:bid, amount:amount } , function(data) { $("#panel_bottom_div").html(data); ch_leds();} );
	}
function basket_inquiry(bid, ppref) { 
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding-right:10px" valign="top"><img src="img/progress/21-1.gif" width="32" height="32" /></td><td valign="top"><div style="font-size:16px">...</div></td></tr></table>');
	$.post('/good_inquiry.php',{ bid:bid } , function(data) { $("#panel_bottom_div").html(data); } );
	}
function basket_inquiry_post(ppref) { 
	$("#panel_bottom").show();
	$.post('/good_inquiry.php', $("#inq_form").serialize() , function(data) { $("#panel_bottom_div").html(data); } );
	}
function sendlink_panel(gid, ppref) { 
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding-right:10px" valign="top"><img src="img/progress/21-1.gif" width="32" height="32" /></td><td valign="top"><div style="font-size:16px">...</div></td></tr></table>');
	$.post('/sendlink.php',{ gid:gid } , function(data) { $("#panel_bottom_div").html(data); } );
	}
function sendlink_go(ppref) { 
	$.post('/sendlink.php', $("#sendlink_form").serialize() , function(data) { $("#panel_bottom_div").html(data); } );
	}
function favorites_add(gid, ppref) { 
	$("#panel_bottom").show();
	$("#panel_bottom_div").html('<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding-right:10px" valign="top"><img src="img/progress/21-1.gif" width="32" height="32" /></td><td valign="top"><div style="font-size:16px">...</div></td></tr></table>');
	$.post('/favorites_add.php',{ gid:gid } , function(data) { $("#panel_bottom_div").html(data); ch_leds(); } );
	}
function gfeed_new(id, ppref) {
	$('#modal_1').modal({minHeight:280}); 
	$.post('/cbk_gfeed_form.php',{ id:id } , function(data) { $("#modal_1").html(data); } );
	}
function gfeed_post(ppref) { 
	$.post('/cbk_gfeed_list.php', $("#gfeed_form").serialize() , function(data) { $("#feed").html(data); $.modal.close(); } );
	}
	
function tabbed(sender) {
	$(sender).parent().find("td").removeClass("mytabbed");
	$(sender).addClass("mytabbed");
	$(sender).parent().parent().parent().parent().find(".tabpage").hide();
	$(sender).parent().parent().parent().parent().find("#tabpage\\["+$(sender).attr("tabid")+"\\]").show();
	}
	
	function rollch(rid){
		if (document.getElementById("dv"+rid).style.display=="none") {
			document.getElementById("dv"+rid).style.display="";
			document.getElementById("bul"+rid).src="img/page/bullet_arrow_top.png";
		} else {
			document.getElementById("dv"+rid).style.display="none";
			document.getElementById("bul"+rid).src="img/page/bullet_arrow_bottom.png";
		}
		}
function ch_leds(){
	if (document.getElementById("ch_led_fav")) {$("#led_fav").html($("#ch_led_fav").html());}
	if (document.getElementById("ch_led_basket")) {$("#led_basket").html($("#ch_led_basket").html());}
	}


$.extend($.expr[':'], {
    focused: function(elem) { return elem.hasFocus; }
});

