package modules.login 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import genericos.*;
	import flash.net.*;
		//Matuto
	import classes.fl.motion.easing.*;
	import classes.greensock.*;
	import classes.matuto.core.*;
	import classes.matuto.core.module.*;
	import classes.matuto.events.*;
	import classes.matuto.interfaces.*;
	import classes.matuto.model.*;
	import classes.matuto.mtween.textinho.*;
	import classes.matuto.ui.*;
	import classes.matuto.utils.display.*;
	import classes.matuto.utils.model.*;	
	

	public class RecuperarSenha extends Sprite 
	{
		
		private var form		:Form;
		
		public var login:MovieClip;
		
		public function RecuperarSenha() 
		{
			
			
			
		}
		
		public function INICIALIZE()
		{
			
			alpha = 0;
			_resp._voltar.addEventListener(MouseEvent.CLICK, onClickVoltar);
			_form._voltar.addEventListener(MouseEvent.CLICK, onClickVoltar);
			_form._enviar.addEventListener(MouseEvent.CLICK, onClick);

			form = new Form("contato","Enviado com sucesso","enviando mensagem");	
			form.addField("email",_form._email,"contato@email.com",Form.MAIL);
			form.addEventListener(FormEvent.STATUS, status);
			
			_resp._voltar._texto.text = "VOLTAR PARA ÁREA DE LOGIN";
			_form._voltar._texto.text = "VOLTAR PARA ÁREA DE LOGIN";
			_form._enviar._texto.text = "RECUPERAÇÃO DE SENHA";
			
		}
		
		private function onClick(e:MouseEvent):void 
		{
			
			if(!form.validation())
				return;
				
			if (form.validation())
			{
				_form._report.text 		= "Enviando...";
				
				
				var urlvars		:URLVariables = new URLVariables;
				urlvars.email = _form._email.text;
				Model.PHP_CONNECT(APP.MODEL_RECUPERAR,urlvars, onComplete, function(e:Object) { } );
				
				
			}
			
		}
		
		public function onComplete(e:Event)
		{
			trace(e.currentTarget.data.email);
			TweenMax.to(_form, 1, { autoAlpha:0, ease:Exponential.easeInOut, onComplete:function() {
			
				_resp.visible = true;
				_resp.alpha = 0;
							TweenMax.to(_resp,1,{autoAlpha:1,ease:Exponential.easeInOut});

				
			}});
			
		}
		
		private function status(e:FormEvent):void
		{
			var resp:String 	= e.params.message;
			_form._report.text 		= resp;
		}
		
		private function onClickVoltar(e:MouseEvent):void 
		{
			TweenMax.to(this, .7, { autoAlpha:0, ease:Exponential.easeInOut, onComplete:function() {
			
				_form.alpha = 1;
				_resp.alpha = 0;
				_form.visible = true;
				_resp.visible = true;
				_form._report.text = "";
				_form._email.text = "contato@email.com";
				
			}});
			
			
			TweenMax.to(login,1,{autoAlpha:1,ease:Exponential.easeInOut,delay:.7});
		}
		
	
		
		public function init()
		{
			visible = true;
			TweenMax.to(this,1,{autoAlpha:1,delay:.7,ease:Exponential.easeInOut});
		}
		
		
	}//END CLASS

}