//Cufon settings
/*Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('#menu a', { textShadow: '#666666 1px 1px 1px' });
Cufon.replace('#loginbox span', { textShadow: '#666666 1px 1px 1px' });*/

$(document).ready(function() {

	//Gestion des tabs de la homepage
	var tabContainers = $('#contents > li');

	tabContainers.hide().filter(':first').show();

	$('ul#tab_navigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();

		$('ul#tab_navigation a').removeClass('selected');

		$(this).addClass('selected');

		if($(this).hasClass('map'))
		{
			LoadMap();
		}
		return false;

	}).filter(':first').click();

	if($('div#map').length)
	{
		LoadMap();
	}
});

function LoadMap() {

	// Appel google map
	var myLatlng = new google.maps.LatLng(48.90117643333875, 2.2252249717712402) ;
	var alLatlng = new google.maps.LatLng(48.898011, 2.233221);
	var npLatlng = new google.maps.LatLng(48.904406467958445, 2.2199034690856934);

	var alContentString = '<div id="alContent">'+
			      '<div id="alSiteNotice">'+
			      '</div>'+
			      '<h1>Centrale Historique</h1>'+
			      '<div id="alBodyContent">'+
			      '<p>2 rue d\'Alen&ccedil;on, courbevoie</p>'+
			      '</div>'+
			      '</div>';

	var npContentString = '<div id="npContent">'+
			      '<div id="npSiteNotice">'+
			      '</div>'+
			      '<h1>Centrale No&euml;l Pons</h1>'+
			      '<div id="npBodyContent">'+
			      '<p>Rue No&euml;l Pons</p>'+
			      '</div>'+
			      '</div>';

	var myOptions = {
		zoom: 14,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	var map = new google.maps.Map(document.getElementById("map"), myOptions);

	var alInfowindow = new google.maps.InfoWindow({
		position: alLatlng,
	    content: alContentString
	});
	var npInfowindow = new google.maps.InfoWindow({
	    content: npContentString,
		position: npLatlng
	});

	var alMarker = new google.maps.Marker({
		position: alLatlng,
		title: "Centrale Alencon",
		icon: 'http://google-maps-icons.googlecode.com/files/factory.png'
	});
	var npMarker = new google.maps.Marker({
		position: npLatlng,
		title: "Noel Pons",
		icon: 'http://google-maps-icons.googlecode.com/files/factory.png'
	});

	// To add the marker to the map, call setMap();
	alMarker.setMap(map);
	npMarker.setMap(map);

	/*
	google.maps.event.addListener(alMarker, 'click', function() {
	      alInfowindow.open(map,alMarker);
	});

	google.maps.event.addListener(npMarker, 'click', function() {
	      npInfowindow.open(map,npMarker);
	});
	*/
}

