//travel insurance
function validateForm() {
        if (document.getElementById('country').value == '') {
                alert('Please pick your country of residence and try again.');
                return false;
        }
        var d=new Date();
        if (document.getElementById('year').value < d.getFullYear() || (document.getElementById('year').value == d.getFullYear() && document.getElementById('month').value < d.getMonth() + 1) || (document.getElementById('year').value == d.getFullYear() && document.getElementById('month').value == d.getMonth() + 1 && document.getElementById('day').value < d.getDate())) {
                alert('Please select a date in the future and try again.');
                return false;
        }
        if (document.getElementById('family').checked == false && document.getElementById('single').checked == false) {
                alert('Please select a type of policy and try again.');
                return false;
        }
}


//tours
function populateToursCityList(country) {
	newcountry = country.replace(/[^0-9a-zA-Z]/g,'');
	newcountry = newcountry.replace(/\'/g,'');
	if (country.length == 0) {
		document.getElementById('cityChoice').length = 1;
		return;
	}

	newOptions = eval(newcountry+'Array');

	document.getElementById('cityChoice').length = 1;
	document.getElementById('cityChoice').options[0] = new Option("All Cities/Regions");
	document.getElementById('cityChoice').options[0].value = '';
	document.getElementById('cityChoice').options[0].selected = true;

	for (i=0; i<newOptions.length; i++) {
		if(newOptions[i] != "") {
			thisEntry = newOptions[i].split("__");
			document.getElementById('cityChoice').length = i+1;
			newOption = new Option(thisEntry[1],thisEntry[1]);
			newOption.value = thisEntry[1] + ';' + country;
			document.getElementById('cityChoice').options[i+1] = newOption;
			if(thisEntry[0] == 'd') {
				document.getElementById('cityChoice').options[i+1].className="tours-searchboxheading";
			}
		}
	}

	//filter out duplicates
	var previousOption;
	$('select[name=cityChoice] option').each(function() {
		if (this.text == previousOption) $(this).remove();
		previousOption= this.text;
	});
}

function clearToursText() {
  if(document.toursForm.tourKeywords.value == 'Keywords (optional)') {
    document.toursForm.tourKeywords.value = '';
  }
}

function checkToursSearchSubmit() {
  if((document.getElementById('countryChoice').value == 'Select a Country' || document.getElementById('countryChoice').value == '') && (document.getElementById('activityChoice').value == 'Select Activity' || document.getElementById('activityChoice').value == '')) {
    alert("Please choose a country or activity");
    return false;
  }
}


