// ==================================================
// ContactForm Class
// ==================================================
var ContactForm =
{
	init: function()
	{
		jQuery.validator.addMethod("mustSelect", function(value, element) { 
		  return value != "";
		}, "Please select.");
		
		$("#contactform").validate({
		rules : {
			contact : { mustSelect : true },
			frequency : { mustSelect : true },
			food_select : { mustSelect : true },
			service_select : { mustSelect : true },
			venue_amenities_select : { mustSelect : true },
			experience_select : { mustSelect : true },
			
		}
	});
	}
}

// ==================================================
// Location Class
// ==================================================
var Location =
{
	init: function()
	{
		Location.latitude = Location.longitude = "";
		Location.geocoder = new google.maps.Geocoder();
		if (Location.latitude == ""||Location.longitude == "")
		{
			var latlng = new google.maps.LatLng(-34.397, 150.644);
			var myOptions = {
			  zoom: 16,
			  center: latlng,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			}
			Location.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
			Location.codeAddress();
			
			var contentString = '<div id="mapAddress"><strong>Garfish  ' + $("#locationName").val() + '</strong><br/>' + $("#address1").val() + '<br/>' + $("#address2").val()+  '</div>';
			Location.infowindow = new google.maps.InfoWindow({
				//maxWidth:50,
				content: contentString
			});
			Location.infowindow.open(map,marker);
		}
		else
		{
			var latlng = new google.maps.LatLng(Location.latitude, Location.longitude);
			var myOptions = {
			  zoom: 16,
			  center: latlng,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			}
			Location.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
			//var image = 'beachflag.png';
			var myLatLng = new google.maps.LatLng(Location.latitude, Location.longitude);
			var beachMarker = new google.maps.Marker({
			position: myLatLng,
			map: Location.map
		  //icon: image
			});
		}
	},
	
	codeAddress: function()
	{
		var address = $("#address1").val() + "," + $("#address2").val();
		
		if (Location.geocoder) {
		  Location.geocoder.geocode( { 'address': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				
			  Location.map.setCenter(results[0].geometry.location);
			  var marker = new google.maps.Marker({
				  map: Location.map, 
				  position: results[0].geometry.location
				  
			  });
			  Location.infowindow.open(Location.map,marker);
			} else {
			  alert("Geocode was not successful for the following reason: " + status);
			}
		  });
		}
	}
}