
function shDIV(vID) {

	var comm = document.getElementById(vID)
	var bt = document.getElementById('bt'+vID)
	var reg_chr = /plus/;

	if (reg_chr.test(bt.src)) { 
		bt.src = 'img/minus1.gif';
		comm.style.visibility = 'visible';	
		comm.style.display = 'block';	
	}
	else {
		bt.src = 'img/plus1.gif';
		comm.style.visibility = 'hidden';
		comm.style.display = 'none';	
	}
}

function showDIV(vID,e) {

	var comm = document.getElementById(vID)
	var bt = document.getElementById('bt'+vID)

	//idNav = navigator.appName.substring(0,1);
//	var X = 650;
//	var Y = 50+document.body.scrollTop;
	/* if (idNav == "M") {
		X = e.clientX + 10;
		Y = comm.offsetTop + 20;
	}
	else {
		X = e.pageX + 10 + "px";
		Y = e.pageY + 10 + "px";	
	} */
//	comm.style.left = X ;
//	comm.style.top = Y;

//alert(bt.name);
//alert(bt.arribute.src);
	bt.src = 'img/minus1.gif';
	comm.style.visibility = 'visible';	
	comm.style.display = 'block';	

	
}

function hideDIV(vID) {
	var comm = document.getElementById(vID)
	comm.style.visibility = 'hidden';
	comm.style.display = 'none';		
//	comm.style.top = parseInt(comm.style.top) - 20;
}

function ltrim(source){
     var index = 0;
     while( source.charAt(index) == " " ) index++;
     return source.substr(index);
 }

 function rtrim(source){
     var index = source.length - 1;
     while(source.charAt(index) == " ") index--;
     return source.substring(0, index + 1);
 }

 function trim(source){
     return ltrim(rtrim(source));
 }
 
function isnum(source){
	var reg_chr = /^([0-9]+)$/;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 } 
 
 function islat(source){
	var reg_chr = /^([a-z]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
 function iscir(source){
	var reg_chr = /^([а-яё]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
  function isfullname(source){
	var reg_chr = /^([а-яё\. ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
  function ispos(source){
	var reg_chr = /^([0-9а-яё\.,\-\/\"\'\(\) ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }

  function isrutxt(source){
	var reg_chr = /^([0-9а-яё№\.,:;\/\-\(\)\"\' ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 } 
 
   function isquest(source){
	var reg_chr = /^([0-9а-яё№\?\.,;\/\-\(\)\" ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 } 
 
  function isanswer(source){
	var reg_chr = /^([0-9а-яё\- ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
 
  function islog(source){
	var reg_chr = /^([_0-9a-zа-яё]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
function ispw(source){
	var reg_chr = /^([0-9a-z]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
function isauthor(source){
	var reg_chr = /^([a-zа-яё()\-\., ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }
 
function isbook(source){
	var reg_chr = /^([0-9a-zа-яё№!\:\-\(\)\"\'\., ]+)$/i;
	if (source == "" || source==null || !reg_chr.test(source)) { 
		return false;
	}
	return true;
 }

 
function is_mail(src) {
//	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
//	var regex = new RegExp(emailReg);
//	return regex.test(src);
	var emailReg = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	var regex = new RegExp(emailReg);
	return regex.test(src);
}

 function is_phone(source){
	var regex = /^([\(\)\- 0-9]+)$/;
	return regex.test(source);
 }  
  
  
function change_pass(form) {
	
	var tmp1 = trim(form.pw1.value);
	if (tmp1.length < 6 || tmp1.length > 20) {
		alert("Неверная длина пароля");
		return;
	}	
	if (!ispw(tmp1)) {
		alert("Используйте допустимые символы!");
		return;
	}		

	var tmp2 = trim(form.pw2.value);	
	if (tmp1 != tmp2) {
		alert("Пароли не одинаковы.");		
		return;
	} 
 
 	document.getElementById("form4").submit ();	 
 }

function check_send(form,n) {
//alert(n);
form.num.value = n;
 document.getElementById("form1").submit ();
     
}
 
 $(function() {
 
 
	$("#weather").load("vs/weather.php");
//	$("#calend").load("vs/calend.php");

	
	$(".linkBr").click(function() {
		var name = $(this).attr("id");
		$("#brake_" + name).toggle('slow');
		if ($(this).html()=='все') $(this).html('свернуть');
		else $(this).html('все');
		return false;
	});	
	
	
	$("a[href='#top']").live("click",function() {
		$('body').animate( { scrollTop:0 }, 1100 );
		return false;
	});		
	
	
 }); 
 
