var AppointmentFor= new Array("Private Estate","Dawn Meadows Upright","Dawn Meadow Sigles",
					"Garden of Comfort II","Pilgrimage Lawn","Mission Terrace",
					"Guadalupe Terrace", "South View Lawn","Mausoleum","Cremation Property",
					"Comming Soon");					
var ErrorMsg="";
var NoOfTrial=0;
function OnComment_Click() {
	defValue=window.document.form1.txtAppText.value;
	curValue=window.document.form1.txtcomments.value;
	if(curValue==defValue) {
		window.document.form1.txtcomments.value="";
	}	
}
function isEmpty(str) {
   if(str == null || str == "")  {
   return true; };
}
function Test()
{
	//if (isEmpty(window.document.form1.txtfirstname.value))
	//curValue=window.document.form1.txtfirstname.value;
	//if(isEmpty(curValue)) {
		//window.document.form1.txtfirstname.value="HI";
		//return false;
	//}	
	return ValidateFirstName();
	
}
function Validate()
{	
	//if (isEmpty(window.document.form1.CalledBy.value)) //If the page is not called from the GPL
	{	
		//if(window.document.form1.Subject.value!="12" && window.document.form1.Subject.value!="11")
		{
			//return ValidateFirstName();
		}		
		if(window.document.form1.lstSubject.value=="11")
		{
			return ValidateForGPL();
		}
		else if(window.document.form1.lstSubject.value=="12")
		{
			return ValidateForPTF();
		}
		else if(window.document.form1.lstSubject.value=="13")
		{
			return ValidateForAppointment();
		}
		else if(window.document.form1.lstSubject.value=="14")
		{
			return ValidateForAppointment();
		}	
		else
		{
			return ValidateMain();
		}	
	}
	//else
	{	
		//return ValidateForGPL();		
	}	
}
function ValidateFirstName(){
	if (isEmpty(window.document.form1.txtfirstname.value))
	{
		ErrorMsg+="You must enter your first name!\n";				
		window.document.form1.txtfirstname.focus();
		return false;
	}
	return true;
}
function ValidateLastName() {
	if (isEmpty(window.document.form1.txtlastname.value))
	{
		ErrorMsg+="You must enter your last name!\n";				
		window.document.form1.txtlastname.focus();
		return false;
	}
	return true;
}
function ValidateContactMethod() {
	if (isEmpty(window.document.form1.lstContactMethod.value))
	{
		ErrorMsg+="You must choose one contact method!\n";				
		window.document.form1.lstContactMethod.focus();
		return false;
	}
	else
	{
		if(window.document.form1.lstContactMethod.value=="1") //E-mail is Selected
		{
			if(ValidateEmail())
			{
				if(ValidateConfirmEmail())
					{
						return VerifyEmail();						
					}
					else
					{
						return false;
					}
					
			}
			else
			{
				return false;
			}
		}
		else if(window.document.form1.lstContactMethod.value=="2")
		{
			if(!ValidateTelephone())
			{
				return false;
			}
			else
			{
				return true;
			}
		}
		else if(window.document.form1.lstContactMethod.value=="3")
		{
			if(!ValidateFax())
			{
				return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			var bvalid=ValidateAddress();
			bvalid=bvalid && ValidateCity();
			bvalid=bvalid && ValidateState();
			bvalid=bvalid && ValidateZipCode();
			return bvalid;
		}
	}
	
	return true;
}
function ValidateAddress() {
	if (isEmpty(window.document.form1.txtAddress.value))
	{
		ErrorMsg+="You must enter the address!\n";				
		window.document.form1.txtAddress.focus();
		return false;
	}
	return true;
}
function ValidateCity() {
	if (isEmpty(window.document.form1.txtCity.value))
	{
		ErrorMsg+="You must enter the city name!\n";				
		window.document.form1.txtCity.focus();
		return false;
	}
	return true;
}
function ValidateState() {
	if (isEmpty(window.document.form1.lstState.value))
	{
		ErrorMsg+="You must choose the state name!\n";				
		window.document.form1.lstState.focus();
		return false;
	}
	return true;
}
function ValidateZipCode() {
	if (isEmpty(window.document.form1.txtZip.value))
	{
		ErrorMsg+="You must enter the zip code!\n";				
		window.document.form1.txtZip.focus();
		return false;
	}
	return true;
}
function ValidateEmail(){
	if (isEmpty(window.document.form1.txtemailAddress.value)){
		ErrorMsg+="You Need to Include your email address!\n";
		window.document.form1.txtemailAddress.focus();
		return false;
	}
	return true;
}
function ValidateConfirmEmail() {
	if (isEmpty(window.document.form1.txtemailAddressConfirm.value))
	{
		ErrorMsg+="You Need to confirm your email adress!\n";
		window.document.form1.txtemailAddressConfirm.focus();
		return false;
	}	
	return true;
}
function VerifyEmail() {
	if (window.document.form1.txtemailAddressConfirm.value !=window.document.form1.txtemailAddress.value)
	{
		ErrorMsg+="Your e-mail addresses do not match!\n";
		window.document.form1.txtemailAddressConfirm.focus();
		return false;
	}	
	return true;
}

function ValidateTelephone() {
	if (isEmpty(window.document.form1.txtTelephone.value))
	{
		ErrorMsg+="You must enter your telephone number!\n";				
		window.document.form1.txtTelephone.focus();
		return false;
	}
	return true;
}
function ValidateFax() {
	if (isEmpty(window.document.form1.txtFax.value))
	{
		ErrorMsg+="You must enter your fax number!\n";				
		window.document.form1.txtFax.focus();
		return false;
	}
	return true;
}
function ValidateCommentSubject() {
	if (isEmpty(window.document.form1.lstSubject.value))
	{
		ErrorMsg+="You must choose one comment subject!\n";				
		window.document.form1.lstSubject.focus();
		return false;
	}
	return true;
}
function ValidateComment() {
	if (isEmpty(window.document.form1.txtcomments.value))
	{
		ErrorMsg+="You must type some comments!\n";				
		window.document.form1.txtcomments.focus();
		return false;
	}
	return true;
}
function ValidateForGPL() {
	var bvalid=ValidateFirstName();
	bvalid=bvalid && ValidateLastName();
	bvalid=bvalid &&ValidateContactMethod();
	bvalid=bvalid &&ValidateZipCode();
	if(!bvalid)
	{
		alert(ErrorMsg);
		ErrorMsg="";
		bvalid=null;
		return false;
	}
	bvalid=null;
	return true;
}
function ValidateForPTF() {
	var bvalid=ValidateFirstName();
	bvalid=bvalid && ValidateLastName();
	bvalid=bvalid && ValidateContactMethod();
	bvalid=bvalid && ValidateZipCode();
	if(!bvalid)
	{
		alert(ErrorMsg);
		ErrorMsg="";
		bvalid=null;
		return false;
	}
	bvalid=null;
	return true;
}
function ValidateForAppointment() {
	var strAppMsg;
	var defValue;
	//NoOfTrial++;	
	//window.alert(window.document.form1.comments.value);
	//strAppMsg="Appointment For Property:" + AppointmentFor[1];
	//if(NoOfTrial==1) {
	//	window.document.form1.comments.value=strAppMsg + "\n" +  defValue;
	//}
	//window.alert(window.document.form1.comments.value);	
	return ValidateForPTF();
}
function ValidateMain() {
	var bvalid=ValidateFirstName();
	bvalid=bvalid && ValidateLastName();
	bvalid=bvalid && ValidateContactMethod();
	bvalid=bvalid && ValidateCommentSubject();
	bvalid=bvalid && ValidateComment();
	//if(!(ValidateFirstName() && ValidateLastName() && ValidateContactMethod() && ValidateCommentSubject()))
	if(!bvalid)
	{
		alert(ErrorMsg);
		ErrorMsg="";
		bvalid=null;
		return false;
	}
	bvalid=null;
	return true;
}
function SelectEmail() {
	window.document.form1.lstContactMethod.selectedIndex=1;
}
function LableColor(str){
	if(str=="Error")
	{
		return "#FF0000" ;// Red Color;
	}
	else
	{
		return ""; //Default Color;
	}
}
function ValidateMax(){
var ErrMsg;
		if (isEmpty(window.document.form1.firstname.value))
		{
			ErrMsg="You must enter your first name!\n";
//			window.document.form1.lblfirstname.color=LableColor("Error");
			//window.document.form1.lblfirstname.color= "#FF0000";
			//window.document.form1.firstname.focus();
			//return false;
		}
		if (isEmpty(window.document.form1.lastname.value))
		{
			ErrMsg+="You must enter your last name!\n";
			//window.document.form1.lastname.focus();
			//return false;
		}
		if (isEmpty(window.document.form1.Zip.value))
		{
			ErrMsg+="You must enter the zip code!\n";
			window.document.form1.Zip.focus();
			//return false;
		}
		if(window.document.form1.ContactMethod.value=="1")
		{
			alert("You Need to Include your email address!");
			return ValidateEmail();
			//return false;
		}			
		if(!isEmpty(ErrMsg))
		{
			//alert(window.document.form1.lblfirstname.size);
//			window.document.form1.lblfirstname.color=document.
			alert(ErrMsg);						
			return false;
		}		
		return false;
}

function ValidateMinimum(){
		if (isEmpty(window.document.form1.firstname.value))
		{
			alert("You must enter your first name!");
			window.document.form1.firstname.focus();
			return false;
		}
		if (isEmpty(window.document.form1.lastname.value))
		{
			alert("You must enter your last name!");
			window.document.form1.lastname.focus();
			return false;
		}
		if (isEmpty(window.document.form1.Zip.value))
		{
			alert("You must enter the zip code!");
			window.document.form1.Zip.focus();
			return false;
		}
		if(window.document.form1.ContactMethod.value=="1")
		{
			//alert("You Need to Include your email address!");
			return ValidateEmail();
			//return false;
		}		
		return true;
}