var RegisterPage = Class.create(PageController,{
	initialize:							function($super) {
		$super();
		this.cb=$('cb');
		this.maddr=$('mailAddr').getElementsBySelector('input, select');
		this.saddr=$('shipAddr').getElementsBySelector('input, select');
		this.success=false;
		this.redirect="";
	},

	disableShip:function(disable,update) {
		var i=0,l=this.maddr.length;
		for (i=0;i<l;++i) {
			if (update) {this.saddr[i].value = this.maddr[i].value;}
			this.saddr[i].disabled = disable;
		}
	},
	
	postResponse:function() {
		if(this.success) {top.location=this.redirect;}
		return true;
	},
	
	formSubmit:function(isValid,theForm) {
		if (isValid) {
			this.disableShip(false,true);
			
			var createReq=function(xhr,json) {
				Register.info("<h4><br/><br/>Submitting Registration</h4>",{
					width:400,height:150,
					title:"<small>Processing Form</small>"
				});
			};
			
			var reqSuccess=function(xhr,json) {
				this.success=json.success;
				this.redirect=json.redirect;
				this.dialogInfoToAlert("cambria","dialogButton","Register.postResponse()",xhr.responseText);
			};
			
			theForm.request({
				asynchronous:true,
				onCreate:createReq,
				onSuccess:reqSuccess.bind(this)
			});
		}
		else {
			this.alert(
				"<h4><br />Please complete the registration form by filling out all the required fields.</h4>",
				{
					title:"<small>Form Error</small>",
					okLabel: "Close",
					width:400,height:150
				}
			);
		}
	}
});