/**********************************************************************************************************************
	LOGIN Functions
**********************************************************************************************************************/
var login_form_name = "formLoginTop";
function DoLogin()
{
	objUserCommonAction.onDoLoginError = handleError;
	objUserCommonAction.DoLogin(xoad.html.exportForm(login_form_name),pg,
	function(result)
		{
			if(pg == 'index.php')
			{
				destravarTela();
			}
		}
	);
	
}

function DoLogoff()
{
	objUserCommonAction.onDoLogoffError = handleError;
	objUserCommonAction.DoLogoff(pg,function(result){});
}


function SetLoginFormName(f_name)
{
	login_form_name = f_name;
}

function ForgotPassword()
{
	AbrirPopUp("forgotPassword.php",'Senha','width=320,height=130');
}

function SendMailWhenForgotPass()
{
	objUserCommonAction.onSendMailWhenForgotPassError = handleError;
	objUserCommonAction.SendMailWhenForgotPass(GetFieldValue('loginForgot'),
		function(result)
		{
			alert( newPassCreated );
			window.close();
		});
}

function ChangePassword()
{
	AbrirPopUp("changePassword.php",'TrocarSenha','width=330,height=115');
}


function ChangePassAction()
{
	objUserCommonAction.onChangePasswordError = handleError;
	objUserCommonAction.ChangePassword(xoad.html.exportForm('formChangePassword'),
		function(result)
		{
			if(!result)
				alert( passChanged );
			else if ( result == 1)
				alert( loginRequired );
			else if ( result == 2)
				alert( newPassLength );
			else if ( result == 3)
				alert( wrongPassConf );
			
			window.close();
		});
}

function MyProfile()
{
	AbrirPopUp("myProfile.php",'TrocarSenha','width=660,height=430');
}


function saveProfile()
{
	objUserCommonAction.onSaveProfileError = handleError;
	objUserCommonAction.SaveProfile(xoad.html.exportForm('formProfile'),
		function(result)
		{
			if(result)
				alert( profileChanged );
			else
				alert( loginRequired );
			window.close();
		});
}