var b="";
var flg_ie=0;
b=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown'
if(b=="IE")
{flg_ie=1;}


var reg_cur_shag=1;
var flg_check_log=0;
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http1;
var nocache=0;

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}


function change_check_value(f)
{
	if(f.checked)
	{f.value="1"}
	else
	{f.value="0"}
}

function openurl(url)
{
    var fakeLink = document.createElement('a');
 
    // Firefox & other browsers
    if (typeof(fakeLink.click) == 'undefined')
    {
        location.href = url;
    }
    // Internet Explorer
    else
    {
        fakeLink.href = url;
        document.body.appendChild(fakeLink);
        fakeLink.click(); 
    }
 
    return true;
}


//показываем всплывающее окно
function showinfopopup(id_popup,popup_text,id_object)
{
	var offset=$("#" + id_object).offset();
	$("#" + id_popup).css('top', offset.top + "px");
	$("#" + id_popup).css('left', offset.left + "px");
	$("#" + id_popup).text(popup_text);
	$("#" + id_popup).fadeIn(500);
	$("#" + id_popup).dropShadow();
	setTimeout('$("#' + id_popup + '").fadeOut(500);$("#' + id_popup + '").removeShadow();', 1500)
}


function check_email(pemail)
{
	//var re_email = /^\w[\w.-]*@([0-9a-z][0-9a-z-]{1,64}\.){1,7}[a-z]{1,10}$/;
	var re_email =/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z])+$/;
    if (!re_email.test(pemail)) 
    {
    	return 1;
    }
    return 0;
}


function getEventTarget(evt)
{  
   evt=evt||window.event;  
   return target=(evt.target)?evt.target:evt.srcElement;  
} 


function hide_sel_lang(evt)
{
	hide_login(evt);
}

//проверка формы поиска
function check_frm_search(f)
{
	if(f.search_text.value.length==0)
	{
		return;
	}
	if(f.search_text.value.length<3)
	{
		alert("Текст для поиска должен быть более 3-х символов.");
		return;
	}
	
	document.location.href=hname+"index.php?search_recipe="+f.search_text.value;
}

function set_search_text(v)
{
	document.getElementById("search_text").value=v
}

//показать окно с авторизацией
function show_login()
{
	//document.getElementById("loading").style.display="block";
	if(document.getElementById("window_autorization").style.display=="none")
	{
		w=getClientWidth();
		l=w-480;
		
		//alert(document.getElementById("change_lang_link").offsetLeft);
		document.getElementById("window_autorization").style.top=(document.getElementById("login_link").offsetTop+12) + "px";
		document.getElementById("window_autorization").style.left=l + "px";
		document.getElementById("window_autorization").style.display="block"
		document.getElementById("input_login").focus();
	}
	else
	{document.getElementById("window_autorization").style.display="none"}
}
//скрыть окно с авторизацией
function hide_login(evt)
{
	if(document.getElementById("loading").style.display=="block")
	{
		return;
	}
	
	var o=getEventTarget(evt);
	
	if(o.className!="div_login1" && o.className!="tbl_login" && o.className!="login_title" && o.className!="input_login" && o.className!="base_input" && o.className!="link_p_blue"  && o.className!="h2_login" && o.className!="aut_left" && o.className!="aut_right" && o.className!="but_login")
	{
		document.getElementById("window_autorization").style.display="none"
		//$("#div_login").fadeOut("fast");
		//$("#window_autorization").fadeOut("fast");
	}
}

//показать блок расширенный поиск
function show_search_block()
{
	//document.getElementById("window_rsearch").style.top=(document.getElementById("search_box").offsetTop-5) + "px";
	//document.getElementById("window_rsearch").style.left=(document.getElementById("search_box").offsetLeft-5) + "px";
	//document.getElementById("icons_box").style.display="none";
	//document.getElementById("search_box").style.display="none";
	var offset=$("#search_box").offset();
	//$("#fixedmodal").css('left', offset.left + "px");
	$("#fixedmodal").css('top', (offset.top-5) + "px");

	document.getElementById("fixedmodal").style.visibility="visible"
	document.getElementById("esearch_text").focus();
}

function hide_search_block()
{
	//document.getElementById("search_box").style.display="block";
	//document.getElementById("fixedmodal").style.display="none"	
	//document.getElementById("icons_box").style.display="block";
	document.getElementById("fixedmodal").style.visibility="hidden"
}

//функции по рассширенному поиску
function show_search_select1()
{
	$("#sel_find2").css("display","none")
	if($("#sel_find1").css("display")=="none")
	{$("#sel_find1").css("display","block");}
	else
	{$("#sel_find1").css("display","none");}
}

function show_search_select2()
{
	$("#sel_find1").css("display","none")
	if($("#sel_find2").css("display")=="none")
	{$("#sel_find2").css("display","block");}
	else
	{$("#sel_find2").css("display","none");}
}

function heide_search_select(evt)
{
	var o=getEventTarget(evt);
	
	if(o.className!="search_select")
	{$("#sel_find1").css("display","none");}
	if(o.className!="search_select")
	{$("#sel_find2").css("display","none");}

}

function do_select1(f)
{
	$("#search_select_text1").text(f.options[f.selectedIndex].text);
	heide_search_select
}

function do_select2(f)
{
	$("#search_select_text2").text(f.options[f.selectedIndex].text);
	heide_search_select
}

//обновление капчи
function update_kcaptcha(v)
{
   if(document.getElementById("msg_loader")!=null)
   {document.getElementById("msg_loader").style.display="block";}
   if(document.getElementById("img_kcaptcha")!=null)
   {document.getElementById("img_kcaptcha").src=v + "&nocache=" + Math.random();}
   if(document.getElementById("msg_loader")!=null)
   {document.getElementById("msg_loader").style.display="none";}
}

//отправка сообщения администрации
function check_frm_send(f)
{
	var err=0;
	
	$("#name_alert").css("display","none");
	$("#email_alert").css("display","none");
	$("#komm_alert").css("display","none");
	$("#code_alert").css("display","none");
	
	if(f.name.value=="")
	{
		err=1;
		$("#name_alert").css("display","block");
	}

	if(check_email(f.email.value)==1)
	{
		err=1;
		$("#email_alert").css("display","block");
	}

	if(f.komm.value=="")
	{
		err=1;
		$("#komm_alert").css("display","block");
	}

	if(f.code.value=="")
	{
		err=1;
		$("#code_alert").css("display","block");
	}

	if(err==0)
	{
		send_back_msg(f);
	}
}

function send_back_msg(f)
{
	document.getElementById("loading").style.display="block";
	http1 = createObject();
	nocache = Math.random();
		
	name=encodeURI(f.name.value);
	email=encodeURI(f.email.value);
	komm=encodeURI(f.komm.value);
	code=encodeURI(f.code.value);

	http1.open('POST',hname + 'library/_ajax_function.php?send_back_msg&nocache = '+nocache);
	http1.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	//http1.setRequestHeader("Accept-Language", "ru, en");
	//http1.setRequestHeader("Accept-Charset", "windows-1251");
	http1.onreadystatechange = GetRetBackMsg;
	http1.send("name=" + name + "&email=" + email + "&komm=" + komm + "&code=" + code);

}

function GetRetBackMsg()
{

if(http1.readyState == 4)
{ 
if (http1.status == 200) 
{
            // обработка ответа
        } else 
        {
        	
            alert("Не удалось получить данные:\n" +
                http1.statusText);
    			flgCheck=0;            
				return
        }

var response = http1.responseText;

//alert(response);

if(response=="-1")
{
	alert("Проверьте введенные данные!");
}
else
{
	if(response=="-101")
	{
	alert("Ошибка при отправке почты!");
	}

	if(response=="0")
	{
		document.getElementById("div_back_msg").innerHTML="Ваше сообщение отправлено"
	}
}

}
document.getElementById("loading").style.display="none";
}


//работа со звездами
function show_zvezda(pid,pnot)
{
	
	if(flg_user_logined==0 || pnot==1)
	{
		return;
	}
	
	for(i=pid; i<=5; i++)
	{
		document.getElementById("zvezda" + i).src=hname+"img/ico_star_passive.png"
	}
	
	for(i=1; i<=pid; i++)
	{
		document.getElementById("zvezda" + i).src=hname+"img/ico_star.png"
	}
}

function click_on_star(prid,pid,pnot,puser)
{
	
	if(flg_user_logined==0 || pnot==1)
	{
		if(pnot==1)
		{showinfopopup("my_popup","Вы уже голосовали за этот рецепт!","div_star");}
		if(flg_user_logined==0)
		{showinfopopup("my_popup","Чтобы проголосовать, Вы должны войти на сайт!","div_star");}
		return;
	}

	http1 = createObject();
	nocache = Math.random();
		
	http1.open('POST',hname + 'library/_ajax_function.php?set_star=' + pid + '&recipie='+ prid + '&user=' + puser + '&nocache = '+nocache);
	http1.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	//http1.setRequestHeader("Accept-Language", "ru, en");
	//http1.setRequestHeader("Accept-Charset", "windows-1251");
	http1.onreadystatechange = GetRetSetStar;
	http1.send(null);
}

function GetRetSetStar()
{
	if(http1.readyState == 4)
	{ 
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
            alert("Не удалось получить данные:\n" +
                http1.statusText);
    			flgCheck=0;            
				return
        }

	var response = http1.responseText;

	//alert(response);
	document.getElementById("span_star_count").innerHTML=response;
	
	flg_user_logined=0;
	}
}

//вход на сайт со ссылки по тексту
function show_login_center()
{
	document.getElementById("loading").style.display="block";
	$("#loading").click(function(){hide_login_center()});
	document.getElementById("ajax_loader").style.display="none";
		w=getClientWidth();
		l=(w/2)-234;
		
		//alert(document.getElementById("change_lang_link").offsetLeft);
		document.getElementById("window_autorization").style.top=(document.getElementById("login_link").offsetTop+180) + "px";
		document.getElementById("window_autorization").style.left=l + "px";
		document.getElementById("login_otmena").style.display="block"
		document.getElementById("window_autorization").style.display="block"
		document.getElementById("input_login").focus();

}

function hide_login_center()
{
		document.getElementById("loading").style.display="none";
		document.getElementById("ajax_loader").style.display="block";
	
		document.getElementById("login_otmena").style.display="none"
		document.getElementById("window_autorization").style.display="none"
		$("#loading").unbind();
}

//отправить рецепт другу
function show_recipie_to_frend(id)
{
	document.getElementById("loading").style.display="block";
	document.getElementById("ajax_loader").style.display="none";
	w=getClientWidth();
	l=(w/2)-234;
	
	//alert(document.getElementById("change_lang_link").offsetLeft);
	document.getElementById("window_sendfrend").style.top=(document.getElementById("a_send_to_friend").offsetTop+180) + "px";
	document.getElementById("window_sendfrend").style.left=l + "px";
	document.getElementById("window_sendfrend").style.display="block"
}

function hide_sendfrend_center()
{
	document.getElementById("loading").style.display="none";
	document.getElementById("ajax_loader").style.display="block";
	
	document.getElementById("window_sendfrend").style.display="none"
}

function check_frm_sendfrend(f,rid)
{
	if(check_email(f.email.value)==1)
	{
		alert("Укажите правильный адрес Email!");
		return;
	}

	http1 = createObject();
	nocache = Math.random();
	http1.open('GET',hname + 'library/_ajax_function.php?send_frend=' + f.email.value + '&rid=' + rid + '&nocache = '+nocache);
	http1.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	//http1.setRequestHeader("Accept-Language", "ru, en");
	//http1.setRequestHeader("Accept-Charset", "windows-1251");
	http1.onreadystatechange = GetRetSendFrend;
	http1.send(null);

}

function GetRetSendFrend()
{
	if(http1.readyState == 4)
	{ 
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
            alert("Не удалось получить данные:\n" +
                http1.statusText);
    			flgCheck=0;            
				return
        }

	var response = http1.responseText;

	//alert(response);
	if(response==0)
	{
		alert("Сообщение отправлено!");
		
		hide_sendfrend_center()
	}
	else
	{
		alert("Неудалось отправить почту, проверьте введенный адрес!");
	}
	
	}
	
}


//проверяем логин
function check_login(log)
{
	http1 = createObject();
	nocache = Math.random();
	http1.open('GET',hname + 'library/_ajax_function.php?check_login=' + log + '&nocache = '+nocache,false);
	http1.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	//http1.setRequestHeader("Accept-Language", "ru, en");
	//http1.setRequestHeader("Accept-Charset", "windows-1251");
	http1.onreadystatechange = GetRetCheckLogin;
	http1.send(null);	
}

function GetRetCheckLogin()
{
if(http1.readyState == 4)
	{ 
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
            alert("Не удалось получить данные:\n" +
                http1.statusText);
    			flgCheck=0;            
				return
        }

	var response = http1.responseText;

	//alert(response);
	if(response==0)
	{
		flg_check_log=0;
	}
	else
	{
		flg_check_log=1;
	}
	
	}
}

//регистрация пользователя
function check_frm_reg(f)
{
	var err=0;
	
	$("#name_alert").css("display","none");
	$("#email_alert").css("display","none");
	$("#log_alert").css("display","none");
	$("#code_alert").css("display","none");
	$("#pw_alert").css("display","none");
	$("#pw1_alert").css("display","none");
	
	
	if(f.name.value=="")
	{
		err=1;
		$("#name_alert").css("display","block");
	}

	if(check_email(f.email.value)==1)
	{
		err=1;
		$("#email_alert").css("display","block");
	}

	if(f.log.value=="")
	{
		err=1;
		$("#log_alert").css("display","block");
	}
	else
	{
		check_login(f.log.value);
		
		if(flg_check_log==1)
		{
			err=1;
			$("#log_alert").css("display","block");
			alert("Пользователь с таким логином уже зарегистрирован!");
			
		}
	}

	if(f.pw.value=="")
	{
		err=1;
		$("#pw_alert").css("display","block");
	}

	if(f.pw1.value=="")
	{
		err=1;
		$("#pw1_alert").css("display","block");
	}

	if(f.pw.value!=f.pw1.value)
	{
		alert("Поля ввода пароля и повтора пароля - должны совпадать!");
	}
	
	if(f.code.value=="")
	{
		err=1;
		$("#code_alert").css("display","block");
	}

	
	document.getElementById("log_alert").innerHTML="Введите логин.";
	
	if(err==0)
	{
		reg_user(f);
	}
}

function reg_user(f)
{
	name=encodeURI(f.name.value);
	email=encodeURI(f.email.value);
	log=encodeURI(f.log.value);
	pw=encodeURI(f.pw.value);
	pw1=encodeURI(f.pw1.value);
	code=encodeURI(f.code.value);

	document.getElementById("loading").style.display="block";
	document.getElementById("ajax_loader").style.display="block";

	http1 = createObject();
	nocache = Math.random();
	http1.open('POST',hname + 'library/_ajax_function.php?reg_user&nocache = '+nocache);
	http1.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	//http1.setRequestHeader("Accept-Language", "ru, en");
	//http1.setRequestHeader("Accept-Charset", "windows-1251");
	http1.onreadystatechange = GetRetRegUser;
	http1.send("name=" + name + "&email=" + email + "&log=" + log + "&pw=" + pw + "&pw1=" + pw1 + "&code=" + code);	
}

function GetRetRegUser()
{
	if(http1.readyState == 4)
	{ 
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
            alert("Не удалось получить данные:\n" +
                http1.statusText);
    			document.getElementById("loading").style.display="none";
				return
        }

	var response = http1.responseText;

	//alert(response);
	if(response==0)
	{
		document.getElementById("div_back_msg").innerHTML="Регистрация завершена. <br /> На адрес электронной почты указанный при регистрации отправлено письмо с Вашими регистрационными данными.";
	}
	else
	{
		if(response==-1)
		{
			alert("Вы неверно ввели проверочный код!\r\nВведите еще раз и нажмите кнопку 'Отправить'");
		}
		if(response==-12)
		{
			alert("Пользователь с указанным логином, уже зарегистрирован!\r\nВведите еще раз и нажмите кнопку 'Отправить'");
		}
		if(response==-13)
		{
			alert("Пользователь с указанным Email, уже зарегистрирован!\r\nВведите еще раз и нажмите кнопку 'Отправить'");
		}
	}
		document.getElementById("loading").style.display="none";
	}

	
}

//восстановление пароля
function check_frm_forgot(f)
{
	var err=0;
	if(check_email(f.email.value)==1)
	{
		err=1;
		$("#email_alert").css("display","block");
	}
	if(err==0)	
	{
		f.submit();
	}
}

//авторизация - login
function check_frm_login(f)
{
	
	if(f.input_login.value=="" || f.input_login.value=="Пароль")
	{
		alert("Введите логин!");
		f.input_login.focus();
		return false;
	}
	
	if(f.input_password.value=="" || f.input_password.value=="Пароль")
	{
		alert("Введите пароль!");
		f.input_password.focus();
		return false;
	}

	
	hide_login_center();
	document.getElementById("loading").style.display="block";
	http1 = createObject();
	nocache = Math.random();
	
	var params="login=" + f.input_login.value + "&passwd=" + f.input_password.value;
	
	
	http1.open('POST', hname + "library/_ajax_function.php?login" + "&nocache" + nocache+"&remember="+f.chk_remember.value,true);

	http1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http1.setRequestHeader("Content-length", params.length);
	http1.setRequestHeader("Connection", "close");

	//http1.setRequestHeader("Accept-Language", "ru, en");
	//http1.setRequestHeader("Accept-Charset", "utf-8");
	http1.onreadystatechange = GetRetLogin;
	//alert("login=" + f.login.value + "&passwd=" + f.pw.value)
	http1.send(params);

	return false;
}

function GetRetLogin()
{
	if(http1.readyState == 4)
	{
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
        	document.getElementById("loading").style.display="none";
            alert("Ошибка авторизации: " + http1.statusText+"\r\nПожалуйста повторите авторизацию позже.");
			
				return
        }
	
	var response = http1.responseText;
	//alert(response);
	document.getElementById("loading").style.display="none";
	if(response==0)
	{
		document.location.href=hname;
	}
	
	if(response==-1)
	{
		alert("Проверьте вводимые данные!");
		show_login_center();
	}
	
	if(response==-11)
	{
		alert("Пользователь с такими данными не найден!");
		show_login_center();
	}
	}	
}

//если ие то ловим enter на форме входа
function login_po_enter(evt)
{
	if(flg_ie==1 && evt.keyCode==13)
	{
		document.getElementById("btn_login").click();
	}
}

//выход с сайта
function exit_from_site()
{
	if(confirm("Вы уверены, что хотите выйти?"))
	{
		document.location.href=hname + "index.php?logout";
	}
}

//удалить фото рецепта
function delete_recipe_foto()
{
	if(document.getElementById("img_foto").src!=hname+"img/bgrec.png")
	{
	if(confirm("Удалить фото рецепта?"))
	{
	 document.getElementById("img_foto").src=hname+"img/bgrec.png";
	 document.getElementById("fname").value="";
	 document.getElementById("recipephoto").style.background="url(../img/bg_recipephoto.png) top left no-repeat";
	}
	}
}

//создание превью
function open_create_preview(file,id)
{
	if(document.getElementById("img_foto").src!=hname+"img/bgrec.png")
	{
		window.open(hname+"create_preview.php?file="+document.getElementById("img_foto").src,"new_preview","width=280,height=400,fullscreen=0,resizable=0,scrollbars=0,menubar=0,location=0,toolbar=0");
	}
}

//добавление рецепта
function check_frm_add_recipe(f)
{
	var err=0;
	
	$("#name_alert").css("display","none");
	$("#tag_alert").css("display","none");
	$("#cat_alert").css("display","none");
	$("#world_alert").css("display","none");
	$("#ing_alert").css("display","none");
	$("#rec_alert").css("display","none");
	
	document.getElementById("name").className="input_based";
	document.getElementById("ing").className="textarea_based";
	document.getElementById("rec").className="textarea_based";
	
	if(f.name.value=="")
	{
		err=1;
		$("#name_alert").css("display","block");
		document.getElementById("name").className="input_error";
	}

	cat_value="";
	for(i=0; i<=dish_type_count-1; i++)
	{
		if(document.getElementById("label"+i).checked)
		{
			cat_value="1";
			break;
		}
	}
	if(cat_value=="")
	{
		err=1;
		$("#cat_alert").css("display","block");
	}
		
	world_value="";
	for(i=0; i<=dish_world_count-1; i++)
	{
		if(document.getElementById("wlabel"+i).checked)
		{
			world_value="1";
			break;
		}
	}
	if(world_value=="")
	{
		err=1;
		$("#world_alert").css("display","block");
	}

	if(f.ing.value=="")
	{
		err=1;
		$("#ing_alert").css("display","block");
		document.getElementById("ing").className="textarea_error";
	}

	if(f.rec.value=="")
	{
		/*err=1;
		$("#rec_alert").css("display","block");
		document.getElementById("rec").className="textarea_error";*/
	}
	
	if(err==1)
	{
		document.location.href=hname+"add_recipe/"+ '#top';
	}
	else
	{
		
		f.submit();
	}
}

//редактирование рецепта
function check_frm_edit_recipe(f)
{
	var err=0;
	
	$("#name_alert").css("display","none");
	$("#tag_alert").css("display","none");
	$("#cat_alert").css("display","none");
	$("#world_alert").css("display","none");
	$("#ing_alert").css("display","none");
	$("#rec_alert").css("display","none");
	
	document.getElementById("name").className="input_based";
	document.getElementById("ing").className="textarea_based";
	document.getElementById("rec").className="textarea_based";
	
	if(f.name.value=="")
	{
		err=1;
		$("#name_alert").css("display","block");
		document.getElementById("name").className="input_error";
	}

	cat_value="";
	for(i=0; i<=dish_type_count-1; i++)
	{
		if(document.getElementById("label"+i).checked)
		{
			cat_value="1";
			break;
		}
	}
	if(cat_value=="")
	{
		err=1;
		$("#cat_alert").css("display","block");
	}
		
	world_value="";
	for(i=0; i<=dish_world_count-1; i++)
	{
		if(document.getElementById("wlabel"+i).checked)
		{
			world_value="1";
			break;
		}
	}
	if(world_value=="")
	{
		err=1;
		$("#world_alert").css("display","block");
	}

	if(f.ing.value=="")
	{
		err=1;
		$("#ing_alert").css("display","block");
		document.getElementById("ing").className="textarea_error";
	}

	if(f.rec.value=="")
	{
		/*err=1;
		$("#rec_alert").css("display","block");
		document.getElementById("rec").className="textarea_error";*/
	}
	
	if(err==1)
	{
		document.location.href=hname+"add_recipe/"+ '#top';
	}
	else
	{
		
		f.submit();
	}
}


//выбор тэгов
function show_select_tag()
{
	var offset=$("#tag").offset();
	document.getElementById("loading1").style.display="block";
	$("#loading1").click(function(){close_tag_window()});
	t=offset.top+30;
	if(flg_ie==0)
	{t=t+0;}
	$("#div_tag").css('top', t + "px");
	$("#div_tag").css('left', (offset.left-0) + "px");

	$("#div_tag").fadeIn(200,function(){$("#div_tag").dropShadow()});
}

function close_tag_window()
{
	$("#div_tag").fadeOut(200);
	$("#div_tag").removeShadow();

	$("#loading1").unbind();
	document.getElementById("loading1").style.display="none";
}

//снять все отметки с тэгов
function uncheck_tag()
{
	$(".chk_tag").removeAttr('checked');
	document.getElementById("tag").value="";
}
//выбрать все тэги
function sel_recipe_tag()
{
	var array_delete_articles = $("input:checkbox[class=chk_tag]:checked"); // загнали в переменную, что бы по несколько раз не делать выборку
	if(array_delete_articles.size() == 0)
	{
		alert("Не выбран ни один тэг!");
		return;
	}
	
	v="";
	for(i=0; i<=array_delete_articles.length-1; i++)
	{
		v=v+","+array_delete_articles[i].value;
	}
	
	/*if(document.getElementById("tag").value!="")
	{document.getElementById("tag").value=document.getElementById("tag").value+v;}
	else
	{document.getElementById("tag").value=v.substring(1);}
	*/
	document.getElementById("tag").value=v.substring(1);
	
	close_tag_window();
}

//выбор категории рецепта
function change_sel_dish_type(id,f)
{
	for(i=0; i<=dish_type_count-1; i++)
	{
		document.getElementById("div_type1_"+i).className="rb";
		document.getElementById("div_type2_"+i).className="rb_r";
		document.getElementById("div_type3_"+i).className="rb_t";
	}
	
	if(f.checked)
	{
		document.getElementById("div_type1_"+id).className="rb_active";
		document.getElementById("div_type2_"+id).className="rb_r_active";
		document.getElementById("div_type3_"+id).className="rb_t_active";
	}
}

//выбор кухни мира
function change_sel_dish_world(id,f)
{
	for(i=0; i<=dish_world_count-1; i++)
	{
		document.getElementById("div_world1_"+i).className="rb";
		document.getElementById("div_world2_"+i).className="rb_r";
		document.getElementById("div_world3_"+i).className="rb_t";
	}
	
	if(f.checked)
	{
		document.getElementById("div_world1_"+id).className="rb_active";
		document.getElementById("div_world2_"+id).className="rb_r_active";
		document.getElementById("div_world3_"+id).className="rb_t_active";
	}	
}

//показать весь список кухонь мира
function show_all_world()
{
	if ($("#other_world").is(":hidden"))
	{
		$("#other_world").slideDown("slow");
	}
	else
	{
		$("#other_world").slideUp();
	}
}

//обновить сессию
function update_session(id)
{
	http1 = createObject();
	nocache = Math.random();
	http1.open('get', hname + "library/_ajax_private.php?update_session="+id+"&nocache" + nocache,true);
	http1.onreadystatechange = GetRetUpdateSession;
	http1.send(null);
	return false;	
}

function GetRetUpdateSession()
{
	if(http1.readyState == 4)
	{
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
        	document.getElementById("loading").style.display="none";
            alert("Не удалось получить данные:\n" +
                http1.statusText);
			
				return
        }
	
	var response = http1.responseText;
	//alert(response);
	}
}

//добавить рецепт в избранное
function add_recipe_to_izb(id)
{
	document.getElementById("loading").style.display="block";
	http1 = createObject();
	nocache = Math.random();
	http1.open('get', hname + "library/_ajax_private.php?add_recipe_to_izb="+id+"&nocache" + nocache,true);
	http1.onreadystatechange = GetRetAddRecipeToIzb;
	http1.send(null);

}

function GetRetAddRecipeToIzb()
{
	if(http1.readyState == 4)
	{
		if (http1.status == 200) 
		{
            // обработка ответа
        } else 
        {
        	document.getElementById("loading").style.display="none";
            alert("Не удалось получить данные:\n" +
                http1.statusText);
			
				return
        }
	
	var response = http1.responseText;
	document.getElementById("loading").style.display="none";
	//alert(response);
	if(response=="0")
	{
		showinfopopup("my_popup","Рецепт добавлен в избранное.","recipe_podmenu");
	}
	else
	{
		alert(response);
	}
	}
}

//поиск рецепта в личном кабинете
function do_seacrh_private_recipe(f,q)
{
	document.location.href=hname+"index.php?private_office="+q+"&field="+f.sel_search.value+"&search_private_recipe="+f.search_recipe.value;
}

function do_order_private_recipe(v,q)
{
	document.location.href=hname+"index.php?private_office="+q+"&order="+v
}

//переключаем  чекбоксы в поиске
function change_chk_search(id)
{
	if(id==0)
	{
		if(document.getElementById("chk_0").checked)
		{
			for(i=1; i<=11; i++)
			{
				document.getElementById("chk_"+i).disabled=true;
			}
		}
		else
		{
			for(i=1; i<=11; i++)
			{
				document.getElementById("chk_"+i).disabled=false;
			}			
		}
	}
	else
	{
		
	}
}

//расширенный поиск
function check_frm_esearch(f)
{
	
}
