// JavaScript Document
var CopyDateValue = false;	//Used to Copy Pickup Date Value to Drop off Date
function ToggleSection(objSender, TableID, ImageID)
{
	if(objSender.ToggleState.toUpperCase() == 'TRUE')
	{
		document.getElementById(TableID).style.display = 'block';
		objSender.ToggleState = 'false';
	}
	else
	{
		document.getElementById(TableID).style.display = 'none';
		objSender.ToggleState = 'true';
	}
	if(ImageID != null)
	{
		var tempImg = document.getElementById(ImageID).src;
		document.getElementById(ImageID).src = objSender.altimg;
		objSender.altimg = tempImg;
	}
}
var PreviousStop = 'tblGeneralStops'
function ToggleStops(objSender, TableID)
{
	document.getElementById(TableID).style.display = 'block';
	if(PreviousStop != "" && PreviousStop.toUpperCase() != TableID.toUpperCase())
	{
		document.getElementById(PreviousStop).style.display = 'none';
	}
	PreviousStop = TableID;
}
var PreviousTab = 'tbCustomerInfo';
var PreviousCornerTab = 'tbCornerCustomerInfo';
function SelectTab(objSender, TabIndex, CornerTabID)
{
	
	var IsErrorFound = false;
	switch(TabIndex)
	{
		case 0:
			document.getElementById('lyrCustomerDetails').style.display = 'block';
			document.getElementById('lyrReservationDetails').style.display = 'none';
			document.getElementById('lyrPaymentInfo').style.display = 'none';
			document.getElementById('tdSetpsInfo').innerHTML = "Step 1 of 3";
		break;
		case 1:
			if(!ValidateCustomerInfo())
			{
				document.getElementById('lyrCustomerDetails').style.display = 'none';
				document.getElementById('lyrReservationDetails').style.display = 'block';
				document.getElementById('lyrPaymentInfo').style.display = 'none';
				document.getElementById('tdSetpsInfo').innerHTML = "Step 2 of 3";
			}
			else
			{
				IsErrorFound = true;
			}
		break;
		case 2:
			if(!ValidateReservationInfo())
			{
				document.getElementById('lyrCustomerDetails').style.display = 'none';
				document.getElementById('lyrReservationDetails').style.display = 'none';
				document.getElementById('lyrPaymentInfo').style.display = 'block';
				document.getElementById('tdSetpsInfo').innerHTML = "Step 3 of 3";
			}
			else
			{
				IsErrorFound = true;
			}
		break;
	}
	
	//Change Tab Style	
	if(!IsErrorFound)
	{
		if(PreviousTab != "" && PreviousTab.toUpperCase() != objSender.id.toUpperCase())
		{
			var TempTabID = objSender;
			objSender.className = "TabOn";
			document.getElementById(PreviousTab).className = "TabOff";
			document.getElementById(CornerTabID).className = "TabOnCornerStyle";
			document.getElementById(PreviousCornerTab).className = "TabOffCornerStyle";
			PreviousCornerTab = CornerTabID;
		}
		PreviousTab = objSender.id;
	}
}

function UpdateSideNav(TabIndex)
{
	try
	{
		//Fill Customer Info
		var CustomerName = "";
		CustomerName = document.Form1.ddlSurName.options[document.Form1.ddlSurName.selectedIndex].text + " " + document.Form1.txtLastName.value + 
		" " + document.Form1.txtFirstName.value + " " + document.Form1.txtMiddleName.value + " " + document.Form1.ddlNameSuffix.options[document.Form1.ddlNameSuffix.selectedIndex].text;
		document.getElementById("SideNav_CICustomerName").innerHTML = CustomerName;
		var CustomerAddress = "<nobr>";
		CustomerAddress = document.Form1.txtAddress1.value + "<br>" + document.Form1.ddlAddressPrefix.options[document.Form1.ddlAddressPrefix.selectedIndex].text + " " + document.Form1.txtAddress2.value + "<br>" + document.Form1.txtCity.value + ", " +
		document.Form1.ddlCustomerState.options[document.Form1.ddlCustomerState.selectedIndex].text +" - " + document.Form1.txtCustomerZipCode.value+"</nobr>";
		document.getElementById("SideNav_CICustomerAddress").innerHTML = CustomerAddress;
		var CustomerContactInfo = "<nobr>";
		CustomerContactInfo = "Home Phone: " + document.Form1.txtHomePhone.value +
		"<br>Cell: " + document.Form1.txtCellPhone.value +
		"<br>Work Ph/Etn: "+ document.Form1.txtWorkPhone.value + "-" + document.Form1.txtWorkExtnPhone.value + 
		"<br>Fax: " + document.Form1.txtFaxNumber.value + 
		"<br>Email: "+ document.Form1.txtEmail.value+"</nobr>";
		document.getElementById("SideNav_CIContactInfo").innerHTML = CustomerContactInfo;
		
		//Fill Reservation Info
		var PickupDateTime = document.Form1.txtPickupDate.value + " " + document.Form1.txtPickupTime.value;
		if(document.Form1.rbPickUpTime[0].checked)
		{
			PickupDateTime += " AM";
		}
		else
		{
			PickupDateTime  += " PM";
		}
		document.getElementById("SideNav_RIPickupDateTime").innerHTML = PickupDateTime;
		
		var DropoffDateTime = document.Form1.txtDropoffDate.value + " " + document.Form1.txtDropoffTime.value;
		if(document.Form1.rbDropoffTime[0].checked)
		{
			DropoffDateTime += " AM";
		}
		else
		{
			DropoffDateTime  += " PM";
		}
		document.getElementById("SideNav_RIDropoffDateTime").innerHTML = DropoffDateTime;
		document.getElementById("SideNav_RITripType").innerHTML = 
			document.Form1.ddlTripType.options[document.Form1.ddlTripType.selectedIndex].text;
		document.getElementById("SideNav_RIVehicleType").innerHTML = 
			document.Form1.ddlVehicleType.options[document.Form1.ddlVehicleType.selectedIndex].text;
		document.getElementById("SideNav_RIBookedBy").innerHTML = document.Form1.txtBookedBy.value;
		document.getElementById("SideNav_RIPaxCount").innerHTML = document.Form1.txtPaxCount.value;
		
		//Fill Payment Info
		document.getElementById("SideNav_PIPayeeName").innerHTML = document.Form1.txtPayeeName.value;
		document.getElementById("SideNav_PIPaymentMethod").innerHTML = 
				document.Form1.ddlPaymentMethod.options[document.Form1.ddlPaymentMethod.selectedIndex].text;
		document.getElementById("SideNav_PICompanyCode").innerHTML = document.Form1.txtCompanyCode.value;
		document.getElementById("SideNav_PICCType").innerHTML = 
			document.Form1.ddlCCType.options[document.Form1.ddlCCType.selectedIndex].text;	
		document.getElementById("SideNav_PICCNumber").innerHTML = 
			document.Form1.txtCCNumber.value;
		document.getElementById("SideNav_PIValidity").innerHTML = 
			document.Form1.ddlExpiryMonth.options[document.Form1.ddlExpiryMonth.selectedIndex].text + "/"+document.Form1.txtExpiryYear.value;
		document.getElementById("SideNav_PICVVNumber").innerHTML = document.Form1.txtCVVCode.value;
		var PayeeAddress = "";
		PayeeAddress = document.Form1.txtPayeeAddress.value + "<br>" + document.Form1.txtPayeeCity.value + ", " + document.Form1.ddlPayeeStates.options[document.Form1.ddlPayeeStates.selectedIndex].text +" - " + document.Form1.txtPayeeZip.value + "<br>Phone No: "+document.Form1.txtPayeePhone.value;
		document.getElementById("SideNav_PIPayeeAddress").innerHTML = PayeeAddress;
	}
	catch (_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');

	}
}

var IsArrivalStopAdded = false;
var IsDepartureStopAdded = false;
function SaveStop(objSender, StopsGridID)
{
	try
	{
		var StopInfo = "";
		var ActualStopInfo = "";
		var StopType = 0;
		var RowLevel = 0;
		var StopGridObj = document.getElementById(StopsGridID);
		var IsErrorFound = false;

		if(document.Form1.rbStopType[0].checked) //General Stops
		{
			if(!ValidateStops(0))
			{
				if(document.getElementById('hdnAddressType').value == 'Other')
				{
				StopInfo = document.Form1.txtStopName.value;
				StopInfo += " | " + document.Form1.txtStopAddress1.value;
				StopInfo += " | " + document.Form1.ddlStopAddressPrefix.options[document.Form1.ddlStopAddressPrefix.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtStopAddress2.value;
				StopInfo += " | " + document.Form1.txtStopCity.value;
				StopInfo += " | " + document.Form1.ddlStopStates.options[document.Form1.ddlStopStates.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtStopZipCode.value;
				StopInfo += " | " + document.Form1.txtStopPhone.value;
				StopInfo += " | " + document.Form1.txtStopComment.value;
				StopType = "22001";
				RowLevel = StopGridObj.rows.length;
				
				ActualStopInfo =  document.Form1.txtStopName.value;
				ActualStopInfo += " | " + document.Form1.txtStopAddress1.value;
				ActualStopInfo += " | " + document.Form1.ddlStopAddressPrefix.value;
				ActualStopInfo += " | " + document.Form1.txtStopAddress2.value;
				ActualStopInfo += " | " + document.Form1.txtStopCity.value;
				ActualStopInfo += " | " + document.Form1.ddlStopStates.value;
				ActualStopInfo += " | " + document.Form1.txtStopZipCode.value;
				ActualStopInfo += " | " + document.Form1.txtStopPhone.value;
				ActualStopInfo += " | " + document.Form1.txtStopComment.value;
				ActualStopInfo += " | " + "22001";
				/*if(IsArrivalStopAdded && !IsDepartureStopAdded)
				{
					RowLevel = StopGridObj.rows.length;
				}
				else if(IsDepartureStopAdded && !IsArrivalStopAdded)
				{
					RowLevel = StopGridObj.rows.length-1;
				}
				else if(IsDepartureStopAdded && IsArrivalStopAdded)
				{
					RowLevel = StopGridObj.rows.length-1;
				}
				else
				{
					RowLevel = StopGridObj.rows.length;
				}*/
				}
				
				if(document.getElementById('hdnAddressType').value == 'Home')
				{
				StopInfo = document.Form1.txtStopName_Home.value;
				StopInfo += " | " + document.Form1.txtStopAddress1_Home.value;
				StopInfo += " | " + document.Form1.ddlStopAddressPrefix_Home.options[document.Form1.ddlStopAddressPrefix_Home.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtStopAddress2_Home.value;
				StopInfo += " | " + document.Form1.txtStopCity_Home.value;
				StopInfo += " | " + document.Form1.ddlStopStates_Home.options[document.Form1.ddlStopStates_Home.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtStopZipCode_Home.value;
				StopInfo += " | " + document.Form1.txtStopPhone_Home.value;
				StopInfo += " | " + document.Form1.txtStopComment_Home.value;
				StopType = "22001";
				RowLevel = StopGridObj.rows.length;
				
				ActualStopInfo =  document.Form1.txtStopName_Home.value;
				ActualStopInfo += " | " + document.Form1.txtStopAddress1_Home.value;
				ActualStopInfo += " | " + document.Form1.ddlStopAddressPrefix_Home.value;
				ActualStopInfo += " | " + document.Form1.txtStopAddress2_Home.value;
				ActualStopInfo += " | " + document.Form1.txtStopCity_Home.value;
				ActualStopInfo += " | " + document.Form1.ddlStopStates_Home.value;
				ActualStopInfo += " | " + document.Form1.txtStopZipCode_Home.value;
				ActualStopInfo += " | " + document.Form1.txtStopPhone_Home.value;
				ActualStopInfo += " | " + document.Form1.txtStopComment_Home.value;
				ActualStopInfo += " | " + "22001";
			
				}
				
				if(document.getElementById('hdnAddressType').value == 'Office')
				{
				StopInfo = document.Form1.txtStopName_Office.value;
				StopInfo += " | " + document.Form1.txtStopAddress1_Office.value;
				StopInfo += " | " + document.Form1.ddlStopAddressPrefix_Office.options[document.Form1.ddlStopAddressPrefix_Office.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtStopAddress2_Office.value;
				StopInfo += " | " + document.Form1.txtStopCity_Office.value;
				StopInfo += " | " + document.Form1.ddlStopStates_Office.options[document.Form1.ddlStopStates_Office.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtStopZipCode_Office.value;
				StopInfo += " | " + document.Form1.txtStopPhone_Office.value;
				StopInfo += " | " + document.Form1.txtStopComment_Office.value;
				StopType = "22001";
				RowLevel = StopGridObj.rows.length;
				
				ActualStopInfo =  document.Form1.txtStopName_Office.value;
				ActualStopInfo += " | " + document.Form1.txtStopAddress1_Office.value;
				ActualStopInfo += " | " + document.Form1.ddlStopAddressPrefix_Office.value;
				ActualStopInfo += " | " + document.Form1.txtStopAddress2_Office.value;
				ActualStopInfo += " | " + document.Form1.txtStopCity_Office.value;
				ActualStopInfo += " | " + document.Form1.ddlStopStates_Office.value;
				ActualStopInfo += " | " + document.Form1.txtStopZipCode_Office.value;
				ActualStopInfo += " | " + document.Form1.txtStopPhone_Office.value;
				ActualStopInfo += " | " + document.Form1.txtStopComment_Office.value;
				ActualStopInfo += " | " + "22001";
			
				}
			}
			else
			{
				IsErrorFound = true;
			}
		}
		if(document.Form1.rbStopType[1].checked) //Commercial Airport Stops
		{
			if(!ValidateStops(1))
			{
				StopInfo = document.Form1.ddlAirport.options[document.Form1.ddlAirport.selectedIndex].text;
				StopInfo += " | " + document.Form1.ddlAirline.options[document.Form1.ddlAirline.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtFlightNo.value;			
				StopInfo += " | " + document.Form1.txtFlightTime.value;
				// CPS 5/1/2008
                if(document.Form1.txtFlightTime.value != '')
				{
                    // this seemes to be inaccurate
				/*	StopInfo += document.Form1.rbFlightTime[0].checked?" AM":" PM";
					if (document.Form1.rbFlightAM.checked)
                    {
                        StopInfo += " AM";
                    }
                    else if (document.Form1.rbFlightPM.checked)
                    {
                        StopInfo += " PM";
                    }
                   */

                    StopInfo += document.Form1.rbFlightTime[0].checked?" AM":" PM";
                }


				StopInfo += " | " + document.Form1.txtOriginatingCity.value;
				StopInfo += " | " + document.Form1.txtFlightComment.value;

				ActualStopInfo += document.Form1.ddlAirport.value;
				ActualStopInfo += " | " + document.Form1.ddlAirline.value;
				ActualStopInfo += " | " + document.Form1.txtFlightNo.value;
				ActualStopInfo += " | " + document.Form1.txtFlightTime.value;
				// CPS 5/1/2008
                if(document.Form1.txtFlightTime.value != '')
				{
                    // this seemes to be inaccurate
                    //if(document.Form1.txtFlightTime.value != '')
					//ActualStopInfo += " " + document.Form1.rbFlightTime[0].checked?" AM":" PM";

					if (document.Form1.rbFlightAM.checked)
                    {
                        ActualStopInfo += " " + " AM";
                    }
                    else if (document.Form1.rbFlightPM.checked)
                    {
                        ActualStopInfo += " " + " PM";
                    }
                }

				ActualStopInfo += " | " + document.Form1.txtOriginatingCity.value;
				ActualStopInfo += " | " + document.Form1.txtFlightComment.value;
				if(document.Form1.rbArrivalDept[0].checked)
				{
					StopType = "22005";
					ActualStopInfo += " | 22005";
				}
				else
				{
					StopType = "22003";
					ActualStopInfo += " | 22003";
				}
				RowLevel = StopGridObj.rows.length;
				/*if(document.Form1.rbArrivalDept[0].checked)
				{
					RowLevel = 1;
					IsArrivalStopAdded = true;
					StopType += "@A";
				}
				else
				{
					RowLevel = StopGridObj.rows.length;
					IsDepartureStopAdded = true;
					StopType += "@D";
				}*/
			}
			else
			{
				IsErrorFound = true;
			}
		}
		if(document.Form1.rbStopType[2].checked) //Private Airplanes
		{
			if(!ValidateStops(2))
			{
				StopInfo = document.Form1.ddlAirStrip.options[document.Form1.ddlAirStrip.selectedIndex].text;
				StopInfo += " | " + document.Form1.txtPrivateFlightNo.value;			
				StopInfo += " | " + document.Form1.txtPrivateFlightTime.value;
				if(document.Form1.txtPrivateFlightTime.value != '')
					StopInfo += document.Form1.rbPrivateFlightTime[0].checked?" AM":" PM";
				StopInfo += " | " + document.Form1.txtPrivateOriginatingCity.value;
				StopInfo += " | " + document.Form1.txtPrivatePlaneComments.value;
				
				ActualStopInfo = document.Form1.ddlAirStrip.value;
				ActualStopInfo += " | " + document.Form1.txtPrivateFlightNo.value;			
				ActualStopInfo += " | " + document.Form1.txtPrivateFlightTime.value;
				if(document.Form1.txtPrivateFlightTime.value != '')
					ActualStopInfo += document.Form1.rbPrivateFlightTime[0].checked?" AM":" PM";
				ActualStopInfo += " | " + document.Form1.txtPrivateOriginatingCity.value;
				ActualStopInfo += " | " + document.Form1.txtPrivatePlaneComments.value;
				
				RowLevel = StopGridObj.rows.length;
				if(document.Form1.rbPrivateArrivalDept[0].checked)
				{
					StopType = "22006";
					ActualStopInfo += " | 22006";
				}
				else
				{
					StopType = "22004";
					ActualStopInfo += " | 22004";
				}
			}
			else
			{
				IsErrorFound = true;
			}
		}		
		CreateNewRow(StopsGridID, StopInfo, StopType, RowLevel, ActualStopInfo);
		
		//Clear Field Values
		if(!IsErrorFound)
		{
			if(document.Form1.rbStopType[0].checked) //General Stops
			{
				if(!ValidateStops())
				{
					document.Form1.txtStopName.value = "";
					document.Form1.txtStopAddress1.value = "";
					document.Form1.ddlStopAddressPrefix.selectedIndex = 0;
					document.Form1.txtStopAddress2.value = "";
					document.Form1.txtStopCity.value = "";
					document.Form1.ddlStopStates.selectedIndex = 0;
					document.Form1.txtStopZipCode.value = "";
					document.Form1.txtStopPhone.value = "";
					document.Form1.txtStopComment.value = "";
					
					document.Form1.txtStopName_Home.value = "";
					document.Form1.txtStopAddress1_Home.value = "";
					document.Form1.ddlStopAddressPrefix_Home.selectedIndex = 0;
					document.Form1.txtStopAddress2_Home.value = "";
					document.Form1.txtStopCity_Home.value = "";
					document.Form1.ddlStopStates_Home.selectedIndex = 0;
					document.Form1.txtStopZipCode_Home.value = "";
					document.Form1.txtStopPhone_Home.value = "";
					document.Form1.txtStopComment_Home.value = "";
					
					document.Form1.txtStopName_Office.value = "";
					document.Form1.txtStopAddress1_Office.value = "";
					document.Form1.ddlStopAddressPrefix_Office.selectedIndex = 0;
					document.Form1.txtStopAddress2_Office.value = "";
					document.Form1.txtStopCity_Office.value = "";
					document.Form1.ddlStopStates_Office.selectedIndex = 0;
					document.Form1.txtStopZipCode_Office.value = "";
					document.Form1.txtStopPhone_Office.value = "";
					document.Form1.txtStopComment_Office.value = "";
				}
			}
			if(document.Form1.rbStopType[1].checked) //Commercial Airport Stops
			{
				document.Form1.ddlAirport.selectedIndex = 0;
				document.Form1.ddlAirline.selectedIndex = 0;
				document.Form1.txtFlightNo.value = "";
				document.Form1.txtFlightTime.value = "";
				document.Form1.rbFlightTime[0].checked = true;
				document.Form1.txtOriginatingCity.value = "";
				document.Form1.txtFlightComment.value = "";
				
					document.Form1.txtStopName_Home.value = "";
					document.Form1.txtStopAddress1_Home.value = "";
					document.Form1.ddlStopAddressPrefix_Home.selectedIndex = 0;
					document.Form1.txtStopAddress2_Home.value = "";
					document.Form1.txtStopCity_Home.value = "";
					document.Form1.ddlStopStates_Home.selectedIndex = 0;
					document.Form1.txtStopZipCode_Home.value = "";
					document.Form1.txtStopPhone_Home.value = "";
					document.Form1.txtStopComment_Home.value = "";

					document.Form1.txtStopName_Office.value = "";
					document.Form1.txtStopAddress1_Office.value = "";
					document.Form1.ddlStopAddressPrefix_Office.selectedIndex = 0;
					document.Form1.txtStopAddress2_Office.value = "";
					document.Form1.txtStopCity_Office.value = "";
					document.Form1.ddlStopStates_Office.selectedIndex = 0;
					document.Form1.txtStopZipCode_Office.value = "";
					document.Form1.txtStopPhone_Office.value = "";
					document.Form1.txtStopComment_Office.value = "";
			}
			if(document.Form1.rbStopType[2].checked) //Private Airplanes
			{
				document.Form1.ddlAirStrip.selectedIndex = 0;
				document.Form1.txtPrivateFlightNo.value = "";
				document.Form1.txtPrivateFlightTime.value = "";
				document.Form1.rbPrivateFlightTime[0].checked = true;
				document.Form1.txtPrivateOriginatingCity.value = "";
				document.Form1.txtPrivatePlaneComments.value = "";
				
				document.Form1.txtStopName_Home.value = "";
					document.Form1.txtStopAddress1_Home.value = "";
					document.Form1.ddlStopAddressPrefix_Home.selectedIndex = 0;
					document.Form1.txtStopAddress2_Home.value = "";
					document.Form1.txtStopCity_Home.value = "";
					document.Form1.ddlStopStates_Home.selectedIndex = 0;
					document.Form1.txtStopZipCode_Home.value = "";
					document.Form1.txtStopPhone_Home.value = "";
					document.Form1.txtStopComment_Home.value = "";
					
					document.Form1.txtStopName_Office.value = "";
					document.Form1.txtStopAddress1_Office.value = "";
					document.Form1.ddlStopAddressPrefix_Office.selectedIndex = 0;
					document.Form1.txtStopAddress2_Office.value = "";
					document.Form1.txtStopCity_Office.value = "";
					document.Form1.ddlStopStates_Office.selectedIndex = 0;
					document.Form1.txtStopZipCode_Office.value = "";
					document.Form1.txtStopPhone_Office.value = "";
					document.Form1.txtStopComment_Office.value = "";
			}
			
		}
		
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
function CreateNewRow(StopsGridID, StopInfo, StopType, RowLevel, ActualStopInfo)
{
	try
	{
		var TempStopInfo = StopInfo.split(" | ").join("");
		if(TempStopInfo != "")
		{
			var GridObj = document.getElementById(StopsGridID);
			var iRowCount = GridObj.rows.length;
			var NewRow = GridObj.insertRow(RowLevel);
			var NewCell = "";
			NewRow.className = "EditGridItem";
			NewCell = NewRow.insertCell(0);
			NewCell.className = "EditGridItem";
			NewCell.align = "center";
			NewCell.innerHTML = RowLevel;
			
			NewCell = NewRow.insertCell(1);
			NewCell.className = "EditGridItem";			
			NewCell.innerHTML = "<nobr title='"+ StopInfo +"'>"+StopInfo+"</nobr>";
			NewCell.focus();
			
			NewCell = NewRow.insertCell(2);
			NewCell.className = "EditGridItem";
			NewCell.innerHTML ="<img src='Images/Delete.gif' style='cursor:hand;' onclick='RemoveStop("+ RowLevel +", \""+ StopsGridID +"\");' />";
			
			NewCell = NewRow.insertCell(3);
			NewCell.className = "HiddenGridItem";
			NewCell.innerHTML = StopType;

			NewCell = NewRow.insertCell(4);
			NewCell.className = "HiddenGridItem";
			NewCell.innerHTML = "";
			
			NewCell = NewRow.insertCell(5);
			NewCell.className = "HiddenGridItem";
			NewCell.innerHTML = ActualStopInfo;

			RearrangeRows(StopsGridID);
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
function RemoveStop(RowIndex, StopGridID)
{
	try
	{
		var GridObj = document.getElementById(StopGridID); 
		for(iRowCount=1; iRowCount<GridObj.rows.length;iRowCount++)
		{
			if(GridObj.rows[iRowCount].cells[4].innerText == RowIndex)
			{
				var sStopType = GridObj.rows[iRowCount].cells[3].innerText;
				if(sStopType.length > 1)
				{
					if(sStopType.split("@")[1] == "A")
					{
						IsArrivalStopAdded = false;
					}
					else if(sStopType.split("@")[1] == "D")
					{
						IsDepartureStopAdded = false;
					}
				}
				GridObj.deleteRow(RowIndex);
			}
		}
		RearrangeRows(StopGridID);
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
function RearrangeRows(StopGridID)
{
	try
	{
		var GridObj = document.getElementById(StopGridID); 
		for(iRowCount=1; iRowCount<GridObj.rows.length;iRowCount++)
		{
			if(iRowCount ==1)
			{
				GridObj.rows[iRowCount].cells[0].innerHTML = "P/U";	
			}
			else if(iRowCount == (GridObj.rows.length-1))
			{
				GridObj.rows[iRowCount].cells[0].innerHTML = "D/O";	
			}
			else
			{
				GridObj.rows[iRowCount].cells[0].innerHTML = iRowCount;
			}
			GridObj.rows[iRowCount].cells[4].innerHTML = iRowCount;
			GridObj.rows[iRowCount].cells[2].innerHTML = "<img src='Images/Delete.gif' style='cursor:hand;' onclick='RemoveStop("+ iRowCount +", \""+ StopGridID +"\");' />";
		}
		
		//Reset Stop Title
		if(GridObj.rows.length == 1)
		{
			document.getElementById("tblStopTitle").innerHTML = "Select your pick up location";
		}
		else
		{
			document.getElementById("tblStopTitle").innerHTML = "Select your drop off or additional stop";
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
/*function SetDateTime(e, objSender, maskType)
{
    var event = (e) ? e : window.event; 
	var currValue = objSender.value;
	var oSelection; // = document.selection.createRange();
	
    //IE support
    if (document.selection) 
    {
       var oSelection = document.selection.createRange();
    }
    else if (objSender.selectionStart || objSender.selectionStart == '0') 
    {
       //MOZILLA/NETSCAPE support
       var startPos = objSender.selectionStart;
       var endPos = objSender.selectionEnd;
       oSelection = objSender.value.substring(0, startPos) + objSender.value.substring(endPos, objSender.value.length);
    }

	
	if(oSelection.text != '' && !IsValidKeyCode(event.keyCode))
	{
		oSelection.text = '';
		//currValue = currValue.replace(oSelection.text,'');
		if (document.selection)
		{
		    oSelection.collapse(true);
		    oSelection.select();
		}
		currValue = objSender.value;
	}
	var KeyCode = event.keyCode;
	var currKeyValue = GetKeyCodeValue(KeyCode);
	if(currKeyValue >='0' && currKeyValue <='9' &&
	currValue.length < objSender.maxLength)
	{
		objSender.value = "";
		if(currValue == "__:__")
		{
			currValue = currKeyValue;
		}
		if(currValue.length == 2)
		{
			currValue = currValue + ":" + 
						FormatInput(currValue, maskType, currKeyValue);
		}
		else
		{
			currValue = currValue + FormatInput(currValue, maskType, currKeyValue);
		}
		if(currValue.length == 2)
		{
			currValue = currValue + ":";
		}
		objSender.value = currValue;		
		event.returnValue = false;
	}
	else
	{
		event.returnValue = IsValidKeyCode(event.keyCode);
	}
}
*/

// CPS 5/1/08
function SetDateTime(e, objSender)
{

	try
	{
	   
        var evt = (e) ? e : window.event; 
        if (evt.keyCode == 8)
            return;    // user hit backspace. no formatting needed.
            
        //alert("KeyCode = " + evt.keyCode + ". CharCode = " + evt.charCode);
            
         
	    // First check to make sure the user didn't enter a non-number
	    var ValidChars = '0123456789';
	    // Get the phone number w/o dashes
	    var Time = objSender.value.split(':').join('');
	    
	    // loop through each character in the string
	    for (var i = 0; i < Time.length; i++)
	    {
	       // get the current character in the string
	       Char = Time.charAt(i);
	       // if the character isn't 0 through 9, delete it from the phone number
	       if (ValidChars.indexOf(Char) == -1)
	            Time = Time.substring(0, Time.length -1);
	    }
	    

    

	    // Add a dash if appropriate
	    if (Time.length >= 2 && Time.length < 5)
	        objSender.value = Time.substring(0, 2) + ':' + Time.substring(2, 4);
	    else
            objSender.value = Time;

	    
	    objSender.focus();
	}
	catch(e)
	{
	    makeAlert('Online Reservation',_e.message,'');
		objSender.focus();
	}
}




function GetKeyCodeValue(key)
{
	switch(key)
	{
		case 48:
		case 96:
				return String.fromCharCode(48);
				break;
		case 49:
		case 97:
				return String.fromCharCode(49);
				break;
		case 50:
		case 98:
				return String.fromCharCode(50);
				break;
		case 51:
		case 99:
				return String.fromCharCode(51);
				break;
		case 52:
		case 100:
				return String.fromCharCode(52);
				break;
		case 53:
		case 101:
				return String.fromCharCode(53);
				break;
		case 54:
		case 102:
				return String.fromCharCode(54);
				break;
		case 55:
		case 103:
				return String.fromCharCode(55);
				break;
		case 56:
		case 104:
				return String.fromCharCode(56);
				break;
		case 57:
		case 105:
				return String.fromCharCode(57);
				break;
	}
}
function IsValidKeyCode(key)
{
	return !(key != 9 && key!= 38 && key!= 39 && key!= 40 && key!= 37 && key!= 8 && key!= 46);
}
function FormatInput(currValue, maskType, currKeyValue)
{
	var Delimeter = ":";
	var tempValue = currValue;
	if(tempValue.length == 2)
	{
		tempValue = tempValue + ":";
	}
	tempValue = tempValue + currKeyValue;
	var fieldValue = tempValue.split(Delimeter);
	if(fieldValue.length <= 1)
	{
		if(parseInt(fieldValue[0]) < 25)
		{
			return currKeyValue;
		}
		else
		{
			return "";
		}
	}
	else
	{
		if(parseInt(fieldValue[1]) < 60)
		{
			return currKeyValue;
		}
		else
		{
			return "";
		}
	}

}
function trunc (i)
{
	var j = Math.round(i * 100);
	return Math.floor(j / 100) + (j % 100 > 0 ? "." + p(j % 100) : "");
}

// Last modified 4/29/08 CPS
function comparePickupTime ()
{
	var IsErrorFound=true;
	var sMsgt="";
	var Onlinewarning = '';
	var Onlinehours = '';
	if (document.getElementById('hdnOnlinewarning'))
	   Onlinewarning=document.Form1.hdnOnlinewarning.value;

    if (document.getElementById('hdnOnlinehours'))
        Onlinehours=document.Form1.hdnOnlinehours.value;

	
	
	var datet=FormatDateTime(document.Form1.txtPickupTime,'rbPickUpTime');
	//var datet=document.Form1.txtPickupTime.value;
	var dated = document.Form1.txtPickupDate.value;
	if (document.Form1.rbPickUpTime[0].checked)
	{
	var dateampm = document.Form1.rbPickUpTime[0].value;
	}
	if (document.Form1.rbPickUpTime[1].checked)
	{
	var dateampm = document.Form1.rbPickUpTime[1].value;
	}
	var selectdate = dated + " " + datet + " " + dateampm;
	var date1 = new Date(selectdate);
	//var date2 = new Date(document.Form1.hdnPickuptimetry.value) ;	
	var sysdate= new Date();
	
	var sec =  date1.getTime()-sysdate.getTime() ; //- date1.getTime();
	//var sec =  sysdate.getTime() - pickuptime.getTime();
	
	var second = 1000;	
	var minute = 60 * second;
	var hour = 60 * minute;
	var hval = sec / hour;
	var	day = 24 * hour;
	
	if (isNaN(sec))
	{
		//alert("Input data is incorrect!");
		sMsgt += "<li>Input data is incorrect!</li>";
		//return;
	}
	//if (sec < 0)
	//{
		//alert("The second date ocurred earlier than the first one!");
		//sMsgt += "<li>The second date ocurred earlier than the first one!</li>";
		//return;
	//}
	if (hval<Onlinehours)
		{
			
			sMsgt +="<li>" + Onlinewarning + "</li>";
			//sMsgt += "<li>Sorry, your trip request is too soon to the pick up time, please contact our office immediately at 281.807.7800 to reserve</li>";
		//return;	
		}
	
	/*var days = Math.floor(sec / day);
	sec -= days * day;
	var hours = Math.floor(sec / hour);
	sec -= hours * hour;
	var minutes = Math.floor(sec / minute);
	sec -= minutes * minute;
	var seconds = Math.floor(sec / second);
	*/
	
		document.getElementById("trValidationResult").style.display = "block";
		document.getElementById("tdValidationResult").innerHTML = "<ui type='disc'>" + sMsgt + "</ui>";
		if(sMsgt == "")
		{
			IsErrorFound = false;
			//document.getElementById("trValidationResult").style.display = "none";
		}
		
	return sMsgt;
}
function FormatDateTime(objSender, RadioObj)
{

	var CurrValue = objSender.value;
	var fieldValue = CurrValue.split(":");

    // CPS 5/5/08
     var NewValue = "";
     var errorMsg = fieldValue[0] + ':' + fieldValue[1] + ' is not a valid time.';

    // if the user types in only three digits(4 to include the colon), return those three digits and do nothing else.
	if (CurrValue.length == 4)
    {
        var stringValue = fieldValue[0] + '' + fieldValue[1];
        // format should be something like 20:5 or 10:5. we need it to be 1:05, for example.
        for (var i = 0; i < stringValue.length; i++)
	    {
	       // if the character isn't 0 through 9, delete it from the phone number
	       if(i == 0)
	           NewValue += stringValue.charAt(i) + ':';
	       else
	           NewValue += stringValue.charAt(i);
	    }


        fieldValue = NewValue.split(':');
        // don't let the user type anything past :59 for the minutes
        if (fieldValue[1] > 59)
        {
            alert(errorMsg);
            objSender.value = '';
            objSender.focus();
            return objSender.value;
        }
        else 
        {
            objSender.value = '0' + fieldValue[0] + ':' + fieldValue[1];
            return objSender.value;
        }
    }


    if (fieldValue[0] >= 24) {
        if (fieldValue[0] == 24) {
            if (fieldValue[1] > 00) {
                // time is something like 24:01, alert the user
                alert(errorMsg);
                objSender.value = '';
                objSender.focus();
                return objSender.value;
            }
        }
        
        if (fieldValue[0] > 24) 
        {
            // the time is definitely something wrong, like 25:00 or higher, abort
            alert(errorMsg);
            objSender.value = '';
            objSender.focus();
            return objSender.value;
        }
    }

    
    // don't let the user type anything past :59 for the minutes
    if (fieldValue[1] > 59)
    {
        alert(errorMsg);
        objSender.value = '';
        objSender.focus();
        return objSender.value;
    }



    // End CPS 5/5/08


	
	if(CurrValue != "")
	{
		if(fieldValue.length == 1)
		{
			if(fieldValue[0].length == 1)
			{
				NewValue = "0" + fieldValue[0] + ":00";
			}
			else
			{
				NewValue = fieldValue[0] + ":00";
			}
		}
		else
		{
			if(fieldValue[0].length == 1)
			{
				fieldValue[0] = "0" + fieldValue[0];
			}
			if(fieldValue[1].length == 1)
			{
				NewValue = fieldValue[0] + ":0" + fieldValue[1];
			}
			else if(fieldValue[1].length == 0)
			{
				NewValue = fieldValue[0] + ":00";
			}
			else
			{
				NewValue = fieldValue[0] + ":" + fieldValue[1];
			}
		}
		fieldValue = NewValue.split(":");
		if(parseInt(fieldValue[0]) > 12 && parseInt(fieldValue[0]) < 24)
		{
			fieldValue[0] = parseInt(fieldValue[0]) - 12;
			if(parseInt(fieldValue[0]) < 9)
			{
				fieldValue[0] = "0"+fieldValue[0];
			}
			eval("document."+objSender.form.name+"."+RadioObj)[1].checked = true;
		}
		else if(parseInt(fieldValue[0]) == 24 || parseFloat(fieldValue[0]) == 0)
		{
			fieldValue[0] = "12";
			eval("document."+objSender.form.name+"."+RadioObj)[0].checked = true;
		}
		else if(parseInt(fieldValue[0]) == 12)
		{
			eval("document."+objSender.form.name+"."+RadioObj)[1].checked = true;
		}
		else if(parseInt(fieldValue[0]) < 12 && !eval("document."+objSender.form.name+"."+RadioObj)[1].checked)
		{
			eval("document."+objSender.form.name+"."+RadioObj)[0].checked = true;
		}
		NewValue = fieldValue[0] + ":" + fieldValue[1];
		objSender.value = NewValue;
		return objSender.value;
		
	}
}

function Trim(s)
{
	var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function ShowPaymentDetails(objSender)
{
	try
	{
		document.getElementById("lyrBilling").style.display = "none";
		document.getElementById("CtlPaymentDetails_tblPaymentInfo").style.display = "none";
		if(objSender.selectedIndex == 0)
		{
			document.getElementById("CtlPaymentDetails_tblPaymentInfo").style.display = "none";
		}
		else if(objSender.options[objSender.selectedIndex].text.toUpperCase() != "BILLING")
		{
				document.getElementById("CtlPaymentDetails_tblPaymentInfo").style.display = "block";
		}
		else
		{
			document.getElementById("lyrBilling").style.display = "block";
		}
		if(objSender.options[objSender.selectedIndex].text.toUpperCase() == "CREDIT CARD")
		{
			document.getElementById("tblCCInfo").style.display = "block";
			document.getElementById("trCompanyCode").style.display = "none";
		}
		else
		{
			document.getElementById("tblCCInfo").style.display = "none";
			document.getElementById("trCompanyCode").style.display = "block";
		}
		if(objSender.options[objSender.selectedIndex].text.toUpperCase() == "BILLING")	
		{
			document.getElementById("trCompanyCode").style.display = "block";
		}
		else
		{
			document.getElementById("trCompanyCode").style.display = "none";
		}
		if(objSender.options[objSender.selectedIndex].text.toUpperCase() == "CASH")	
		{
			document.getElementById("tblPayeeAddress").style.display = "none";
		}
		else
		{
			document.getElementById("tblPayeeAddress").style.display = "block";
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
function ShowQuoteOutofTripDetails()
{
	try
	{
		
		document.getElementById("Ctl_tblOutofTown").style.display = "none";
		for (var b = 0; b <2; b++){
			 if (document.Form1.rbTripType[1].checked)
				 //document.Form1.rbTripType[b].value == "outoftown")
			 {	document.getElementById("Ctl_tblOutofTown").style.display = "block";
			 }
				else
			{
			document.getElementById("Ctl_tblOutofTown").style.display = "none";
				}
		}
		
			//return radioButtonOrGroup[b];

		/*if(objSender.options[objSender.selectedIndex].text.toUpperCase() == "CREDIT CARD")
		if(objSender.options[objSender.selectedIndex].text.toUpperCase() == "CREDIT CARD")
		{
			document.getElementById("tblCCInfo").style.display = "block";
			document.getElementById("trCompanyCode").style.display = "none";
		}
		else
		{
			document.getElementById("tblCCInfo").style.display = "none";
			document.getElementById("trCompanyCode").style.display = "block";
		}*/
		
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}



function ToggleButtonStatus(objSender)
{
	try
	{
		if(objSender.checked)
		{
			document.Form1.btnCreateReservation.disabled = false;
		}
		else
		{
			document.Form1.btnCreateReservation.disabled = true;
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

function ValidateCustomerInfo()
{
	var IsErrorFound = true;
	try
	{
		var sMsg = "";
		if(Trim(document.Form1.txtFirstName.value) == "")
		{
			sMsg += "<li>Enter First Name</li>";
		}
		if(Trim(document.Form1.txtLastName.value) == "")
		{
			sMsg += "<li>Enter Last Name</li>";
		}
		var iPhoneCount = 0;
		if(Trim(document.Form1.txtHomePhone.value).split("-").join("") == "")
		{
			iPhoneCount++;
		}
		if(Trim(document.Form1.txtWorkPhone.value).split("-").join("") == "")
		{
			iPhoneCount++;
		}
		if(Trim(document.Form1.txtCellPhone.value).split("-").join("") == "")
		{
			iPhoneCount++;
		}
		if(iPhoneCount == 3)
		{
			sMsg += "<li>Enter one phone Number</li>";
		}
		if(Trim(document.Form1.txtEmail.value) == "")
		{
			sMsg += "<li>Enter Email ID</li>";
		}
		else if(Trim(document.Form1.txtEmail.value) != "")
		{
			var EmailRegEx = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
			var RegExObj = new RegExp(EmailRegEx);
			var Match = RegExObj.exec(Trim(document.Form1.txtEmail.value));
			if(Match == null)
			{
				sMsg += "<li>Enter valid Email ID</li>";
			}
		}
		
		document.getElementById("trValidationResult").style.display = "block";
		document.getElementById("tdValidationResult").innerHTML = "<ui type='disc'>" + sMsg + "</ui>";
		if(sMsg == "")
		{
			IsErrorFound = false;
			document.getElementById("trValidationResult").style.display = "none";
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}	
	return IsErrorFound;
}

function ValidateReservationInfo()
{
	var IsErrorFound = true;
	
	try
	{
		var sMsg = "";
		if(Trim(document.Form1.txtPickupDate.value) == "")
		{
			sMsg += "<li>Enter Pickup Date</li>";
		}
		if(Trim(document.Form1.txtPickupTime.value) == "")
		{
			sMsg += "<li>Enter Pickup Time</li>";
		}
		if(Trim(document.Form1.txtDropoffDate.value) == "")
		{
			sMsg += "<li>Enter Dropoff Date</li>";
		}
		if(Trim(document.Form1.txtDropoffTime.value) == "")
		{
			sMsg += "<li>Enter Dropoff Time</li>";
		}
		if(sMsg == "")	//Date Time Validation
		{
			var PickDate = document.Form1.txtPickupDate.value;
			var DropOffDate = document.Form1.txtDropoffDate.value;
			var PickTime = document.Form1.txtPickupTime.value;
			var PickHrs = 0;			
			var PickMins = PickTime.split(":")[1];
			var DropTime = document.Form1.txtDropoffTime.value;
			var DropHrs = 0;
			var DropMins = DropTime.split(":")[1];
			
			if(document.Form1.rbPickUpTime[1].checked && PickTime.split(":")[0] != "12")
			{
				PickHrs = parseFloat(PickTime.split(":")[0]) + 12;									
			}
			else
			{
				PickHrs = parseFloat(PickTime.split(":")[0]);
			}
			if(document.Form1.rbDropoffTime[1].checked && DropTime.split(":")[0] != "12")
			{
				DropHrs = parseFloat(DropTime.split(":")[0]) + 12;									
			}
			else
			{
				DropHrs = parseFloat(DropTime.split(":")[0]);
			}			
			var oPickDate = new Date(PickDate.substring(6,10), PickDate.substring(0,2)-1,
										PickDate.substring(3,5), PickHrs, PickMins);
			var oDropDate = new Date(DropOffDate.substring(6,10), DropOffDate.substring(0,2)-1,
										DropOffDate.substring(3,5), DropHrs, DropMins);
			var tempDate = new Date();
			var todayDate = new Date(tempDate.getYear(), tempDate.getMonth().toString(), tempDate.getDate().toString(), tempDate.getHours(), tempDate.getMinutes());			
			if(oPickDate <= todayDate)
			{
				sMsg += "<li>PickUp Date/Time Should be greater than Today's Date</li>";
			}
			else if(oPickDate >= oDropDate)
			{
				sMsg += "<li>PickUp Date/Time Should be lesser than Dropoff Date</li>";
			}
			else
			{
				var sPickuptime = oPickDate.getFullYear() + "/" +
						  (oPickDate.getMonth() + 1) + "/" +
						  oPickDate.getDate() + " " +
						  (oPickDate.getHours()) + ":" + 
						  oPickDate.getMinutes();
				sDropofftime = oDropDate.getFullYear() + "/" +
						  (oDropDate.getMonth() + 1) + "/" +
						  oDropDate.getDate() + " " +
						  (oDropDate.getHours()) + ":" + 
						  oDropDate.getMinutes();
						  
				document.Form1.hdnPickuptime.value = sPickuptime;
				document.Form1.hdnDropofftime.value = sDropofftime;
			}
		}
		
		if(document.Form1.ddlTripType.selectedIndex == 0)
		{
			sMsg += "<li>Select Trip Type</li>";
		}
		if(document.Form1.ddlVehicleType.selectedIndex == 0)
		{
			sMsg += "<li>Select Vehicle Type</li>";
		}
		if(document.getElementById("tblStopsList").rows.length == 1)
		{
			sMsg += "<li>Minimum one stop is required</li>";
		}

		var msg= comparePickupTime();

		sMsg += msg;
        document.getElementById("trValidationResult").style.display = "block";
		document.getElementById("tdValidationResult").innerHTML = "<ui type='disc'>" + sMsg + "</ui>";
			if ((sMsg == "") && (msg==""))
			{
				IsErrorFound = false;
				document.getElementById("trValidationResult").style.display = "none";
			}
				
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}	
	
	return IsErrorFound;
}
function ValidateQuoteInfo()
{
	var IsErrorFound = true;
	
	try
	{
		var sMsg = "";
		
		/*if(Trim(document.Form1.txtCustomer_Name.value)== "" )
		{
			sMsg += "<li>Enter Customer Name</li>";
		}*/
		if(Trim(document.Form1.txtCustomer_First_Name.value)== "" )
		{
			sMsg += "<li>Enter First Name</li>";
		}
		if(Trim(document.Form1.txtCustomer_Last_Name.value)== "" )
		{
			sMsg += "<li>Enter Last Name</li>";
		}
		if(Trim(document.Form1.txtEmail.value) == "")
		{
			sMsg += "<li>Enter Email ID</li>";
		}
		else if(Trim(document.Form1.txtEmail.value) != "")
		{
			var EmailRegEx = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
			var RegExObj = new RegExp(EmailRegEx);
			var Match = RegExObj.exec(Trim(document.Form1.txtEmail.value));
			if(Match == null)
			{
				sMsg += "<li>Enter valid Email ID</li>";
			}
		}
		
		if(document.Form1.ddlVehicleType.selectedIndex == 0)
		{
			sMsg += "<li>Select Vehicle Type</li>";
		}
		if(document.Form1.ddlTripType.selectedIndex == 0)
		{
			sMsg += "<li>Select Trip Type</li>";
		}
		if(Trim(document.Form1.txtPickupDate.value) == "")
		{
			sMsg += "<li>Enter Pickup Date</li>";
		}
		
		if(Trim(document.Form1.txtPickupTime.value) == "")
		{
			sMsg += "<li>Enter Pickup Time</li>";
		}
		
		if(sMsg == "")	//Date Time Validation
		{
			var PickDate = document.Form1.txtPickupDate.value;
			//var DropOffDate = document.Form1.txtDropoffDate.value;
			var PickTime = document.Form1.txtPickupTime.value;
			var PickHrs = 0;			
			var PickMins = PickTime.split(":")[1];
		//	var DropTime = document.Form1.txtDropoffTime.value;
		//	var DropHrs = 0;
			
			
			if(document.Form1.rbPickUpTime[1].checked && PickTime.split(":")[0] != "12")
			{
				PickHrs = parseFloat(PickTime.split(":")[0]) + 12;									
			}
			else
			{
				PickHrs = parseFloat(PickTime.split(":")[0]);
			}
		//	if(document.Form1.rbDropoffTime[1].checked && DropTime.split(":")[0] != "12")
		//	{
		///		DropHrs = parseFloat(DropTime.split(":")[0]) + 12;									
		//	}
		//	else
		////	{
		//		DropHrs = parseFloat(DropTime.split(":")[0]);
		//	}			
			var oPickDate = new Date(PickDate.substring(6,10), PickDate.substring(0,2)-1,
										PickDate.substring(3,5), PickHrs, PickMins);
		//	var oDropDate = new Date(DropOffDate.substring(6,10), DropOffDate.substring(0,2)-1,
		//								DropOffDate.substring(3,5), DropHrs, DropMins);
			var tempDate = new Date();
			var todayDate = new Date(tempDate.getYear(), tempDate.getMonth().toString(), tempDate.getDate().toString(), tempDate.getHours(), tempDate.getMinutes());			
			if(oPickDate <= todayDate)
			{
				sMsg += "<li>PickUp Date/Time Should be greater than Today's Date</li>";
			}
		//	else if(oPickDate >= oDropDate)
		//	{
		//		sMsg += "<li>PickUp Date/Time Should be lesser than Dropoff Date</li>";
		//	}
			else
			{
				var oDropDateAMPMval;
				var oPickDateAMPMval;
				var temp_rentalhours;
				var oDropDateHours;
				var oPickDateHours;
				temp_rentalhours=0;
					if (oPickDate.getHours()>12){
					oPickDateHours=(oPickDate.getHours())%12;
					oPickDateAMPMval='PM';}
					else if(oPickDate.getHours()<12)
					{oPickDateHours=oPickDate.getHours();
					oPickDateAMPMval='AM';}
					else if (oPickDate.getHours()==12)
					{
					
						if(document.Form1.rbPickUpTime[0].checked)
						{
						
						oPickDateHours=12;
						oPickDateAMPMval='AM';
						}	
						//if(document.Form1.rbPickUpTime[1].checked)
						else
						{
						
						oPickDateHours=12;
						oPickDateAMPMval='PM';
						}
						
					}
					
				var sPickuptime = oPickDate.getFullYear() + "/" +
						  (oPickDate.getMonth() + 1) + "/" +
						  oPickDate.getDate() + " " +
						 oPickDateHours + ":" + 
						PickMins+ " " + oPickDateAMPMval;
				
				temp_rentalhours=Number(document.Form1.txtRental_Period.value);
				oDropDate=addHours(oPickDate,temp_rentalhours) // pass current date and numbar of days to add
				var oDropMinutes;
				
				if (oDropDate.getMinutes()<10)
				{
					oDropMinutes=2;
				}
				else
				{						
					oDropMinutes=1;
				}
				//document.Form1.rbDropoffTime[1].checked	
				if (oDropDate.getHours()>12){				
					oDropDateHours=(oDropDate.getHours())%12;
					oDropDateAMPMval='PM';}
					else if(oDropDate.getHours()<12)
					{oDropDateHours=oDropDate.getHours();
					oDropDateAMPMval='AM';
					}
					else if (oDropDate.getHours()==12)
					{
					
						if(document.Form1.rbPickUpTime[0].checked)
						{
						oDropDateHours=12;
						oDropDateAMPMval='AM';
						}	
						if(document.Form1.rbPickUpTime[1].checked)
						{
						oDropDateHours=12;
						oDropDateAMPMval='PM';
						}	
						
					}						
					
					sDropofftime = (oDropDate.getMonth() + 1) + "/" + oDropDate.getDate()+ "/" +  oDropDate.getFullYear()  
					+ " " + oDropDateHours + ":" + 
						  oDropDate.getMinutes()+ " " + oDropDateAMPMval;
				document.Form1.hdnPickuptime.value = sPickuptime;
				document.Form1.hdnDropofftime.value = sDropofftime;
				
				
				
				
			}
		}
	
		if(Trim(document.Form1.txtRental_Period.value) == "")
		{
			sMsg += "<li>Enter Rental Period </li>";
		}
		if(document.Form1.rbTripType[1].checked)
		{
			if(Trim(document.Form1.txtPickuplocation.value) == "")
			{
				sMsg += "<li>Enter Pick up Location</li>";
			}
			if(Trim(document.Form1.txtDropoffLocation.value) == "")
			{
				sMsg += "<li>Enter Drop off Location</li>";
			}
		}
		
		document.getElementById("trValidationResult").style.display = "block";
		document.getElementById("tdValidationResult").innerHTML = "<ui type='disc'>" + sMsg + "</ui>";
		if(sMsg == "")
		{
			IsErrorFound = false;
			document.getElementById("trValidationResult").style.display = "none";
		}
				
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}	
	
	return IsErrorFound;
}
function addHours(myDate,hours) {
//var tempsec;
//tempsec=parseFloat(hours.split(".")[0]);
//alert(tempsec);
return new Date(myDate.getTime() + hours*60*60*1000);
//return new Date(myDate.getTime() + hours*60*60*1000);
}
//parseFloat(PickTime.split(":")[0]);
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*60*60*1000);
}
function ValidatePaymentInfo()
{
	var IsErrorFound = true;
	try
	{
		var sMsg = "";
		if(document.Form1.ddlPaymentMethod.selectedIndex == 0)
		{
			sMsg += "<li>Select Payment Method</li>";
		}
		else
		{
            // CPS 5/5/08 
            // This value was 19004, changed it to 19003
			if(document.Form1.ddlPaymentMethod.value == "19003")
			{
				if(document.Form1.ddlCCType.selectedIndex == 0)
				{
					sMsg += "<li>Select Credit Card Type</li>";
				}
				if(Trim(document.Form1.txtCCNumber.value) == "")
				{
					sMsg += "<li>Enter Credit Card Number</li>";
				}
				if(document.Form1.ddlExpiryMonth.selectedIndex == 0)
				{
					sMsg += "<li>Select Expiry Month</li>";
				}
				if(document.Form1.ddlExpiryYear.selectedIndex == 0)
				{
					sMsg += "<li>Select Expiry Year</li>";
				}
				if(Trim(document.Form1.txtCVVCode.value) == "")
				{
					sMsg += "<li>Enter CVV2_CVC2 Code</li>";
				}
			}
		}
		document.getElementById("trValidationResult").style.display = "block";
		document.getElementById("tdValidationResult").innerHTML = "<ui type='disc'>" + sMsg + "</ui>";

		if(sMsg == "")
		{
			IsErrorFound = false;
			document.getElementById("trValidationResult").style.display = "none";
		}		
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}	
	return IsErrorFound;
}

function ValidateStops(StopType)
{
	var IsErrorFound = true;
	try
	{
		var sMsg = "";
		switch(StopType)
		{
			case 0:
				if(document.getElementById('hdnAddressType').value == 'Other')
				{
					if(Trim(document.Form1.txtStopName.value) == "")
					{
						sMsg += "<li>Enter Location Name</li>";
					}
					if(Trim(document.Form1.txtStopAddress1.value) == "")
					{
						sMsg += "<li>Enter Address 1</li>";
					}
					/*	if(document.Form1.ddlStopAddressPrefix.selectedIndex == "")
					{
						sMsg += "<li>Select Address 2 Prefix</li>"
					}
					if(Trim(document.Form1.txtStopAddress2.value) == "")
					{
						sMsg += "<li>Enter Address 2 </li>"
					}*/
				}
				
				if(document.getElementById('hdnAddressType').value == 'Home')
				{
					if(Trim(document.Form1.txtStopName_Home.value) == "")
					{
						sMsg += "<li>Enter Location Name</li>";
					}
					if(Trim(document.Form1.txtStopAddress1_Home.value) == "")
					{
						sMsg += "<li>Enter Address 1</li>";
					}
				
				}
				
				if(document.getElementById('hdnAddressType').value == 'Office')
				{
					if(Trim(document.Form1.txtStopName_Office.value) == "")
					{
						sMsg += "<li>Enter Location Name</li>";
					}
					if(Trim(document.Form1.txtStopAddress1_Office.value) == "")
					{
						sMsg += "<li>Enter Address 1</li>";
					}
				
				}
				break;
			case 1:
				if(document.Form1.ddlAirport.selectedIndex == 0)
				{
					sMsg += "<li>Select Airport</li>";
				}
				if(document.Form1.ddlAirline.selectedIndex == 0)
				{
					sMsg += "<li>Select Airlines</li>";
				}
				break;
			case 2:
				if(document.Form1.ddlAirStrip.selectedIndex == 0)
				{
					sMsg += "<li>Select Air Strip</li>";
				}
				break;
		}
		
		document.getElementById("trValidationResult").style.display = "block";
		document.getElementById("tdValidationResult").innerHTML = "<ui type='disc'>" + sMsg + "</ui>";

		if(sMsg == "")
		{
			IsErrorFound = false;
			document.getElementById("trValidationResult").style.display = "none";
		}		
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}	
	return IsErrorFound;
}

function CreateReservation()
{
	try
	{
		if(!ValidatePaymentInfo())
		{
			
			document.Form1.hdnSubmitStatus.value = "1";
			document.Form1.hdnStopsList.value = "";
			var tblStopInfo = document.getElementById("tblStopsList");
			var StopDetails = "";
			for(iStopCount = 1; iStopCount < tblStopInfo.rows.length; iStopCount++)
			{
                // CPS 5/1/2008 - changed from innertext (non-IE issues)
				StopDetails += tblStopInfo.rows[iStopCount].cells[5].innerHTML + "@@";
			}
			document.Form1.hdnStopsList.value = StopDetails;
			document.Form1.action = document.location.href;
			document.Form1.submit();
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

//New Function to create Profile
function CreateProfile()
{
	try
	{
		if(!ValidateCustomerInfo())
		{			
			document.Form1.action = document.location.href;
			document.Form1.submit();
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

function CreateQuote()
{
	try
	{
		if(!ValidateQuoteInfo())
		{	
			
			document.Form1.action ="Quote.php";
			document.Form1.submit();
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}


function FormatPhoneNumber(e, objSender)
{

	try
	{
	   
        var evt = (e) ? e : window.event; 
        if (evt.keyCode == 8)
            return;    // user hit backspace. no formatting needed.
            
        //alert("KeyCode = " + evt.keyCode + ". CharCode = " + evt.charCode);
            
         
	    // First check to make sure the user didn't enter a non-number
	    var ValidChars = '0123456789';
	    // Get the phone number w/o dashes
	    var PhoneNumber = objSender.value.split('-').join('');
	    
	    // loop through each character in the string
	    for (var i = 0; i < PhoneNumber.length; i++)
	    {
	       // get the current character in the string
	       Char = PhoneNumber.charAt(i);
	       // if the character isn't 0 through 9, delete it from the phone number
	       if (ValidChars.indexOf(Char) == -1)
	            PhoneNumber = PhoneNumber.substring(0, PhoneNumber.length -1);
	    }
	    	    
	    
	    // Add a dash if appropriate
	    if (PhoneNumber.length >= 3 && PhoneNumber.length < 6)
	        objSender.value = PhoneNumber.substring(0, 3) + '-' + PhoneNumber.substring(3, 6);
	    else if(PhoneNumber.length >= 3 && PhoneNumber.length >= 6)
	        objSender.value = PhoneNumber.substring(0, 3) + '-' + PhoneNumber.substring(3, 6) + '-' + PhoneNumber.substring(6);
	    else
            objSender.value = PhoneNumber;	    
    
	    
	    objSender.focus();
	}
	catch(e)
	{
	    makeAlert('Online Reservation',_e.message,'');
		objSender.focus();
	}
}

function CheckFieldValue(objSender, IsNumeric)
{
	try
	{	
		if(Trim(objSender.value) != "")
		{
			
				if(!parseInt(objSender.value) && IsNumeric)
				{ //alert('m here');
					alert("Enter only numeric values");
					objSender.value="";
					objSender.focus();
				}
			
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

function ToggleLabels(objSender)
{
	try
	{
		if(document.Form1.rbStopType[1].checked)
		{
			if(objSender.id.toUpperCase() == "RBFLIGHTARRIVAL")
			{
				document.getElementById("tdFlightTime").innerHTML = "Arrival Time";
			}
			else
			{
				document.getElementById("tdFlightTime").innerHTML = "Dept. Time";
			}
		}
		if(document.Form1.rbStopType[2].checked)
		{
			if(objSender.id.toUpperCase() == "RBPRIVATEARRIVAL")
			{
				document.getElementById("tdPrivateFlightTime").innerHTML = "Arrival Time";
			}
			else
			{
				document.getElementById("tdPrivateFlightTime").innerHTML = "Dept. Time";
			}
		}
	}
	catch(_e)
	{
		//alert(_e.message)
		makeAlert('Online Reservation',_e.message,'');
	}
}

var TargetObj = "";
var WinCal = "";
function ShowCalendar(Value1, FormName, Value2, Value3, DateFormat, CopyValue)
{
	try
	{
		CopyDateValue = CopyValue;
		TargetObj = FormName;
		WinCal = show_calendar(Value1, 'GetSelectedDate',Value2,Value3, DateFormat);		
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

function GetSelectedDate(DateValue)
{
	try
	{
		eval("document." + TargetObj).value = DateValue;
		if(CopyDateValue)
		{
			document.Form1.txtDropoffDate.value = DateValue;
		}
		WinCal = "";
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

function ShowTermsContions()
{
	try
	{
		WinPara = "directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=no,width=504,height=254,dependent=yes,resizeable=no,minimize=no,maximize=no,left=200,top=200";
		ChildWin = window.open("TermsConditions.php","",WinPara);
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
function ShowreceiptPage(Rid)
{
	try
	{
		WinPara = "directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=no,width=504,height=254,dependent=yes,resizeable=no,minimize=no,maximize=no,left=200,top=200";
		ChildWin = window.open("tt.php?RID=Rid","",WinPara);
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}

function checknumber(objSender)
{	
var IsErrorFound=true;
var x=objSender.value;
var anum=/(^\d+$)|(^\d+$)/;
try
	{	
	
		if(Trim(objSender.value) != "")
		{			
			if (anum.test(x))
			IsErrorFound=false;
			else{
			alert("Enter only numeric values");
			objSender.value="";
			objSender.focus();
			IsErrorFound=true;
			}
			
		}
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
return IsErrorFound;
}
function SetSearchdate(searchval)
{
	try
	{
		if(searchval==0)
		{
		
		var tempDate = new Date();
		var currentdate = new Date(tempDate.getYear(), tempDate.getMonth().toString(), tempDate.getDate().toString(), tempDate.getHours(), tempDate.getMinutes());	
		var todaymonth=tempDate.getMonth();
		todaymonth++;
		document.Form1.FromDay.value=tempDate.getDate();
		document.Form1.FromMonth.value=todaymonth;
		document.Form1.FromYear.value=tempDate.getYear();
		var t_mon = todaymonth++; 
		var nextdate = new Date(tempDate.getYear(), t_mon, tempDate.getDate().toString(), tempDate.getHours(), tempDate.getMinutes());	document.Form1.ToDay.value=tempDate.getDate();
		document.Form1.ToMonth.value=todaymonth;
		document.Form1.ToYear.value=tempDate.getYear();
		}

	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}
function ReceiptPrint()
{
	document.form1.butprint.visible=false;
	javascript:print();
	
}

function CmpSearchdate()
{
	var IsErrorFound=true;
	sMsgt="";
	try
	{
		
		var months = new Array(13);
	   months[0]  = "January";
	   months[1]  = "February";
	   months[2]  = "March";
	   months[3]  = "April";
	   months[4]  = "May";
	   months[5]  = "June";
	   months[6]  = "July";
	   months[7]  = "August";
	   months[8]  = "September";
	   months[9]  = "October";
	   months[10] = "November";
	   months[11] = "December";
       var now         = new Date();
	   var monthnumber = now.getMonth();
	   var monthname   = months[parseInt(document.Form1.FromMonth.value-1)];
	   var monthday    = document.Form1.FromDay.value;
	   var year        = document.Form1.FromYear.value;
	    var dateString = year+ ' ' +monthname +
						' ' +
						monthday;
		var oFromDate = new Date(dateString);
		var oToDate = new Date(document.Form1.ToYear.value,document.Form1.ToMonth.value-1,document.Form1.ToDay.value);
			
		if(oToDate < oFromDate)
		{
			//alert('The To  Date must occur after the From Date');
			sMsgt += "<li>The To  Date must occur after the From Date!</li>";
			makeAlert('Online Reservation','The To  Date must occur after the From Date','');
			//IsErrorFound=false;			
		}
		
		if(sMsgt == "")
		{
			IsErrorFound = false;
		}	
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
	return IsErrorFound;
}
function ReantalPeriodvalidation(objSender)
{
var IsErrorFound=true;
var x=objSender.value;
sMsgt="";
var anum=/(^\d+$)|(^\d+\.\d+$)/;
	try
	{	
		var rentalval=document.Form1.txtRental_Period.value;
		if(Trim(objSender.value) != "")
		{	
			
			if (!anum.test(x))
			{
			alert('Enter only numeric values');
			sMsgt += "<li>Enter only numeric values!</li>";
			document.Form1.txtRental_Period.value="";
			document.Form1.txtRental_Period.focus();			
			}
			else
			{
				if (rentalval.indexOf('.')>=0)
						{
							if(rentalval.substr(rentalval.indexOf('.')+1,rentalval.length).length>2)
								{	
								alert('Two numbers are allowed after Decimal');
								sMsgt += "<li>Two numbers are allowed after Decimal!</li>";
								document.Form1.txtRental_Period.value="";
								document.Form1.txtRental_Period.focus();
								//IsErrorFound=false;
								
							}
							else
							{
								if(rentalval.substr(rentalval.indexOf('.')+1,rentalval.length)>60)
								{
									alert('Value after decimal should be less or equal than 60');
									sMsgt += "<li>Value after decimal should be less or equal than 60!</li>";
									document.Form1.txtRental_Period.value="";
									document.Form1.txtRental_Period.focus();
									//IsErrorFound=false;
								}
							}
						}
							
			}
		}
		
		if(sMsgt == "")
		{
			IsErrorFound = false;
			
		}	
		
		
	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
	return IsErrorFound;
}


function FillAddress(AddressCode)
{
	try
	{
	var IsErrorFound = false;
	document.Form1.rbStopType[0].checked = true ;
	switch(AddressCode)
	{

		case 0:
			document.getElementById('Ctl_tblOtherAddress').style.display = 'block';
			document.getElementById('Ctl_tblHomeAddress').style.display = 'none';
			document.getElementById('Ctl_tblOfficeAddress').style.display = 'none';
			document.getElementById('hdnAddressType').value = 'Other';
					
		break;
		case 1:
			document.getElementById('Ctl_tblOtherAddress').style.display = 'none';
			document.getElementById('Ctl_tblHomeAddress').style.display = 'block';
			document.getElementById('Ctl_tblOfficeAddress').style.display = 'none';
			document.getElementById('hdnAddressType').value = 'Home';
					document.getElementById('txtStopName_Home').value = 'Customers Home';
					document.getElementById('txtStopAddress1_Home').value = document.getElementById('hdntxtStopAddress1_Home').value;
					document.getElementById('ddlStopAddressPrefix_Home').options.selectedvalue = document.getElementById('hdnddlStopAddressPrefix_Home').value;
					document.getElementById('txtStopAddress2_Home').value = document.getElementById('hdntxtStopAddress2_Home').value;
					document.getElementById('txtStopCity_Home').value = document.getElementById('hdntxtStopCity_Home').value;
				document.getElementById('ddlStopStates_Home').options.selectedvalue = document.getElementById('hdnddlStopStates_Home').value;
				//[document.getElementById('ddlStopStates_Home').selectedIndex =
					document.getElementById('txtStopZipCode_Home').value = document.getElementById('hdntxtStopZipCode_Home').value;
					document.getElementById('txtStopPhone_Home').value = document.getElementById('hdntxtStopPhone_Home').value;
					//document.getElementById('txtStopComment_Home').value =document.getElementById('hdntxtStopComment_Home').value;
		break;
		case 2:
			if(!ValidateCustomerInfo())
			{
				document.getElementById('Ctl_tblOtherAddress').style.display = 'none';
				document.getElementById('Ctl_tblHomeAddress').style.display = 'none';
				document.getElementById('Ctl_tblOfficeAddress').style.display = 'block';
				document.getElementById('hdnAddressType').value = 'Office';
				document.getElementById('txtStopName_Office').value = document.getElementById('hdntxtStopName_Office').value;
					document.getElementById('txtStopAddress1_Office').value = document.getElementById('hdntxtStopAddress1_Office').value;
					document.getElementById('ddlStopAddressPrefix_Office').options.selectedvalue = document.getElementById('hdnddlStopAddressPrefix_Office').value;
					//document.getElementById('txtStopAddress2_Office').value = document.getElementById('hdntxtStopAddress2_Office').value;
					document.getElementById('txtStopCity_Office').value = document.getElementById('hdntxtStopCity_Office').value;
					document.getElementById('ddlStopStates_Office').options.selectedvalue =document.getElementById('hdnddlStopStates_Office').value;
					document.getElementById('txtStopZipCode_Office').value = document.getElementById('hdntxtStopZipCode_Office').value;
					document.getElementById('txtStopPhone_Office').value = document.getElementById('hdntxtStopPhone_Office').value;
					//document.getElementById('txtStopComment_Office').value =document.getElementById('hdntxtStopComment_Office').value;
			}
		break;
		
	}

	}
	catch(_e)
	{
		//alert(_e.message);
		makeAlert('Online Reservation',_e.message,'');
	}
}