// JavaScript Document



// DECLARE VAR
var leftColColor1 = "#cee4f1";
var leftColColor2 = "#cee4f1";
var rightColColor1 = "#cee4f1";
var rightColColor2 = "#cee4f1";
var alertColor = "#f1d16e";
var textFieldAlertColor = "#fff7c9";
var planSelect = false;
var pricingOptionSelect = false;
var pricingOptionExtra = false;
var specialPricingExtra = false;
var mailProposalToSelect = false;
var mailProposalToExtra = false;


// DECLARE FUNCTIONS

function validateForm() {

	// VALIDATE REQUESTOR First NAME
	if (document.getElementById("FirstName").value.length != 0) {
		document.getElementById("FirstName_text").style.fontWeight = "normal";
		document.getElementById("FirstName_text_container").style.backgroundColor = leftColColor1;
		document.getElementById("FirstName_mid_container").style.backgroundColor = leftColColor1;
		document.getElementById("FirstName_input_container").style.backgroundColor = rightColColor1;
		document.getElementById("FirstName").style.backgroundColor = "#ffffff";
		document.getElementById("FirstName_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("FirstName_alert").style.display = "none";
	} else {
		document.getElementById("FirstName").focus();
		document.getElementById("FirstName_text").style.fontWeight = "bold";
		document.getElementById("FirstName_text_container").style.backgroundColor = alertColor;
		document.getElementById("FirstName_mid_container").style.backgroundColor = alertColor;
		document.getElementById("FirstName_input_container").style.backgroundColor = alertColor;
		document.getElementById("FirstName").style.backgroundColor = textFieldAlertColor;
		document.getElementById("FirstName_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("FirstName_alert").style.display = "block";
		return false;
	}
	
	// VALIDATE REQUESTOR Last NAME
	if (document.getElementById("LastName").value.length != 0) {
		document.getElementById("LastName_text").style.fontWeight = "normal";
		document.getElementById("LastName_text_container").style.backgroundColor = leftColColor1;
		document.getElementById("LastName_mid_container").style.backgroundColor = leftColColor1;
		document.getElementById("LastName_input_container").style.backgroundColor = rightColColor1;
		document.getElementById("LastName").style.backgroundColor = "#ffffff";
		document.getElementById("LastName_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("LastName_alert").style.display = "none";
	} else {
		document.getElementById("LastName").focus();
		document.getElementById("LastName_text").style.fontWeight = "bold";
		document.getElementById("LastName_text_container").style.backgroundColor = alertColor;
		document.getElementById("LastName_mid_container").style.backgroundColor = alertColor;
		document.getElementById("LastName_input_container").style.backgroundColor = alertColor;
		document.getElementById("LastName").style.backgroundColor = textFieldAlertColor;
		document.getElementById("LastName_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("LastName_alert").style.display = "block";
		return false;
	}
	
	/*	// VALIDATE REQUESTOR TITLE
	if (document.getElementById("JobFunction").value.length != 0) {
		document.getElementById("JobFunction_text").style.fontWeight = "normal";
		document.getElementById("JobFunction_text_container").style.backgroundColor = leftColColor1;
		document.getElementById("JobFunction_mid_container").style.backgroundColor = leftColColor1;
		document.getElementById("JobFunction_input_container").style.backgroundColor = rightColColor1;
		document.getElementById("JobFunction").style.backgroundColor = "#ffffff";
		document.getElementById("JobFunction_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("JobFunction_alert").style.display = "none";
	} else {
		document.getElementById("JobFunction").focus();
		document.getElementById("JobFunction_text").style.fontWeight = "bold";
		document.getElementById("JobFunction_text_container").style.backgroundColor = alertColor;
		document.getElementById("JobFunction_mid_container").style.backgroundColor = alertColor;
		document.getElementById("JobFunction_input_container").style.backgroundColor = alertColor;
		document.getElementById("JobFunction").style.backgroundColor = textFieldAlertColor;
		document.getElementById("JobFunction_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("JobFunction_alert").style.display = "block";
		return false;
	}*/
	
	// VALIDATE REQUESTOR EMAIL
	if (document.getElementById("email").value.length != 0) {
		document.getElementById("email_text").style.fontWeight = "normal";
		document.getElementById("email_text_container").style.backgroundColor = leftColColor1;
		document.getElementById("email_mid_container").style.backgroundColor = leftColColor1;
		document.getElementById("email_input_container").style.backgroundColor = rightColColor1;
		document.getElementById("email").style.backgroundColor = "#ffffff";
		document.getElementById("email_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("email_alert").style.display = "none";
	} else {
		document.getElementById("email").focus();
		document.getElementById("email_text").style.fontWeight = "bold";
		document.getElementById("email_text_container").style.backgroundColor = alertColor;
		document.getElementById("email_mid_container").style.backgroundColor = alertColor;
		document.getElementById("email_input_container").style.backgroundColor = alertColor;
		document.getElementById("email").style.backgroundColor = textFieldAlertColor;
		document.getElementById("email_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("email_alert").style.display = "block";
		return false;
	}
	
	/*// VALIDATE REQUESTOR PHONE
	if (validatePhone(document.getElementById("Referral_Phone").value)) {
		document.getElementById("Referral_Phone_text").style.fontWeight = "normal";
		document.getElementById("Referral_Phone_text_container").style.backgroundColor = leftColColor1;
		document.getElementById("Referral_Phone_mid_container").style.backgroundColor = leftColColor1;
		document.getElementById("Referral_Phone_input_container").style.backgroundColor = rightColColor1;
		document.getElementById("Referral_Phone").style.backgroundColor = "#ffffff";
		document.getElementById("Referral_Phone_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("Referral_Phone_alert").style.display = "none";
	} else {
		document.getElementById("Referral_Phone").focus();
		document.getElementById("Referral_Phone_text").style.fontWeight = "bold";
		document.getElementById("Referral_Phone_text_container").style.backgroundColor = alertColor;
		document.getElementById("Referral_Phone_mid_container").style.backgroundColor = alertColor;
		document.getElementById("Referral_Phone_input_container").style.backgroundColor = alertColor;
		document.getElementById("Referral_Phone").style.backgroundColor = textFieldAlertColor;
		document.getElementById("Referral_Phone_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("Referral_Phone_alert").style.display = "block";
		return false;
	}
	
	// VALIDATE EMPLOYER COMPANY
	if (document.getElementById("Company").value.length != 0) {
		document.getElementById("Company_text").style.fontWeight = "normal";
		document.getElementById("Company_text_container").style.backgroundColor = leftColColor2;
		document.getElementById("Company_mid_container").style.backgroundColor = leftColColor2;
		document.getElementById("Company_input_container").style.backgroundColor = rightColColor2;
		document.getElementById("Company").style.backgroundColor = "#ffffff";
		document.getElementById("Company_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("Company_alert").style.display = "none";
	} else {
		document.getElementById("Company").focus();
		document.getElementById("Company_text").style.fontWeight = "bold";
		document.getElementById("Company_text_container").style.backgroundColor = alertColor;
		document.getElementById("Company_mid_container").style.backgroundColor = alertColor;
		document.getElementById("Company_input_container").style.backgroundColor = alertColor;
		document.getElementById("Company").style.backgroundColor = textFieldAlertColor;
		document.getElementById("Company_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("Company_alert").style.display = "block";
		return false;
	}
	
	// VALIDATE EMPLOYER Address
	if (document.getElementById("Address").value.length != 0) {
		document.getElementById("Address_text").style.fontWeight = "normal";
		document.getElementById("Address_text_container").style.backgroundColor = leftColColor2;
		document.getElementById("Address_mid_container").style.backgroundColor = leftColColor2;
		document.getElementById("Address_input_container").style.backgroundColor = rightColColor2;
		document.getElementById("Address").style.backgroundColor = "#ffffff";
		document.getElementById("Address_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("Address_alert").style.display = "none";
	} else {
		document.getElementById("Address").focus();
		document.getElementById("Address_text").style.fontWeight = "bold";
		document.getElementById("Address_text_container").style.backgroundColor = alertColor;
		document.getElementById("Address_mid_container").style.backgroundColor = alertColor;
		document.getElementById("Address_input_container").style.backgroundColor = alertColor;
		document.getElementById("Address").style.backgroundColor = textFieldAlertColor;
		document.getElementById("Address_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("Address_alert").style.display = "block";
		return false;
	}*/
	// VALIDATE EMPLOYER City
	if (document.getElementById("City").value.length != 0) {
		document.getElementById("City_text").style.fontWeight = "normal";
		document.getElementById("City_text_container").style.backgroundColor = leftColColor2;
		document.getElementById("City_mid_container").style.backgroundColor = leftColColor2;
		document.getElementById("City_input_container").style.backgroundColor = rightColColor2;
		document.getElementById("City").style.backgroundColor = "#ffffff";
		document.getElementById("City_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("City_alert").style.display = "none";
	} else {
		document.getElementById("City").focus();
		document.getElementById("City_text").style.fontWeight = "bold";
		document.getElementById("City_text_container").style.backgroundColor = alertColor;
		document.getElementById("City_mid_container").style.backgroundColor = alertColor;
		document.getElementById("City_input_container").style.backgroundColor = alertColor;
		document.getElementById("City").style.backgroundColor = textFieldAlertColor;
		document.getElementById("City_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("City_alert").style.display = "block";
		return false;
	}
	// VALIDATE EMPLOYER STATE
	if (document.getElementById("State").value != " ") {
		document.getElementById("State_text").style.fontWeight = "normal";
		document.getElementById("State_text_container").style.backgroundColor = leftColColor2;
		document.getElementById("State_mid_container").style.backgroundColor = leftColColor2;
		document.getElementById("State_input_container").style.backgroundColor = rightColColor2;
		document.getElementById("State").style.backgroundColor = "#ffffff";
		document.getElementById("State_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("State_alert").style.display = "none";
	} else {
		document.getElementById("State").focus();
		document.getElementById("State_text").style.fontWeight = "bold";
		document.getElementById("State_text_container").style.backgroundColor = alertColor;
		document.getElementById("State_mid_container").style.backgroundColor = alertColor;
		document.getElementById("State_input_container").style.backgroundColor = alertColor;
		document.getElementById("State").style.backgroundColor = textFieldAlertColor;
		document.getElementById("State_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("State_alert").style.display = "block";
		return false;
	}
	/*// VALIDATE EMPLOYER Zip
	if (document.getElementById("Zip").value.length != 0) {
		document.getElementById("Zip_text").style.fontWeight = "normal";
		document.getElementById("Zip_text_container").style.backgroundColor = leftColColor2;
		document.getElementById("Zip_mid_container").style.backgroundColor = leftColColor2;
		document.getElementById("Zip_input_container").style.backgroundColor = rightColColor2;
		document.getElementById("Zip").style.backgroundColor = "#ffffff";
		document.getElementById("Zip_alert_img").src = "/images/forms/req_green.gif";
		document.getElementById("Zip_alert").style.display = "none";
	} else {
		document.getElementById("Zip").focus();
		document.getElementById("Zip_text").style.fontWeight = "bold";
		document.getElementById("Zip_text_container").style.backgroundColor = alertColor;
		document.getElementById("Zip_mid_container").style.backgroundColor = alertColor;
		document.getElementById("Zip_input_container").style.backgroundColor = alertColor;
		document.getElementById("Zip").style.backgroundColor = textFieldAlertColor;
		document.getElementById("Zip_alert_img").src = "/images/forms/req_red.gif";
		document.getElementById("Zip_alert").style.display = "block";
		return false;
	}*/
	
	return true;

}


window.onload = function() {
	if (document.getElementById('contactForm')) {
		document.getElementById('contactForm').onsubmit = function() {		
			var validate = validateForm();
			
			if (validate) {
				if (document.getElementById('FullName_')) {
					document.getElementById('FullName_').value = document.getElementById('FirstName').value+" "+document.getElementById('LastName').value;
				}
				//build name/value list
				if (document.getElementById('url')) {
					var qs = "?Name="+document.getElementById('FirstName').value+"+"+document.getElementById('LastName').value+"&email="+document.getElementById('email').value+"&Address="+document.getElementById('Address').value+"&City="+document.getElementById('City').value+"&State="+document.getElementById('State').value+"&Zip="+document.getElementById('Zip').value+"&Referral_Phone="+document.getElementById('Referral_Phone').value+"&JobFunction="+document.getElementById('JobFunction').value+"&Company="+document.getElementById('Company').value;
					
					if (document.getElementById('url').value.substr(document.getElementById('url').value.length-4,4) == ".php") { //no values added
						document.getElementById('url').value += qs;
					} else {
						var urlSplit = document.getElementById('url').value.split("?");
						document.getElementById('url').value = urlSplit[0] + qs;
					}
				}
			}
			
		};
		
	}
};
