window.onload = function()
{
  try
  {
    formInit();
  } catch(e) {
  	initError = "There were errors initializing the form:\n";
  	for (var i in e) {
  		initError += "\n error." + i + " : " + e[i];
  	}
  	alert (initError);
  }
}

var E8_Form;

function formInit()
{


  // create an instance of the form class
  E8regForm = new DraftfcbForm(document.forms["E8_signup"]);

  // project-specific form properties
  E8regForm.ErrorPrefix = "There is a problem with the information you entered:";
  E8regForm.SixteenBefore = new Date("May 16, 1992");
  E8regForm.Rules.push(
    { Field: "txt_firstname",		Method: "Required",    Message: "'First Name' is a required field." },
    { Field: "txt_lastname",		Method: "Required",    Message: "'Last Name' is a required field." },
	{ Field: "txt_email",		Method: "Required",    Message: "'Email Address' is a required field." },
    { Field: "txt_email",		Method: "EmailFormat", Message: "You don't seem to have entered a valid email address." },
    { Field: "txt_email_confirm", Method: "Required",    Message: "'Re-enter Email Address' is a required field." },
    { Field: "txt_email",         Method: "Matching",    Message: "'Email Address' and 'Re-enter Email Address' did not match." },
    { Field: "txt_zip",			Method: "Required",    Message: "'Zip Code' is a required field." },
    { Field: "txt_zip",			Method: "ZipFivePlusFour", Message: "You ZIP code must be in the format xxxxx or xxxxx-xxxx." },
    { Field: "txt_mobile",		Method: "Required",    Message: "'Primary Phone Number' is a required field." },
    { Field: "txt_mobile",		Method: "PhoneTenDashes", Message: "Your primary phone number doesn't appear to be valid. It should be in the format xxx-xxx-xxxx." },
    { Field: "txt_birthmonth",	Method: "Required",    Message: "'Birth month' is a required field." },
    { Field: "txt_birthday",	Method: "Required",    Message: "'Birth date' is a required field." },
    { Field: "txt_birthyear",	Method: "Required",    Message: "'Birth year' is a required field." },     
    { Field: "txt_carrier",		Method: "Required",    Message: "'Purchase Year' is a required field." }
    
  );

}


function formValidate()
{
  return E8regForm.Validate(E8regForm.Rules);
}



//custom form event handler functions
//pre-validation submit event handler
function handleSubmit() {
}



//popup
function popup(url) {
	newwindow=window.open(url,'name','width=620,height=550,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}


//  hide show elements

function show(id) {
	document.getElementById(id).style.display = 'block';
}

function hide(id) {
	document.getElementById(id).style.display = 'none';
}