function fillHotel() {
	var HotelNames = new arr ("Hotel Gellert****","Hotel Taverna****",
            "Club Hotel Ambra****","Hotel Pava Plaza****",
            "Hotel Burg***","Hotel Sissi***",
            "Hotel City Panzio Matyas***","Hotel Anna***",
            "Hotel Corvin***","Hotel Beatrix Panzio***",
            "Hotel Classic***","Hotel Wien Best Western***",
            "Hotel Benta***","Hotel Remete***",
            "Hotel Romantik***","Hotel Senator Haz***","Bacchus Panzio",
            "Hotel Apollo***","Hotel Palma***",
            "Hotel Club Tihany**** - Tihany","Hotel Fured*** - Balatonfured",
            "Nemeth Panzio - Balatonfured","Hotel Marina Port*** - Balatonkenese",
            "BLE-001 Holiday Rental - Balatonlelle","BLE-002 Holiday Rental - Balatonlelle",
            "BLE-003 Holiday Rental - Balatonlelle","BLE-004 Holiday Rental - Balatonlelle",
            "BLE-005 Holiday Rental - Balatonlelle","Agas Panzio - Csopak",
		"GYD-001 Holiday Rental - Gyenesdias");
	var i;

	document.Form.Hotel.selectedIndex = 0;
	switch (document.Form.HotelCity.selectedIndex) {
		case 1:	document.Form.Hotel.options.length = 15;
				document.Form.Hotel.options[0].text = "Select a Hotel in Budapest";
				for (i=0; i<14; i++) {document.Form.Hotel.options[i+1].text = HotelNames[i];	}
				break;

		case 2:	document.Form.Hotel.options.length = 4;
				document.Form.Hotel.options[0].text = "Select a Hotel in Eger";
				for (i=0; i<3; i++) {document.Form.Hotel.options[i+1].text = HotelNames[i+14];	}
				break;
				
		case 3:	document.Form.Hotel.options.length = 3;
				document.Form.Hotel.options[0].text = "Select a Hotel in Kecskemet";
				for (i=0; i<2; i++) {document.Form.Hotel.options[i+1].text = HotelNames[i+17];	}
				break;
				
		case 4:	document.Form.Hotel.options.length = 12;
				document.Form.Hotel.options[0].text = "Select a Hotel in Lake Balaton";
				for (i=0; i<11; i++) {document.Form.Hotel.options[i+1].text = HotelNames[i+19];	}
				break;
			
	   default:		document.Form.Hotel.options.length = 31;
				document.Form.Hotel.options[0].text = "Select a Hotel";
				for (i=0; i<30; i++) {document.Form.Hotel.options[i+1].text = HotelNames[i];	}
				
	}
}

function setHotel() {
	var sortHotelNames = new arr ("gellert","taverna","ambra","pava",
            "burg","sissi","matyas","anna","corvin","beatrix",
            "classic","wien","benta","remete","romantik","senator",
            "bacchus","apollo","palma","tihany","fured","nemeth",
            "marina","ble001","ble002","ble003","ble004","ble005",
            "agas","gyd001");

	var queryString = document.location.search.substring(1);
	var city;
	var hotel;
	if (queryString.length > 0) {
		var queryArray = queryString.split("&");
		for (var n=0; n < queryArray.length; n++) {
			pairSplit = queryArray[n].indexOf("=");
			if (pairSplit != -1) {
				if (queryArray[n].substring(0,pairSplit) == "hotel") {
				hotel = queryArray[n].substring(pairSplit+1);
				for (var j = 0; j < sortHotelNames.length; j++) {
					if (sortHotelNames[j] == hotel) {
						document.Form.Hotel.selectedIndex = j + 1;
					}
				}
				}
			}
		}
	}
}

function setCar() {
	var sortCarNames = new arr ("seicento","punto","palio","sedan",
            "bravo","marea","wagon","convertible","alfa156","lybra",
		"multipla","barchetta","mondeo","mondeoaut","alfa166","spider",
		"minivan","delivery","maxi");

	var queryString = document.location.search.substring(1);
	var car;
	if (queryString.length > 0) {
		var queryArray = queryString.split("&");
		for (var n=0; n < queryArray.length; n++) {
			pairSplit = queryArray[n].indexOf("=");
			if (pairSplit != -1) {
				if (queryArray[n].substring(0,pairSplit) == "car") {
				car = queryArray[n].substring(pairSplit+1);
				for (var j = 0; j < sortCarNames.length; j++) {
					if (sortCarNames[j] == car) {
						document.Form.CarType.selectedIndex = j + 1;
					}
				}
				}
			}
		}
	}
}

function setHydro() {
	var sortHydroNames = new arr ("btov01","btov02","btov03","btov04",
            "btov05","vtob01","vtob02","vtob03","vtob04","vtob05");

	var queryString = document.location.search.substring(1);
	var hydro;
	if (queryString.length > 0) {
		var queryArray = queryString.split("&");
		for (var n=0; n < queryArray.length; n++) {
			pairSplit = queryArray[n].indexOf("=");
			if (pairSplit != -1) {
				if (queryArray[n].substring(0,pairSplit) == "hydro") {
				hydro = queryArray[n].substring(pairSplit+1);
				for (var j = 0; j < sortHydroNames.length; j++) {
					if (sortHydroNames[j] == hydro) {
						document.Form.HydroLine.selectedIndex = j + 1;
					}
				}
				}
			}
		}
	}
}

function setTours() {
	var sortTourNames = new arr ("le001","le002","cr001","cr002",
            "cr002a","cr003","cr004","cr005","cr006","cr007",
            "cr008","cr009","cr010");

	var queryString = document.location.search.substring(1);
	var tour;
	if (queryString.length > 0) {
		var queryArray = queryString.split("&");
		for (var n=0; n < queryArray.length; n++) {
			pairSplit = queryArray[n].indexOf("=");
			if (pairSplit != -1) {
				if (queryArray[n].substring(0,pairSplit) == "tour") {
				tour = queryArray[n].substring(pairSplit+1);
				for (var j = 0; j < sortTourNames.length; j++) {
					if (sortTourNames[j] == tour) {
						document.Form.Tour1.selectedIndex = j + 1;
					}
				}
				}
			}
		}
	}
}

function stepSelect() {
var step = "0000";
	if (document.Form.Hotel.checked == true) {
		step = "1" + step.substring(1,4);
		}
	if (document.Form.Car.checked == true) {
		step = step.substring(0,1) + "1" + step.substring(2,4);
		}
	if (document.Form.Hydro.checked == true) {
		step = step.substring(0,2) + "1" + step.substring(3,4);
		}
	if (step == "0000") {
		alert("You must select at least one option, or enter your Quotation Number!");
		return(false);
		}
	goNext(0,step);
}

function goNext(fromPage,step) {
	var queryString = document.location.search.substring(1);
	var nextPage = new Array ('form_wizard.htm','form_wizard2.htm',
					'form_wizard3.htm','form_wizard4.htm','form_wizard5.htm');
	var i = fromPage;
	if (queryString.length > 0) {
		var queryArray = queryString.split("&");
		for (var n=0; n < queryArray.length; n++) {
		pairSplit = queryArray[n].indexOf("=");
		if (pairSplit != -1) {
			if (queryArray[n].substring(0,pairSplit) == "step") {
			step = queryArray[n].substring(pairSplit+1);
				}
			}
		}
	}
	while (i < 4) {
	if (step.substring(i,i+1) == "1")
		break
	i++;
	}
	document.Form._browser_out.value = nextPage[i];
	document.Form.action = "/cgi-bin/besthotelz/hungary/wizard.cgi?step=" + step;
}

function setActualDate(mName,dName,yName,day) {
	var DayName = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')
	var actDate = new Date();
	document.Form.elements[mName].options.selectedIndex = actDate.getMonth();
	document.Form.elements[dName].options.selectedIndex = actDate.getDate() - 1;
	document.Form.elements[yName].options.selectedIndex = actDate.getFullYear() - document.Form.elements[yName].options[0].text;
	if (document.all) {
		document.all(day).innerHTML = DayName[actDate.getDay()];
	}
	if (document.layers) {
	//	document.layers[day].document.write(DayName[actDate.getDay()]);
      //	document.layers[day].document.close();
	}
}

function resetForm() {
	document.Form.reset();
	initForm();
}

function checkHotel() {
                	var curDate = new Date(); 
                	var todayDate = new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate() ); 
                	var arrivalDate = new Date(document.Form.YArrival.options[document.Form.YArrival.selectedIndex].text, document.Form.MArrival.selectedIndex, document.Form.DArrival.selectedIndex + 1); 
				  	var departureDate = new Date(document.Form.YDeparture.options[document.Form.YDeparture.selectedIndex].text, document.Form.MDeparture.selectedIndex, document.Form.DDeparture.selectedIndex + 1);

                if (document.Form.HotelCity.selectedIndex == 0 && document.Form.Hotel.selectedIndex == 0 &&
                    document.Form.Room1.value.length == 0 && document.Form.Room2.value.length == 0 && document.Form.Room3.value.length == 0 && document.Form.Room4.value.length == 0 &&
                    document.Form.Apartment.value.length == 0 && document.Form.SpareBed.value.length == 0)
                {
                   return (true);
                }

				  if (todayDate - arrivalDate > 0)
				  {
					alert("Sorry, the Arrival Date is invalid.");
					document.Form.DArrival.focus();
					return (false);
				  }


				  if (departureDate - arrivalDate < 0)
				  {
					alert("Sorry, the Departure Date is earlier than Arrival Date.");
					document.Form.DDeparture.focus();
					return (false);
				  }

                if (document.Form.Hotel.selectedIndex == 0)
                {
                   alert("Please select a Hotel.");
                   document.Form.Hotel.focus();
                   return (false);
                }

                if (document.Form.Room1.value == "" & document.Form.Room2.value == "" & document.Form.Room3.value == ""
                    & document.Form.Room4.value == "" & document.Form.Apartment.value == "")
                {
                   alert("Please enter the number of rooms or apartments.");
                   document.Form.Room1.focus();
                   return (false);
                }

                return (true);
}

function checkCar() {

                	var curDate = new Date(); 
                	var todayDate = new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate() ); 
                	var pickupDate = new Date(document.Form.YPickup.options[document.Form.YPickup.selectedIndex].text, document.Form.MPickup.selectedIndex, document.Form.DPickup.selectedIndex + 1); 
				  	var returnDate = new Date(document.Form.YReturn.options[document.Form.YReturn.selectedIndex].text, document.Form.MReturn.selectedIndex, document.Form.DReturn.selectedIndex + 1);

                if (document.Form.PLocation.value == "" && document.Form.FlightNumber.value == "" &&
                    document.Form.RLocation.value == "" && document.Form.CarType.selectedIndex == 0)
                {
                   return (true);
                }

                if (document.Form.PLocation.value == "")
                {
                   alert("Please enter the Pickup Location.");
                   document.Form.PLocation.focus();
                   return (false);
                }

				  if (todayDate - pickupDate > 0)
				  {
					alert("Sorry, the Pickup Date is invalid.");
					document.Form.DPickup.focus();
					return (false);
				  }


                if (document.Form.RLocation.value == "")
                {
                   alert("Please enter the Return Location.");
                   document.Form.RLocation.focus();
                   return (false);
                }

				  if (returnDate - pickupDate < 0)
				  {
					alert("Sorry, the Return Date is earlier than Pickup Date.");
					document.Form.DReturn.focus();
					return (false);
				  }

                if (document.Form.CarType.selectedIndex == "0")
                {
                   alert("Please select a Car Type.");
                   document.Form.CarType.focus();
                   return (false);
                }

					  return (true);
}

function checkHydro() {

                	var curDate = new Date(); 
                	var todayDate = new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate() ); 
                	var hydroDate = new Date(document.Form.HydroDateY.options[document.Form.HydroDateY.selectedIndex].text, document.Form.HydroDateM.selectedIndex, document.Form.HydroDateD.selectedIndex + 1); 
				  	var hReturnDate = new Date(document.Form.HReturnDateY.options[document.Form.HReturnDateY.selectedIndex].text, document.Form.HReturnDateM.selectedIndex, document.Form.HReturnDateD.selectedIndex + 1);

                if (document.Form.HydroLine.selectedIndex == "0" && document.Form.HReturnLine.selectedIndex == "0" &&
                    document.Form.HydroAdults.value == "" && document.Form.HydroChildren.value == "" &&
                    document.Form.HydroChildrenU6.value == "" && document.Form.HydroComments.value == "")
                {
                   return (true);
                }
                
				  if (todayDate - hydroDate > 0)
				  {
					alert("Sorry, the Date Of Travel is invalid.");
					document.Form.HydroDateD.focus();
					return (false);
				  }


                if (document.Form.HydroAdults.value == "")
                {
                   alert("Please enter the number of Adults and Children");
                   document.Form.HydroAdults.focus();
                   return (false);
                }

                return (true);
}

function checkTours() {
                	var curDate = new Date(); 
                	var todayDate = new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate() ); 
                	var tour1Date = new Date(document.Form.YTour1.options[document.Form.YTour1.selectedIndex].text, document.Form.MTour1.selectedIndex, document.Form.DTour1.selectedIndex + 1); 
                	var tour2Date = new Date(document.Form.YTour2.options[document.Form.YTour2.selectedIndex].text, document.Form.MTour2.selectedIndex, document.Form.DTour2.selectedIndex + 1); 
                	var tour3Date = new Date(document.Form.YTour3.options[document.Form.YTour3.selectedIndex].text, document.Form.MTour3.selectedIndex, document.Form.DTour3.selectedIndex + 1); 
                	var tour4Date = new Date(document.Form.YTour4.options[document.Form.YTour4.selectedIndex].text, document.Form.MTour4.selectedIndex, document.Form.DTour4.selectedIndex + 1); 

                if (tour1Date - todayDate == 0 && tour2Date - todayDate == 0 &&
                    tour3Date - todayDate == 0 && tour4Date - todayDate == 0 &&
                    document.Form.Tour1.selectedIndex == "0" && document.Form.Tour2.selectedIndex == "0" &&
                    document.Form.Tour3.selectedIndex == "0" && document.Form.Tour4.selectedIndex == "0" &&
                    document.Form.TourAdults1.value == "" && document.Form.TourChildren1.value == "" &&
                    document.Form.TourAdults2.value == "" && document.Form.TourChildren2.value == "" &&
                    document.Form.TourAdults3.value == "" && document.Form.TourChildren3.value == "" &&
                    document.Form.TourAdults4.value == "" && document.Form.TourChildren4.value == "")
                {
                   return (true);
                }
                
                if (tour1Date - todayDate == 0 && document.Form.Tour1.selectedIndex == "0" & 
                    document.Form.TourAdults1.value == "")
                {
 
                }
                else
                {
                   if (todayDate - tour1Date > 0)
                   {
                      alert("Sorry, the Date is not valid.");
                      document.Form.DTour1.focus();
                      return (false);
                   }

                   if (document.Form.Tour1.selectedIndex == "0")
                   {
                      alert("Please select a Tour.");
                      document.Form.Tour1.focus();
                      return (false);
                   }

                   if (document.Form.TourAdults1.value == "")
                   {
                      alert("Please enter the Number Of Adults.");
                      document.Form.TourAdults1.focus();
                      return (false);
                   }               
                }

                if (tour2Date - todayDate == 0 && document.Form.Tour2.selectedIndex == "0" & 
                    document.Form.TourAdults2.value == "")
                {
 
                }
                else
                {
                   if (todayDate - tour2Date > 0)
                   {
                      alert("Sorry, the Date is not valid.");
                      document.Form.DTour2.focus();
                      return (false);
                   }

                   if (document.Form.Tour2.selectedIndex == "0")
                   {
                      alert("Please select a Tour.");
                      document.Form.Tour2.focus();
                      return (false);
                   }

                   if (document.Form.TourAdults2.value == "")
                   {
                      alert("Please enter the Number Of Adults.");
                      document.Form.TourAdults2.focus();
                      return (false);
                   }               
                }

                if (tour3Date - todayDate == 0 && document.Form.Tour3.selectedIndex == "0" & 
                    document.Form.TourAdults3.value == "")
                {
 
                }
                else
                {
                   if (todayDate - tour3Date > 0)
                   {
                      alert("Sorry, the Date is not valid.");
                      document.Form.DTour3.focus();
                      return (false);
                   }

                   if (document.Form.Tour3.selectedIndex == "0")
                   {
                      alert("Please select a Tour.");
                      document.Form.Tour3.focus();
                      return (false);
                   }

                   if (document.Form.TourAdults3.value == "")
                   {
                      alert("Please enter the Number Of Adults.");
                      document.Form.TourAdults3.focus();
                      return (false);
                   }               
                }

                if (tour4Date - todayDate == 0 && document.Form.Tour4.selectedIndex == "0" & 
                    document.Form.TourAdults4.value == "")
                {
 
                }
                else
                {
                   if (todayDate - tour4Date > 0)
                   {
                      alert("Sorry, the Date is not valid.");
                      document.Form.DTour4.focus();
                      return (false);
                   }

                   if (document.Form.Tour4.selectedIndex == "0")
                   {
                      alert("Please select a Tour.");
                      document.Form.Tour4.focus();
                      return (false);
                   }

                   if (document.Form.TourAdults4.value == "")
                   {
                      alert("Please enter the Number Of Adults.");
                      document.Form.TourAdults4.focus();
                      return (false);
                   }               
                }
                return (true);
}

function checkPersonal() {
             	var curDate = new Date(); 
             	var todayDate = new Date(curDate.getFullYear(), curDate.getMonth()); 
             	var expiryDate = new Date(document.Form.CValidYear.options[document.Form.CValidYear.selectedIndex].text, document.Form.CValidMonth.selectedIndex); 

                if (document.Form.FirstName.value == "")
                {
                   alert("Please enter your First Name.");
                   document.Form.FirstName.focus();
                   return (false);
                }

                if (document.Form.LastName.value == "")
                {
                   alert("Please enter your Last Name.");
                   document.Form.LastName.focus();
                   return (false);
                }

                if (document.Form.Address.value == "")
                {
                   alert("Please enter your Address.");
                   document.Form.Address.focus();
                   return (false);
                }

                if (document.Form.City.value == "")
                {
                   alert("Please enter your City.");
                   document.Form.City.focus();
                   return (false);
                }

                if (document.Form.ZipCode.value == "")
                {
                   alert("Please enter your ZIP Code.");
                   document.Form.ZipCode.focus();
                   return (false);
                }

                if (document.Form.Country.selectedIndex == "0")
                {
                   alert("Please select your Country.");
                   document.Form.Country.focus();
                   return (false);
                }

                if (document.Form.Country.options[document.Form.Country.selectedIndex].text == "USA" & document.Form.State.selectedIndex == "0")
                {
                   alert("Please select your State, too.");
                   document.Form.State.focus();
                   return (false);
                }

                if (document.Form.e_mail.value == "")
                {
                   alert("Please enter your E-mail.");
                   document.Form.e_mail.focus();
                   return (false);
                }

                if (document.Form.Guarantee[0].checked == false & document.Form.Guarantee[1].checked == false)
                {
                   alert("Please select a Guarantee.");
                   document.Form.email.focus();
                   return (false);
                }

                if (document.Form.Guarantee[1].checked)
                {
                   if (document.Form.CName.value == "" || document.Form.CName.value == " ")
                   {
                      alert("Please enter the Cardholder's Name.");
                      document.Form.CName.focus();
                      return (false);
                   }

                   if (document.Form.CAddress.value == "")
                   {
                      alert("Please enter the Cardholder's Address.");
                      document.Form.CAddress.focus();
                      return (false);
                   }

                   if (document.Form.CCity.value == "")
                   {
                      alert("Please enter the Cardholder's City.");
                      document.Form.CCity.focus();
                      return (false);
                   }

                   if (document.Form.CZipCode.value == "")
                   {
                      alert("Please enter the Cardholder's ZIP Code.");
                      document.Form.CZipCode.focus();
                      return (false);
                   }

                   if (document.Form.CCountry.selectedIndex == "0")
                   {
                      alert("Please select the Cardholder's Country.");
                      document.Form.CCountry.focus();
                      return (false);
                   }

                   if (document.Form.CCountry.options[document.Form.CCountry.selectedIndex].text == "USA" & document.Form.CState.selectedIndex == "0")
                   {
                      alert("Please select the Cardholder's State, too.");
                      document.Form.CState.focus();
                      return (false);
                   }

                   if (document.Form.CNumber.value == "")
                   {
                      alert("Please enter the Credit Card Number.");
                      document.Form.CNumber.focus();
                      return (false);
                   }
                   if (expiryDate - todayDate < 0)
                   {
                      alert("Sorry, your Credit Card has expired!");
                      document.Form.CValidMonth.focus();
                      return (false);
                   }

                }

                return (true);
}

function Copy() {
                document.Form.CName.value = document.Form.FirstName.value + " " +document.Form.LastName.value;
                document.Form.CAddress.value = document.Form.Address.value;
                document.Form.CCity.value = document.Form.City.value;
                document.Form.CZipCode.value = document.Form.ZipCode.value;
                document.Form.CCountry.selectedIndex= document.Form.Country.selectedIndex;
                document.Form.CState.selectedIndex= document.Form.State.selectedIndex;
}

function Clear() {
                document.Form.CName.value = "";
                document.Form.CAddress.value = "";
                document.Form.CCity.value = "";
                document.Form.CZipCode.value = "";
                document.Form.CCountry.selectedIndex = 0;
                document.Form.CState.selectedIndex = 0;
                document.Form.CNumber.value = "";
}
