/*
// Site	: www.hi-hotel.fr
// Date	: 2008-10-16
*/

$(document).ready(function()
{

	//
	// Variable initialization
	var scroll_speed = 1000;
	var reveal_speed = 800;

	$.scrollTo.defaults.axis = 'xy';

	// Hidentity Navigation
	$('#hidentity').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_1"), scroll_speed);
	});

	// Rooms Navigation
	$('#espaces').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_2"), scroll_speed);
	});
	
	// Rooms Navigation UK
	$('#espaces_uk').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_2"), scroll_speed);
	});

	// Services Navigation
	$('#services').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_3"), scroll_speed);
	});

	// Hibookings Navigation
	$('#hibookings').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_4"), scroll_speed);
	});

	// Medias Navigation
	$('#media').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_5"), scroll_speed);
	});

	// Network Navigation
	$('#network').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_6"), scroll_speed);
	});

	// Network Navigation
	$('#network_contact').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_6"), scroll_speed);
	});

	// Network Navigation
	$('#network_contact_uk').click(function(e){
		e.preventDefault();
		$("#container").stop().scrollTo($("#contenu_6"), scroll_speed);
	});

	//
	// Initialize
	// Handle Content 1
	$('#radio_player').load("radio_player.php", function(data)
	{
		reveal(this);
		
	$('#contenu_1').load("hidentity.php", function(data)
	{
		reveal(this);

		// Handle Content 2
		$('#contenu_2').load("espaces.php", function(data)
		{
			reveal(this);

			// Handle Content 3
			$('#contenu_3').load("services.php", function(data)
			{
				reveal(this);

				// Handle Content 4
				$('#contenu_4').load("hibookings.php", function(data)
				{
					reveal(this);

					// Handle Content 5
					$('#contenu_5').load("media.php", function(data)
					{
						reveal(this);

						// Handle Content 6
						$('#contenu_6').load("network.php", function(data)
						{
							// Attach Google Map.
							onLoad();

							reveal(this);

							$.scrollTo.defaults.axis = 'xy';

							// Hidentity Navigation
							$('.goto_top_hidentity').click(function(e){
								e.preventDefault();
								$("#contenu_1").scrollTo(0, scroll_speed);
							});


							// Rooms Navigation
							$('.goto_top_room').click(function(e){
								e.preventDefault();
								$("#contenu_2").scrollTo(0, scroll_speed);
							});


							// Services Navigation
							$('.goto_top_services').click(function(e){
								e.preventDefault();
								$("#contenu_3").scrollTo(0, scroll_speed);
							});


							// Hibookings Navigation
							$('.goto_top_booking').click(function(e){
								e.preventDefault();
								$("#contenu_4").scrollTo(0, scroll_speed);
							});


							// Medias Navigation
							$('.goto_top_media').click(function(e){
								e.preventDefault();
								$("#contenu_5").scrollTo(0, scroll_speed);
							});


							// Network Navigation
							$('.goto_top_network').click(function(e){
								e.preventDefault();
								$("#contenu_6").scrollTo(0, scroll_speed);
							});

							// 
							// Menu ScrollTo assignation
							$('#contenu_1 .menu').click(function(e){
								e.preventDefault();
								$("#contenu_1").scrollTo($(this).attr("href").replace(window.location,""), scroll_speed);
							});

							$('#contenu_2 .menu').click(function(e){
								e.preventDefault();
								$("#contenu_2").scrollTo($(this).attr("href").replace(window.location,""), scroll_speed);
							});

							$('#contenu_3 .menu').click(function(e){
								e.preventDefault();
								$("#contenu_3").scrollTo($(this).attr("href").replace(window.location,""), scroll_speed);
							});

							$('#contenu_4 .menu').click(function(e){
								e.preventDefault();
								$("#contenu_4").scrollTo($(this).attr("href").replace(window.location,""), scroll_speed);
							});

							$('#contenu_5 .menu').click(function(e){
								e.preventDefault();
								$("#contenu_5").scrollTo($(this).attr("href").replace(window.location,""), scroll_speed);
							});

							$('#contenu_6 .menu').click(function(e){
								e.preventDefault();
								$("#contenu_6").scrollTo($(this).attr("href").replace(window.location,""), scroll_speed);
							});

							//
							// Handle Hibooking Form
							$('.date-pick').datePicker({clickInput:true});

						});
					});
				});
			});
		});
	});
	});


	//
	// Handle Content Slide down
	function reveal(obj)
	{
		$(obj).animate({
	       	height  : "100%",
	        opacity : 1
		}, reveal_speed, "swing");
	}


	//
	// Handle Date Picker
	Date.format = 'yyyy-mm-dd';
	$('.date-pick').datePicker({clickInput:true});


	//
	// Handle Lightbox
	//jQuery("#flyer").lightBox();
	


	//
	// Handle Gmap
	var points = [];
	var markers = [];
	var counter = 0;
	var icon = [];

	icon[0] = new GIcon();
	icon[0].image = "http://www.hi-hotel.net/integration_test/network/images/gmap/ico_hi.gif";
	icon[0].iconSize = new GSize(21,20);
	icon[0].iconAnchor = new GPoint(10,10);
	icon[0].infoWindowAnchor = new GPoint(10,10);

	icon[1] = new GIcon();
	icon[1].image = "http://www.hi-hotel.net/integration_test/network/images/gmap/ico_hi_beach.gif";
	icon[1].iconSize = new GSize(21,20);
	icon[1].iconAnchor = new GPoint(10,10);
	icon[1].infoWindowAnchor = new GPoint(10,10);

	icon[2] = new GIcon();
	icon[2].image = "http://www.hi-hotel.net/integration_test/network/images/gmap/ico_hi_busi.gif";
	icon[2].iconSize = new GSize(21,20);
	icon[2].iconAnchor = new GPoint(10,10);
	icon[2].infoWindowAnchor = new GPoint(10,10);

	var map = null;

	function onLoad()
	{
		if (GBrowserIsCompatible())
		{
			var mapObj = document.getElementById("map");

			if (mapObj != "undefined" && mapObj != null)
			{
				map = new GMap2(document.getElementById("map"));
				map.setCenter(new GLatLng(43.696274, 7.254297), 16, G_NORMAL_MAP);
				var bds = new GLatLngBounds(new GLatLng(43.69356693, 7.25274047), new GLatLng(43.69898007, 7.25585453));
				map.setZoom(map.getBoundsZoomLevel(bds));
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GScaleControl());

				var point = new GLatLng(43.697598,7.255552);
				var marker = createMarker(point,"<font face=\"Courier New\", Courier, monospace\"><b>Hi Hotel :</b><br /> 3 avenue des Fleurs<br />06000, Nice</font>","<div id=\"gmapmarker\"><font face=\"Courier New\", Courier, monospace\"><b>Hi Hotel :<\/b><br \/> 3 avenue des Fleurs<br \/>06000, Nice<\/font><\/div>", 0,"");

				map.addOverlay(marker);

				var point = new GLatLng(43.693620,7.255824);
				var marker = createMarker(point,"<font face=\"Courier New\", Courier, monospace\"><b>Hi Beach :</b><br /> 47 promenade des anglais<br />06000, Nice</font>","<div id=\"gmapmarker\"><font face=\"Courier New\", Courier, monospace\"><b>Hi Beach :<\/b><br \/> 47 promenade des anglais<br \/>06000, Nice<\/font><\/div>", 1,"");

				map.addOverlay(marker);

				var point = new GLatLng(43.698639,7.254152);
				var marker = createMarker(point,"<font face=\"Courier New\", Courier, monospace\"><b>Hi Business :</b><br /> Immeuble Le Palmeira<br />9 rue caffarelli<br />06000, Nice</font>","<div id=\"gmapmarker\"><font face=\"Courier New\", Courier, monospace\"><b>Hi Business :<\/b><br \/> Immeuble Le Palmeira<br \/>9 rue caffarelli<br \/>06000, Nice<\/font><\/div>", 2,"");

				map.addOverlay(marker);
			}
		}else{
			alert("Sorry, the Google Maps API is not compatible with this browser.");
		}
	}

	function createMarker(point, title, html, n, tooltip)
	{
		if(n >= 3) { n = 2; }
		var marker = new GMarker(point,{'icon': icon[n], 'title': tooltip});
		if(isArray(html)) { GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml(html); }); }
		else { GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); }
		points[counter] = point;
		markers[counter] = marker;
		counter++;
		return marker;
	}

	function isArray(a)
	{
		return isObject(a) && a.constructor == Array;
	}

	function isObject(a)
	{
		return (a && typeof a == 'object') || isFunction(a);
	}

	function isFunction(a)
	{
		return typeof a == 'function';
	}

	function showInfoWindow(idx,html)
	{
		map.centerAtLatLng(points[idx]);
		markers[idx].openInfoWindowHtml(html);
	}

});

//
// Open Hi-Live Windows
function opencd()
{
	window.open('http://hi-hotel.net/hi_cd/hi_cd.html','cd','width=294,height=575,top=107,left=730,menubar=no,scrollbars=no,statusbar=no,resizable=no,status=no');
	var sp = new Array();
	var ci = "";
	sp[0]="?_hid=8F121CE07D74717E0B1F21D122E04521";
	sp[1]="&_title=Hi_radio-cd";
	sp[2]="&_class=radio-cd";
	if (typeof sp_t != 'undefined') sp_tracker(sp,ci);
}	

