
function show_by_char(id)
{
	if(id==0)
	{
		document.location.href=hname;
	}
	else
	{
		document.location.href=hname+"author/"+id+"/";
	}
}

//проверка email
function check_email(pemail)
{
	var s=new String(pemail);
	if(pemail=="")
	{
		return 1;
	}
	if(s.indexOf(",")>=0 || s.indexOf(" ")>=0)
	{
		return 1;
	}
	if(s.indexOf("#")>=0 || s.indexOf("'")>=0)
	{
		return 1;
	}
	if(s.indexOf(":")>=0 || s.indexOf(";")>=0)
	{
		return 1;
	}
	if(s.indexOf("@")>=0 && s.indexOf(".")>=0)
	{
		return 0;
	}

	//var re_email = /^\w[\w.-]*@([0-9a-z][0-9a-z-]{1,64}\.){1,7}[a-z]{2,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 update_kcaptcha(id,v)
{
   var tid="";
   if(id!=0)
   {
   	tid=id;
   }
   if(document.getElementById("msg_loader")!=null)
   {document.getElementById("msg_loader").style.display="block";}
   if(document.getElementById("img_kcaptcha" + tid)!=null)
   {document.getElementById("img_kcaptcha" + tid).src=v + "&nocache=" + Math.random();}
   if(document.getElementById("msg_loader")!=null)
   {document.getElementById("msg_loader").style.display="none";}
}


function check_frm_send(f)
{

	if(f.name.value=="")
	{
		alert("Введите Ваше имя!");
		return false;
	}

	if(f.code.value=="")
	{
		alert("Введите защитный код!");
		return false;
	}

 	if(check_email(f.email.value)==1)
	{
		alert("Введите корректный E-mail!");
		return false;
	}
	
	if(f.komm.value=="")
	{
		alert("Введите Ваше сообщение!");
		return false;
	}

	f.submit();
}

function check_input_book_name()
{
	var o=document.getElementById("book_name")
	if(o.value=="Не учитывать")
	{
		o.value="";
	}
}

function check_output_book_name()
{
	var o=document.getElementById("book_name")
	if(o.value=="")
	{
		o.value="Не учитывать";
	}	
}

function check_input_author_name()
{
	var o=document.getElementById("author_name")
	if(o.value=="Не учитывать")
	{
		o.value="";
	}
}

function check_output_author_name()
{
	var o=document.getElementById("author_name")
	if(o.value=="")
	{
		o.value="Не учитывать";
	}	
}

function check_frm_search(f)
{
	if((f.author_name.value=="" && f.book_name.value=="") || (f.author_name.value=="Не учитывать" && f.book_name.value=="Не учитывать")) 
	{
		alert("Введите имя автора или название книги!");
		return false;
	}
	if(f.author_name.value=="Не учитывать")
	{
		f.author_name.value="";
	}
	if(f.book_name.value=="Не учитывать")
	{
		f.book_name.value="";
	}
	
	document.location.href=hname+"index.php?search&author_name="+encodeURI(f.author_name.value)+"&book_name="+encodeURI(f.book_name.value);
}
