var waittext = "<div align=\"center\">Загружается...&nbsp;<img src=\"/inc/loading.gif\"></div>";var no_post_text = '<div align=\"center\">нет ни одного сообщения</div>';function no_post(n) {	switch (n) {		case 0:	{$('#waitTab').html(no_post_text); break;}		case 1:	{$('#accTab').html(no_post_text); break;}		case 2:	{$('#rejTab').html(no_post_text); break;}	}};function login() {	var user = encodeURI(document.getElementById('userLogin').value);	var psw = encodeURI(document.getElementById('pswLogin').value);	var nocache = Math.random();	$('#guru_content').html(waittext).load('/guru_func.php?act=in&user='+user+'&pass='+psw+'&nocache='+nocache);}function comment_login() {	var firm_id = document.getElementById('firm_id').value;	var login = encodeURI(document.getElementById('userLogin').value);	var psw = encodeURI(document.getElementById('pswLogin').value);	var nocache = Math.random();	$('#comment_body').html(waittext).load('/guru_func.php', {act: 'com_in', user: login, pass: psw, fi_id: firm_id, n: nocache});}function registerUser() {	$('#reg_result').html(waittext);	var user = encodeURI(document.getElementById('userReg').value);	var pass = encodeURI(document.getElementById('passReg').value);	var pass2 = encodeURI(document.getElementById('pass2Reg').value);	var fullname = encodeURI(document.getElementById('fullnameReg').value);	var email = encodeURI(document.getElementById('emailReg').value);	var wmz = encodeURI(document.getElementById('wmzReg').value);	var yad = encodeURI(document.getElementById('yadReg').value);	var phone_no = encodeURI(document.getElementById('phoneReg').value);	var nocache = Math.random();	if (pass != pass2) {		$("#reg_result").html('<span class="error_msg">Пароль и его повтор не совпадают!</span>');	}	else {		$("#reg_result").load('guru_func.php?act=reg&user='+user+'&pass='+pass+'&fullname='+fullname+'&email='+email+'&wmz='+wmz+'&yad='+yad+'&phone='+phone_no+'&nocache='+nocache);	};}function send_post() {	var firm_id = document.getElementById('firm_id').value;	var caption = document.getElementById('post_caption').value;	var posttext = document.getElementById('post_text').value;	var nocache = Math.random();	$('#post_send_res').html(waittext).load("/guru_func.php", {act:"newpost", c: caption, t: posttext, fid: firm_id, n: nocache}, function() {		$('#post_send_res').html('<span class="ok_msg">Сообщение отправлено.</span>');		document.getElementById('do_post').reset();	});/**/}function show_post_form () {	$('#guru_action').html(waittext).load("guru_func.php?act=postform","", function() {		$('#submit_post').click( send_post );	});/**/}function get_posts (st,pg) {	var s = "";	switch (st) {		case 0:	{s = "#wait"; break;}		case 1:	{s = "#acc"; break;}		case 2:	{s = "#rej"; break;}	}	$(s+'Post').load("guru_func.php?act=getpost&st="+st+"&pg="+pg).hide().fadeIn('normal');	$(s+'Tab .post_page_list').removeClass('post_current_page');	$('#page_'+st+'_'+pg).addClass('post_current_page');}function change_page () {	var s = $(this).attr('id');	var stat = parseInt(s.substring(5,20));	var page = parseInt(s.substring(7,20));//	alert("Status: "+stat+" Page: "+page);	get_posts(stat,page);}function show_posts () {	$('#guru_action').html(waittext).load("guru_func.php?act=viewpost","", function() {		$('#view_posts').tabs({ fxFade: true, fxSpeed: 'fast' });	});}function show_profile() {	$('#guru_action').html(waittext).load("guru_func.php?act=show_profile");}function update_profile () {	var fn = document.getElementById('fullnamePrf').value;	var em = document.getElementById('emailPrf').value;	var ph = document.getElementById('phonePrf').value;	var wz = document.getElementById('wmzPrf').value;	var yd = document.getElementById('yadPrf').value;	var nocache = Math.random();	$('#prf_result').html(waittext).load("/guru_func.php", {act:"upd_profile", fullname: fn, email: em, wmz: wz, yad: yd, phone: ph, n: nocache}, function() {		$('#prf_result').html('<span class="ok_msg">Профиль обновлён.</span>');	});/**/}function init_login_reg() {	$('#log_reg').tabs({ fxFade: true, fxSpeed: 'fast' });	$('#buttonLogin').click ( login );	$('#buttonReg').click ( registerUser );}function do_in_reg () {	$().ready( function () {		$('#guru_content').load("guru_func.php","", function() {			init_login_reg();			show_posts();		});	});};function set_firm_id ( fid ) {	$('#firm_id').val(fid);	$().ready( function () {		$('#submit_post').click( send_post );		$('#buttonLogin').click( comment_login );	});};/* =========== admins ============== */function set_post_status(obj,st) {	var s = $(obj).attr('id');	var pid = s.substring(4,10);	$('#post_'+pid).hide();	var comment = $('#comment_'+pid).val();	var guru = $('#guru_'+pid).val();	$.post("guru_adm_func.php", {act: 'acc_rej', id: pid , gid: guru, c: comment, s:st});};function accept_post () {	set_post_status(this,1);}function reject_post () {	set_post_status(this,2);}function set_reply() {	var s = $(this).attr('id');	var pid = s.substring(11,20);	$('#comment_'+pid).val( $(this).text() ).focus();}function show_guru_posts_adm() {	$('#guru_adm_workspace').html(waittext).load("guru_adm_func.php", {act: 'post_list'});}function show_guru_adm() {	$('#guru_adm_workspace').html(waittext).load("guru_adm_func.php", {act: 'guru_list'});}function do_pay_guru () {	var s = $(this).attr('id');	var g_id = parseInt(s.substring(7,20));	var q = $('#pay_q_'+g_id).val();	if (q == "") q = 0;	var cur = $('#paid_'+g_id).text();//	alert('guru: '+g_id+' q: '+q+' current: '+cur);	$('#paid_'+g_id).html(waittext).load("guru_adm_func.php", {act: 'do_pay', gid: g_id, val: q});}