

var MonthNames = new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
var MonthNamesLong = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var MonthNamesLower = new Array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
var TwoDigitMonths = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
var TwoDigitDays = new Array('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');

function getListValue( option_object  )
{
 return option_object[ option_object.selectedIndex ].value;
}



function fOptionText(rSelect) {
    return rSelect.options[rSelect.selectedIndex].text;
}

function TranslateInputs( FormName) {

	var Today = new Date();
	var PickUpDate = new Date( document.forms.CarHireMetaSearch.PickUpYear.value, document.forms.CarHireMetaSearch.PickUpMonth.value - 1, document.forms.CarHireMetaSearch.PickUpDay.value);
	var DropOffDate = new Date( document.forms.CarHireMetaSearch.DropOffYear.value, document.forms.CarHireMetaSearch.DropOffMonth.value - 1, document.forms.CarHireMetaSearch.DropOffDay.value);
	var strPickUp = 'None'; // default
    strPickUp = document.forms.CarHireMetaSearch.PickUp.value;

    if(!fValidate(strPickUp)) {
        alert('Please select a country');
        return false;
    }

	if (PickUpDate < Today) {
		alert('Please select a pick-up date on or after today.');
		return false;
	}

	if (DropOffDate <= PickUpDate) {
		alert('Please select a pick-up date on or after the drop-off date.');
		return false;
	}

	
	RecordTracking()
    
	if (FormName == 'EconomyCarHire') {

        var loc
		switch (document.forms.CarHireMetaSearch.PickUp.value) 
		{ 
		   case 'Bulgaria': 
		      loc = 24
		      break 
		   case 'Croatia': 
		      loc = 11
		      break 
		   case 'Cyprus': 
		      loc = 9
		      break 
		   case 'Estonia': 
		      loc = 18
		      break 
		   case 'Greece - Islands': 
		      loc = 14
		      break 
		   case 'Hungary': 
		      loc = 23
		      break 
		   case 'Greece - Mainland': 
		      loc = 13
		      break 
		   case 'Italy - Mainland': 
		      loc = 6
		      break 
		   case 'Italy - Sardinia': 
		      loc = 7
		      break 
		   case 'Italy - Sicily': 
		      loc = 8
		      break 
		   case 'Ireland': 
		      loc = 20
		      break 
		   case 'Latvia': 
		      loc = 19
		      break 
		   case 'Malta': 
		      loc = 10
		      break 
		   case 'Montenegro': 
		      loc = 17
		      break 
		   case 'Morocco':
		      loc = 26
		      break
		   case 'Netherlands': 
		      loc = 22
		      break 
		   case 'Portugal - Madeira': 
		      loc = 5
		      break 
		   case 'Portugal - Mainland': 
		      loc = 4
		      break 
		   case 'Serbia': 
		      loc = 16
		      break 
		   case 'Slovenia': 
		      loc = 12
		      break 
		   case 'Spain - Balearic Islands': 
		      loc = 3
		      break 
		   case 'Spain - Canary Islands': 
		      loc = 2
		      break 
		   case 'Spain - Mainland': 
		      loc = 1
		      break 
		   case 'Turkey': 
		      loc = 15
		      break 
		   case 'United Kingdom': 
		      loc = 21
		      break 
		   case 'Lithuania': 
		      loc = 25
		      break 
		   default:
              loc = 1
		}

        document.forms['EconomyCarHire']['country'].value = loc
        document.forms['EconomyCarHire']['start'].value = TwoDigitDays[document.forms.CarHireMetaSearch.PickUpDay.value - 1] + '-' + TwoDigitMonths[document.forms.CarHireMetaSearch.PickUpMonth.value - 1] + '-' + document.forms.CarHireMetaSearch.PickUpYear.value.substring(2,4) + '-13-00'; //dd-mm-yy-hh-mm
        document.forms['EconomyCarHire']['stop'].value = TwoDigitDays[document.forms.CarHireMetaSearch.DropOffDay.value - 1] + '-' + TwoDigitMonths[document.forms.CarHireMetaSearch.DropOffMonth.value - 1] + '-' + document.forms.CarHireMetaSearch.DropOffYear.value.substring(2,4) + '-13-00'; //dd-mm-yy-hh-mm

        fFormSubmit(FormName);
	}

	if (FormName == 'OvertureCarHireHOWO') {

        fFormSubmit(FormName);
	}

	if (FormName == 'CarRentals') {

        fFormSubmit(FormName);
	}


}

function ShowHelp() {

	alert('Please complete Step 2 and select one of our partners to conduct your search.');
}


function fFormSubmit(vFormName) {
    bigwin(vFormName);
    document.forms[vFormName].submit();
}

function fValidate(strSelected) {    
    if(strSelected == 'None') {
        return false;
    } else {
        return true;
    }    
}
