function testForms(paxnum)
{
    var lo_BirthDateField; 

	//top form validation
    if(document.consumer.prefix){
    	if (document.consumer.prefix.selectedIndex == 0)
        {
        alert("Please enter a valid prefix.  (Mr,Mrs,Ms,Miss,Dr,Rev,Capt)");
        document.consumer.prefix.focus();
        return;
        } 
    } 
    
    
    //contains new validation for first and last names
    if(document.consumer.fname){
        if (document.consumer.fname.value == "") {
            alert("Please enter your first name.");
            document.consumer.fname.focus();
            return;
        } else if (!isAlphaOnly(document.consumer.fname.value)) {
            alert("First name is not valid."); 
            document.consumer.fname.focus();
            return; 
        } 
    }
    
    if(document.consumer.lname){    
        if (document.consumer.lname.value == "") {
            alert("Please enter your last name.");
            document.consumer.lname.focus();
            return;
        } else if (!isAlphaOnly(document.consumer.lname.value)) {
            alert("Last name is not valid.");
            document.consumer.lname.focus();
            return;
        }
    }
    //end new validation
   
    
    if (document.consumer.addr1.value == "")
    {
    alert("Please enter your address.");
    document.consumer.addr1.focus();
    return;
    }
    if (document.consumer.addr1.value.length > 25)
    {
    alert("Please limit your street address to 25 characters.  Use abbreviations where possible.");
    document.consumer.addr1.focus();
    return;
    }
    if (document.consumer.addr2.value.length > 25)
    {
    alert("Please limit your street address to 25 characters.  Use abbreviations where possible.");
    document.consumer.addr2.focus();
    return;
    }
    if (document.consumer.city.value == "")
    {
    alert("Please enter your city.");
    document.consumer.city.focus();
    return;
    }
	
    if (document.consumer.city.value.length > 20)
    {
    alert("Please limit your city name to 20 characters.");
    document.consumer.city.focus();
    return;
    }
	
	if (verify_cityname(document.consumer.city.value) < 0) 
	{
		alert("City name cannot include numbers. Please re-enter city name.");
		document.consumer.city.focus();
		return;
	}
	
    if (document.consumer.state.value == "")
    {
    alert("Please enter your state.");
    document.consumer.state.focus();
    return;
    }
    if ((document.consumer.zip.value.replace(' ','').length != 5) || isNaN(document.consumer.zip.value))
    {
    alert("Please enter your 5 digit zip code.");
    document.consumer.zip.focus();
    return;
    }

	homearea = document.consumer.hcode.value;
	homephone = document.consumer.hexchange.value + document.consumer.hnumber.value;

	homearea = homearea.replace(' ', '')
	homephone = homephone.replace(' ', '')
	
	
    if ((document.consumer.hcode.value == "") || (homephone == "") || (homephone.length != 7)  || isNaN(homephone) || (homearea.length !=3) || isNaN(document.consumer.hcode.value))
	{
		alert("Please enter your phone number in the correct format (xxx xxx xxxx)");
		document.consumer.hcode.focus();
		return;
	}
	
	workarea = document.consumer.wacode.value;
	workphone = document.consumer.wexchange.value + document.consumer.wnumber.value;

	workarea = workarea.replace(' ', '')
	workphone = workphone.replace(' ', '')
	
	if ((workarea != "") || (workphone != ""))
	{ 
       if ((workarea == "") || (workphone == "") || (workphone.length != 7)  || isNaN(workphone) || (workarea.length !=3) || isNaN(document.consumer.wacode.value))
	   {
		  alert("Please enter your phone number in the correct format (xxx xxx xxxx)");
		  document.consumer.wacode.focus();
		  return;
	   }
	}
	
	if (document.consumer.email)
    {
    	if (verify_email(document.consumer.email.value) < 0) 
    	{
    		alert("Please enter a valid e-mail address.");
    		document.consumer.email.focus();
    
    		return;
    	}
	}
    
    if (document.consumer.paxEmailAddress)
    {
    	if (paxnum == 1)
        {
        
            if (verify_email(document.consumer.paxEmailAddress.value) < 0) 
        	{
        		alert("Please enter a valid e-mail address.");
        		document.consumer.paxEmailAddress.focus();
        
        		return;
        	}
        }
        else
        {
            if (verify_email(document.consumer.paxEmailAddress[0].value) < 0) 
        	{
        		alert("Please enter a valid e-mail address.");
        		document.consumer.paxEmailAddress[0].focus();
        
        		return;
        	}
        }            
	}

	    //Validate pax info
		for (i=0; i<paxnum; i++)
		{
			j = i + 1;

            if (paxnum == 1){
            
                if (document.consumer.passPrefix.selectedIndex == 0)
                {
                    alert("Please enter a valid prefix.  (Mr,Mrs,Ms,Miss,Dr,Rev,Capt)");
                    document.consumer.passPrefix.focus();
                    return;
                }		
				if (document.consumer.Fnamepax.value == "")
				{
					alert("Please enter the passenger first name.");
					document.consumer.Fnamepax.focus();
					return;
				}
				else if (document.consumer.Fnamepax.value.length < 2)
				{
					alert("Please enter a valid first name, longer then 1 letter.");
					document.consumer.Fnamepax.focus();
					return;
				}
				else if (document.consumer.Fnamepax.value.indexOf("-") != -1)
				{
					alert("First name cannot contain a -. Please simply leave a space.");
					document.consumer.Fnamepax.focus();
					return;
			    }				
				else if (document.consumer.Fnamepax.value.indexOf("&") != -1)
				{
					alert("First name cannot contain a &. Please enter passenger's first name only.");
					document.consumer.Fnamepax.focus();
					return;
			    }	
				if (document.consumer.Lnamepax.value == "")
				{
					alert("Please enter the passenger last name.");
					document.consumer.Lnamepax.focus();
					return;
				}
				else if (document.consumer.Lnamepax.value.length < 2)
				{
					alert("Please enter a valid last name, longer than 1 letter.");
					document.consumer.Lnamepax.focus();
					return;
				}
				else if (document.consumer.Lnamepax.value.indexOf("-") != -1)
				{
					alert("Last name cannot contain a -. Please simply leave a space.");
					document.consumer.Lnamepax.focus();
					return;
			    }
				
				// The Drop Down now defaults to US, no need to validate
				//if (document.consumer.citzcountrycode.selectedIndex == 0)
				//{
				//	alert("Please select a country of citizenship.");
				//	document.consumer.citzcountrycode.focus();
				//	return;
			   // } 	 
            }
			
            else
            {
                                               
                if (document.consumer.passPrefix[i].selectedIndex == 0)
                {
                    alert("Please enter a valid prefix.  (Mr,Mrs,Ms,Miss,Dr,Rev,Capt)");
                    document.consumer.passPrefix[i].focus();
                    return;
                }	
				if (document.consumer.Fnamepax[i].value == "")
				{
					alert("Please enter the passenger first name.");
					document.consumer.Fnamepax[i].focus();
					return;
				}

				else if (document.consumer.Fnamepax[i].value.length < 2)
				{
					alert("Please enter a valid first name, longer then 1 letter.");
					document.consumer.Fnamepax[i].focus();
					return;
                } else if (!isAlphaOnly(document.consumer.Fnamepax[i].value)) {
                    alert("Passenger " + (i + 1) + " first name is not valid."); 
                    document.consumer.Fnamepax[i].focus();
                    return; 
                }                
                else if (document.consumer.Fnamepax[i].value.indexOf("-") != -1)
				{
					alert("First name cannot contain a -. Please simply leave a space.");
					document.consumer.Fnamepax[i].focus();
					return;
			    }				
				
				if (document.consumer.Lnamepax[i].value == "")
				{
					alert("Please enter the passenger last name.");
					document.consumer.Lnamepax[i].focus();
					return;				
				} else if (document.consumer.Lnamepax[i].value.length < 2) {
					alert("Please enter a valid last name, longer than 1 letter.");
					document.consumer.Lnamepax[i].focus();
					return;
				} else if (!isAlphaOnly(document.consumer.Lnamepax[i].value)) {
                    alert("Passenger " + (i + 1) + " last name is not valid."); 
                    document.consumer.Lnamepax[i].focus();
                    return; 
                } 
                else if (document.consumer.Lnamepax[i].value.indexOf("-") != -1)
				{
					alert("Last name cannot contain a -. Please simply leave a space.");
					document.consumer.Lnamepax[i].focus();
					return;
			    }				
				
                // The Drop Down now defaults to US, no need to validate
				//if (document.consumer.citzcountrycode[i].selectedIndex == 0)
				//{
				//	alert("Please select a country of citizenship.");
				//	document.consumer.citzcountrycode[i].focus();
				//	return;
			   // } 	 
            }
            
               
			if (j == 1)
			{
				lo_BirthDateField = document.consumer.birthdate1;
			}
			else if ( j == 2 ) 
			{
				lo_BirthDateField = document.consumer.birthdate2;
			}
			else if ( j == 3 ) 
			{
				lo_BirthDateField = document.consumer.birthdate3;
			}
			else if ( j == 4 ) 
			{
				lo_BirthDateField = document.consumer.birthdate4;
			}
			else if ( j == 5 ) 
			{
				lo_BirthDateField = document.consumer.birthdate5;
			}

			birthdate = lo_BirthDateField.value;
            
            // Make sure birthday has at least 2 slashes in the date
			if (!containsOnlyTwoSlashes(birthdate))
				{
					alert("Please enter a valid date of birth in the form of mm/dd/yyyy.");

					setFocusToField(lo_BirthDateField);
					return;
				}
				
			if (birthdate.length != 10)
				{
					alert("Please enter a valid date of birth in the form of mm/dd/yyyy.");
					
					setFocusToField(lo_BirthDateField);
					return;
				}
			
			if (!isValidMonth(birthdate))
				{
					alert("Please enter a valid date of birth in the form of mm/dd/yyyy.");
					
					setFocusToField(lo_BirthDateField);
					return;
				}
				
			if (!isValidDayOfMonth(birthdate))
				{
					alert("Please enter a valid date of birth in the form of mm/dd/yyyy.");
					
					setFocusToField(lo_BirthDateField);
					return;
				}

			if (!isValidYear(birthdate))
				{
					alert("Please enter a valid date of birth in the form of mm/dd/yyyy.");
					
                    setFocusToField(lo_BirthDateField);
					return;
				}

            if (!isDateInPast(birthdate)){            
                    alert("Please enter a valid date of birth in the form of mm/dd/yyyy.");
					
                    setFocusToField(lo_BirthDateField);
					return;            
            }	
            
            if (isCheckBoxSelected(document.consumer.addToMailingList,i))
            {        
                if (i==0)
                {
                    if (verify_email(document.consumer.paxEmailAddress.value) < 0) 
                    {
                    alert("Please enter a valid e-mail address.");
                    document.consumer.paxEmailAddress.focus();
                    
                    return;
                    }   
                }
                else
                {         
                    if (verify_email(document.consumer.paxEmailAddress[i].value) < 0) 
                    {
                    alert("Please enter a valid e-mail address.");
                    document.consumer.paxEmailAddress[i].focus();
                    
                    return;
                    }                
                }
            }	
		}// end for
		
 
	document.consumer.submit();
	EntirePage.style.display = "none";
	WaitPage.style.display = "block";
	doc = window.document;
	SubmitFormSP(doc);
	
}



//THIS IS A SEPERATE VALIDATIOIN FUNCTION FOR ORBITZ ------------------------------------------
function testForms_OR(paxnum)
{

	//top form validation
    if(document.consumer.prefix){
    	if (document.consumer.prefix.selectedIndex == 0)
        {
        alert("Please enter a valid prefix.  (Mr,Mrs,Ms,Miss,Dr,Rev,Capt)");
        document.consumer.prefix.focus();
        return;
        } 
    }
    
    if(document.consumer.fname){
        if (document.consumer.fname.value == "")
        {
        alert("Please enter your first name.");
        document.consumer.fname.focus();
        return;
        } 
		if (document.consumer.fname.value.indexOf("&") != -1)
        {
        alert("First name cannot contain an &, Please enter your first name only.");
        document.consumer.fname.focus();
        return;
        } 
    }
    
    if(document.consumer.lname){    
        if (document.consumer.lname.value == "")
        {
        alert("Please enter your last name.");
        document.consumer.lname.focus();
        return;
        }
    }
    // The Drop Down now defaults to US, no need to validate
	//if (document.consumer.citzcountrycode.selectedIndex == 0)
	//{
	//  alert("Please select a country of citizenship.");
	//  document.consumer.citzcountrycode.focus();
	//  return;
   // } 	 
    
    if (document.consumer.addr1.value == "")
    {
    alert("Please enter your address.");
    document.consumer.addr1.focus();
    return;
    }
    if (document.consumer.addr1.value.length > 25)
    {
    alert("Please limit your street address to 25 characters.  Use abbreviations where possible.");
    document.consumer.addr1.focus();
    return;
    }
    if (document.consumer.addr2.value.length > 25)
    {
    alert("Please limit your street address to 25 characters.  Use abbreviations where possible.");
    document.consumer.addr2.focus();
    return;
    }
    if (document.consumer.city.value == "")
    {
    alert("Please enter your city.");
    document.consumer.city.focus();
    return;
    }
    if (document.consumer.city.value.length > 20)
    {
    alert("Please limit your city name to 20 characters.");
    document.consumer.city.focus();
    return;
    }
	if (verify_cityname(document.consumer.city.value) < 0) 
	{
		alert("City name cannot include numbers. Please re-enter city name.");
		document.consumer.city.focus();
		return;
	}
    if (document.consumer.state.value == "")
    {
    alert("Please enter your state.");
    document.consumer.state.focus();
    return;
    }
    if ((document.consumer.zip.value.replace(' ','').length != 5) || isNaN(document.consumer.zip.value))
    {
    alert("Please enter your 5 digit zip code.");
    document.consumer.zip.focus();
    return;
    }

	homearea = document.consumer.hcode.value;
	homephone = document.consumer.hexchange.value + document.consumer.hnumber.value;
	
    if (document.consumer.hcode.value == "" || homephone == "" || homephone.length != 7  || isNaN(homephone) || homearea.length !=3 || isNaN(document.consumer.hcode.value))
	{
		alert("Please enter your phone number in the correct format (xxx xxx xxxx)");
		document.consumer.hcode.focus();
		return;
	}
	
	workarea = document.consumer.wacode.value;
	workphone = document.consumer.wexchange.value + document.consumer.wnumber.value;

	workarea = workarea.replace(' ', '')
	workphone = workphone.replace(' ', '')
	
	if ((workarea != "") || (workphone != ""))
	{ 
       if ((workarea == "") || (workphone == "") || (workphone.length != 7)  || isNaN(workphone) || (workarea.length !=3) || isNaN(document.consumer.wacode.value))
	   {
		  alert("Please enter your phone number in the correct format (xxx xxx xxxx)");
		  document.consumer.wacode.focus();
		  return;
	   }
	}
	
	if (document.consumer.email.value == "")
    {
        alert("Please enter your Email Address.");
        document.consumer.email.focus();
        return;
    }
	
	if (verify_email(document.consumer.email.value) < 0) 
	{
		alert("Please enter a valid e-mail address.");
		document.consumer.email.focus();

		return;
	}
	

	    //Validate pax info
		for (i=0; i<paxnum; i++)
		{
			j = i + 1;
            if (paxnum == 1){
            
                if (document.consumer.passPrefix.selectedIndex == 0)
                {
                    alert("Please enter a valid prefix.  (Mr,Mrs,Ms,Miss,Dr,Rev,Capt)");
                    document.consumer.passPrefix.focus();
                    return;
                }		
				if (document.consumer.Fnamepax.value == "")
				{
					alert("Please enter the additional passenger names.");
					document.consumer.Fnamepax.focus();
					return;
				}
				else if (document.consumer.Fnamepax.value.length < 2)
				{
					alert("Please enter a valid first name, longer then 1 letter.");
					document.consumer.Fnamepax.focus();
					return;
				}
				else if (document.consumer.Fnamepax.value.indexOf("-") != -1)
				{
					alert("First name cannot contain a -. Please simply leave a space.");
					document.consumer.Fnamepax.focus();
					return;
			    }				
				else if (document.consumer.Fnamepax.value.indexOf("&") != -1)
				{
					alert("First name cannot contain a &. Please enter Passnger's first name only.");
					document.consumer.Fnamepax.focus();
					return;
			    }
				if (document.consumer.Lnamepax.value == "")
				{
					alert("Please enter the additional passenger names.");
					document.consumer.Lnamepax.focus();
					return;
					
					
				}
				else if (document.consumer.Lnamepax.value.length < 2)
				{
					alert("Please enter a valid last name, longer than 1 letter.");
					document.consumer.Lnamepax.focus();
					return;
				}
				else if (document.consumer.Lnamepax.value.indexOf("-") != -1)
				{
					alert("Last name cannot contain a -. Please simply leave a space.");
					document.consumer.Lnamepax.focus();
					return;
			    }
            }
            else
            {
                //---prefix validation
                if (document.consumer.passPrefix[i].selectedIndex == 0)
                {
                    alert("Please enter a valid prefix.  (Mr,Mrs,Ms,Miss,Dr,Rev,Capt)");
                    document.consumer.passPrefix[i].focus();
                    return;
                }		
                
                //---first name validation
				if (document.consumer.Fnamepax[i].value == "")
				{
					alert("Please enter the additional passenger names.");
					document.consumer.Fnamepax[i].focus();
					return;
				} else if (document.consumer.Fnamepax[i].value.length < 2) {
					alert("Please enter a valid first name, longer then 1 letter.");
					document.consumer.Fnamepax[i].focus();
					return;
				} else if (!isAlphaOnly(document.consumer.Fnamepax[i].value)) {
                    alert("Passenger " + i + " first name is not valid."); 
                    document.consumer.Fnamepax[i].focus();
                    return; 
                } 
                
                //---the code below was consolodated into one statement above
                //---to coincide with an apparent rule change
				//else if (document.consumer.Fnamepax[i].value.indexOf("-") != -1)
				//{
				//	alert("First name cannot contain a -. Please simply leave a space.");
				//	document.consumer.Fnamepax[i].focus();
				//	return;
			    //}				
				//	else if (document.consumer.Fnamepax[i].value.indexOf("&") != -1)
				//{
				//	alert("First name cannot contain a &. Please enter passenger's first name only.");
				//	document.consumer.Fnamepax[i].focus();
				//	return;
			    //}	
                
                //---last name validation
				if (document.consumer.Lnamepax[i].value == "")
				{
					alert("Please enter the additional passenger names.");
					document.consumer.Lnamepax[i].focus();
					return;					
				} else if (document.consumer.Lnamepax[i].value.length < 2) {
					alert("Please enter a valid last name, longer than 1 letter.");
					document.consumer.Lnamepax[i].focus();
					return;
                } else if (!isAlphaOnly(document.consumer.Lnamepax[i].value)) {
                    alert("Passenger " + i + " last name is not valid."); 
                    document.consumer.Lnamepax[i].focus();
                    return; 
                } 
				//else if (document.consumer.Lnamepax[i].value.indexOf("-") != -1)
				//{
				//	alert("Last name cannot contain a -. Please simply leave a space.");
				//	document.consumer.Lnamepax[i].focus();
				//	return;
			    //}                
                
                //---countrycode validation
                // The Drop Down now defaults to US, no need to validate
				//if (document.consumer.citzcountrycode[i].selectedIndex == 0)
				//{
				//	alert("Please select a country of citizenship.");
				//	document.consumer.citzcountrycode[i].focus();
				//	return;
			   // } 	 
            }
            
                
			if (j == 1)
			{
				birthdate = document.consumer.birthdate1.value;
			}
			else if ( j == 2 ) 
			{
				birthdate = document.consumer.birthdate2.value;
			}
			else if ( j == 3 ) 
			{
				birthdate = document.consumer.birthdate3.value;
			}
			else if ( j == 4 ) 
			{
				birthdate = document.consumer.birthdate4.value;
			}
			else if ( j == 5 ) 
			{
				birthdate = document.consumer.birthdate5.value;
			}
			
			
			
			var returnString = "";
			var p;
			var bag;
			var slashcount = 0;
			bag = "/";

			for (p = 0; p < birthdate.length; p++)
				{   
				 // Check that current character isn't whitespace.
				var c = birthdate.charAt(p);
				if (bag.indexOf(c) == -1){
					returnString += c;
					}
				else{
					slashcount = slashcount + 1;
					}
				
				}
				
			if (slashcount != 2 )
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}
				
			//alert(slashcount);
			//alert(returnString);
			if (isNaN(returnString))
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy.");
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
					
				}
			if (returnString.length != 8)
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}

			var monthstring, daystring, yearstring
			monthstring = returnString.charAt(0) + returnString.charAt(1);
			daystring = returnString.charAt(2) + returnString.charAt(3);
			yearstring = returnString.charAt(4) + returnString.charAt(5) + returnString.charAt(6) + returnString.charAt(7) ;
			
			if (monthstring < 1 || monthstring > 12)
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}
				
			if ((monthstring == 1 || monthstring == 3 || monthstring == 5 || monthstring == 7 || monthstring == 8 || monthstring == 10 || monthstring == 12) && (daystring < 1 || daystring > 31))
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}
			
			if ((monthstring == 2) && (daystring < 1 || daystring > 29))
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}
			
			if ((monthstring == 4 || monthstring == 6 || monthstring == 9 || monthstring == 11) && (daystring < 1 || daystring > 30))
				{
					alert("Please enter a valid birthdate. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}
			
			if (yearstring < 1900 || yearstring > 2500)
				{
					alert("Please enter a valid year. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;
				}

            //Since birthdate was validated in previous lines of code we can assume the date from the 
            //input box to is valid to compare against the current date
            ld_CurrentDate = new Date();
            ld_BirthDate = new Date(yearstring, monthstring-1, daystring);

            if (ld_BirthDate > ld_CurrentDate){            
                    alert("Please enter a valid year. In the form mm/dd/yyyy. Such as 02/08/1965.");
					
					if ( j == 1 ) 
					{
					document.consumer.birthdate1.focus();
					}
					else if ( j == 2 ) 
					{
					document.consumer.birthdate2.focus();
					}
					else if ( j == 3 ) 
					{
					document.consumer.birthdate3.focus();
					}
					else if ( j == 4 ) 
					{
					document.consumer.birthdate4.focus();
					}
					else if ( j == 5 ) 
					{
					document.consumer.birthdate5.focus();
					}
					return;            
            }                
	            		
							
		}// end for
		
		if (document.consumer.table)
	{
		table = document.consumer.table.options[document.consumer.table.selectedIndex].value;
		if (table == "N")
		{
			alert("Please select a table size.");
			document.consumer.table.focus;
			return;
		}
	}
	
	document.consumer.submit();
	EntirePage.style.display = "none";
	WaitPage.style.display = "block";
	doc = window.document;
	SubmitFormSP(doc);
	
}
// END OF ORBITZ FORM VALILDATION ---------------------------------------------------------




//verify the phone number is a number
function verify_phone(phone)
{
	if (isNaN(phone.value))  
		{
			alert("Please enter a valid area code and phone number.");
			phone.focus();
			return -1;
		}
	return	1;
}

//verify no numbers are in city name
function verify_cityname(city)
{
   var invalidchars = "0123456789";
   for (i=0; i<invalidchars.length; i++)
	{
		badchar = invalidchars.charAt(i);
		if (city.indexOf(badchar,0) >= 0) 
		{
			return -1;
		}
	}
	return 1;
}

//verify the e-mail is a valid e-mail
function verify_email(email_address)
{
	var invalidchars = " /,;:";
    var i;
    
    if (email_address != "")
    {
    	for (i=0; i<invalidchars.length; i++)
    	{
    		badchar = invalidchars.charAt(i);
    		if (email_address.indexOf(badchar,0) >= 0) 
    		{
    			return -1;
    		}
    	}
    		
    	var atpos = email_address.indexOf("@",0);
    	if (atpos == -1) 
    	{
    		return -1;
    	}
    	
    	if (email_address.indexOf("@",atpos + 1) != -1) 
    	{
    		return -1;
    	}
    
    	var periodpos = email_address.indexOf(".",atpos);
    	if (periodpos == -1) 
    	{
    		return -1;
    	}
    	
    	if (periodpos + 3 > email_address.length) 
    	{
    		return -1;
    	}
	    return 1;
    }
    else
    {
        return -1;
    }        
}


function genderadd(paxnum)
{

    if (paxnum == 1)
		{

        if (document.consumer.passPrefix[0].selectedIndex != null){
            prefix = (document.consumer.passPrefix[0].options[document.consumer.passPrefix[0].selectedIndex].value)            
        }
        else
        {
            prefix = (document.consumer.passPrefix.options[document.consumer.passPrefix.selectedIndex].value)
        }

			if (prefix == "Ms") 
			{
				document.consumer.gender1[1].checked = true;
			}
			else if (prefix == "Mrs") 
			{
				document.consumer.gender1[1].checked = true;
			}
			else if (prefix == "Miss") 
			{
				document.consumer.gender1[1].checked = true;
			}
			else 
			{
				document.consumer.gender1[0].checked = true;
			}
		}
	
		if (paxnum == 2)
		{
            
            prefix = (document.consumer.passPrefix[1].options[document.consumer.passPrefix[1].selectedIndex].value)

			if (prefix == "Ms") 
			{
				document.consumer.gender2[1].checked = true;
			}
			else if (prefix == "Mrs") 
			{
				document.consumer.gender2[1].checked = true;
			}
			else if (prefix == "Miss") 
			{
				document.consumer.gender2[1].checked = true;
			}
			else 
			{
				document.consumer.gender2[0].checked = true;
			}                        
		}
        		
		
		if (paxnum == 3)
		{
			prefix2 = (document.consumer.passPrefix[2].options[document.consumer.passPrefix[2].selectedIndex].value)

			if (prefix2 == "Ms") 
			{
				document.consumer.gender3[1].checked = true;
			}
			else if (prefix2 == "Mrs") 
			{
				document.consumer.gender3[1].checked = true;
			}
			else if (prefix2 == "Miss") 
			{
				document.consumer.gender3[1].checked = true;
			}
			else 
			{
				document.consumer.gender3[0].checked = true;
			}
			
	}
		
		if (paxnum == 4)
		{
			prefix2 = (document.consumer.passPrefix[3].options[document.consumer.passPrefix[3].selectedIndex].value)

			if (prefix2 == "Ms") 
			{
				document.consumer.gender4[1].checked = true;
			}
			else if (prefix2 == "Mrs") 
			{
				document.consumer.gender4[1].checked = true;
			}
			else if (prefix2 == "Miss") 
			{
				document.consumer.gender4[1].checked = true;
			}
			else 
			{
				document.consumer.gender4[0].checked = true;
			}
	}
	
	if (paxnum == 5)
		{
			prefix2 = (document.consumer.passPrefix[4].options[document.consumer.passPrefix[4].selectedIndex].value)

			if (prefix2 == "Ms") 
			{
				document.consumer.gender5[1].checked = true;
			}
			else if (prefix2 == "Mrs") 
			{
				document.consumer.gender5[1].checked = true;
			}
			else if (prefix2 == "Miss") 
			{
				document.consumer.gender5[1].checked = true;
			}
			else 
			{
				document.consumer.gender5[0].checked = true;
			}
		}
}

function changePhoneDisplay(form){
		
		index = form.phoneType.selectedIndex;  //Netscape fix
        alert(index);
		
		//form.phoneID.value = arrayPhoneID[index];
		if (form.phonecountry){
			form.phonecountry.value = arrayPhoneCountry[index];
			if (arrayCityCode[index] == ""){
				form.hcode.value = arrayAreaCode[index];
			}else{
				form.hcode.value = arrayCityCode[index];
			}
		}else if (form.hcode){
			form.hcode.value = arrayAreaCode[index];		
		}
		
		form.hexchange.value = arrayExchange[index];
		form.hnumber.value = arrayNumber[index];
		
		if (form.extension){
			form.extension.value = arrayExtension[index];
		}
		
		if (form.dayCall){
			if (arrayDayCall[index] == 'WEEKDAY') {
				form.dayCall.selectedIndex = 1;
			}else if (arrayDayCall[index] == 'WEEKEND'){
				form.dayCall.selectedIndex = 2;
			}else {
				form.dayCall.selectedIndex = 0;
			}
		}
		
		if (form.timeCall){
			if (arrayTimeCall[index] == 'M') {
				form.timeCall.selectedIndex = 1;
			}else if (arrayTimeCall[index] == 'A'){
				form.timeCall.selectedIndex = 2;
			}else if (arrayTimeCall[index] == 'E'){
				form.timeCall.selectedIndex = 3;
			}else {
				form.timeCall.selectedIndex = 0;
			}
		}
		
		if (form.timezone){
			form.timezone.options[0] = new Option (arrayTimeZoneName[index], arrayTimeZone[index]);
			form.timezone.selectedIndex = 0;
		}
	
		return;
	}
    
    
//a function that does a regular expression match
//for special charachters in the entered text
function isAlphaOnly(as_value) {
    var re = /[^-\'a-zA-Z ]+/;
    
    if(as_value.search(re) != -1) {
        return false;
    } else {
        return true;
    }               
}

function isCheckBoxSelected(ao_checkbox, ai_index)
{
    if (ao_checkbox)
    {
        if (ai_index == 0)
        {
            return ao_checkbox.checked; 
        }
        else
        {
            if(ao_checkbox[ai_index])
                return ao_checkbox[ai_index].checked;   
            else
                return false;
                                 
        }
    }
    else
    {
        return false;
    }
}

function containsOnlyTwoSlashes(as_BirthDate)
{
    var returnString = "";
	var p;
    var bag;
	var slashcount = 0;
	bag = "/";

	for (p = 0; p < as_BirthDate.length; p++)
	{   
	    // Check that current character isn't whitespace.
		var c = as_BirthDate.charAt(p);
		
        if (bag.indexOf(c) == -1)
        {
		    returnString += c;
		}
		else
        {
		    slashcount = slashcount + 1;
		}
	}

    if (slashcount == 2)
    {
        return true;
    }
    else
    {
        return false;
    }                
}

function setFocusToField(ao_FormField)
{
    ao_FormField.focus();
}

function isValidMonth(as_Date)
{
    var li_Month = getMonthFromDate(as_Date);
    
    if (li_Month < 1 || li_Month > 12)
    {
        return false;
    }
    else
    {
        return true;
    }        			
}

function getMonthFromDate(as_Date)
{
    var monthstring;    
    monthstring = as_Date.charAt(0) + as_Date.charAt(1);
    
    return monthstring;
}

function getDayFromDate(as_Date)
{
    var daystring;
    daystring = as_Date.charAt(3) + as_Date.charAt(4);
    
    return daystring;
}

function getYearFromDate(as_Date)
{  
    var yearstring;    
    yearstring = as_Date.charAt(6) + as_Date.charAt(7) + as_Date.charAt(8) + as_Date.charAt(9) ;
    
    return yearstring;
}

function isValidDayOfMonth(as_Date)
{
    var li_Month = getMonthFromDate(as_Date);
    var li_Day   = getDayFromDate(as_Date);
    
    if ((li_Month == 1 || li_Month == 3 || li_Month == 5 || li_Month == 7 || li_Month == 8 || li_Month == 10 || li_Month == 12) && (li_Day < 1 || li_Day > 31))
    {
        return false;
    }
    else if ((li_Month == 2) && (li_Day < 1 || li_Day > 29))
    {
        return false;
    }
    else if ((li_Month == 4 || li_Month == 6 || li_Month == 9 || li_Month == 11) && (li_Day < 1 || li_Day > 30))
    {
        return false;
    }
    else
    {
        return true;
    }    
}

function isValidYear(as_Date)
{
    li_year = getYearFromDate(as_Date);
    
    if (isNaN(li_year) == false)
    {
        if ((li_year < 1900 || li_year > 2500))
        {
            return false;
        }
        else
        {
            return true;
        }  
    }
    else
    {
        return false;
    }              
}

function isDateInPast(as_Date)
{
    ld_CurrentDate = new Date();
    ld_BirthDate = new Date(getYearFromDate(as_Date), getMonthFromDate(as_Date)-1, getDayFromDate(as_Date));
    
    if (ld_BirthDate > ld_CurrentDate)
    {
        return false;
    }
    else
    {
        return true;
    }
}
