// JavaScript Document

// functions related to the index page, stage 1 of availability check

// Set up array of cars to populate car select box
AFcars = new Array(13)

AFcars[0] = "Tata Indica"
AFcars[1] = "Toyota Qualis"
AFcars[2] = "Toyota Innova"
AFcars[3] = "Maruti Esteem"
AFcars[4] = "Ford Ikon"
AFcars[5] = "Mitsubishi Lancer"
AFcars[6] = "Honda City"
AFcars[7] = "Maruti Baleno"
AFcars[8] = "Toyota Corolla"
AFcars[9] = "Hyundai Sonata"
AFcars[10] = "Toyota Camry"
AFcars[11] = "Mercedes Benz E-Class"
AFcars[12] = "Mercedes Benz S-Class"

function AFSetInitialSelections()
{
	document.availability1.Service.selectedIndex = 0
	document.availability1.Car.selectedIndex = 1
	document.availability1.SIMcards.selectedIndex = 1
	document.availability1.Cellphones.selectedIndex = 0
}

// Change form element attributes based on the service selected
function AFChangeByService()
{
	//allows our select objects to be called with a single variable
	AFserviceSelect = document.availability1.Service
	AFcarSelect = document.availability1.Car
	AFSIMSelect = document.availability1.SIMcards
	AFcellSelect = document.availability1.Cellphones
	
	var AFswitchVar = AFserviceSelect.selectedIndex	//the selected service as the switch variable
	
	
	//Disable appropriate select boxes, set size of car select and populate as necessary
	switch (AFswitchVar) {
			case 0 : 
					AFcarSelect.length = 13
					AFSIMSelect.selectedIndex = 1
					AFcellSelect.selectedIndex = 0
					AFSIMSelect.disabled = 0
					AFcellSelect.disabled = 0
			
					for (i = 0; i < AFcarSelect.length; i++)
						AFcarSelect.options[i] = new Option(AFcars[i], i)
					;
					break
			case 1 : 
					AFcarSelect.length = 2
					AFSIMSelect.selectedIndex = 0
					AFcellSelect.selectedIndex = 0
					AFSIMSelect.disabled = 1
					AFcellSelect.disabled = 1
			
					for (i = 0; i < AFcarSelect.length; i++)
						AFcarSelect.options[i] = new Option(AFcars[i], i)
					;
					break
			case 2 : 
					AFcarSelect.length = 2
					AFSIMSelect.selectedIndex = 0
					AFcellSelect.selectedIndex = 0
					AFSIMSelect.disabled  = 1
					AFcellSelect.disabled = 1
			
					for (i = 0; i < AFcarSelect.length; i++)
						AFcarSelect.options[i] = new Option(AFcars[i], i)
					;
					break
			case 3 : 
					AFcarSelect.length = 2
					AFSIMSelect.selectedIndex = 1
					AFcellSelect.selectedIndex = 0
					AFSIMSelect.disabled = 0
					AFcellSelect.disabled = 0
			
					for (i = 0; i < AFcarSelect.length; i++)
						AFcarSelect.options[i] = new Option(AFcars[i], i)
				;
				break
			}
	
	AFcarSelect.selectedIndex = 1
				
}	

//information pop up function
function AFPopUp(url)
{
	newWindow=window.open(url,'name','height=180,width=300');
	if (window.focus) {newWindow.focus()}
}	
	
//function to pass details onto next page, stage 2 of availability check/booking form.
function AFPassToNextPage()
{
	//allows our select objects to be called with a single variable
	AFserviceSelect = document.availability1.Service
	AFcarSelect = document.availability1.Car
	AFSIMSelect = document.availability1.SIMcards
	AFcellSelect = document.availability1.Cellphones
	AFcurrencySelect = document.availability1.Currency
	
	document.location.href = "checkavail.htm?selectedService="+AFserviceSelect.selectedIndex+
						"&selectedCar="+AFcarSelect.selectedIndex+
						"&selectedSIM="+AFSIMSelect.selectedIndex+
						"&selectedCell="+AFcellSelect.selectedIndex+
						"&currency="+AFcurrencySelect.selectedIndex+
						""
}	

