
var contactTypeChecked = 0;

function checkForm(){
	
	var errorCheck = 0;
	var errorMessage = "";
	
/*
	if(document.formMain.comments.value == "" ){
		errorMeassage="Please enter a message."
		errorCheck = 1;
	}
*/

	if(document.formMain.topic.selectedIndex == 2 &&  document.formMain.topic.options.length ==7){
		
		if(document.formMain.zip.value == "" ){
			errorMeassage="Please enter a zip code."
			errorCheck = 1;
		}
		if(document.formMain.city.value == "" ){
			errorMeassage="Please enter a city."
			errorCheck = 1;
		}
		if(document.formMain.address.value == "" ){
			errorMeassage="Please enter a streeet address."
			errorCheck = 1;
		}
		
		
		
		
	}
	

	//-- check if the email address is in the proper format
	if(document.formMain.email.value.indexOf("@")==-1 || document.formMain.email.value.indexOf(".")==-1){
		errorCheck = 1;
		errorMeassage="Please enter a valid email address."
	}else{
		if(document.formMain.email.value.indexOf("@") > document.formMain.email.value.lastIndexOf(".")){
			errorCheck = 1;
			errorMeassage="Please enter a valid email address."
		}
	}
	
	
	if(document.formMain.firstName.value == "" || document.formMain.lastName.value==""){
		errorMeassage="Please enter a first and last name."
		errorCheck = 1;
	}

	if(document.formMain.phone.value.length > 0 && document.formMain.phone.value.length != 10){
						errorMeassage="The phone number is not formatted correctly, please enter only 10 digits, no dashes, spaces or other characters."
						errorCheck = 1;
					}

	/*
	if(document.formMain.topic.selectedIndex == 0 ){
		errorMeassage="Please select a topic."
		errorCheck = 1;
	}
	*/

	if(contactTypeChecked == 0){
		errorMeassage="Please select a topic."
		errorCheck = 1;
	}

	
	if(errorCheck == 1){
		alert(errorMeassage)
	}else{
		document.formMain.submit();
	}
}

uType=0;

function userType(ut){
	contactTypeChecked = 0;
	uType=ut;
	if(ut == 1){
		document.getElementById("custChoices").style.height="0";
		document.getElementById("custChoices").style.visibility="hidden";
		document.getElementById("nonCustChoices").style.position="relative";
		document.getElementById("nonCustChoices").style.height="40";
		document.getElementById("nonCustChoices").style.visibility="visible";
		
		
	/*
		document.formMain.topic.options[3] = null
		document.formMain.topic.options[2] = null
		document.formMain.topic.options[1] = null
		
		var option1 = new Option("I would like to build a new home and need more information.", "Sales Inquiry")
		document.formMain.topic.options[1] = option1
		
		var option2 = new Option(" I would like to comment about my experience with Tilson Homes", "Tilson Comment")
		document.formMain.topic.options[2] = option2
		
		var option3 = new Option( " I have a warranty request.", "Warranty Request")
		document.formMain.topic.options[3] = option3
		*/

		
	}else{
				document.getElementById("nonCustChoices").style.height="0";
				document.getElementById("nonCustChoices").style.visibility="hidden";
				document.getElementById("custChoices").style.position="relative";
				document.getElementById("custChoices").style.height="40";
		document.getElementById("custChoices").style.visibility="visible";
		
		
		/*
		document.formMain.topic.options[3] = null
		document.formMain.topic.options[2] = null
		document.formMain.topic.options[1] = null
		
		

		var option1 = new Option( "I am looking to build a new home and need more information.", "Online Sales Counselor")
		document.formMain.topic.options[1] = option1
		

		var option2 = new Option("I am having trouble logging into my portfolio or would like to report a problem with the website. ", "Website Request")
		document.formMain.topic.options[2] = option2
		
		var option3 = new Option( "I would like more information about working for Tilson Homes.", "Employment Information")
		document.formMain.topic.options[3] = option3
		*/

		
	}

		document.getElementById("salesQuestions").style.position="absolute";
		document.getElementById("salesQuestions").style.visibility="hidden";
		//document.getElementById("salesQuestions").style.height="0";
		//document.getElementById("salesQuestions").style.width="0";
	
	
}

function checkContactType(contactType){
	contactTypeChecked =1
	//if(document.formMain.topic.selectedIndex == 1 && uType==0){
	if(contactType == 1){
		document.getElementById("salesQuestions").style.position="relative";
		document.getElementById("salesQuestions").style.visibility="visible";
		document.getElementById("salesQuestions").style.height="650";
		document.getElementById("salesQuestions").style.width="700";
		
	}else{
		document.getElementById("salesQuestions").style.position="absolute";
		document.getElementById("salesQuestions").style.visibility="hidden";
		//document.getElementById("salesQuestions").style.height="0";
		//document.getElementById("salesQuestions").style.width="0";
		
	}
}





