var JadeWizzard = {
	controlNext: '',
	controlPrevius: '',
	currentStep: 1,
	steps:[],
	x: 0,
	y: 0,
	SetPosition: function(x, y){
		this.x=x+'px';
		this.y=y+'px';
	},
	CreateStep: function(step){
		var section=Jade.DOM.Add(gpBody,'div');
		section.style.position='absolute';
		section.add=function(name,x,y,width,height,type,text){
			var control = {};
			var control_type=true;
			switch(type){
				case 'text': case 'label':
					control = new Jade.Objects.Text(text);
					break;
				case 'textbox':
					control = new Jade.Objects.TextBox();
					break;
				case 'password':
					control = new Jade.Objects.TextBox('password')
					break;
				case 'combobox': case 'combo':
					control = new Jade.Objects.ComboBox();
					break;
				case 'group': case 'container':
					control = new Jade.Objects.Container();
					break;
				case 'checkbox':
					control = new Jade.Objects.CheckBox(text);
					break;
				case 'message':
					control = new Jade.Objects.Container();
					control.text = new Jade.Objects.Text(text);
					control.text.Location(10,10,width-20,height-20);
					control.text.Add(control);
					control.set_style=function(style){ this.SetStyle(style);	}
					control.set_text=function(texto){ this.text.SetText(texto) }

					break;
			}
			control.visible = true;
			control.show=function(){
				Jade.FX.Show(this); 
			}
			control.hide=function(){
				Jade.FX.Hide(this); 
			}
			switch(name){
				case 'validator':
					control = new Jade.Objects.Validator();
					control._parent=this;
					control_type=false;
					control.add=function(controls,stament,labels){
						var fControls=[];
						if(typeof(controls)==typeof([])) {
							for(var i in controls){
								fControls.push(this._parent[controls[i]]);
							}
						}
						else { fControls=this._parent[controls]; }
						this.Add(fControls,stament,labels);
					}
					control.validate=function(){ return this.Validate(); };
					break;
			}
			if(control_type){
				control.Location(x,y,width,height);
				control.Add(this);
			}
			this[name] = control;
		}
		this.steps[step]=section;
		return section;
	},
	ChangeStep: function(step){
		for(var i in this.steps){
			Jade.FX.Hide(this.steps[i]);
		}
		if(typeof(this.beforeChangeStep)!="undefined") { this.beforeChangeStep(); }
		if(typeof(this.onChangeStep)!="undefined") { this.onChangeStep(); }
		if(typeof(this.steps[step])!="undefined"){
			this.steps[step].style.left=this.x;
			this.steps[step].style.top=this.y;
			Jade.FX.Show(this.steps[step]);
			if(typeof(this.steps[step].inicial)!="undefined"){ this.steps[step].inicial(); };
		}
	},
	MovePrevius: function(){
		Jade.Wizzard.currentStep--;
		Jade.Wizzard.ChangeStep(Jade.Wizzard.currentStep);
	},
	MoveNext: function(){
		Jade.Wizzard.currentStep++;
		//$.fire(Jade.Wizzard, Jade.Wizzard.ChangeStep, Jade.Wizzard.currentStep);
		Jade.Wizzard.ChangeStep(Jade.Wizzard.currentStep);
	},
	Start:function(){
		Jade.Wizzard.currentStep=1;
		Jade.Wizzard.ChangeStep(Jade.Wizzard.currentStep);
	}
}
Jade.LoadLibrary('Wizzard', JadeWizzard);