// JavaScript Document

function hideGallery(){
    $('#overlay').hide();
    $('#media').show();
    $('#UI_gallery').hide();
}
function showGallery(){
    $('#overlay').show();
    $('#media').hide();
    $('#UI_gallery').show();
    centerWindow($('#UI_gallery'));
    
}
function centerWindow(target) {
	var wWidth = $(window).width();
	var wHeight = $(window).height();

	var path = $(target);

	var newX = wWidth/2 - path.width()/2;
	var newY = wHeight/2 - path.height()/2;

	path.css({left: newX, top: newY});
}

function createGoogleMarker(point, legend, type) {
    // icons
    var iconHotel = new GIcon(G_DEFAULT_ICON);
    iconHotel.image = "http://www.hotel-maurepas-st-quentin.com/images/icons/hotel.png";
    iconHotel.iconSize = new GSize(26, 28);

    var iconGare = new GIcon(G_DEFAULT_ICON);
    iconGare.image = "http://www.hotel-maurepas-st-quentin.com/images/icons/icon.gare.png";
    iconGare.iconSize = new GSize(32, 32);

    if(type == "Hotel"){
        var option = { icon:iconHotel };
    }else if(type == "Gare"){
        var option = { icon:iconGare };
    }else{
    }
    var marker = new GMarker(point, option);

    GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(legend);
    });
    return marker;
}
function loadGoogleMaps_rm_paris(lng){
    var map;
    var directionsPanel;
    var directions;

    $('#UI_player').height(400);
    $('#gmap').height(400);
    $('#groute').html('');

    map = new GMap2(document.getElementById("gmap"));
    map.setCenter(new GLatLng(48.759478,1.945267), 13);
    map.addControl(new GSmallMapControl());
    directionsPanel = document.getElementById("groute");
    directions = new GDirections(map, directionsPanel);
    directions.load("from: Porte de St-Cloud, Paris, France to: route de camargue, 78 Maurepas, France", {"locale":lng});
}
function loadGoogleMaps_rm_versailles(lng){
    var map;
    var directionsPanel;
    var directions;

    $('#UI_player').height(400);
    $('#gmap').height(400);
    $('#groute').html('');

    map = new GMap2(document.getElementById("gmap"));
    map.setCenter(new GLatLng(48.759478,1.945267), 14);
    map.addControl(new GSmallMapControl());
    directionsPanel = document.getElementById("groute");
    directions = new GDirections(map, directionsPanel);
    directions.load("from: 78 Versailles, France to: route de camargue, 78 Maurepas, France", {"locale":lng});
}
function loadGoogleMaps_rm_rambouillet(lng){
    var map;
    var directionsPanel;
    var directions;

    $('#UI_player').height(400);
    $('#gmap').height(400);
    $('#groute').html('');

    map = new GMap2(document.getElementById("gmap"));
    map.setCenter(new GLatLng(48.759478,1.945267), 14);
    map.addControl(new GSmallMapControl());
    directionsPanel = document.getElementById("groute");
    directions = new GDirections(map, directionsPanel);
    directions.load("from: 78 Rambouillet, France to: route de camargue, 78 Maurepas, France", {"locale":lng});
}
function loadGoogleMaps() {
    /*
    http://www.google.com/maps?f=q&source=s_q&hl=fr&geocode=&q=route+de+camargue,+Maurepas&sll=48.877753,2.356383&sspn=0.012898,0.025985&ie=UTF8&ll=48.759478,1.945267&spn=0.006464,0.012993&z=17
    */
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("gmap"));

        $('#UI_player').height(290);
        $('#gmap').height(290);
        $('#groute').html('');

        map.setCenter(new GLatLng(48.759478,1.945267), 14);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        //map.setMapType(G_HYBRID_MAP);

        // hotel
        var point = new GLatLng(48.759478,1.945267);
        var legend = "<p><strong>Best Western Maurepas St-Quentin</strong></p><p>1, rocade de Camargue<br />78310 MAUREPAS<br />FRANCE</p>";
        map.addOverlay(createGoogleMarker(point, legend, 'Hotel'));

        // gare(s)
        var point = new GLatLng(48.755453,1.943915);
        var legend = "<strong>Gare SNCF La Verrière</strong>";
        map.addOverlay(createGoogleMarker(point, legend, 'Gare'));
    }
}
$(document).ready(function(){
	$('#UI_tabs div.panel:gt(0)').hide();
	$('#UI_tabs ul.tabs li:eq(0)').addClass('current');

	$('#UI_tabs ul.tabs li').click(function(){
		var n = $(this).parent().children("li").index(this);

		$('#UI_tabs ul.tabs li').removeClass('current');
		$(this).addClass('current');
		
		$('#UI_tabs div.panel').hide();
		$('#UI_tabs div.panel:eq('+n+')').show();

	});
	$('#UI_gmaps').click(function(){
        document.location = 'http://www.hotel-maurepas-st-quentin.com/FR/contact.html';
    });
	//loadGoogleMaps();
	start_fb();
});
