newsi.BudgetCalculator={};
newsi.BudgetCalculator.UI=function(){
if(!this.dom){return;};//NN4
if(!this.true1_5){this.gebid("nonjs").setAttribute("class","show");return;};
this.dom=new newsi.HTML.DOM({scriptversion:"scriptversion"});
this.dom.setClass({el:this.gebid("scriptversion"),className:"show"});
this.dom.setClass({el:this.gebid("nonjs"),className:"none"});
this.headers={our:["Your lifestyle","Your flights","Your motoring","Your details"],
		my:["Your lifestyle","Your flights","Your motoring","Your details"]
		}
this.textField=[
"txtAge",
"txtHours",
"txtAnnlEmp",
"txtSpouseAnnlEmp",
"txtSelfAnnlEmp",
"txtDivIncm",
"txtSpouseDivIncm",
"txtSavInc",
"txtSpouseSavInc",
"txtRentIncm",
"txtSpouseRentIncm",
"txtNonStatePen",
"txtSpouseNonStatePen",
"txtCigs",
"txtBeer",
"txtWine",
"txtSpirits",
"txtFuel",
"txtFlghtShrtSt",
"txtFlightShortPr",
"txtFlghtLngSt",
"txtFlghtLngPr",
"txtCC1LP",
"txtCC1EM",
"txtCC2LP",
"txtCC2EM",
"txtSpCC1EM",
"txtSpCC2EM"
];
this.zone={
spouse:[
	["rdSpouseGenderM","rdSpouseGenderF","txtSpouseAge","txtSpouseHours"],
	["txtSpouseAnnlEmp"],
	["txtSpouseSelfAnnlEmp"],
	["txtSpouseDivIncm"],
	["txtSpouseSavInc"],
	["txtSpouseRentIncm"],
	["txtSpouseNonStatePen"]
	]
	};
this.init();
};
newsi.BudgetCalculator.UI.prototype=newsi.html;
newsi.BudgetCalculator.UI.prototype.init=function(){
trace("newsi.BudgetCalculator.UI init - ok");
this.st=new newsi.BudgetCalculator.Widget({content:"helpcontent1",linkId:"help1",ui:this});
this.st=new newsi.BudgetCalculator.Widget({content:"helpcontent2",linkId:"help2",ui:this});
this.listen();
this.spouseChange({state:"hide",head:"my"});
};
newsi.BudgetCalculator.UI.prototype.listen=function(){
var ev=new newsi.Event();
ev.addListener("onmouseup","IncludeSpouse",this,"spouseShow",false);
var x=0;
while(x<this.textField.length){
	var ev=new newsi.Event();
	ev.addListener("onkeyup",this.textField[x],this,"validate",false,this.gebid(this.textField[x]),x);
	x++;
	}
};
newsi.BudgetCalculator.UI.prototype.spouseShow=function(){
if(this.gebid("spouse1").getAttribute("class")=="show"){this.spouseChange({state:"hide",head:"my"});return;};
this.spouseChange({state:"show",head:"our"});return;
};
newsi.BudgetCalculator.UI.prototype.spouseChange=function(o){
var i=0;
while(this.gebid("spouse"+i)){
	this.changeState({el:this.gebid("spouse"+i),state:o.state});
	i++;
	}
var i=0;	
while(this.gebid("head"+i)){
	this.dom.iH({el:this.gebid("head"+i),text:this.headers[o.head][i]});
	i++;
	}	
}
newsi.BudgetCalculator.UI.prototype.validate=function(){
var val=this.gebid(this.textField[arguments[0][1]]).value;
this.gebid(this.textField[arguments[0][1]]).value=val.replace(/\D+/g,"");
};
newsi.BudgetCalculator.UI.prototype.changeState=function(o){
	this.dom.setClass({el:o.el,className:o.state});
	};

newsi.BudgetCalculator.UI.prototype.disable=function(o){o.el.disabled=true;};
newsi.BudgetCalculator.UI.prototype.enable=function(o){o.el.disabled=false;};
newsi.BudgetCalculator.Widget=function(o){
this.ui=o.ui;
this.arr=[];
this.content=o.content;
this.linkId=o.linkId;
var ev=new newsi.Event();
ev.addListener("onclick",this.linkId,this,"_toggle",false);
this.ui.changeState({el:this.gebid(this.content),state:"hide"});
this.ui.changeState({el:this.gebid(this.linkId),state:"showbut"});
};
newsi.BudgetCalculator.Widget.prototype=newsi.html;
newsi.BudgetCalculator.Widget.prototype._toggle=function(){
if(this.ui.dom.getClass({el:this.gebid(this.content)})=="show"){
this.ui.changeState({el:this.gebid(this.content),state:"hide"});
this.ui.changeState({el:this.gebid(this.linkId),state:"showbut"});
//this.ui.hide({lnk:this.gebid(this.linkId),el:this.gebid(this.content)});
return;}
this.ui.changeState({el:this.gebid(this.content),state:"show"});
this.ui.changeState({el:this.gebid(this.linkId),state:"hidebut"});
};
