$(function(){	today = new Date();	current_city = "";		var msg = [];	msg['en'] = {		warning_sarnia_title:	"Warning!",		warning_sarnia_text:	"<b>Please note that the location has changed to:</b><br/>Anchored off Sarnia Yacht Club. Ferry services provided.",		invalid_add:	"Invalid address!<br/>Try to be more specific.<br/>Example: my address, my city, my country, my postal code.",		mute: 			"mute", 		play: 			"play",		pause: 			"pause"	};	msg['fr'] = {		warning_sarnia_title:	"Attention!",		warning_sarnia_text:	"<b>Veuillez noter le changement de lieu qui est maintenant:</b><br/>Ancr&eacute; au large du Club de yachting de Sarnia. Service de traversier fourni.",		invalid_add:	"Adresse invalide!<br/>Essayez d'&ecirc;tre plus pr&eacute;cis.<br/>Exemple: mon adresse, ma ville, mon pays, mon code postal.",		mute: 			"sourdine", 		play: 			"jouer",		pause: 			"arr&ecirc;t"	};		// _____________________ Utilities _____________________ \\			var checkUrl = function(url) {		url = url.substring(url.lastIndexOf('#')+1);		//remove http:// + host part of the string		urlFilter = new RegExp ("^.*?://.*?(/.*)$");		if(urlFilter.test(url)){			url = urlFilter.exec(url)[1];		}		return url;	}		// _____________________ Load cities from xml _____________________ \\			var loadCities = function(lang) {		$.ajax({			type: "GET",			url: "../cities_"+lang+".xml",			dataType: "xml",			success: function(xml) {				$("#cities ul").empty();				$(xml).find('city').each(function(i){					var id = $(this).attr('id');					//Left part of infos					var name = $(this).find('name').text();					var days = [];					var monthnames = [];					$(this).find('dateshort').each(function(i){						days[i] = $(this).find('day').text();						monthnames[i] = $(this).find('monthname').text();					});					var gmap = $(this).find('gmap').text();										//Right part of infos					var address = $(this).find('address').text();					var dates = [];					var hours = [];					$(this).find('datelong').each(function(i){						dates[i] = $(this).find('date').text();						hours[i] = $(this).find('hour').text();					});										//check if current					var activedate = new Date($(this).find('enddate').text());										if(!current_city.length){						if (activedate > today){							current_city = id;						}									}					//Add a bullet separator if not first					if(i != 0){						var separator = "&bull; ";					}else{						var separator = "";					}										//Create a link for the city					city_link = $("<a id='l_"+id+"' href='#"+ id +"'>"+ name +"</a>");																				//If this is the current city, add active class, populate city infos					$("<li>"+separator+"</li>").append(city_link).appendTo().appendTo("#cities ul");					// _____________________ Exception : sarnia_____________________ \\							if(id=="sarnia"){						$("body").append("<div style='text-align:center;margin-top:10px;font-size:14px' id='dialog' title='"+ msg[current_lang].warning_sarnia_title +"'>"+ msg[current_lang].warning_sarnia_text +"</div>");						$('#dialog').dialog({							autoOpen: false,							width: 550,							modal:true,							buttons: {								"Ok": function() { 									$(this).dialog("close"); 								}							}						});												city_link.click(function(){							$('#dialog').dialog('open');						});					}										//Attach the gld plugin to the city link so all data are stored and actions attached					city_link.gldCity({  						cId: id,						//Left part of infos						cName: name,						cDateshortDays: days,						cDateshortMonthnames: monthnames,						//Right part of infos						cAddress: address,						cDatelongDate: dates,						cDatelongHour: hours,						cGmap: gmap					}); 				});				$("a#l_"+current_city,"#cities").click();			}		});	}// _____________________ Tabbed box _____________________ \\		$("#gld_tabs li a").not("#tab_map").click(function() {		if(!$(this).is(".active")){			$("#videos_list").slideUp({ duration: 1200, easing: "easeOutBounce"});				var boxId = $(this).attr("href");			var activeTab = $("#gld_tabs li a.active");			$(activeTab.attr("href")).animate(			{opacity: 'hide'},			{ 				duration: 700,				easing: 'swing',				complete: function(){					$(this).addClass("active");					$(boxId).animate(					{opacity: 'show'},					{ 						duration: 1500,						easing: 'swing'					})				}			});			activeTab.removeClass("active");			$(this).addClass("active");		}		return false;	});		// _____________________ GoogleMap _____________________ \\		$("a#tab_map","#gld_tabs li").click(function() {		$("#videos_list").slideUp({ duration: 1200, easing: "easeOutBounce"});			$($("#gld_tabs li a.active").attr("href")).hide();		$("#map").show();		$("#gld_tabs li a.active").removeClass("active");		$(this).addClass("active");				loadMap();		return false;	});		var loadMap = function() {		var geocode = $("#cities li a.active").data("gldCity").getGeocode();				$('#gmap').jmap('init', {			language: current_lang,			mapType: 'hybrid',			mapCenter: [geocode[0], geocode[1]],			mapZoom: 15,			mapShowjMapIcon: false,			mapEnableScaleControl: false,			mapCOntrolSize: 'large',			mapEnableScrollZoom: true,			mapEnableSmoothZoom: true		}).jmap('AddMarker', {pointLatLng:[geocode[0], geocode[1]]});		return false;	}			$("#city_direction a","#cities_infos").click(function() {		getDir();		//test if google have found a direction after 2 seconds (wait for google response)		setTimeout(haveDir,2000);		return false;	});		//Test direction	var haveDir = function() {		if($("#directions").is(":empty")){			$("#directions").append("<div id='invalid_address'>" + msg[current_lang].invalid_add + "</div>");			$("#print_direction").hide();		}else{			$("#print_direction").show();		}	}			//Trigger the search on enter key in the address text field	$("#city_direction input","#cities_infos").keyup(function(e) {		//alert(e.keyCode);		if(e.keyCode == 13) {			$("#city_direction a","#cities_infos").click();		}	});	  	//Directions	var getDir = function() {		$("#directions").empty();		$("a#tab_map","#gld_tabs li").click();				if(!$('#address').val().length){			$("#directions").html("<div id='invalid_address'>" + msg[current_lang].invalid_add + "</div>");		}else{			var geocode = $("#cities li a.active").data("gldCity").getGeocode();			var query="from: "+ $('#address').val() +" to: " + geocode[0] +", "+ geocode[1];			$('#gmap').jmap('SearchDirections', {					query: query,				panel:'#directions',				locale: current_lang + '_CA'			}, 			function(result, options) {				var valid = Mapifies.SearchCode(result.getStatus());				if (valid.success) {					$.each(result.Placemark, function(i, point){						$('#map').jmap('AddMarker',{							'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],							'pointHTML':point.address						});					});				} else {					//$('#address').val(valid.message);				}			});		}	}		// _____________________ Videos _____________________ \\			$("a#tab_video","#gld_tabs li").click(function() {		$("#videos_list").slideUp({			duration: 0, 			complete: function(){				$(this).slideDown({ duration: 1200, easing: "easeOutBounce"});				}		});		$("a.video:first","#videos_list").click();	});					$("a.video","#videos_list").click(function(){		loadVideo($(this).attr("href"));		$("a.video.play","#videos_list").removeClass("play");		$(this).addClass("play");		return false;	});		var loadVideo = function(videoUrl) {		$("#video_player").flowplayer("../flash/flowplayer/flowplayer-3.1.2.swf", { 		    clip: { 		        url: videoUrl, 		        autoPlay: true, 		        autoBuffering: true ,				onStart: function(clip) { 					//alert("Playing"); 				} 						    }, 		    plugins: { 			    controls: { 			        // location of the controlbar plugin 			        url: '../flash/flowplayer/flowplayer.controls-3.1.2.swf', 			 			        // display properties such as size, location and opacity 			        //top: 20, 			        left: 0, 			        bottom: 0, 			        opacity: 0.95, 			 			        // styling properties (will be applied to all plugins) 			        //background: '#114455 url(/my/custom/controls.png) no-repeat 3px 6px', 			       // backgroundGradient: 'low', 			 			        // controlbar specific settings 			        timeColor: '#cc9e42', 			        all: false, 			        play: true, 			        scrubber: true, 					volume: true,					mute: true,					progressColor:'#959ca1',					bufferColor:'#838383',					sliderColor:'#000000',					volumeSliderColor:'#838383',					buttonColor:'#838383',					buttonOverColor:'#cc9e42',			        // tooltips (since 3.1) 			        tooltips: { 			            buttons: true, 			            mute: msg[current_lang].mute, 						pause: msg[current_lang].pause,						play: msg[current_lang].play			        } 			    } 								    }, 			    onLoad: function(){ 		    }		});			}	// _____________________ Photos _____________________ \\		$("a.photo","#videos_list").click(function(){		var picUrl = $(this).attr("href");		var styleClass = $(this).attr('class');		$.picHtml = "<img id='media_image' src='"+ picUrl +"' class='"+ styleClass +"'></img>";		$("#video_player").html($.picHtml).hide().fadeIn(1000);		return false;	});	$("img#media_image","#video_player").click(function(){		return $(this).attr("src");	});	// _____________________ Page init _____________________ \\		if(window.location.href.indexOf('#') != -1){		current_city = checkUrl(window.location.href);	}			loadCities(current_lang);	$('label.overlay',"#city_direction").labelOver();		//print page button	$("#print_link, #print_direction_link").click(function(){		window.print();		return false;	});	//$("a#tab_video","#gld_tabs li").click();	// _____________________ Fix elements styles _____________________ \\	//aims only msie v6.x	if(jQuery.browser.msie && jQuery.browser.version.substring(0,1) == 6){		$('#boat').ifixpng(); 	}		});