$(document).ready(function(){
	// alert('Welcome to Mexican Auto Insurance!');
		
  $('#goQuoteButton').click(function(){
  	var polType = $('#policyTypeSelect').val();
  	if (polType == 'auto') {
	    $('#quickQuote').show();
			// alert('You selected policy type: Auto!');
    } else if (polType == 'home') {
    	document.location  = 'https://secure.mexicanautoinsurance.com/buy/home/homeowners-mexican-insurance.lasso';
    } else if (polType == 'boat') {
    	document.location  = 'http://www.mexicanautoinsurance.com/boat-mexican-insurance.html';
    } else if (polType == 'medical') {
    	document.location  = 'http://www.worldtrips.com/quotes/atlas/quote.asp?referid=22324021A&language=english';
    } else if (polType == 'medicalEvac') {
    	document.location  = 'http://www.mexicanautoinsurance.com/skymed.html';
    } else if (polType == 'kidnap') {
    	document.location  = 'http://www.mexicanautoinsurance.com/kidnap-ransom-mexican-insurance.html';
    } else {
    	alert('Not yet implemented: ' + $('#policyTypeSelect').val());
    }
  });	
	
$('#dateofentry').datepicker({
  showOn: 'both',
  buttonText: 'Choose a date',
  buttonImage: 'calendar.png',
  buttonImageOnly: true,
  numberOfMonths: 2,
  maxDate: '2m',
  minDate: '0d',
  showButtonPanel: true
});

$("form").submit(function() {
	var error = false;
	$(this).find("select").each(function() {
		if ($(this).val().length == 0) {
			alert("All fields are required.");
			$(this).focus();
			error = true;
			return false;  // Only exits the "each" loop
		}
	});
	if (error) {
		// alert('Validation returns FALSE');
		return false;
	}
	// alert('Validation returns TRUE');
	return true;
});
	
	
});
