// Create our own, custom Electronation Javascript object
$.electronation = {
	// Initialize the Electronation object
	init: function() {
		// Load the lightbox plugin for single images
		$(".lightbox").lightbox({fitToScreen: true});
		
		// Focus on the first visible user input field in a form
		$('#content form:first :input:visible:enabled:first').focus();
		
		// Plot a venue if a party view page is loaded and has a div#gmap
		if ($('div#party div.location div#gmap').length > 0){
			// Get the venue name
			var venueName           = $("div#party div.location dl.vcard dt.org a.fn").text();
			var venueUrl            = $("div#party div.location dl.vcard dt.org a.fn").attr('href');
			var venueStreetaddress  = $("div#party div.location dl.vcard dl.adr dd.street-address").text();
			var venuePostalcode     = $("div#party div.location dl.vcard dl.adr dd.postal-code").text();
			var venueCity           = $("div#party div.location dl.vcard dl.adr dd.locality").text();
			var venueCountry        = $("div#party div.location dl.vcard dl.adr dd.country-name").text();
			var venueLatitude       = $("div#party div.location dl.vcard dl.adr dd.latitude").attr('title');
			var venueLongitude      = $("div#party div.location dl.vcard dl.adr dd.longitude").attr('title');

			// Plot the venue on the map
			$.electronationMaps.plotVenue(venueName,venueUrl,venueStreetaddress,venuePostalcode,venueCity,venueCountry,venueLatitude,venueLongitude);
		}
	}
};


// Initialize the Electronation object, which handles all Electronation.nl initialization
$(document).ready(function() {
	$.electronation.init();
});