package classes.matuto.core
{
	import classes.fl.motion.easing.Exponential;
	import classes.greensock.TweenMax;
	import classes.matuto.core.module.Module;
	import classes.matuto.interfaces.IDisplay;
	import classes.matuto.mtween.TextLetter;
	import classes.matuto.utils.display.DisplayObjectUtils;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.DropShadowFilter;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	public class MatutoBase extends MovieClip
	{
		
		private var logo		:Logo;
		private var menuM		:MenuMT;
		private var rodaPe		:RodaPe;
	
		public function MatutoBase()
		{
			super();
			
			logo 	= new Logo();
			menuM	= new MenuMT();
			rodaPe	= new RodaPe();
			
			Matuto.addReference(logo,"home");
			
			addChild(logo);
			addChild(menuM);
			addChild(rodaPe);

			Matuto.getStage.addEventListener(Event.RESIZE,resize);
			resize(null);	
		}
		
		public static function addModuleCad(value:String,module:Module):void
		{
			var texto		:TextField;
			var formato		:TextFormat;
			var fonte		:Font;
			
			fonte					= new MatutoFont();
			
			formato 				= new TextFormat();
			formato.align   		= TextFieldAutoSize.LEFT;
			formato.size 			= 25;
			formato.font    		= fonte.fontName;
			formato.color  		    = 0x333333;
			formato.letterSpacing   = 2;
			
			texto 						= new TextField();
			texto.width 				= 1600;
			texto.defaultTextFormat     = formato;
			texto.selectable       	    = false;
			
			texto.filters  				= [new DropShadowFilter(2,45,0x33FFFF,1,0,0)];
			
			TextLetter.sort(texto,value,.5,1);
			
			texto.x 				= -400;
			texto.y 				= -20;

			var shape:Sprite 		= DisplayObjectUtils.getRecShape(0xFFFFFF,350,60,0,0);
			shape.alpha 	 		= 0;
			
			module.addChild(texto);
			module.addChild(shape);
		}
		
		public function resize(e:Event):void
		{
			logo.x   = 20;
			logo.y   = 20;
			menuM.y   = int(Matuto.getStage.stageHeight-65);
			rodaPe.y  = int(Matuto.getStage.stageHeight-40);
			rodaPe.x   = int(Matuto.getStage.stageWidth-160);
		}
		
		public function dispose():void
		{
			
		}
		
	
	}//end class

}

import classes.fl.transitions.easing.Strong;
import classes.greensock.TweenMax;
import classes.matuto.core.Button;
import classes.matuto.core.ButtonNav;
import classes.matuto.core.Matuto;
import classes.matuto.core.module.ModuleInfo;
import classes.matuto.model.Model;
import classes.matuto.mtween.TextLetter;
import classes.matuto.utils.display.DisplayObjectUtils;

import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
import flash.text.AntiAliasType;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

class Logo extends ButtonNav
{
	private var texto		:TextField;
	private var formato		:TextFormat;
	private var fonte		:Font;
	
	public function Logo()
	{
		super();
	
		fonte					= new MatutoFont();
		
		formato 				= new TextFormat();
		formato.align   		= TextFieldAutoSize.LEFT;
		formato.size 			= 50;
		formato.font    		= fonte.fontName;
		formato.color  		    = 0x000000;

		texto 					= new TextField();
		texto.width 			= 1600;
		texto.defaultTextFormat = formato;
		texto.selectable        = false;
				
		filters  				= [new DropShadowFilter(2,45,0x33FFFF,1,0,0)];
		
		TextLetter.sort(texto,"MatutoV4",.5,1);

		var shape:Sprite 		= DisplayObjectUtils.getRecShape(0x327575,350,60,0,0);
		shape.alpha 	 		= 0;
		
		addChild(texto);
		addChild(shape);
	}
	
	public override function over() :void
	{
		TweenMax.to(this,.3,{autoAlpha:.9	,ease:Strong.easeInOut});
	}
	
	public override function out() :void
	{
		
		if (enabled) 
		{	
			TweenMax.to(this,.3,{autoAlpha:1	,ease:Strong.easeInOut});
		}
		
	}
	
	
	override public function set enabled(value:Boolean):void 
	{			
		super.enabled = value;
		
		if (value)out();
		else over();
	}
	
	
}//end class




class MenuMT extends MovieClip
{
	
	private var bg1		:Sprite;
	private var bg2		:Sprite;
	private var botoes	:Array;
	
	
	public function MenuMT()
	{
		bg1 = DisplayObjectUtils.getRecShape(0xFFFFFF,2000,60,0,0);
		bg2 = DisplayObjectUtils.getRecShape(0x000000,2000,60,0,0);
		
		addChild(bg2);
		addChild(bg1);
		
		bg1.y  = 1;	
		botoes = [];
		
		var botao:BotaoMenu;
		var aux:int = 0;
		
		Model.XML_CONNECT("visao/xml/SiteMaps.xml",function(xml:XML):void
		{
		
			for each(var item:XML in xml.modules.module)
			{			
				
				botao   = new BotaoMenu(item.attribute('id'),item.attribute('id'));
				botao.x = (aux * 90)+30; 	
				botao.y = int(23);
				aux++;
				addChild(botao);
				
				if(item.attribute('id')=="home")
				botao.enabled = false;
			}
		
		});
	}
	
}//end class


class BotaoMenu extends ButtonNav
{
	
	private var texto		:TextField;
	private var formato		:TextFormat;
	private var fonte		:Font;
	
	public function BotaoMenu(name:String,module:String)
	{
		fonte					= new MatutoFont();
		
		formato 				= new TextFormat();
		formato.align   		= TextFieldAutoSize.LEFT;
		formato.size 			= 12;
		formato.font    		= fonte.fontName;
		formato.color  		    = 0x000000;
		
		texto 					= new TextField();
		texto.defaultTextFormat = formato;
		texto.selectable        = false;
		texto.antiAliasType 	= AntiAliasType.ADVANCED;
		texto.height			= 20;
		texto.text  			= name.toLocaleUpperCase()+"  ";
						
		var shape:Sprite 		= DisplayObjectUtils.getRecShape(0xFFFFFF,60,20,0,0);
		shape.alpha 	 		= 0;
		
		Matuto.addReference(this,module);
		
		addChild(texto);
		addChild(shape);	
	}
	
	public override function over() :void
	{
		TweenMax.to(this,.3,{autoAlpha:.4,ease:Strong.easeInOut});
		
	}
	
	public override function out() :void
	{
		if (enabled) 
		{	
			TweenMax.to(this,.3,{autoAlpha:1,ease:Strong.easeInOut});
		}
	}
	
	
	override public function set enabled(value:Boolean):void 
	{			
		super.enabled = value;
		
		if (value)out();
		else over();
	}




}//end class



class RodaPe extends Button
{
	
	private var texto		:TextField;
	private var formato		:TextFormat;
	private var fonte		:Font;
	
	public function RodaPe()
	{
		fonte					= new MatutoFont();
		
		formato 				= new TextFormat();
		formato.align   		= TextFieldAutoSize.LEFT;
		formato.size 			= 12;
		formato.font    		= fonte.fontName;
		formato.color  		    = 0x000000;
		formato.letterSpacing 	= 2; 
		formato.underline		= true;

		texto 					= new TextField();
		texto.defaultTextFormat = formato;
		texto.selectable        = false;
		texto.antiAliasType 	= AntiAliasType.ADVANCED;
		texto.height			= 20;
		texto.width				= 150;
		texto.text  			= "@GUSTAVOCOSME";
		//texto.background 		= true;
		//texto.backgroundColor   = 0x33FFFF;
		
		var shape:Sprite 		= DisplayObjectUtils.getRecShape(0xFFFFFF,60,20,0,0);
		shape.alpha 	 		= 0;
		
		
		addChild(texto);
		addChild(shape);	
	}
	
	public override function over() :void
	{
		TweenMax.to(this,.3,{autoAlpha:.4	,ease:Strong.easeInOut});
		
	}
	
	public override function out() :void
	{
		
		if (enabled) 
		{	
			TweenMax.to(this,.3,{autoAlpha:1	,ease:Strong.easeInOut});
		}
		
	}
	
	
	override public function set enabled(value:Boolean):void 
	{			
		super.enabled = value;
		
		if (value)out();
		else over();
	}
	
	
	
	
}//end class



