

function init_Booking_Map() {
	
	var selectOpen = 0;
	var mapOpen = 0;
	var bookingHover = 0;
	
	$(".booking-panel").hoverIntent({
		over:		grow,
		out:		shrink,
		interval:	100,
		sensitivity:3,
		timeout:	500
	});
	
	function grow()
	{
		bookingHover = 1;
		if (!mapOpen) {
			mapOpen = 1;
			$("#booking-map").animate({width:'toggle'},200);
		}
	}
	function shrink()
	{
		bookingHover = 0;
		if (!selectOpen) {
			mapOpen = 0;
			$("#booking-map").animate({width:'toggle'},100);
		}
	}
	
	// Fix IE dropdown select problem where jQuery thinks it's left the booking panel
	$(".booking-panel select").each(function(e) {
		this.onclick  = function() { selectOpen = 1; }
		this.onchange = function() { selectOpen = 0; }
		this.onfocus  = function() { selectOpen = 1; }
		this.onblur   = function() { selectOpen = 0; if (!bookingHover) { shrink() }; }
		this.onselect = function() { selectOpen = 0; }
	});
	
	var ifRouteMapDefault = "NONE";
	/*
	$("area").mouseover(function() {
		map_SwitchRoute($(this).attr("id"));
	}).mouseout(function() {
		map_SwitchRoute(ifRouteMapDefault);
	}).click(function() {
		ifRouteMapDefault = $(this).attr("id");
		return false; 
	});*/
	$("select#OutRoute").change(function() { map_SwitchRoute($(this).find("option:selected").attr("value")); ifRouteMapDefault = $(this).children("[@selected]").attr("value"); $(".map-text").show(); });
	$("select#RetRoute").change(function() { map_SwitchRoute($(this).find("option:selected").attr("value")); ifRouteMapDefault = $(this).children("[@selected]").attr("value"); $(".map-text").show(); });
	
	var ifRouteValues =   
	[
     	{
			"out"   	: "DUS_HHS",
			"ret"		: "HHS_DUS",
			"title-EN" 	: "Dublin / Holyhead",
			"title-FR" 	: "Dublin / Holyhead",
			"text-EN"	: "Fast ferry from just <strong>1hr 49mins</strong>!<br>Cruise ferry from just <strong>3hrs 15mins</strong>!",
			"text-FR"	: "Ferry rapide, environ <strong>1h49</strong>!<br>Ferry de croisi&egrave;re, environ <strong>3h15</strong>!"
		},
		
		{
			"out"   	: "ROS_PEM",
			"ret"   	: "PEM_ROS",
			"title-EN" 	: "Rosslare / Pembroke",
			"title-FR" 	: "Rosslare / Pembroke",
			"text-EN"  	: "Cruise ferry from just <strong>4hrs</strong>!",
			"text-FR"  	: "Ferry de croisi&egrave;re, environ <strong>4h</strong>!"
		},
		
		{
			"out"   	: "ROS_RSC",
			"ret"   	: "RSC_ROS",
			"title-EN" 	: "Rosslare / Roscoff",
			"title-FR" 	: "Rosslare / Roscoff",
			"text-EN"  	: "Travel on our <strong>luxury</strong> cruise ferry, the Oscar Wilde.",
			"text-FR"  	: "Voyagez sur notre ferry de croisi&egrave;re l'Oscar Wilde."
		},

		{
			"out"   	: "ROS_CER",
			"ret"   	: "CER_ROS",
			"title-EN" 	: "Rosslare / Cherbourg",
			"title-FR" 	: "Rosslare / Cherbourg",
			"text-EN"  	: "Travel on our <strong>luxury</strong> cruise ferry, the Oscar Wilde.",
			"text-FR"  	: "Voyagez sur notre ferry de croisi&egrave;re l'Oscar Wilde."
		},

		{
			"out"   	: "NONE",
			"ret"   	: "-",
			"title-EN" 	: "View routes &amp; journey times",
			"title-FR" 	: "Lignes &amp; dur&eacute;e des travers&eacute;es",
			"text-EN"  	: "Roll over one of our routes to view more information.",
			"text-FR" 	: "Choisissez la ligne pour plus d'information."
		}


	];
	
	function map_SwitchRoute(route) {
		
		var theRoute = undefined;
		
		for(var i in ifRouteValues)
		{
			if (ifRouteValues[i].out == route) {
				theRoute = i;
			} else if (ifRouteValues[i].ret == route) {
				theRoute = i;
			}
		}
		
		if (theRoute != undefined)
		{
			var mapLang = $('input#Language').val();
			$("img.routes").attr("src","images/Booking/map/route-"+ifRouteValues[theRoute].out+".gif");
			$(".map-text p.title").html(ifRouteValues[theRoute]["title-"+mapLang]);
			$(".map-text p.text").html(ifRouteValues[theRoute]["text-"+mapLang]);
				
		}
	}
	
}


