function check_form()
{
	if(!check_form_basic()){return false;}
	if(!checkEmailFormat($F('mail'))){return false;}
	return true;
}
function check_login()
{
	var param = "login=" + $F('login');
	new Ajax.Request(url_root + "/user/checklogin/", {
		  method: 'post',
		  parameters : param,
		  onComplete: afterCheckLogin
		});
}
function afterCheckLogin(resultat)
{
	var res = eval('('+resultat.responseText+')');
	if(res[0] == "KO")
	{
		alert(res[1]);
		setError($('login'));
		$("img_login").src = url_root + "/images/2.gif";
	}
	else
	{
		clearError($('login'));
		$("img_login").src = url_root + "/images/1.gif"; 
	}
}
function check_mail()
{
	var param = "mail=" + $F('mail');
	new Ajax.Request(url_root + "/user/checkmail/", {
		  method: 'post',
		  parameters : param,
		  onComplete: afterCheckMail
		});
}
function afterCheckMail(resultat)
{
	var res = eval('('+resultat.responseText+')');
	if(res[0] == "KO")
	{
		alert(res[1]);
		setError($('mail'));
		$("img_mail").src = url_root + "/images/2.gif";
	}
	else
	{
		clearError($('mail'));
		$("img_mail").src = url_root + "/images/1.gif"; 
	}
}

function forgotpass()
{
	var html = $("div_forgotpass").innerHTML;
	$("div_forgotpass").innerHTML = "<img src='"+url_root+"/images/ajax-loader.gif' alt='Charger encour...' />";
	
	Dialog.confirm({url: url_root + "/user/getpass/", options: {method: 'get'}},
	{top: 50, width:800, className: "alphacube", okLabel: "Valider", cancelLabel:"Retour", 
		draggable:true,maximizable:true,minimizable:true,recenterAuto:false,destroyOnClose:true,closable:true,
		onOk: function(win){
				$("GetPass").getInputs('text').each(function(element){$(element).observe('keydown', function(event){ clearError($(element)); });});
				$("GetPass").select('select').each(function(element){$(element).observe('change', function(event){ clearError($(element)); });});
				
				if(check_form_basic()==true)
				{
					$("div_forgotpass").innerHTML = html;
					$("GetPass").request({
				  		onComplete: afterValid
					});
				}
			},
		onCancel:function(win){$("div_forgotpass").innerHTML = html;}});
}
