(function($){	//Gld city object class	var GldCity = function(element, options){		element = $(element);		var obj = this;		var settings = $.extend({			cId:					'',			//Left part of infos			cName: 					'',			cDateshortDays:			'',			cDateshortMonthnames:	'',							cGmap:					'',			//Right part of infos			cAddress: 				'',			cDatelongDate:			'',			cDatelongHour:			''		}, options || {});				//Attach click and mouseout event to the link		element.click(function() {			$("a.active","#cities").removeClass("active");			element.addClass("active");			fillCityInfos(settings);			moveBoat($(this));			$("#city_name").scrambledWriter(1);			$("#city_dates span").typewriter();			//$("#city_where").hide().fadeIn(2000);			$("#city_when span").scrambledWriter(2);			updateLangLink(settings.cId);			if($("#directions").is(":empty")){				loadDirection(settings);			}else{				$("#directions").empty();				$("#print_direction").hide();				$("a#tab_map","#gld_tabs li").click();			}		});								this.getGeocode = function(){			return getLatLng(settings);		}					};	//Plugin declaration	$.fn.gldCity = function(options) {		return this.each(function() {			//Assign current element to variable, in this case is link element			var obj = $(this);				// Return early if this element already has a plugin instance			if (obj.data('gldCity')) return;			// pass options to plugin constructor			var gldCity = new GldCity(this, options);			// Store plugin object in this element's data			obj.data('gldCity', gldCity);		});		return this;	}	// *	// private functions	//*			function updateLangLink(city_id) {		current_url = $('#link_lang').attr("href");		url = current_url.substring(0,current_url.lastIndexOf('#')+1) + city_id;		$('#link_lang').attr("href",url);	}				function moveBoat(obj) {		var posParent = parseInt($("#boat_track").offset().left);		var pos = parseInt(obj.offset().left);		var width = obj.width();		$("#boat").stop(true,false).animate({ 			marginLeft: pos - posParent - 35 + (width / 2)},			{duration:1500, easing:'swing'}		);	}		function fillCityInfos(options) {		//Left part of infos		$("#city_name","#cities_infos").html(options.cName);		var dateshort = "";		for (var i=0; i<options.cDateshortDays.length; i++) {			dateshort += "<div class='date_short'>";			dateshort += options.cDateshortDays[i].replace(new RegExp("_", 'g'),"<span class='uscore'>_</span>");			if(options.cDateshortMonthnames[i].length){				dateshort += " <span class='monthname'>"+ options.cDateshortMonthnames[i] +"</span>";			}				dateshort += "</div>";		}		$("#city_dates","#cities_infos").html(dateshort);		//$("a","#cities_infos #city_direction").attr("href",options.cGmap);				//Right part of infos		var datelong = "";		for (var i=0; i<options.cDatelongDate.length; i++) {			datelong += "<div class='datehour'>";			datelong += " <span class='daydate'>"+ options.cDatelongDate[i] +"</span> ";			if(options.cDatelongHour[i].length){				datelong += options.cDatelongHour[i];			}				datelong += "</div>";		}		$("#city_when","#cities_infos").html(datelong);							$("#city_where","#cities_infos").html(options.cAddress);			}	function getLatLng(options){		geocode = (options.cGmap).split(",");		var lat = parseFloat(geocode[0]);		var lng = parseFloat(geocode[1]);		var returnValue = [];		returnValue[0] = lat;		returnValue[1] = lng;		return returnValue;	}		function loadDirection(options) {		if($("#tab_map").hasClass("active")){			var geocode = getLatLng(options);			//ADD fade out/fade in animation while the boat move so it's avoid lag			$('#gmap').animate(			{opacity: 'hide'},			{ 				duration: 1500,				easing: 'swing',				complete: function(){					$('#gmap').jmap("MoveTo", {mapCenter: [geocode[0], geocode[1]]}).jmap('AddMarker', {pointLatLng:[geocode[0], geocode[1]]});					$('#gmap').animate(					{opacity: 'show'},					{ 						duration: 1500,						easing: 'swing'					})				}			});								}	}	})(jQuery);