function send(elem, len) {
	    if ($(elem).val().length < len) {	    	    
		$(elem).next("em").css({display: "inline", opacity: "0.01"}).animate({opacity: "1"}, "slow");
		return false;}
		else {
	    $(elem).next("em").animate({opacity: "hide"}, "slow");
	    return true;}
	}
function checklogin(elem,path) {
        if ($(elem).val().length < "5") {		    	    
		$(elem).next("em").css({display: "inline", opacity: "0.01"})
		.html("Введите логин, минимум 5 символов")
		.animate({opacity: "1"}, "slow");
		return false;}
		else {
	    $.post(path + "script/ajaxlogin.php",{"login" : $(elem).val()},function(data){
		    if(data > 0) {	
	        $(elem).next("em").css({display: "inline", opacity: "0.01"})
	        .html("Такой логин уже используется")
		    .animate({opacity: "1"}, "slow");
	        return false;}   
	        else {	
	        $(elem).next("em").animate({opacity: "hide"}, "slow");}
		}); 
		return true;}  
    }		
function checkmail(elem,path) {
        if ($(elem).val().indexOf("@",0) == -1) {	    	    
		$(elem).next("em").css({display: "inline", opacity: "0.01"}).animate({opacity: "1"}, "slow");
		return false;}
		else if ($(elem).val().indexOf(".",0) == -1) {	    	    
		$(elem).next("em").css({display: "inline", opacity: "0.01"}).animate({opacity: "1"}, "slow");
		return false;}
		else {
	    $.post(path + "script/ajaxmail.php",{"email" : $(elem).val()},function(data){
		    if(data > 0) {	
	        $(elem).next("em").css({display: "inline", opacity: "0.01"})
	        .html("Такой почтовый адрес уже используется")
		    .animate({opacity: "1"}, "slow");
	        return false;}   
	        else {	
	        $(elem).next("em").animate({opacity: "hide"}, "slow");}
		});
	return true;} 	
    }
function checkpass(pass, passconf) {
	    if ($(pass).val() != $(passconf).val()) {	    	    
		$(passconf).next("em").css({display: "inline", opacity: "0.01"}).animate({opacity: "1"}, "slow");
		return false;}
		else {
	    $(passconf).next("em").animate({opacity: "hide"}, "slow");
	    return true;}
	}
function checkcode(code, codeval) {
	    if (md5($(code).val()) != codeval) {	    	    
		$(code).next().next("em").css({display: "inline", opacity: "0.01"}).animate({opacity: "1"}, "slow");
		return false;}
		else {
	    $(code).next().next("em").animate({opacity: "hide"}, "slow");
	    return true;}
	}			    
function validate(codeval,path) {
	    if(checklogin("#login",path)==true&&send("#password","5")==true&&checkpass("#password","#passconfirm")==true&&
		send("#name","5")==true&&send("#adress","10")==true&&send("#phone","7")==true&&
		checkmail("#mail",path)==true&&checkcode("#code",codeval)==true) {
		$("#form").submit();}	
	}
function sendform(codeval) {
		if(send("#name","5")==true&&checkmail("#mail")==true&&send("#text","10")==true&&checkcode("#code",codeval)==true) {
		$("#form").submit();}	
	}
