/**
 * @author chardcastle
 * @extends mootool01.js
 */

anyjunk = {};

anyjunk.form = {
	errorFields:{},
	errorCount:0,
	removeErrorText:function(form){
		var errorFields = document.getElementsBySelector('.required',form);
		var j = 0;
			while(j < errorFields.length){
				errorFields[j].removeClass("errortext");
				j++;
			}
	},
	clearData: function(obj){
		var startFrom = $(obj);
		anyjunk.form.removeErrorText(obj);
		var formFieldList = document.getElementsBySelector('input,select',startFrom); 
		var checkboxes = document.getElementsBySelector("input[type='radio'],input[type='checkbox']",startFrom);   
		// clear inputs and selections
		var i = 0;		
		while(i < formFieldList.length){				
			if(formFieldList[i].tagName == "SELECT"){
				$(formFieldList[i]).selectedIndex = 0;					
				i++;
			}else{
				$(formFieldList[i]).value = "";								
				i++;
			}
		}	
		var j = 0;
		while(j < checkboxes.length){			
			$(checkboxes[j]).checked=false;
			j++;
		}
		// clear all checkboxes
		var labels = $$("strong");
		x=0;		
		while(x < labels.length){
			if(labels[x].hasClass("fail")){				
				labels[x].removeClass("fail");
			}
			x++;
		}	
		// clear message panel
		$("errorMessages").innerHTML = "";	
    },
	isFieldOk: function(fieldId, errorText){	
	
		if(anyjunk.form.isEmpty(fieldId)){
			anyjunk.form.setToFail(fieldId, errorText);
			return false;		
		}else{
			anyjunk.form.setToPass(fieldId, errorText);
			return true;
		}
	},
	isEmpty: function(field){
		if($(field).value == ""){
			return true;
		}else{
			return false;
		}
	},
	isEmailReal: function(emailField, errorText){
		var emailregex = /^[\w-\.\+]+@([\w-]+\.)+[\w]{2,}$/;
		var emailValue = $(emailField).value;		
		if(!emailregex.exec(emailValue)){			
			anyjunk.form.setToFail(emailField, errorText);
			return false;
		}else{
			anyjunk.form.setToPass(emailField, errorText);
			return true;
		}
	},		
	isCheckBoxSectionOk: function(sectionName){
		var section = $(sectionName);		
		var fields = $$("."+sectionName);
		x = 0;
		isOk = false;
		checkedItems = 0;		
		while(x < fields.length){
			if(fields[x].checked){
				checkedItems++;									
			}
			x++;
		}	
		if(checkedItems > 0){
			isOk = true;
		}else{
			var ele = document.getElementsBySelector("."+sectionName+"_other");
			if(ele.length > 0){
				i = 0;			
				while(i < ele.length){						
						isOk = ($(ele[i]).value.length > 0)?true:false;
						if(!isOk){							
							$(ele[i]).addClass("errortext");
						}else{
							$(ele[i]).removeClass("errortext");
						}
						i++;
				}
			}
		}
		return isOk;	
	},
	isDefaultSelect: function(fieldId, errorText){
		/* for <select> elements */

		if($(fieldId).selectedIndex == 0){
			if (($(fieldId).options[$(fieldId).selectedIndex].text == "-please select-") || ($(fieldId).options[$(fieldId).selectedIndex].text == "Please Choose")) {				
				anyjunk.form.setToFail(fieldId, errorText);
				return false;
			}else{
				anyjunk.form.setToPass(fieldId, errorText);
				return true;
			}
		}else{
			anyjunk.form.setToPass(fieldId, errorText);
			return true;
		}		
	},
	openErrorMsgWindow: function(){

			var fx1 = new Fx.Styles($("errorOuter"), {duration:500, wait:false}); 
			$('errorOuter').style.width = window.getWidth()+"px";	
			$('errorOuter').style.height = window.getScrollHeight()+"px";			
			fx1.element.setOpacity(0);
			fx1.element.style.display = "";			
			fx1.start({'opacity': [0, 0.7]}).chain(function(){
				if(window.ie6){
					var fxOnePointFive = new Fx.Styles($("iframeOuter"), {duration:500, wait:false}); 
					fxOnePointFive.element.setOpacity(0.1);
					$('iframeOuter').style.width = window.getWidth()+"px";	
					$('iframeOuter').style.height = window.getScrollHeight()+"px";					
					$('iframeOuter').style.display = "";												
				}				
				var fx2 = new Fx.Styles($("errorWrapper"), {duration:500, wait:false}); 
				fx2.element.setOpacity(0);
				fx2.element.style.display = "";				
				fx2.start({'opacity': [0, 1]})
			});
	},
	closeErrorMsgWindow: function(){

			var fx3 = new Fx.Styles($("errorOuter"), {duration:500, wait:false}); 
			fx3.element.setOpacity(0.7);
			fx3.start({'opacity': [0.7, 0]}).chain(function(){
					if(window.ie6){
						$('iframeOuter').style.display = "none";
						$('iframeOuter').style.width = 0+"px";	
						$('iframeOuter').style.height = 0+"px";				
					}				
				fx3.element.style.display = "";	
				var fx4 = new Fx.Styles($("errorWrapper"), {duration:500, wait:false}); 							
				// executes immediately after completion of above effect		
				fx4.start({'opacity': [1, 0]})
				fx4.element.style.display = "";
			});			
	},	
	startErrorMsg:"<div style='width:96%;margin-top:20px;'><a onclick=\"anyjunk.form.closeErrorMsgWindow();\"><img style='float:right;cursor:pointer;display:block' src='/tpl/anyjunk/images/common/close.png' alt='Close this box'/></a></div><h3>Error!</h3></br><p style='color:#ff0000'>Please fill in the following sections:</br></br></p>",
	endErrorMsg:"<div id=\"errorContentBottom\"></div>",
	closeErrorWindow: function(){
		$("errorWrapper").style.display = "none";
	},
	generateErrorMessages: function(){			
		var message = anyjunk.form.startErrorMsg; 
		for(var error in anyjunk.form.errorFields){
			if(anyjunk.form.errorFields[error] == true){
				message += error+"<br/>";		
			}
		}		
		message += anyjunk.form.endErrorMsg;	
		return message;		
	},
	setToFail: function(element, errorContent){
		$(element).addClass("errortext");
		var message = anyjunk.form.tidyMessage($(element).name);			
		anyjunk.form.errorFields["<span>"+errorContent+" - "+message+"</span>"] = true;
		anyjunk.form.errorCount++;
	},
	setToPass: function(element, errorToBeRemoved){
		$(element).removeClass("errortext");	
		var message = anyjunk.form.tidyMessage($(element).name);	
		anyjunk.form.errorFields["<span>"+errorToBeRemoved+" - "+message+"</span>"] = false;
		anyjunk.form.errorCount--;
	},	
	tidyMessage: function(message){
		var value = message.replace(/_/, " ");
		return value;
	},
	passSection: function(title){
		$(title+"Title").removeClass("sectionFail");
		$(title+"Title").addClass("sectionPass");
	},
	failSection: function(title){
		$(title+"Title").removeClass("sectionPass");
		$(title+"Title").addClass("sectionFail");	
	}					
};
anyjunk.form.jobapplication = {
	//
	formName:"jobApplication",	
	//
	driverFields:["ageConfDiv","liecenceConfDiv","accidentQueryDiv"],
	//
	nonEuFields:["visaTypeDiv","visaExpDateDiv"],	
	//
	init: function(){	
		thisRef = anyjunk.form.jobapplication;	
		var posElement = $("position");	
		if (posElement.options.length > 1){
			posElement.selectedIndex = 0;
			posElement.addEvent("change", thisRef.checkDriverRequest);				
		}
		var euElement = $("euAuthenticated");
		if(euElement.options.length > 1){
			euElement.selectedIndex = 0;
			euElement.addEvent("change", thisRef.checkNonEu);			
		}
		//$('formTitle').innerHTML = "<h4>Job application</h4>";
	},
	clearData: function(){
		formInUse = anyjunk.form.jobapplication.formName;
		obj = anyjunk.form.jobapplication;
		anyjunk.form.removeErrorText(formInUse);
		var startFrom = $(formInUse);
		var formFieldList = document.getElementsBySelector('input,select',startFrom);    
		var i = 0;
		while(i < formFieldList.length){				
			if(formFieldList[i].tagName == "SELECT"){
				$(formFieldList[i]).selectedIndex = 0;					
				i++;
			}else{
				$(formFieldList[i]).value = "";								
				i++;
			}
		}
		obj.hideEuFields();
		obj.hideDriverFields();				
    },
	isDriverSelected: function(){		
		var choice = $('position').selectedIndex;
		var result = (choice == 1)?true:false;		
		return result;		
	},
	isEuSelected: function(){
		var choice = $('euAuthenticated').selectedIndex;
		var result = (choice == 2)?true:false;
		return result;	
	},
	checkDriverRequest: function(){	
		thisRef = anyjunk.form.jobapplication;
		var isDefault = thisRef.isDriverSelected();
		if(isDefault){	
			//$('formTitle').innerHTML = "<h4>Job application for drivers</h4>";
			thisRef.showDriverFields();			
		}else{
			//$('formTitle').innerHTML = "<h4>Job application for navigators</h4>";
			thisRef.hideDriverFields();
		}
	},
	checkNonEu: function (){
		thisRef = anyjunk.form.jobapplication;
		var isEu = thisRef.isEuSelected();
		if(isEu){
			thisRef.showEuFields();	
		}else{
			thisRef.hideEuFields();
		}
	},
	hideField: function(ref){
			$(ref).style.display = "none";
			$(ref).removeClass("required");
			$(ref).addClass("optional");
	},
	showField: function(ref){
			$(ref).style.display = "block";
			$(ref).addClass("required");
			$(ref).removeClass("optional");
	},
	showDriverFields: function(){
		thisRef = anyjunk.form.jobapplication
		fieldArray = thisRef.driverFields;
		limit = fieldArray.length;	
		for(x=0;x<=limit--;x++){				
			thisRef.showField(fieldArray[x]);		
		}
	},
	hideDriverFields: function(){
		thisRef = anyjunk.form.jobapplication;
		fieldArray = thisRef.driverFields;
		limit = fieldArray.length;	
		for(x=0;x<=limit--;x++){			
			thisRef.hideField(fieldArray[x]);
		}
		return;
	},
	showEuFields: function(){
		thisRef = anyjunk.form.jobapplication;
		fieldArray =thisRef.nonEuFields;
		limit = fieldArray.length;	
		for(x=0;x<limit;x++){			
			thisRef.showField(fieldArray[x]);
		}
	},
	hideEuFields: function(){
		thisRef = anyjunk.form.jobapplication;
		fieldArray =thisRef.nonEuFields;
		limit = fieldArray.length;	
		for(x=0;x<limit;x++){			
			thisRef.hideField(fieldArray[x]);
		}
		return;
	},
	checkForm: function(){
		
		var errorTotal = 0;
		
		errorTotal += anyjunk.form.jobapplication.checkSection_AreaOfInterest();	
		errorTotal += anyjunk.form.jobapplication.checkSection_PersonalDetails();
		errorTotal += anyjunk.form.jobapplication.checkSection_WorkingForAnyJunk();
		errorTotal += anyjunk.form.jobapplication.checkSection_AboutYou();
					
		if(errorTotal <= 0){
			//alert("The form has passed validation");
			return true;
		}else{
			//alert("The form failed the validation");
			errorData = anyjunk.form.generateErrorMessages();
			$("errorMessages").innerHTML = errorData;
			window.location.href="#top";
			anyjunk.form.openErrorMsgWindow();
			return false;
		}		
	},
	checkSection_AreaOfInterest: function(){
		error = 0;
		error += (anyjunk.form.isDefaultSelect("position","Area of interest"))?0:1;
		error += (anyjunk.form.isDefaultSelect("location","Area of interest"))?0:1;		
		if(error > 0){
			anyjunk.form.failSection("areaOfInterest");
			return 1;
		}else{		
			anyjunk.form.passSection("areaOfInterest");
			return 0;
		}			
	},
	checkSection_PersonalDetails: function(){
		error = 0;
		error += (anyjunk.form.isFieldOk("firstName","Personal details"))?0:1;
		error += (anyjunk.form.isFieldOk("lastName","Personal details"))?0:1;		
		error += (anyjunk.form.isFieldOk("address","Personal details"))?0:1;		
		error += (anyjunk.form.isFieldOk("telephone","Personal details"))?0:1;				
		if(! anyjunk.form.isFieldOk("email","Personal details")){
			error++;	
		}else if(! anyjunk.form.isEmailReal("email", "Personal details")){
			error++;	
		}
		if(error > 0){
			anyjunk.form.failSection("personalDetails");
			return 1;
		}else{		
			anyjunk.form.passSection("personalDetails");
			return 0;
		}		
	},
	checkSection_WorkingForAnyJunk: function(){
		error = 0;
		error += (anyjunk.form.isDefaultSelect("availibility","Working for AnyJunk"))?0:1;
		error += (anyjunk.form.isDefaultSelect("euAuthenticated","Working for AnyJunk"))?0:1;
		if(anyjunk.form.jobapplication.isDriverSelected()){
			error += (anyjunk.form.isDefaultSelect("ageConf","Working for AnyJunk"))?0:1;
			error += (anyjunk.form.isDefaultSelect("liecenceConf","Working for AnyJunk"))?0:1;
		}									
		if(error > 0){
			anyjunk.form.failSection("workingForAnyJunk");
			return 1;
		}else{		
			anyjunk.form.passSection("workingForAnyJunk");
			return 0;
		}		
	},
	checkSection_AboutYou: function(){
		error = 0;
		error += (anyjunk.form.isFieldOk("interestDesc","About you"))?0:1;
		error += (anyjunk.form.isFieldOk("employmentHistory","About you"))?0:1;								
		error += (anyjunk.form.isFieldOk("education","About you"))?0:1;
		error += (anyjunk.form.isFieldOk("otherInterests","About you"))?0:1;				
		error += (anyjunk.form.isFieldOk("prevEmployerRef","About you"))?0:1;
		error += (anyjunk.form.isFieldOk("otherInfo","About you"))?0:1;	
		if(error > 0){
			anyjunk.form.failSection("aboutYou");
			return 1;
		}else{		
			anyjunk.form.passSection("aboutYou");
			return 0;
		}		
	}
}		
anyjunk.form.enquiry = {
	formName:"enquiry",
	errorCount:0,
	init: function(){
		anyjunk.form.errorCount = 0;	
	},
	handleSubmit: function(){	
		anyjunk.form.errorFields={};
		var hasPassed = anyjunk.form.enquiry.additionalChecks();
		if(hasPassed){	
			//alert("The form has passed validation");			
			return true;			
		}else{						
			//alert("The form failed the validation");
			errorData = anyjunk.form.generateErrorMessages();
			$("errorMessages").innerHTML = errorData;
			window.location.href="#top";
			anyjunk.form.openErrorMsgWindow();		
			return false;			
		}		
	},
	additionalChecks: function(){	
		error = 0;		
		error += anyjunk.form.enquiry.checkSectionSubject();
		error += anyjunk.form.enquiry.checkSectionMessage();		
		error += anyjunk.form.enquiry.checkSectionContact();		
		if(error > 0){			
			return false;
		}else{
			return true;
		}
	},
	checkSectionSubject: function(){
		error = 0;
		error = (anyjunk.form.isDefaultSelect("about", "Subject"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("topic");
			return 1;
		}else{
			anyjunk.form.passSection("topic");
			return 0;
		}
	},
	checkSectionMessage: function(){
		if(! anyjunk.form.isFieldOk("messageBody", "Message")){
			anyjunk.form.failSection("message");
			return 1;
		}else{
			anyjunk.form.passSection("message");
			return 0;
		}
	},
	checkSectionContact: function(){
		error = 0;				
		error += (anyjunk.form.isFieldOk("name", "Contact"))?0:1;
		error += (anyjunk.form.isFieldOk("telephoneNo","Contact"))?0:1;	
		error += (anyjunk.form.isFieldOk("postCode","Contact"))?0:1;
		if(! anyjunk.form.isFieldOk("emailAddress","Contact")){
			error++;	
		}else if(! anyjunk.form.isEmailReal("emailAddress", "Contact")){
			error++;	
		}
		error += (anyjunk.form.isDefaultSelect("responsePref","Contact"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("contact");
			return 1;
		}else{
			anyjunk.form.passSection("contact");
			return 0;
		}
	}
}
anyjunk.form.account = {
	formName:"accountSetup",	

	init: function(){	
		var element1 = $("orgRegAddress1");							
		element1.addEvent("change", anyjunk.form.account.storeOrgAdd1);						

		var element2 = $("orgRegAddress2");							
		element2.addEvent("change", anyjunk.form.account.storeOrgAdd2);
			
		var element3 = $("orgRegTownCity");							
		element3.addEvent("change", anyjunk.form.account.storeOrgTownCity);
		
		var element4 = $("orgRegPostcode");							
		element4.addEvent("change", anyjunk.form.account.storeOrgPostcode);						
	},
	storeOrgAdd1: function(){
		$("memoryBillAddress1").value = $("orgRegAddress1").value;
	},
	storeOrgAdd2: function(){
		$("memoryBillAddress2").value = $("orgRegAddress2").value;
	},
	storeOrgTownCity: function(){
		$("memoryBillTownCity").value = $("orgRegTownCity").value;
	},
	storeOrgPostcode: function(){
		$("memoryBillPostcode").value = $("orgRegPostcode").value;
	},			
	addDataToFields: function(){
		anyjunk.form.account.storeOrgAdd1();
		anyjunk.form.account.storeOrgAdd2();
		anyjunk.form.account.storeOrgTownCity();
		anyjunk.form.account.storeOrgPostcode();
		$("billContactAddress1").value = $("memoryBillAddress1").value;
		$("billContactAddress2").value = $("memoryBillAddress2").value;
		$("billContactTownCity").value = $("memoryBillTownCity").value;
		$("billContactPostcode").value = $("memoryBillPostcode").value;				
	},
	isEmpty: function(field){
		if($(field).value == ""){
			return true;
		}else{
			return false;
		}
	},
	isRadioSectionOk: function(){
		
	},
	isChecked: function(checkBoxId,section){
		if($(checkBoxId).checked){
			anyjunk.form.setToPass(checkBoxId, section);
			return true;
		}else{
			anyjunk.form.setToFail(checkBoxId, section);
			return false;
		}
	},
	checkForm: function(){			
		
		var errorTotal = 0;
		errorTotal += anyjunk.form.account.checkOrganisationSection();
		errorTotal += anyjunk.form.account.checkBookingSection();
		errorTotal += anyjunk.form.account.checkBillingSection();
		//errorTotal += anyjunk.form.account.checkSupplier1Section();	
		//errorTotal += anyjunk.form.account.checkSupplier2Section();	
		errorTotal += anyjunk.form.account.checkTermsSection();
		if(errorTotal <= 0){
			//alert("The form has passed validation");
			return true;
		}else{
			//alert("The form failed the validation");
			errorData = anyjunk.form.generateErrorMessages();
			$("errorMessages").innerHTML = errorData;
			window.location.href="#top";
			anyjunk.form.openErrorMsgWindow();
			return false;
		}		
	},
	// sections checks
	checkOrganisationSection: function(){
		var error = 0;
		error += (anyjunk.form.isFieldOk("orgName","Organisation"))?0:1;
		error += (anyjunk.form.isFieldOk("orgRegAddress1","Organisation"))?0:1;
		//error += (anyjunk.form.isFieldOk("orgRegAddress2","Organisation"))?0:1;
		error += (anyjunk.form.isFieldOk("orgRegTownCity","Organisation"))?0:1;
		error += (anyjunk.form.isFieldOk("orgRegPostcode","Organisation"))?0:1;
		error += (anyjunk.form.isFieldOk("orgTelephone","Organisation"))?0:1;
		error += (anyjunk.form.isFieldOk("orgActivity","Organisation"))?0:1;
		error += (anyjunk.form.isDefaultSelect("orgType","Organisation"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("organisation");
			return 1;
		}else{		
			anyjunk.form.passSection("organisation");
			return 0;
		}
	},
	checkBookingSection: function(){
		error = 0;
		error += (anyjunk.form.isFieldOk("bookingMainContact","Booking contacts"))?0:1;
		error += (anyjunk.form.isFieldOk("bookingContactPos","Booking contacts"))?0:1;
		error += (anyjunk.form.isFieldOk("bookingContactTelNo","Booking contacts"))?0:1;
		if(! anyjunk.form.isFieldOk("bookingContactEmailAdd","Booking contacts")){
			error++;	
		}else if(! anyjunk.form.isEmailReal("bookingContactEmailAdd", "Booking contacts")){
			error++;	
		}
		//error += (anyjunk.form.isFieldOk("bookContactOther","Booking contacts"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("bookingContacts");
			return 1;
		}else{		
			anyjunk.form.passSection("bookingContacts");
			return 0;
		}		
	},
	checkBillingSection: function(){
		error = 0;
		error += (anyjunk.form.isFieldOk("billContactName","Billing and credit"))?0:1;
		error += (anyjunk.form.isFieldOk("billContactAddress1","Billing and credit"))?0:1;
		//error += (anyjunk.form.isFieldOk("billContactAddress2","Billing and credit"))?0:1;
		error += (anyjunk.form.isFieldOk("billContactTownCity","Billing and credit"))?0:1;
		error += (anyjunk.form.isFieldOk("billContactPostcode","Billing and credit"))?0:1;
		error += (anyjunk.form.isFieldOk("billContactTelephone","Billing and credit"))?0:1;				
		if(! anyjunk.form.isFieldOk("billContactEmail","Billing and credit")){
			error++;	
		}else if(! anyjunk.form.isEmailReal("billContactEmail", "Billing and credit")){
			error++;	
		}
		error += (anyjunk.form.isFieldOk("accountSetMethod","Billing and credit"))?0:1;
		error += (anyjunk.form.isFieldOk("expectedValuePerMonth","Billing and credit"))?0:1;
		error += (anyjunk.form.isFieldOk("creditLimit","Billing and credit"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("billingContacts");
			return 1;
		}else{		
			anyjunk.form.passSection("billingContacts");
			return 0;
		}			
	},
	checkSupplier1Section: function(){
		error = 0;
		error += (anyjunk.form.isFieldOk("ref1CompanyName","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1Contact","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1Position","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1PhoneNo","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1Email","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1Address1","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1Address2","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1TownCity","Supplier 1"))?0:1;
		error += (anyjunk.form.isFieldOk("ref1Postcode","Supplier 1"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("supplier1");
			return 1;
		}else{		
			anyjunk.form.passSection("supplier1");
			return 0;
		}		
	},
	checkSupplier2Section: function(){
		var error = 0;
		error += (anyjunk.form.isFieldOk("ref2CompanyName","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2Contact","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2Position","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2PhoneNo","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2Email","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2Address1","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2Address2","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2TownCity","Supplier 2"))?0:1;
		error += (anyjunk.form.isFieldOk("ref2Postcode","Supplier 2"))?0:1;
		if(error > 0){
			anyjunk.form.failSection("supplier2");
			return 1;
		}else{		
			anyjunk.form.passSection("supplier2");
			return 0;
		}		
	},
	checkTermsSection: function(){
		if(anyjunk.form.account.isChecked("terms","Terms and conditions")){
			anyjunk.form.passSection("terms");
			return 0;
		}else{			
			anyjunk.form.failSection("terms");
			return 1;
		}
	}	
}


