function checkRegistrationForm(form) {
	var retval = true;
	start = "<b><font color=\"red\">";
	end = "<b></font></b><br>";
	error.innerHTML = "";


	if (isEmpty(document.getElementById('applicantType').value)) {
		error.innerHTML += start + "You must select an Applicant Type." + end;
		retval = false;
	}	
	if (document.getElementById('applicantType').value == "OWNER" && isEmpty(document.getElementById('ownerName').value)) {
		error.innerHTML += start + "You must enter an Owner Name." + end;
		retval = false;
	}
	else if (document.getElementById('applicantType').value == "CONTRACTOR") {
		if (isEmpty(document.getElementById('contractorName').value)) {
			error.innerHTML += start + "You must select an Agent For." + end;
			retval = false;
		}
		if (isEmpty(document.getElementById('applAgent').value)) {
			error.innerHTML += start + "You must enter a Contractor Name." + end;
			retval = false;
		}
	}
	else if (document.getElementById('applicantType').value == "UTILITY" && isEmpty(document.getElementById('owner').value)) {
		error.innerHTML += start + "You must select a Company Name." + end;
		retval = false;
	}
	else if (document.getElementById('applicantType').value == "GOVERNMENT" && isEmpty(document.getElementById('owner').value)) {
		error.innerHTML += start + "You must select an Agency Name." + end;
		retval = false;
	}
	if (document.getElementById('applicantType').value != "OWNER") {
		if (isEmpty(document.getElementById('repFirstName').value)) {
			error.innerHTML += start + "You must enter a First Name." + end;
			retval = false;
		}
		else if (!isAlpha(document.getElementById('repFirstName').value)) {
			error.innerHTML += start + "First Name can only contain characters in the range of A-Z." + end;
			retval = false;
		}
		if (isEmpty(document.getElementById('repLastName').value)) {
			error.innerHTML += start + "You must enter a Last Name." + end;
			retval = false;
		}
		else if (!isAlpha(document.getElementById('repLastName').value)) {
			error.innerHTML += start + "Last Name can only contain characters in the range of A-Z." + end;
			retval = false;
		}
	}

	if (isEmpty(document.getElementById('address').value) || isEmpty(document.getElementById('street').value)) {
		error.innerHTML += start + "You must enter an Address and Street." + end;
		retval = false;
	}
	if (isEmpty(document.getElementById('city').value)) {
		error.innerHTML += start + "You must enter a City." + end;
		retval = false;
	}
	if (isEmpty(document.getElementById('zip').value)) {
		error.innerHTML += start + "You must enter a Zip Code." + end;
		retval = false;
	}
	else {
		var valid = "0123456789-";
		var hyphencount = 0;
		var zip = document.getElementById('zip').value;
		var validBool = true;
		var hyphenBool = true;
		
		if (zip.length!=5 && zip.length!=10) {
			validBool = false;
			hyphenBool = false;
			error.innerHTML += start + "Please enter your 5 digit or 5 digit + 4 zip code." + end;
			retval = false;
		}
		for (var i=0; i < zip.length; i++) {
			temp = "" + zip.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1" && validBool) {
				validBool = false;
				hyphenBool = false;				
				error.innerHTML += start + "Invalid characters in your zip code." + end;
				retval = false;
			}
			if ((hyphencount > 1) || ((zip.length==10) && "" + zip.charAt(5)!="-") && hyphenBool) {
				validBool = false;			
				hyphenBool = false;
				error.innerHTML += start + "The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'." + end;						
				retval = false;
			}
		}
	}
	if (isEmpty(document.getElementById('authRepPhone').value)) {
		error.innerHTML += start + "You must enter a Phone Number." + end;
		retval = false;
	}
	else if (!isPhone(document.getElementById('authRepPhone').value)) {
		error.innerHTML += start + "Phone Number must be in the format 555-555-5555." + end;
		retval = false;
	}
	if (isNotEmpty(document.getElementById('authRepFax').value)) {
		if (!isPhone(document.getElementById('authRepFax').value)) {
			error.innerHTML += start + "Fax must be in the format 555-555-5555." + end;
			retval = false;
		}	
	}
	if (isEmpty(document.getElementById('authRepEmail').value)) {
		error.innerHTML += start + "You must enter an Email Address." + end;
		retval = false;
	}
	else if (!isEmail(document.getElementById('authRepEmail').value)) {
		error.innerHTML += start + "The Email Address entered is not properly formatted." + end;
		retval = false;
	}
	if (isEmpty(document.getElementById('confirmEmail').value)) {
		error.innerHTML += start + "You must confirm your Email Address." + end;
		retval = false;
	}
	if (!isMatch(document.getElementById('authRepEmail').value, document.getElementById('confirmEmail').value)) {
		error.innerHTML += start + "The Email Address and Confirmation do not match." + end;
		retval = false;
	}
	if (isEmpty(document.getElementById('passWord').value)) {
		error.innerHTML += start + "You must enter a Password." + end;
		retval = false;
	}
	if (isEmpty(document.getElementById('confirmPassWord').value)) {
		error.innerHTML += start + "You must confirm your Password." + end;
		retval = false;
	}
	if (!isMatch(document.getElementById('passWord').value, document.getElementById('confirmPassWord').value)) {
		error.innerHTML += start + "The Password and Confirmation do not match." + end;
		retval = false;
	}

	return retval;
}

function checkForm(form) {
	var retval = true;
	start = "<b><font color=\"red\">";
	end = "<b></font></b><br>";
	error.innerHTML = "";

	if (document.getElementById('authRepEmail').value == "") {
		error.innerHTML += start + "You must enter an Email Address to continue." + end;
		retval = false;
	}
	if (document.getElementById('passWord').value == "") {
		error.innerHTML += start + "You must enter a Password to continue." + end;
		retval = false;
	}

	return retval;
}

/*
function disableOwner() {
	if (document.getElementById('homeowner').checked) {
		document.getElementById('owner').value = "";
		document.getElementById('owner').disabled=true;
	}
	else {
		document.getElementById('owner').disabled=false;		
	}
}
*/

function displayRegister() {
	if (document.getElementById('applicantType').value == "OWNER") {
		document.getElementById('ownerDiv').style.display="inline";
		document.getElementById('bodyDiv').style.display="inline";		
		document.getElementById('nameDiv').style.display="none";		
		document.getElementById('contractorDiv').style.display="none";
		document.getElementById('contractorOwnerDiv').style.display="none";		
		document.getElementById('utilityDiv').style.display="none";	
		document.getElementById("utilityTextDiv").innerHTML = "";					
//		document.getElementById("loginWarning").innerHTML = "";
//		document.getElementById("error").innerHTML = "";			
	}
	else if (document.getElementById('applicantType').value == "CONTRACTOR") {
		document.getElementById('ownerDiv').style.display="none";
		document.getElementById('bodyDiv').style.display="inline";		
		document.getElementById('nameDiv').style.display="inline";		
		document.getElementById('contractorDiv').style.display="inline";
		document.getElementById('contractorOwnerDiv').style.display="inline";		
		document.getElementById('utilityDiv').style.display="none";
		document.getElementById("utilityTextDiv").innerHTML = "";						
	}
	else if (document.getElementById('applicantType').value == "UTILITY") {
		document.getElementById('ownerDiv').style.display="none";
		document.getElementById('bodyDiv').style.display="inline";		
		document.getElementById('nameDiv').style.display="inline";		
		document.getElementById('contractorDiv').style.display="none";
		document.getElementById('contractorOwnerDiv').style.display="none";		
		document.getElementById('utilityDiv').style.display="inline";
		document.getElementById("utilityTextDiv").innerHTML = "Company Name: *";		
	}
	else if (document.getElementById('applicantType').value == "GOVERNMENT") {
		document.getElementById('ownerDiv').style.display="none";
		document.getElementById('bodyDiv').style.display="inline";		
		document.getElementById('nameDiv').style.display="inline";		
		document.getElementById('contractorDiv').style.display="none";
		document.getElementById('contractorOwnerDiv').style.display="none";		
		document.getElementById('utilityDiv').style.display="inline";
		document.getElementById("utilityTextDiv").innerHTML = "Agency Name: *";		
	}
	else if (document.getElementById('applicantType').value == "") {
		document.getElementById('ownerDiv').style.display="none";
		document.getElementById('bodyDiv').style.display="none";		
		document.getElementById('nameDiv').style.display="none";		
		document.getElementById('contractorDiv').style.display="none";
		document.getElementById('contractorOwnerDiv').style.display="none";		
		document.getElementById('utilityDiv').style.display="none";
		document.getElementById("utilityTextDiv").innerHTML = "";				
	}
}

function loadForm() {
	document.LoginForm[0].authRepEmail.focus();
}

function loadRegisterForm() {
//	document.LoginForm[0].authRepEmail.focus();
//	disableOwner();
}

function passwordDialog() {
	var handleSubmit = function() {	this.submit(); };
	var handleCancel = function() {	this.cancel(); };
	var handleSuccess = function(o) {
		document.getElementById("forgotPassword").innerHTML = o.responseText;
		document.getElementById("loginWarning").innerHTML = "";	
	};
	var handleFailure = function(o) { alert("Submission failed: " + o.status); };

	// Instantiate the Dialog
	document.getElementById("emailPassword").style.display="block";
	YAHOO.container.emailPassword = new YAHOO.widget.Dialog("emailPassword", 
							{ width : "30em",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  close : false,
							  buttons : [ { text:"Submit", handler:handleSubmit },
								      { text:"Cancel", handler:handleCancel } ]
							});

	YAHOO.container.emailPassword.validate = function() {
		var data = this.getData();
		if (data.authRepEmail == "") {
			alert("Please enter your email address to continue.");
			return false;
		} else {
			return true;
		}
	};

	YAHOO.container.emailPassword.callback = { success: handleSuccess, failure: handleFailure };
	
	// Render the Dialog
	YAHOO.container.emailPassword.render();
	YAHOO.util.Event.addListener("show", "click", YAHOO.container.emailPassword.show, YAHOO.container.emailPassword, true);
	YAHOO.util.Event.addListener("hide", "click", YAHOO.container.emailPassword.hide, YAHOO.container.emailPassword, true);
}


