var gValidForm = true;
/////////////////////////////////////////////////////////////////////////////////////////////
function checkElement(fieldName, message, fieldCondition) {
	if(gValidForm == true) {
		if(document.getElementById(fieldName).value == fieldCondition) {
			alert(message);
			document.getElementById(fieldName).focus();
			gValidForm = false;
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////
function checkForm() {
	gValidForm = true;
	checkElement("firstName", "Please enter your first name.", "");
	checkElement("lastName", "Please enter your last name.", "");
	checkElement("companyName", "Please enter your company name.", "");
	checkElement("emailAddress", "Please enter your email address.", "");
	checkElement("phoneNumber", "Please enter your phone number.", "");
	checkElement("quoteAddress1", "Please enter your company address.", "");
	checkElement("quoteCity", "Please enter your city.", "");
	checkElement("quoteState", "Please select your state.", "");
	checkElement("quoteZip", "Please enter your zip code.", "");
	checkElement("quoteCountry", "Please select your country.", "");
	
	var aproductChoices = "";
	var aFeithCategoryName = "";
	var aSP_Flag = "N";
	var aTP_Flag = "N";
	var aOther_Flag = "N";
	for(var i=0;i<document.getElementById("webForm").productChoice.length;i++) {
		if(document.getElementById("webForm").productChoice[i].checked == true) {
			var currProdChoice = document.getElementById("webForm").productChoice[i].value;
			if(currProdChoice == "Mobile Offices" || currProdChoice == "Classrooms"  || currProdChoice == "Container Offices") {
				aTP_Flag = "Y";
			}
			else if(currProdChoice == "Storage Containers" || currProdChoice == "$1.99 Special Offer Storage Promotion") {
				aSP_Flag = "Y"
			}
			else {
				aOther_Flag = "Y";
			}
			
			if(aproductChoices == "") {
				aproductChoices += currProdChoice;
			}
			else {
				aproductChoices += ", " + currProdChoice;
			}
		}
	}
	
	if(aTP_Flag == "Y" && aSP_Flag == "N" && aOther_Flag == "N") {
		aFeithCategoryName = "TRADITIONAL_PRODUCT";
	}
	else if(aTP_Flag == "N" && aSP_Flag == "Y" && aOther_Flag == "N") {
		aFeithCategoryName = "STORAGE_PRODUCT";
	}
	else {
		aFeithCategoryName = "OTHER";
	}
	
	if(aproductChoices == "" && gValidForm == true) {
		alert("Please select your product choice.");
		document.getElementById("webForm").productChoice[0].focus();
		gValidForm = false;
	}
	
	var atimeFrame = "";
	for(var i=0;i<document.getElementById("webForm").timeFrame.length;i++) {
		if(document.getElementById("webForm").timeFrame[i].checked == true) {
			atimeFrame = document.getElementById("webForm").timeFrame[i].value;
		}
	}
	
	if(atimeFrame == "" && gValidForm == true) {
		alert("Please select when you need your WS product.");
		document.getElementById("webForm").timeFrame[0].focus();
		gValidForm = false;
	}
	
	
	var aIndustry = "";
	for(var i=0;i<document.getElementById("webForm").industry.length;i++) {
		if(document.getElementById("webForm").industry[i].checked == true) {
			if(aIndustry == "") {
				aIndustry += document.getElementById("webForm").industry[i].value;
			}
			else {
				aIndustry += ", " + document.getElementById("webForm").industry[i].value;
			}
		}
	}
	
	if(aIndustry == "" && gValidForm == true) {
		alert("Please select your industry.");
		document.getElementById("webForm").industry[0].focus();
		gValidForm = false;
	}
	
	if(gValidForm == true) {
		document.getElementById("theproductChoice").value = aproductChoices;
		document.getElementById("theFeithCatName").value = aFeithCategoryName;
		document.getElementById("thetimeFrame").value = atimeFrame;
		document.getElementById("theIndustry").value = aIndustry;
		if(document.getElementById("formSubmitBtnFlag").value == "N") {
			document.getElementById("requestQuoteBtn").disabled = true;
			document.getElementById("formSubmitBtnFlag").value = "Y";
			document.getElementById("webForm").submit();
		}
	}
	else {
		return false;
	}
}
