/*
	Author:				Kathy Gannon
	Date Created		3/10/2009
	Project:			B2B Redesign
	Name:				validateContactForm.js
*/

function ValidateContactForm(theForm) {

    if (theForm.refPage.value == "SHSMD") {
	   document.getElementById("option1").style.color = "#000000";
	   document.getElementById("option2").style.color = "#000000";
		if (!theForm.rptOption1.checked && !theForm.rptOption2.checked) {
		   alert("Please select at least one report option.");
		   theForm.rptOption1.focus();
		   document.getElementById("option1").style.color = "#990000";
		   document.getElementById("option2").style.color = "#990000";
		   return false;}	
	}		
  
	if (theForm.first_name.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your First Name.");
		theForm.first_name.focus();
		return false;} 

	if (theForm.last_name.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your Last Name.");
		theForm.last_name.focus();
		return false;}

	if (theForm.refPage.value != "CercLogin") {
		if (theForm.company.value.replace(/[ ]/g, "").length == 0)
		   {alert("Please enter your " + companyTitle +".");
			theForm.company.focus();
			return false;}
		}

    if (theForm.job_function.selectedIndex == 0)		
	   {alert("Please select your Job Function.");
		theForm.job_function.focus();
		return false;}
		
	if (theForm.title.value.replace(/[ ]/g, "").length == 0 && theForm.refPage.value != "PreVisitPatient")
	   {alert("Please enter your Job Title.");
		theForm.title.focus();
		return false;}

    if (theForm.company_type.selectedIndex == 0)		
	   {alert("Please select your " + companyTitle +" Type.");
		theForm.company_type.focus();
		return false;}
		
	if (theForm.email.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your Email Address.");
		theForm.email.focus();
		return false;}	
		
	if (theForm.email.value.replace(/[ ]/g, "").length != 0) {
 		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value))
		  {alert("Invalid Email Address, please re-enter.");
		   theForm.email.focus();
		   return false;} 
		}
					
	if (theForm.phone.value.replace(/[ ]/g, "").length == 0 && theForm.refPage.value != "PreVisitPatient")
	   {alert("Please enter your Phone Number.");
		theForm.phone.focus();
		return false;}	
		
	if (theForm.city.value.replace(/[ ]/g, "").length == 0 && theForm.refPage.value != "PreVisitPatient")
	   {alert("Please enter your City.");
		theForm.city.focus();
		return false;}	
		
    if (theForm.state.selectedIndex == 0)		
	   {alert("Please select your State.");
		theForm.state.focus();
		return false;}
		
	if (theForm.zip.value.replace(/[ ]/g, "").length == 0 && theForm.refPage.value != "PreVisitPatient")
	   {alert("Please enter your Zip code.");
		theForm.zip.focus();
		return false;}	

    if (theForm.refPage.value == "marketingRatingsSignin") {
		if (theForm.seccode.value.replace(/[ ]/g, "").length == 0)
		   {alert("Please enter your Customer Code.");
			theForm.seccode.focus();
			return false;}	
	}		
   return true;		
   }		

function resetForm() {
  document.contactUs.reset();
}

function ValidateNotifyForm(theForm) {
	if (theForm.first_name.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your First Name.");
		theForm.first_name.focus();
		return false;} 

	if (theForm.last_name.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your Last Name.");
		theForm.last_name.focus();
		return false;}

	if (theForm.email.value.replace(/[ ]/g, "").length == 0) {
	    alert("Please enter your Email Address.");
		theForm.email.focus();
		return false;}	
		
	if (theForm.email.value.replace(/[ ]/g, "").length != 0) {
 		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value)) {
		   alert("Invalid Email Address, please re-enter.");
		   theForm.email.focus();
		   return false;} 
		}
		
   if (theForm.confirm_email.value.replace(/[ ]/g, "").length == 0)
      {alert("Please re-enter your Email Address.");
	   theForm.confirm_email.focus();
	   return false;}		

   if (theForm.email.value != theForm.confirm_email.value)
      {alert("Your email and re-typed email do not match.  Please re-enter.");
	   theForm.email.focus();
	   return false;}			
}

function ValidateSubForm(theForm) {
	if (theForm.first_name.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your First Name.");
		theForm.first_name.focus();
		return false;} 

	if (theForm.last_name.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your Last Name.");
		theForm.last_name.focus();
		return false;}

	if (theForm.email.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your Email Address.");
		theForm.email.focus();
		return false;}	
		
	if (theForm.email.value.replace(/[ ]/g, "").length != 0) {
 		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value))
		  {alert("Invalid Email Address, please re-enter.");
		   theForm.email.focus();
		   return false;} 
		}
   return true;		
}
function ValidateMRSignup(theForm) {
	if (theForm.email.value.replace(/[ ]/g, "").length == 0)
	   {alert("Please enter your Email Address.");
		theForm.email.focus();
		return false;}	
		
	if (theForm.email.value.replace(/[ ]/g, "").length != 0) {
 		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value))
		  {alert("Invalid Email Address, please re-enter.");
		   theForm.email.focus();
		   return false;} 
		}

	if(theForm.sendemail.value == "N") {
		if (theForm.seccode.value.replace(/[ ]/g, "").length == 0)
		   {alert("Please enter your Customer Code.");
			theForm.seccode.focus();
			return false;}	
			
	    if (!theForm.UserAgreement.checked)
		   {alert("You must agree to the user agreement");
			return false; }
	}
		
   return true;		
}
function toggleMessage(display) {
	document.getElementById("messageBox").style.display = display;
}
function mailCode() {
	document.signin.sendemail.value = "Y";
	document.signin.submit();
}