$(document).ready(function()
{
	$('.connexion .field').focus(function() {
		//$(this).next("span").css('display','inline').fadeOut(1000);
		var title = $(this).attr('alt') || '';
		if ( $(this).val() == title ) $(this).val('');
		//alert(title);
	});
	$('.connexion .field').blur(function() {
		//$(this).next("span").css('display','inline').fadeOut(1000);
		var title = $(this).attr('alt') || '';
		if ( $(this).val() == '' ) $(this).val(title);
		//alert(title);
	});

	$("a.fancy").fancybox({
		'titleShow'		: false
	});
	$("a.fancy-titled").fancybox({
		'titlePosition'  : 'over'
	});
	
});

/* ********************************************************** GGMAP ********* */

	var map;
	var markersArray = [];
	var bounds = new google.maps.LatLngBounds();
	
	var gmap_hotel_icon = new google.maps.MarkerImage('/images/icones/gmap/hotel.png',
		new google.maps.Size(62, 30),
		new google.maps.Point(0,0),
		new google.maps.Point(31, 30));
	var gmap_hotel_shadow = new google.maps.MarkerImage('/images/icones/gmap/hotel_shadow.png',
		new google.maps.Size(46, 20),
		new google.maps.Point(0,0),
		new google.maps.Point(7, 20));
	var gmap_hotel_shape = {
		coord: [1, 1, 1, 30, 62, 30, 62, 1],
		type: 'poly'
	};
	var gmap_adv_icon = new google.maps.MarkerImage('/images/icones/gmap/annonceur.png',
		new google.maps.Size(12, 20),
		new google.maps.Point(0,0),
		new google.maps.Point(6, 20));
	var gmap_adv_shadow = new google.maps.MarkerImage('/images/icones/gmap/annonceur_shadow.png',
		new google.maps.Size(22, 20),
		new google.maps.Point(0,0),
		new google.maps.Point(0, 10));
	var gmap_adv_shape = {
		coord: [1, 1, 1, 20, 20, 20, 20, 1],
		type: 'poly'
	};
	
	var gmap_page_shadow = new google.maps.MarkerImage('/images/icones/gmap/page_shadow.png',
		new google.maps.Size(22, 20),
		new google.maps.Point(0,0),
		new google.maps.Point(5, 7));
	var gmap_page_shape = {
		coord: [1, 1, 1, 20, 18, 20, 18 , 1],
		type: 'poly'
	};
	
	// Etend la vue sur le NPdC
	function gmap_extend_bounds()
	{
		//bounds.extend(new google.maps.LatLng(50.645760, 3.044243));
		//bounds.extend(new google.maps.LatLng(50.628776, 3.084497));
		bounds.extend(new google.maps.LatLng(51.447160, -1.527100));
		bounds.extend(new google.maps.LatLng(48.661943, 5.833740));
	}
	
	// Initialise la map
	function gmap_initialize(elt,latlng,zoom)
	{
		var mapOptions = {
			zoom: zoom,
			center: latlng,
			scrollwheel: false,
			mapTypeId: google.maps.MapTypeId.ROADMAP // SATELLITE //
			};
		map =  new google.maps.Map(document.getElementById(elt), mapOptions);
		
	  /*google.maps.event.addListener(map, 'click', function(event) {
		addMarker(event.latLng);
	  });*/
	}
	
	function gmap_placer_hotel(hotel)
	{
		var myLatLng = new google.maps.LatLng(hotel[1], hotel[2]);
		var marker = new google.maps.Marker({
			position: myLatLng,
			map: map,
			shadow: gmap_hotel_shadow,
			icon: gmap_hotel_icon,
			shape: gmap_hotel_shape,
			title: hotel[0],
			zIndex: hotel[3]
		});
		var infowindow = new google.maps.InfoWindow({
			content: hotel[4]
		});
		
		google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); });
		bounds.extend(myLatLng);
		
	}

	function gmap_placer_hotels(locations)
	{
		for (var i = 0; i < locations.length; i++) {
			gmap_placer_hotel(locations[i]);
		}
	}
	
	function gmap_placer_annonceur(adv)
	{
		var icon = gmap_adv_icon;
		var shadow = gmap_adv_shadow;
		var shape = gmap_adv_shape;
		if (adv[5]) {
			icon = new google.maps.MarkerImage('/images/icones/gmap/'+adv[5]+'.png',
				new google.maps.Size(19, 20),
				new google.maps.Point(0,0),
				new google.maps.Point(10, 10));
			shadow = gmap_page_shadow;
			shape  = gmap_page_shape;
		}
		
		var myLatLng = new google.maps.LatLng(adv[1], adv[2]);
		var marker = new google.maps.Marker({
			position: myLatLng,
			map: map,
			shadow: shadow,
			icon: icon,
			shape: shape,
			title: adv[0],
			zIndex: adv[3]
		});
		var infowindow = new google.maps.InfoWindow({
			content: adv[4]
		});
		
		bounds.extend(myLatLng);
		google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); });
		
	}

	function gmap_placer_annonceurs(locations)
	{
		for (var i = 0; i < locations.length; i++) {
			var adv = locations[i];
			gmap_placer_annonceur(adv);
		}
	}

	function gmap_fitBounds()
	{
		map.fitBounds(bounds);
	}



/* ********************************************************* DIVERS ********* */

function mentions()
{
	window.open("/mentions.php","mentions","width=530,height=520,scrollbars=yes");
}














/******************************************************************************/

/*
 function HomeControl(controlDiv, map) {

  // Set CSS styles for the DIV containing the control
  // Setting padding to 5 px will offset the control
  // from the edge of the map
  controlDiv.style.padding = '5px';

  // Set CSS for the control border
  var controlUI = document.createElement('DIV');
  controlUI.style.backgroundColor = 'white';
  controlUI.style.borderStyle = 'solid';
  controlUI.style.borderWidth = '2px';
  controlUI.style.cursor = 'pointer';
  controlUI.style.textAlign = 'center';
  controlUI.title = 'Click to set the map to Home';
  controlDiv.appendChild(controlUI);

  // Set CSS for the control interior
  var controlText = document.createElement('DIV');
  controlText.style.fontFamily = 'Arial,sans-serif';
  controlText.style.fontSize = '12px';
  controlText.style.paddingLeft = '4px';
  controlText.style.paddingRight = '4px';
  controlText.innerHTML = 'Home';
  controlUI.appendChild(controlText);

  // Setup the click event listeners: simply set the map to
  // Chicago
  google.maps.event.addDomListener(controlUI, 'click', function() {
    map.setCenter(chicago)
  });
}
		var homeControlDiv = document.createElement('DIV');
		var homeControl = new HomeControl(homeControlDiv, map);
	  
		homeControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
		*/

