/**
 * Specific code for Flexirent.com Customer Contact Form (Updating Details)
 *
 */


function FC_init() {
	
	var fiFirstName = new FC_FormItem("First_name");
	FCV.appendValidator(new FC_Validate(fiFirstName, "First Name"));
	
	var fiSurname = new FC_FormItem("Surname"); 
	FCV.appendValidator(new FC_Validate(fiSurname, "Surname"));
	
	var fiDOB = new FC_FormItem("Date_of_Birth");
	FCV.appendValidator(new FC_ValidateDate(fiDOB, "Date of Birth", "/", true, true));
	
	var fiAgr = new FC_FormItem("Agreement_Number");
	FCV.appendValidator(new FC_ValidateNumber(fiAgr, "Agreement Number"));
	
	//an item for the list of options
	var fiOptions = new FC_FormList("options", new Array("addressCheck1","addressCheck2","businessPhoneCheck", "afterHoursCheck","mobileCheck","emailCheck"));
	FCV.appendValidator(new FC_ValidateList(fiOptions, "update"));
	
	//container for the Address section
	var fiAddCheck = new FC_FormItem("addressCheck1");
	var cntAdd = new FC_Container("addressCheck1", fiAddCheck.object.checked);
	var ciAdd = new FC_ContainerItem("addressContainer1","DISPLAY", cntAdd);
	FCV.appendContainer(cntAdd);
	
	//Address section
	var fiAdd1 = new FC_FormItem("Address_1");
	fiAdd1.setContainer(cntAdd);
	FCV.appendValidator(new FC_Validate(fiAdd1,"Address 1"));
	
	var fiAdd2 = new FC_FormItem("Address_2");
	fiAdd2.setContainer(cntAdd);
	FCV.appendValidator(new FC_Validate(fiAdd2,"Address 2",false));
	
	var fiSuburb = new FC_FormItem("Suburb");
	fiSuburb.setContainer(cntAdd);
	FCV.appendValidator(new FC_Validate(fiSuburb,"Suburb"));
	
	var fiState = new FC_FormItem("State");
	fiState.setContainer(cntAdd);
	FCV.appendValidator(new FC_Validate(fiState,"State"));
	
	var fiPcode = new FC_FormItem("Postcode");
	fiPcode.setContainer(cntAdd);
	FCV.appendValidator(new FC_ValidateNumber(fiPcode,"Postcode", true, 4));
	
	
	//container for Mailing Address section
	var fiMailCheck = new FC_FormItem("addressCheck2");
	var cntMail = new FC_Container("addressCheck2",fiMailCheck.object.checked);
	var ciMail = new FC_ContainerItem("addressContainer2","DISPLAY", cntMail);
	new FC_ContainerItem("addressContainer2SAME","VISIBILITY", cntMail);
	FCV.appendContainer(cntMail);
	
	//mirror for Mailing Address section
	var mrrAddress = new FC_Mirror("addressMirrorCheck"); 
	FCV.appendMirror(mrrAddress);
	
	//Mailing Address
	var fiMA1 = new FC_FormItem("Mailing_Address_1");
	fiMA1.setContainer(cntMail);
	new FC_MirrorItem(fiAdd1,fiMA1,mrrAddress);
	FCV.appendValidator(new FC_Validate(fiMA1,"Mailing Address 1"));
	
	var fiMA2 = new FC_FormItem("Mailing_Address_2");
	fiMA2.setContainer(cntMail);
	new FC_MirrorItem(fiAdd2,fiMA2,mrrAddress);
	FCV.appendValidator(new FC_Validate(fiMA2,"Mailing Address 2",false));
	
		
	var fiMSuburb = new FC_FormItem("Mailing_Suburb");
	fiMSuburb.setContainer(cntMail);
	new FC_MirrorItem(fiSuburb,fiMSuburb,mrrAddress);
	FCV.appendValidator(new FC_Validate(fiMSuburb,"Mailing Suburb"));
	
	var fiMState = new FC_FormItem("Mailing_State");
	fiMState.setContainer(cntMail);
	new FC_MirrorItem(fiState,fiMState,mrrAddress);
	FCV.appendValidator(new FC_Validate(fiMState,"Mailing State"));
	
	var fiMPcode = new FC_FormItem("Mailing_Postcode");
	fiMPcode.setContainer(cntMail);
	new FC_MirrorItem(fiPcode,fiMPcode,mrrAddress);
	FCV.appendValidator(new FC_ValidateNumber(fiMPcode,"Mailing Postcode", true, 4));
	
	//business phone
	var fiBHPCheck = new FC_FormItem("businessPhoneCheck");
	var cntBHPhone = new FC_Container("businessPhoneCheck", fiBHPCheck.object.checked); 
	var ciBHPhone = new FC_ContainerItem("bhpContainer", "VISIBILITY", cntBHPhone);
	FCV.appendContainer(cntBHPhone); 
	
	var fiBHPhoneCode = new FC_FormItem("Business_Hours_Phone_Code");
	fiBHPhoneCode.setContainer(cntBHPhone);
	FCV.appendValidator(new FC_Validate(fiBHPhoneCode, "Business Hours Phone (Area Code)"));
	
	var fiBHPhoneNbr = new FC_FormItem("Business_Hours_Phone_Number");
	fiBHPhoneNbr.setContainer(cntBHPhone);
	FCV.appendValidator(new FC_ValidateNumber(fiBHPhoneNbr, "Business Hours Phone (Number)", true, 8));
	
	//after hours phone
	var fiAFPCheck = new FC_FormItem("afterHoursCheck");
	var cntAFPhone = new FC_Container("afterHoursCheck", fiAFPCheck.object.checked); 
	var ciAFPhone = new FC_ContainerItem("ahpContainer", "VISIBILITY", cntAFPhone);
	FCV.appendContainer(cntAFPhone); 
	
	var fiAFPhoneCode = new FC_FormItem("After_Hours_Phone_Code");
	fiAFPhoneCode.setContainer(cntAFPhone);
	FCV.appendValidator(new FC_Validate(fiAFPhoneCode, "After Hours Phone (Area Code)"));
	
	var fiAFPhoneNbr = new FC_FormItem("After_Hours_Phone_Number");
	fiAFPhoneNbr.setContainer(cntAFPhone);
	FCV.appendValidator(new FC_ValidateNumber(fiAFPhoneNbr, "After Hours Phone (Number)", true, 8));
	
	//mobile
	var fiMobCheck = new FC_FormItem("mobileCheck");
	var cntMobile = new FC_Container("mobileCheck", fiMobCheck.object.checked);
	var ciMobile = new FC_ContainerItem("Mobile_Phone", "VISIBILITY", cntMobile);
	FCV.appendContainer(cntMobile); 
	
	var fiMobile = new FC_FormItem("Mobile_Phone");
	fiMobile.setContainer(cntMobile);
	FCV.appendValidator(new FC_ValidateNumber(fiMobile, "Mobile Phone", true, 10));
	
	//email
	var fiEmailCheck = new FC_FormItem("emailCheck");
	var cntEmail = new FC_Container("emailCheck", fiEmailCheck.object.checked);
	var ciEmail = new FC_ContainerItem("Email", "VISIBILITY", cntEmail);
	FCV.appendContainer(cntEmail); 
	
	var fiEmail = new FC_FormItem("Email");
	fiEmail.setContainer(cntEmail);
	FCV.appendValidator(new FC_ValidateEmail(fiEmail, "Email"));
	
	
	//========================
	//ALTERATIONS 
	//========================
	
	//business phone should include area code
	var fiBHPhone = new FC_FormItem("Business_Hours_Phone"); 
	fiBHPhone.setContainer(cntBHPhone);
	FCA.appendAlteration(new FC_Alteration(fiBHPhone, "(%0) %1", new Array(fiBHPhoneCode, fiBHPhoneNbr)));
	
	//after hours phone should include area code
	var fiAFPhone = new FC_FormItem("After_Hours_Phone"); 
	fiAFPhone.setContainer(cntAFPhone);
	FCA.appendAlteration(new FC_Alteration(fiAFPhone, "(%0) %1", new Array(fiAFPhoneCode, fiAFPhoneNbr)));	
}
