// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
		alert('Vous avez dépassé le nombre de caractères autorisés pour ce message')
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
	
}

function initMap(lng,lat) {
  if (GBrowserIsCompatible()) {
    small_map = new GMap2(document.getElementById("map"));
    // On centre sur le site
    zoom = 11;
    center = new GLatLng(lat, lng);
    small_map.setCenter(center, zoom);
    small_map.addControl(new GSmallMapControl());
    small_map.addControl(new GScaleControl());
  }
}

marker = new Array;
function addUserToMap(lng,lat,info,value) {
  center = new GLatLng(lat, lng);
  marker[value] = new GMarker(center);
  marker[value].value = value;
  GEvent.addListener(marker[value], "mouseover", function() {
    object = 'result_'+marker[value].value;
    $(object).style.backgroundColor = "#FFFFA2";
    // new Effect.Highlight(object, { startcolor: '#FFFFA2', endcolor: '#FFFFFF' })
  });
  GEvent.addListener(marker[value], "mouseout", function() {
    object = 'result_'+marker[value].value;
    $(object).style.backgroundColor = "#FFFFFF";
    // new Effect.Highlight(object, { startcolor: '#FFFFA2', endcolor: '#FFFFFF' })
  });
  GEvent.addListener(marker[value], "click", function() {
    $("contact_message_"+value).show();
    new Effect.toggle("infos_" + value);
    new Effect.Fade("contact_" + value);
    appel_cible("user_" + value);
        
  });
  small_map.addOverlay(marker[value]);
}


function appel_cible(ancre) {
  self.location.hash=ancre;
}
