// JavaScript Document


function validate() {
	
	var firstName = document.getElementById("firstName");
	var lastName = document.getElementById("lastName");
	var phone = document.getElementById("phone");
	var email = document.getElementById("email");
	
	var errorMessage = "";

	if( firstName.value == "" ) {
		errorMessage += "First Name\n";
	}
	
	if( lastName.value == "" ) {
		errorMessage += "Last Name\n";
	}
	
	if( phone.value == "" ) {
		errorMessage += "Phone\n";
	}
	
	if( email.value == "" ) {
		errorMessage += "Email\n";
	}
	
	if( errorMessage != "" ) {		
		alert("Please complete the following fields before continuing: \n\n"+errorMessage);
		return false;		
	}
	
	return true;
	
}

function getUnitTypes() {

	var location_id = $('#location').val();
	
	if( location_id == 0 ) {
		return 0;	
	}

	  $.get("includes/ajax.reserve_form.php", { location: location_id, type: "unitType" },
			  function(data) {
				  $('#rf_types').show();
				  $('#rf_types').html(data);				  
			  }
			);
}

function getUnitTypes1() {

	var location_id = $('#location').val();
	if( location_id == 0 ) {
		return 0;	
	}

	  $.get("../../../../includes/ajax.reserve_form.php", { location: location_id, type: "unitType", page_in: "location_info" },
			  function(data) {
				  $('#rf_types').show();
				  $('#rf_types').html(data);				  
			  }
			);
}

function getSizes() {

	var location_id = $('#location').val();
	var unitType_text = $('#unitType option:selected').text();
	var unitType_id = $('#unitType').val();
	
	if( unitType_id == 0 ) {
		return 0;	
	}

	  $.get("includes/ajax.reserve_form.php", { location: location_id, unitType: unitType_text, type: "unitSize" },
			  function(data) {
				  $('#rf_sizes').show();
				  $('#rf_sizes').html(data);				  
			  }
			);

}

function getSizes1() {

	var location_id = $('#location').val();
	var unitType_text = $('#unitType option:selected').text();
	var unitType_id = $('#unitType').val();
	
	if( unitType_id == 0 ) {
		return 0;	
	}

	  $.get("../../../../includes/ajax.reserve_form.php", { location: location_id, unitType: unitType_text, type: "unitSize", page_in: "location_info" },
			  function(data) {
				  $('#rf_sizes').show();
				  $('#rf_sizes').html(data);				  
			  }
			);

}

function getPrice() {

	var location_id = $('#location').val();
	var unitType_text = $('#unitType option:selected').text();
	var unitType_id = $('#unitType').val();
	var size_text = $('#sizes option:selected').text();
	var sizes_id = $('#sizes').val();

	if( sizes_id == 0 ) {
		return 0;	
	}
	
	 $.get("includes/ajax.reserve_form.php", { location: location_id, unitType: unitType_text, size: size_text, type: "price" },
			  function(data) {
				  $('#price').show();
				  $('#price').html(data);				  
			  }
			);
	
}

function getPrice1() {

	var location_id = $('#location').val();
	var unitType_text = $('#unitType option:selected').text();
	var unitType_id = $('#unitType').val();
	var size_text = $('#sizes option:selected').text();
	var sizes_id = $('#sizes').val();

	if( sizes_id == 0 ) {
		return 0;	
	}
	
	 $.get("../../../../includes/ajax.reserve_form.php", { location: location_id, unitType: unitType_text, size: size_text, type: "price" },
			  function(data) {
				  $('#price').show();
				  $('#price').html(data);				  
			  }
			);
	
}


$(document).ready(function(){  
	$("#location").change(getUnitTypes);
});  
