$(document).ready(function(){
  $('.jmenu ul:not(.jmenu)').hide();
  $('.jmenu li').hoverIntent({    
     sensitivity: 3,   
     interval: 50, 
     over: function(){
		$(this).children('ul').stop(true, true);
		$(this).children('ul').slideDown('slow');
		$(this).addClass('hover');
	 }, 
     timeout: 250, 
     out:function(){
		$(this).removeClass('hover');
		if($(this).children('.hover').size() == 0) {
			//$(this).children('ul').hide();
			$(this).children('ul').stop(true, true);
			$(this).children('ul').slideUp('slow');
		}
	 }
  });
  $('#search_input').focus(function(){
	if($(this).attr('value') == 'Recherche') $(this).attr('value', '');
  });
  $('#search_input').blur(function(){
	if($(this).attr('value') == '') $(this).attr('value', 'Recherche');
  });
  $('#search_form').submit(function(){
	if($('#search_input').attr('value') != '' && $('#search_input').attr('value') != 'Recherche') {
		document.location.href = 'index.php?/recherche/'+$('#search_input').attr('value');
	}
	return false;
  });
});

var map = null;
var geocoder = null;
function initialize(address) {
  setTimeout( function() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	geocoder = new GClientGeocoder();
	showAddress(address);
  } }, 0.1);
}
function showAddress(address) {
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  alert(address + " introuvable.");
		} else {
		  map.setCenter(point, 13);
		  var marker = new GMarker(point);
		  map.addOverlay(marker);
		  marker.openInfoWindowHtml(address);
		}
	  }
	);
  }
}