	function vis_hide(x)
	{
	  document.getElementById(x).style.visibility='hidden';
	  document.getElementById(x).style.height='0px';
	}

	function vis_show(x)
	{
	  document.getElementById(x).style.visibility='visible';
	  document.getElementById(x).style.height='100%';
	}

	function vis(x)
	{
	 if (document.getElementById(x).style.visibility=='hidden')
	 {
	  vis_show(x);
	 } else
	 {
	  vis_hide(x);
	 }
	}

	function strrep(search, replace, subject)
	{
	 return subject.split(search).join(replace);
	}

	function strpos( haystack, needle, offset)
	{
	    var i = haystack.indexOf( needle, offset ); // returns -1
	    return i >= 0 ? i : false;
	}

	function vis_url(x,url)
	{
	 var url_main=document.location.href;
	 var uhost=document.location.hostname;

	 url_main=strrep('http://', '', url_main);
	 url_main=strrep('https://', '', url_main);
	 url_main=strrep(uhost, '', url_main);

	 if (url_main!='/')
	 {
	  url=' '+url;
	  if (strpos(url.toLowerCase(),url_main.toLowerCase(),1)) {vis_show(x);};
	 };
	}

	function vis_urlb(x,url)
	{
	 var url_main=document.location.href;
	 var uhost=document.location.hostname;

	 url_main=strrep('http://', '', url_main);
	 url_main=strrep(uhost, '', url_main);
	 url_main=' '+url_main;
	 if (url_main!='/')
	 {
	  if (strpos(url_main.toLowerCase(),url.toLowerCase(),1)) {vis_show(x);};
	 }
	}

	function valid_mail(x,txt)
	{
	 var reg =/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	 var st = x.value;
	 if (st.match(reg)) {
	  document.getElementById(txt).innerHTML = "<font color=green>правильно</font>";
	 } else {
	  document.getElementById(txt).innerHTML = "<font color=red>ошибка</font>";
	 }
	 return true;
	}

	function valid_tel(x,txt)
	{
	 var reg =/^8\d{10}$/;
	 var st = x.value;
	 if (st.match(reg)) {
	  document.getElementById(txt).innerHTML = "<font color=green>правильно</font>";
	 } else {
	  document.getElementById(txt).innerHTML = "<font color=red>ошибка</font>";
	 }
	 return true;
	}

	function valid_login(x,txt)
	{
	 var reg =/^[0-9_a-z_A-Z]*$/;
	 var st = x.value;
	 if (st.match(reg)) {
	  if (st.length>4)
	  {
 	   document.getElementById(txt).innerHTML = "<font color=green>правильно</font>";
	  } else {
	   document.getElementById(txt).innerHTML = "<font color=red>ошибка</font>";
	  }
	 } else {
	  document.getElementById(txt).innerHTML = "<font color=red>ошибка</font>";
	 }
	 return true;
	}

	function valid_pass(x,txt)
	{
	 var reg =/^[0-9_a-z_A-Z]*$/;
	 var st = x.value;	 
	 if (st.match(reg)) {
	  if (st.length>=6)
	  {
 	   document.getElementById(txt).innerHTML = "<font color=green>правильно</font>";
	  } else {
	   document.getElementById(txt).innerHTML = "<font color=red>ошибка</font>";
	  }
	 } else {
	   document.getElementById(txt).innerHTML = "<font color=red>ошибка</font>";
	 }
	 return true;
	}

