function load_map_data() {
	$.get(base_url()+"/flash/carte_interactive/liste_points.xml", {}, function(data) {
			var d = "<div class='col' >";	
			var points = data.getElementsByTagName('point');
			var mx = points.length;
			var sep = Math.ceil(mx / 3);
			for(var i=0; i < mx; i++) {
				var titre = points[i].getElementsByTagName("titre")[0].firstChild.nodeValue;
				var posX = points[i].getElementsByTagName("posX")[0].firstChild.nodeValue;
				var posY = points[i].getElementsByTagName("posY")[0].firstChild.nodeValue;
				if(i == sep || i == 2*sep-1) d += "</div><div class='col' >";
				d += "<a onclick=\"afficherPoint('"+posX+"', '"+posY+"', true);\" class='lien_map' >"+titre+"</a>";
			}
			d += "</div>";
			document.getElementById("map_data").innerHTML = d;
		}, "xml");
}

function manif_suivante(){
	$('#manifestion_home_'+current_manif).hide();
	
	current_manif++;
	
	if(current_manif>nbManifs){
		current_manif = 1;	
	}
	//$('#manifestion_home_'+current_manif).fadeIn();
	$('#manifestion_home_'+current_manif).effect('slide', {direction:"right", mode:"show"});
	
}
function manif_precedente(){
	
	$('#manifestion_home_'+current_manif).hide();
	
	current_manif--;
	
	if(current_manif==0){
		current_manif = nbManifs;	
	}
	$('#manifestion_home_'+current_manif).effect('slide');
}
function changerActu(id){
	if(id!=current_actu){
		$('#actualite_home_'+current_actu).hide();
		$('#puce_actu_'+current_actu).removeClass('puce_actu_on').addClass('puce_actu_off');
		Cufon.replace('#puce_actu_'+current_actu, {hover:true});
		current_actu = id;
		
		$('#actualite_home_'+current_actu).fadeIn();
		$('#puce_actu_'+current_actu).removeClass('puce_actu_off').addClass('puce_actu_on');
		Cufon.replace('#puce_actu_'+current_actu, {hover:true});
	}
}
function nextActu(){
	
	next_actu = current_actu + 1;
	if(next_actu>nbActus){
		next_actu = 1;
	}
	
	changerActu(next_actu);
}

$(document).ready(function(){
	setTimeout('afficherContenu()', 200);
	
});

var latlng = null;
var latlng2 = null;
var myOptions = null;

var latitude = 48.755277;
var longitude = 7.380555;

var gmarkers = [];
var htmls = [];
var to_htmls = [];
var from_htmls = [];
var i=0;

var map=null;
var marker=null;

function createMarker(point,name,html) {

	html = html + '<div id="bulle_m'+i+'" class="bulleGM" style="text-align:left;"><a href="javascript:tohere('+i+')" title="Depuis Monswiller" style="color:#000; font-weight:bold;">&raquo; Se rendre &agrave; Monswiller</a><br/><br/><a href="javascript:fromhere('+i+')" title="Vers Monswiller" style="color:#000; font-weight:bold;">&raquo; Partir de Monswiller</a><div class="cleaner"></div><br /></div>' +
	
		'<div id="bulle_t'+i+'" class="bulleGM" style="height:40px;display:none;overflow:visible;" ><span style="color:black">Lieu de d&eacute;part:</span><form action="http://maps.google.fr/maps" method="get" target="_blank" style="margin:0px;padding:0px;" >' +
	'<input type="text" SIZE=20 MAXLENGTH=40 name="saddr" id="saddr" value="" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000;" />' +
	'<INPUT value="Envoyer" TYPE="SUBMIT" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000;margin-left:3px;">' +
	'<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +
	'"/><br/><br/><a href="#" onclick="general_bulleGM();return false;" >&raquo; revenir</a></form></div>' +
	
	'<div id="bulle_f'+i+'" class="bulleGM" style="height:40px;display:none;overflow:visible;" ><span style"color:black">Lieu d\'arriv&eacute;e:</span><form action="http://maps.google.fr/maps" method="get"" target="_blank" style="margin:0px;padding:0px;">' +
	'<input type="text" SIZE=20 MAXLENGTH=40 name="daddr" id="daddr" value="" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000;" />' +
	'<INPUT value="Envoyer" TYPE="SUBMIT" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#000000;margin-left:3px;">' +
	'<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
	'"/><br/><br/><a href="#" onclick="general_bulleGM();return false;" >&raquo; revenir</a></form></div>';

	html = "<div style='width:230px; height:140px;'>" + html +"</div>";
	var infowindow = new google.maps.InfoWindow({
		content: html
	});
	
	marker = new google.maps.Marker({
		position: latlng,
		map: map,
		title:""
	});
	infowindow.open(map,marker);
	
	google.maps.event.addListener(marker, 'click', function() {
		$(".bulleGM").each(function() {this.style.display = ((this.id.indexOf("bulle_m")==0)?"block":"none");});
		infowindow.open(map,marker);
	});

	gmarkers[i] = marker;
	htmls[i] = html;
	i++;
	return marker;
}

function general_bulleGM() {
	$(".bulleGM").each(function() {this.style.display = ((this.id.indexOf("bulle_m")==0)?"block":"none");});
}

function tohere(i) {
	$(".bulleGM").each(function() {this.style.display = ((this.id.indexOf("bulle_t")==0)?"block":"none");});
}

function fromhere(i) {
	$(".bulleGM").each(function() {this.style.display = ((this.id.indexOf("bulle_f")==0)?"block":"none");});
}

function base_url() {
	if(document.domain.indexOf("hdrsw11.com") != -1)
		return "/~monswill";
	return "";
}



function afficherContenu(){

	document.getElementById("conteneur").style.display = 'block';
	document.getElementById("pied").style.display = 'block';
	
	if(afficherMap){
		latlng = new google.maps.LatLng(latitude,longitude);
		latlng2 = new google.maps.LatLng((latitude+0.3),longitude);
		myOptions = {
		  zoom: 8,
		  center: latlng2,
		  mapTypeId: google.maps.MapTypeId.ROADMAP 
		}
		map = new google.maps.Map(document.getElementById("GoogleMap"), myOptions);
		createMarker(latlng,"hdr", contenuMarqueur);
	}

}

function appelFlash(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
    }
    else {
	    return document[movieName];
    }
}


function afficherPoint(posX, posY, flag){
	appelFlash("carteInteractive").afficherPoint(posX, posY, flag);
}

