function valider_envoi_modele() {
		$("#resultat_envoi").hide();
		id_seance = $("#formulaire_envoi_mail [@name=id_seance]").attr("value");
		adresse_expediteur = $("#formulaire_envoi_mail [@name=adresse_expediteur]").attr("value");
		
		if (!adresse_expediteur || adresse_expediteur.indexOf("@") < 1) {
			$("#resultat_envoi").html("Exp&eacute;diteur incorrect");
			$("#resultat_envoi").slideDown();

			return false;
		}

		
		adresse_destinataire = $("#formulaire_envoi_mail [@name=adresse_destinataire]").attr("value");
		if (!adresse_destinataire  || adresse_destinataire.indexOf("@") < 1) {
			$("#resultat_envoi").html("Destinataire incorrect");
			$("#resultat_envoi").slideDown();

			return false;
		}

		texte_message = $("#formulaire_envoi_mail [@name=message]").attr("value");


		$("#resultat_envoi").html("Envoi du message...");
		
		$("#resultat_envoi").slideDown();
		
		if (texte_message === undefined) texte_message = "";
		$.post("spip.php?page=mail_seance&id_seance="+id_seance+"&message="+texte_message+"&adresse_expediteur="+adresse_expediteur+"&adresse_destinataire="+adresse_destinataire,{envoyer_mail:adresse_destinataire, auteur_mail:adresse_expediteur}, function(data) { $("#resultat_envoi").html(data);});		
		
		
		pageTracker._trackEvent('Email', 'Envoi');
}




	afficher_film = 7721;


	var map;
	var zoom_level;
	var afficher_film;
	var afficher_vovf = ".";
	var geocoder = new Array();
	var point = new Array();
	var markville = new Array();
	var film_jour;
	var film_debut;
	var film_fin;
	var cinema_popup;


	var iconeCinema = new GIcon();
	iconeCinema.image = "logos/plume.png";
	iconeCinema.shadow = "logos/plume-shadow.png";
	iconeCinema.iconSize = new GSize(32,41);
	iconeCinema.iconAnchor = new GPoint(16, 41);
	iconeCinema.infoWindowAnchor = new GPoint(30, 10);

	var iconeCinemaoff = new GIcon();
	iconeCinemaoff.image = "local/cache-gd2/99639901a85319dcf32933562d035aef.png";
	iconeCinemaoff.iconSize = new GSize(32,41);
	iconeCinemaoff.iconAnchor = new GPoint(16,41);
	iconeCinemaoff.infoWindowAnchor = new GPoint(30, 10);

		var baseRond = new GIcon();
		baseRond.image = "rien.gif";
		baseRond.shadow = "logos/fond-grand-rond-bleu.png";
		baseRond.iconSize = new GSize(1,1);
		baseRond.iconAnchor = new GPoint(24, 12);




	var iconeCinema3751e = new GIcon();
	iconeCinema3751e.image = "logos/plume-cgr.png";
	iconeCinema3751e.shadow = "logos/plume-shadow.png";
	iconeCinema3751e.iconSize = new GSize(32,41);
	iconeCinema3751e.iconAnchor = new GPoint(16, 41);
	iconeCinema3751e.infoWindowAnchor = new GPoint(30, 10);
	
	var iconeCinema3751eoff = new GIcon();
	iconeCinema3751eoff.image = "local/cache-gd2/91f715717213ccf22c011c0320c8f2ca.png";
	iconeCinema3751eoff.iconSize = new GSize(32,41);
	iconeCinema3751eoff.iconAnchor = new GPoint(16, 41);
	iconeCinema3751eoff.infoWindowAnchor = new GPoint(30, 10);

	var iconeCinema7455d = new GIcon();
	iconeCinema7455d.image = "logos/plume-gaumont.png";
	iconeCinema7455d.shadow = "logos/plume-shadow.png";
	iconeCinema7455d.iconSize = new GSize(32,41);
	iconeCinema7455d.iconAnchor = new GPoint(16, 41);
	iconeCinema7455d.infoWindowAnchor = new GPoint(30, 10);
	
	var iconeCinema7455doff = new GIcon();
	iconeCinema7455doff.image = "local/cache-gd2/56415ad33c8811ce8d789dc39eb16eee.png";
	iconeCinema7455doff.iconSize = new GSize(32,41);
	iconeCinema7455doff.iconAnchor = new GPoint(16, 41);
	iconeCinema7455doff.infoWindowAnchor = new GPoint(30, 10);

	var iconeCinema6ccc5 = new GIcon();
	iconeCinema6ccc5.image = "logos/plume-max-linder.png";
	iconeCinema6ccc5.shadow = "logos/plume-shadow.png";
	iconeCinema6ccc5.iconSize = new GSize(32,41);
	iconeCinema6ccc5.iconAnchor = new GPoint(16, 41);
	iconeCinema6ccc5.infoWindowAnchor = new GPoint(30, 10);
	
	var iconeCinema6ccc5off = new GIcon();
	iconeCinema6ccc5off.image = "local/cache-gd2/515c95ad80b16f11876489b714286d42.png";
	iconeCinema6ccc5off.iconSize = new GSize(32,41);
	iconeCinema6ccc5off.iconAnchor = new GPoint(16, 41);
	iconeCinema6ccc5off.infoWindowAnchor = new GPoint(30, 10);

	var iconeCinema9f424 = new GIcon();
	iconeCinema9f424.image = "logos/plume-mk2.png";
	iconeCinema9f424.shadow = "logos/plume-shadow.png";
	iconeCinema9f424.iconSize = new GSize(32,41);
	iconeCinema9f424.iconAnchor = new GPoint(16, 41);
	iconeCinema9f424.infoWindowAnchor = new GPoint(30, 10);
	
	var iconeCinema9f424off = new GIcon();
	iconeCinema9f424off.image = "local/cache-gd2/13037b35967959453918dc96574b768f.png";
	iconeCinema9f424off.iconSize = new GSize(32,41);
	iconeCinema9f424off.iconAnchor = new GPoint(16, 41);
	iconeCinema9f424off.infoWindowAnchor = new GPoint(30, 10);

	var iconeCinema43c32 = new GIcon();
	iconeCinema43c32.image = "logos/plume-pathe.png";
	iconeCinema43c32.shadow = "logos/plume-shadow.png";
	iconeCinema43c32.iconSize = new GSize(32,41);
	iconeCinema43c32.iconAnchor = new GPoint(16, 41);
	iconeCinema43c32.infoWindowAnchor = new GPoint(30, 10);
	
	var iconeCinema43c32off = new GIcon();
	iconeCinema43c32off.image = "local/cache-gd2/765bd5f33953ceb4031e4790318983f8.png";
	iconeCinema43c32off.iconSize = new GSize(32,41);
	iconeCinema43c32off.iconAnchor = new GPoint(16, 41);
	iconeCinema43c32off.infoWindowAnchor = new GPoint(30, 10);

	var iconeCinemaa3d8a = new GIcon();
	iconeCinemaa3d8a.image = "logos/plume-ugc.png";
	iconeCinemaa3d8a.shadow = "logos/plume-shadow.png";
	iconeCinemaa3d8a.iconSize = new GSize(32,41);
	iconeCinemaa3d8a.iconAnchor = new GPoint(16, 41);
	iconeCinemaa3d8a.infoWindowAnchor = new GPoint(30, 10);
	
	var iconeCinemaa3d8aoff = new GIcon();
	iconeCinemaa3d8aoff.image = "local/cache-gd2/f76bc2e99c76b335d895ac84157d7cfb.png";
	iconeCinemaa3d8aoff.iconSize = new GSize(32,41);
	iconeCinemaa3d8aoff.iconAnchor = new GPoint(16, 41);
	iconeCinemaa3d8aoff.infoWindowAnchor = new GPoint(30, 10);


	var iconeDirNW = new GIcon();
	iconeDirNW.image = "logos/NW.png";
	iconeDirNW.iconSize = new GSize(24,24);
	iconeDirNW.iconAnchor = new GPoint(-5, -5);

	var iconeDirNE = new GIcon();
	iconeDirNE.image = "logos/NE.png";
	iconeDirNE.iconSize = new GSize(24,24);
	iconeDirNE.iconAnchor = new GPoint(29, -5);

	var iconeDirSW = new GIcon();
	iconeDirSW.image = "logos/SW.png";
	iconeDirSW.iconSize = new GSize(24,24);
	iconeDirSW.iconAnchor = new GPoint(-5, 29);

	var iconeDirSE = new GIcon();
	iconeDirSE.image = "logos/SE.png";
	iconeDirSE.iconSize = new GSize(24,24);
	iconeDirSE.iconAnchor = new GPoint(29, 29);

	var iconeDirN = new GIcon();
	iconeDirN.image = "logos/N.png";
	iconeDirN.iconSize = new GSize(33,17);
	iconeDirN.iconAnchor = new GPoint(16, -5);

	var iconeDirS = new GIcon();
	iconeDirS.image = "logos/S.png";
	iconeDirS.iconSize = new GSize(33,17);
	iconeDirS.iconAnchor = new GPoint(16, 22);

	var iconeDirW = new GIcon();
	iconeDirW.image = "logos/W.png";
	iconeDirW.iconSize = new GSize(17,33);
	iconeDirW.iconAnchor = new GPoint(-5, 16);

	var iconeDirE = new GIcon();
	iconeDirE.image = "logos/E.png";
	iconeDirE.iconSize = new GSize(17,33);
	iconeDirE.iconAnchor = new GPoint(22, 16);




function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return myHeight;
}

function fixer_hauteur_map() {
	h_win = alertSize();
	h_haut = $("#bandeau-haut").height();
	h_bas = $("#choisir-genre").height();
	
	h_map = h_win - h_haut;

//	h_droite = h_win  - (250 + 99) ;
	h_droite = h_win  - 99 ;
	
	$("#map").css({height: h_map});
	$("#pave-droite").css({height: h_droite});
//	$("#map").css({height: h_win});
	
}



var total_charge = 0;
var total_mem = 0;
var connexions_numero = 0;
var mem_script = new Array();
var connexions_chargement = new Array();

function installScript( script ) 
{ 
	if (!script) return;
	if (window.execScript) window.execScript(script);
	else window.setTimeout(script,0);
} 

function charger_script(page) {
	total_charge = total_charge + 1;
	if (mem_script[page]) {
		installScript(mem_script[page]);
		total_charge = total_charge - 1;

		// afficher_charge();
	}
	else {
		connexions_numero++;
		connexions_chargement[connexions_numero] = $.get ( page, function(rtnTxt){ 
				mem_script[page] = rtnTxt;
				
				
				total_mem = total_mem + 1;
				
				if (total_mem > 300) {
					mem_script = new Array();
					total_mem = 0;
				}
				
				installScript(rtnTxt); 
				total_charge = total_charge - 1;
		
				// afficher_charge();
			});
	}
}

var slideur;
var slideur_actif;
var slideur_left;
var slideur_decal;
var slideur_mouse_x;



var mouseX = 0;
var mouseY = 0;
$().mousemove( function(e) {
	mouseX = e.pageX; 
	mouseY = e.pageY;
});

function getMouseX(e) {


	return mouseX;
}



function deplacer_slide(evnt) {

	if (slideur) {
		largeur_int = $(slideur).parent().width();


		var x = getMouseX(evnt);



		
		if (slideur_mouse_x) {
			slideur_decal = slideur_mouse_x - x;
		} else {
			slideur_decal = 0;
		}

		if (!slideur_actif && Math.abs(slideur_decal) > 3) slideur_actif = true;
		
		slideur_left = parseInt($(slideur).css("left"));
		left = slideur_left - slideur_decal;
		
		if (left > 0) left = 0;
		largeur_totale = $(slideur).width();
		
		$("#sauver_adresse").html(largeur_totale);		
		
		if (left < (largeur_int - largeur_totale)) left = (largeur_int - largeur_totale);
		
		if (largeur_totale <= largeur_int) left = 0;
		
		slideur_left = left;
		slideur_mouse_x = x;

		if (slideur_decal != 0) $(slideur).css("left", left);
	}
}


function debut_slide(slid) {

	slideur = slid;
	
	slideur_actif = false;

	$("#sauver_adresse").html(slideur);
	

	if ($(slideur).is(":animated")) {
		$(slideur).stop();
	}


	
	slideur_decal = 0;

	slideur_mouse_x = false;


	slideur_left = parseInt($(slideur).css("left"));	
}

function fin_slide(evnt) {
	slideur_tmp = slideur;
	slideur = false;

	// Continuer a bouger



	left = slideur_left - (10 * slideur_decal);
	largeur_int = $(slideur_tmp).parent().width();



	if (left > 0) left = 0;
	largeur_totale = $(slideur_tmp).width();

	
	if (left < (largeur_int - largeur_totale)) left = (largeur_int - largeur_totale);
	
	if (largeur_totale <= largeur_int) left = 0;
	$(slideur_tmp).animate({left: left}, 'slow','easeOutExpo');
	
	slideur_left = left;
}

var decal = new Array();
	decal[0] = "";
	decal[1] = "d";	
	decal[2] = "h";
	decal[3] = "g";
	decal[4] = "g";
	decal[5] = "b";
	decal[6] = "b";
	decal[7] = "d";
	decal[8] = "d";
	decal[9] = "d";
	decal[10] = "h";
	decal[11] = "h";
	decal[12] = "h";
	decal[13] = "g";
	decal[14] = "g";
	decal[15] = "g";
	decal[16] = "g";

	decal[16] = "b";
	decal[17] = "b";
	decal[18] = "b";
	decal[19] = "b";
	
	decal[20] = "d";
	decal[21] = "d";
	decal[22] = "d";
	decal[23] = "d";

	decal[24] = "h";
	decal[25] = "h";
	decal[26] = "h";
	decal[27] = "h";
	decal[28] = "h";

	decal[29] = "g";
	decal[30] = "g";
	decal[31] = "g";
	decal[32] = "g";
	decal[33] = "g";

	decal[34] = "b";
	decal[35] = "b";
	decal[36] = "b";
	decal[37] = "b";
	decal[38] = "b";
	decal[39] = "b";

	decal[40] = "d";
	decal[41] = "d";
	decal[42] = "d";
	decal[43] = "d";
	decal[44] = "d";
	decal[45] = "d";

	decal[46] = "h";
	decal[47] = "h";
	decal[48] = "h";
	decal[49] = "h";
	decal[50] = "h";
	decal[51] = "h";
	decal[52] = "h";

	decal[53] = "g";
	decal[54] = "g";
	decal[55] = "g";
	decal[56] = "g";
	decal[57] = "g";
	decal[58] = "g";
	decal[59] = "g";

	decal[60] = "b";
	decal[61] = "b";
	decal[62] = "b";
	decal[63] = "b";
	decal[64] = "b";
	decal[65] = "b";
	decal[66] = "b";
	decal[67] = "b";

	decal[68] = "d";
	decal[69] = "d";
	decal[70] = "d";
	decal[71] = "d";
	decal[72] = "d";
	decal[73] = "d";
	decal[74] = "d";
	decal[75] = "d";


	decal[76] = "h";
	decal[77] = "h";
	decal[78] = "h";
	decal[79] = "h";
	decal[80] = "h";
	decal[81] = "h";
	decal[82] = "h";
	decal[83] = "h";
	decal[84] = "h";

	decal[85] = "g";
	decal[86] = "g";
	decal[87] = "g";
	decal[88] = "g";
	decal[89] = "g";
	decal[90] = "g";
	decal[91] = "g";
	decal[92] = "g";
	decal[93] = "g";

	decal[94] = "b";
	decal[95] = "b";
	decal[96] = "b";
	decal[97] = "b";
	decal[98] = "b";
	decal[99] = "b";
	decal[100] = "b";
	decal[101] = "b";
	decal[102] = "b";
	decal[103] = "b";

var positions = new Array();
var positions_point = new Array();

function memo_point (nom_point, latitudex, longitude) {
	
	// Desactiver le deplacement
	//	return new GLatLng(latitudex,longitude);
	
	rap = 17 - zoom_level;
	
	rap = Math.pow(2,rap);
	
		
	dl = Math.round(7000 / rap);
	dt = Math.round(3100 / rap);
	
	latitudex = Math.round(latitudex * dl);
	longitude = Math.round(longitude * dt);

	i = 0;

	while (positions[latitudex+"-"+longitude] && i < 104) {
		i= i +1;
		if (decal[i] == "d") longitude = longitude + 1;
		else if (decal[i] == "h")  latitudex = latitudex + 1;
		else if (decal[i] == "g") longitude = longitude - 1;
		else if (decal[i] == "b")  latitudex = latitudex - 1;
		
	}
	
//	$("#sauver_adresse").html(nom_point + " / " + i + " / " + decal[i]);	
	positions[latitudex+"-"+longitude] = true;	
	positions_point[nom_point] = latitudex+"-"+longitude;

	/* Introduire un decalage vertical */
	decalage_v = 3;
	latitudex = latitudex + ((Math.round(longitude / decalage_v) * decalage_v) - longitude) / decalage_v;
		
	latitudex = latitudex / dl;
	longitude = longitude / dt;


	return new GLatLng(latitudex,longitude);
}



	function chercher_adresse_cinema (adresse, id) {
	
		geocoder[id] = new GClientGeocoder();	
		
		geocoder[id].getLocations(adresse, 
			function(response) {
				if (!response || response.Status.code != 200) {
					 // alert(adresse + " not found");
					$("#sauver_adresse").load("?page=sauver_adresse_cinema&id_cinema="+id+"&commentaire=mauvaise-adresse");
	
				} else {
					place = response.Placemark[0];
					latitude = place.Point.coordinates[1];
					longitude = place.Point.coordinates[0];
					
					point["new"+id] = new GLatLng(latitude,longitude);
					markville["new"+id] = new GMarker(point["new"+id]);
					map.addOverlay(markville["new"+id]);
					adresse = place.address;
	
					$("#sauver_adresse").load("?page=sauver_adresse_cinema&id_cinema="+id+"&latitude="+latitude+"&longitude="+longitude);
					
//					alert(adresse)
	
				}
			}
		);
	
	}


function map_tout_effacer() {
		map.clearOverlays();
		markville = new Array();
		positions = new Array();
		total_charge = 0;
		total_markville = 0;

		
		jQuery.each(cinemas, function() {
			this.visible = false;
		});
		

}

cinemas = new Array();

	function cinema (id_cinema, nom, latitude, longitude, logo, logooff, films) {
//		$("#sauver_adresse").html("Nouveau: "+ id_cinema);
	
		this.id_cinema = id_cinema;
		this.nom = nom;
		this.latitude = latitude;
		this.longitude = longitude;
		this.logo = logo;
		this.logooff = logooff;
		this.visible = false;
		this.films = films;		
		
//		alert(id_cinema + " / " + latitude + " / " + longitude);

	}

	function infoWindowCinema(id_cinema) {
		if ($("#pave-cinema"+id_cinema).is(":visible")) {

//			alert("?page=pave-cinema&id_cinema="+id_cinema+"&film_debut="+escape(film_debut)+"&film_fin="+escape(film_fin));


			$("#pave-cinema"+id_cinema).load("?page=pave-cinema&id_cinema="+id_cinema+"&film_debut="+escape(film_debut)+"&film_fin="+escape(film_fin), function() {
				if (slideur_left < 0) {
					$("#slide"+id_cinema).css("left", slideur_left);
				} else if (afficher_film) {
					slideur_tmp = "#slide"+id_cinema;;

					numero = $("#slide"+id_cinema+" .pave_film_cinema .numero"+afficher_film).html();

					if (numero > 0) {
							numero = parseInt(numero) - 1;					
							largeur_int = parseInt($(slideur_tmp).parent().css("width"));
							largeur_totale = parseInt($(slideur_tmp).css("width"));
							
							if (largeur_totale > largeur_int) {
								left = parseInt((-80 * numero) + (largeur_int/2) - 40);
								if (left > 0) left = 0;
								if (left < (largeur_int - largeur_totale)) left = (largeur_int - largeur_totale);
								if (largeur_totale <= largeur_int) left = 0;

								$(slideur_tmp).css("left", left);
							}
					
					}





//					$("#sauver_adresse").html("num: "+left);
				
				}
			});
		} else {
			setTimeout("infoWindowCinema("+id_cinema+")",100);
		}
		pageTracker._trackEvent('InfoWindow', "Cinema", id_cinema);	
		
	}


	function afficher_cinemas() {
		var liste_cinemas = "";
		var bounds = map.getBounds();

		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		
		South = southWest.lat();
		North = northEast.lat();
		West = southWest.lng();
		East = northEast.lng();

		var position_map = map.getCenter();
		var zoom_map = map.getZoom();

		$.cookie('immonimo_position_map',position_map, { expires: 30 });
		$.cookie('immonimo_zoom_map',zoom_map, { expires: 30 });

		
		margeNS = (North - South) / 10;
		
		margeEW = (East - West) / 20;

		d1 = 40000;
		d2 = 40000;
		d3 = 40000;
		d4 = 40000;
		d5 = 40000;
		c1 = 0;
		c2 = 0;
		c3 = 0;
		c4 = 0;
		c5 = 0;


		cinemas_visibles = 0;
		cinemas_invisibles = 0;


		jQuery.each(cinemas, function() {
			id_cinema = this.id_cinema;
						
						
			latitude = this.latitude;
			longitude = this.longitude;
			films = this.films;
			
			//		alert(id_cinema + " / " + latitude + " / " + longitude);

			// Calculer nombre de visibles
			if (latitude >= South && latitude <= North && longitude >= West && longitude <= East) {
				visible = true;
					if (afficher_film > 0) {
						if (films.indexOf("|"+afficher_film+"|") < 0) {
							visible = false;
						}
					}
				if (visible) {
					cinemas_visibles ++;
					liste_cinemas = liste_cinemas + "," + id_cinema;		
				}
				else {
					cinemas_invisibles ++;
				}
			}
		});
		
		cinemas_total = cinemas_visibles + cinemas_invisibles;
//		$("#sauver_adresse").html(cinemas_visibles + " / " + cinemas_invisibles + " / " + cinemas_total);
		


		
		jQuery.each(cinemas, function() {
			id_cinema = this.id_cinema;
			
			index = id_cinema;
			
			latitude = cinemas[index].latitude;
			longitude = cinemas[index].longitude;
			films = cinemas[index].films;

//			$("#sauver_adresse").html(id_cinema + " / " + latitude + " / " + longitude);

			
			
			if ((latitude < South || latitude > North) || (longitude < West || longitude > East)) {
				visible = true;
					if (afficher_film > 0) {
						if (films.indexOf("|"+afficher_film+"|") < 0) {
							visible = false;
						}
					}
				if (visible) {	
					if (latitude < South) dlat = South - latitude;
					else dlat = latitude - North;
	
					dlat = dlat * 111;
					
					if (longitude < West) dlong = West - longitude;
					else dlong = longitude - East;
					
					dlong = dlong * 73;
					
					d = Math.sqrt((dlong * dlong) + (dlat * dlat));
					
					if (d < d1) {
						d5 = d4;
						d4 = d3;
						d3 = d2;
						d2 = d1;
						d1 = d;
						
						c5 = c4;
						c4 = c3;
						c3 = c2;
						c2 = c1;
						c1 = id_cinema;
					} else if (d < d2) {
						d5 = d4;
						d4 = d3;
						d3 = d2;
						d2 = d;
						
						c5 = c4;
						c4 = c3;
						c3 = c2;
						c2 = id_cinema;
					} else if (d < d3) {
						d5 = d4;
						d4 = d3;
						d3 = d;
						
						c5 = c4;
						c4 = c3;
						c3 = id_cinema;
					} else if (d < d4) {
						d5 = d4;
						d4 = d;
						
						c5 = c4;
						c4 = id_cinema;
					} else if (d < d5) {
						d5 = d;
						
						c5 = id_cinema;
					}
				}

			}
			
			if (latitude >= (South - margeNS) && latitude <= (North + margeNS) && longitude >= (West - margeEW) && longitude <= (East + margeEW)) {
				logo = cinemas[index].logo;
				logooff = cinemas[index].logooff;
			
			
			
				if(!markville['cinema'+id_cinema]) {


					visible = true;
					if (afficher_film > 0) {
						if (films.indexOf("|"+afficher_film+"|") < 0) {
							visible = false;
						}
					}
	
	
					if (visible || cinemas_total < 80){

						if (!point['cinema'+id_cinema]) point['cinema'+id_cinema] = memo_point('cinema'+id_cinema, latitude, longitude);
					
						
						
						
						if (logo) {
	
							if (visible) {
								markville['cinema'+id_cinema] = new GMarker(point['cinema'+id_cinema], {icon: logo, draggable: false});
							} else {
								markville['cinema'+id_cinema] = new GMarker(point['cinema'+id_cinema], {icon: logooff, draggable: false});
							}
						} else {
							
							if (visible) {
								markville['cinema'+id_cinema] = new GMarker(point['cinema'+id_cinema], {icon:iconeCinema, draggable: false});
							} else {
								markville['cinema'+id_cinema] = new GMarker(point['cinema'+id_cinema], {icon:iconeCinemaoff, draggable: false});
							}
						}
	
	
	
						if (!cinemas[index].visible) {
						
						
							if (visible) {
								map.addOverlay(markville['cinema'+id_cinema]);
							} else {
								if (cinemas_total < 40) {
									map.addOverlay(markville['cinema'+id_cinema]);
								} else {
	//								map.addOverlay(markville['cinema'+id_cinema]);
	//								map.removeOverlay(markville['cinema'+id_cinema]);
								}
							}
						}

						var le_cinema = cinemas[index].id_cinema;
													
						GEvent.addListener(markville['cinema'+le_cinema], 'click', function() {
						
							markville['cinema'+le_cinema].openInfoWindowHtml("<div id='pave-cinema"+le_cinema+"' class='pave-cinema'><div style='text-align: center; padding-top: 60px;'><img src='squelettes/imgs/loading.gif' alt='loading' /></div></div>");
	//						$("#pave-cinema"+le_cinema).load("?page=pave-cinema&id_cinema="+le_cinema);
							slideur_left = false;
							setTimeout("infoWindowCinema("+le_cinema+")",100);
							cinema_popup = le_cinema;
							ouvrir_cinema(le_cinema);
						});	
						GEvent.addListener(markville['cinema'+le_cinema], 'mouseover', function() {
							markville['survol'+le_cinema] = new GMarker(point['cinema'+le_cinema], {icon:baseRond});
							map.addOverlay(markville['survol'+le_cinema]);    
						});
						GEvent.addListener(markville['cinema'+le_cinema], 'mouseout', function() {
							map.removeOverlay(markville['survol'+le_cinema]);    
						});

						// Cinemas draggable, et enregistrement du deplacement
						GEvent.addListener(markville['cinema'+le_cinema], "dragend", function() {
							latitude = markville['cinema'+le_cinema].getPoint().lat().toFixed(6);
							longitude = markville['cinema'+le_cinema].getPoint().lng().toFixed(6);
							$("#sauver_adresse").load("?page=sauver_adresse_cinema&id_cinema="+le_cinema+"&latitude="+latitude+"&longitude="+longitude);
						});

					} else {
					
					}
				} else {
					if (!cinemas[index].visible) map.addOverlay(markville['cinema'+id_cinema]);
				}
				cinemas[index].visible = true;
			} else {
				if(markville['cinema'+id_cinema] && cinemas[index].visible) {
					map.removeOverlay(markville['cinema'+id_cinema]);
				}
				cinemas[index].visible = false;
			}
			
		});

		
		if (cinema_popup) {
//			id_cinema = cinema_popup;
//			markville['cinema'+id_cinema].openInfoWindowHtml("<div id='pave-cinema"+id_cinema+"' class='pave-cinema'><div style='text-align: center; padding-top: 60px;'><img src='squelettes/imgs/loading.gif' alt='loading' /></div></div>");
//			setTimeout("infoWindowCinema("+id_cinema+")",100);
		}
		
//		afficher_proximite("c1", c1, d1);
//		afficher_proximite("c2", c2, d2);
//		afficher_proximite("c3", c3, d3);
//		afficher_proximite("c4", c4, d4);
//		afficher_proximite("c5", c5, d5);

	$("#liste_cinemas").load("?page=liste_cinemas&liste_cinemas=" + liste_cinemas + "&proximite=" +  c1 + "," +  c2 + "," +  c3 + "," +  c4 + "," +  c5 + "&afficher_film=" + afficher_film +"&film_debut="+escape(film_debut)+"&film_fin="+escape(film_fin));
//&id_film="+le_cinema+"&film_debut="+film_debut+"&film_fin="+film_fin + "
		
	}

	function afficher_proximite (mark, id_cinema, dist) {
		
		if (markville["dir"+mark]) map.removeOverlay(markville["dir"+mark]);

		if (id_cinema > 0) {
			latitude = cinemas[id_cinema].latitude;
			longitude = cinemas[id_cinema].longitude;
	
	
			var bounds = map.getBounds();
	
			var southWest = bounds.getSouthWest();
			var northEast = bounds.getNorthEast();
			
			South = southWest.lat();
			North = northEast.lat();
			West = southWest.lng();
			East = northEast.lng();
	
	
			dir = "";
			
			if (latitude < South) {
				dir = "S";
				afflat = South;
			}
			else if (latitude > North) {
				dir = "N";
				afflat = North;
			} else {
				afflat = latitude;
			}
			
			if (longitude < West) {
				dir = dir + "W";
				afflong = West;
			}
			else if (longitude > East) {
				dir = dir + "E";
				afflong = East;
			} else {
				afflong = longitude;
			}

			point["dir"+mark] = new GLatLng(afflat,afflong);
			if (dir == "NW")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirNW});
			else if (dir == "NE")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirNE});
			else if (dir == "SW")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirSW});
			else if (dir == "SE")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirSE});
			else if (dir == "N")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirN});
			else if (dir == "S")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirS});
			else if (dir == "E")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirE});
			else if (dir == "W")	markville["dir"+mark] = new GMarker(point["dir"+mark], {icon: iconeDirW});
			else markville["dir"+mark] = new GMarker(point["dir"+mark]);
			map.addOverlay(markville["dir"+mark]);
			
			
//			GEvent.addListener(markville["dir"+mark], 'click', function() {
//				map.setCenter(new GLatLng(latitude,longitude)); 
//			});

		}
	}
	
	
	function montrer_cinema(id_cinema, longitude, latitude)	{
		var le_cinema = id_cinema;
	    map.setCenter(new GLatLng(latitude,longitude));		
		markville['cinema'+le_cinema].openInfoWindowHtml("<div id='pave-cinema"+le_cinema+"' class='pave-cinema'><div style='text-align: center; padding-top: 60px;'><img src='squelettes/imgs/loading.gif' alt='loading' /></div></div>");		
		setTimeout("infoWindowCinema("+le_cinema+")",100);
		cinema_popup = le_cinema;
		ouvrir_cinema(le_cinema);
	    
	}

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));

		
			<!-- Cinema: 106 -->
		    map.setCenter(new GLatLng(47.805691,7.101440), 15);
		

	    


				

		zoom_level = map.getZoom();

		map.addControl(new GLargeMapControl3D());
		map.addControl(new GOverviewMapControl(new GSize(150,120)));
		map.addControl(new GScaleControl());

		var mapControl = new GMapTypeControl();
		map.addControl(mapControl);

		map.enableContinuousZoom();


//		alert("?page=afficher_films&film_debut="+film_debut+"&film_fin="+film_fin);

		ouvrir_film(7721);

		$.getScript("?page=afficher_films&film_debut="+film_debut+"&film_fin="+film_fin);



		



		GEvent.addListener(map, "moveend", function() {
			afficher_cinemas();
		});
		GEvent.addListener(map, "zoomend", function() {
			point = new Array();
			zoom_level = map.getZoom();
			map_tout_effacer();
			afficher_cinemas();

		});

		

      }      
    }


var heure_debut;
var heure_fin;


	$(window).bind("load", function() {

		fixer_hauteur_map();


		maintenant = new Date();
		film_jour = maintenant.getFullYear() + "-" + (maintenant.getMonth()+1) + "-" + maintenant.getDate();
		film_heure = maintenant.getHours();
		
		jour_semaine = maintenant.getDay();
		$("#selec-jour"+jour_semaine).addClass("sel-jour");
		
		if (film_heure < 12) {
			$("#selec-horaire6").addClass('selec-horaire');
			film_debut = "6:00:00";
			film_fin = "12:00:00";
		} else if (film_heure < 15) {
			$("#selec-horaire12").addClass('selec-horaire');
			film_debut = "12:00:00";
			film_fin = "15:00:00";
		} else if (film_heure < 17) {
			$("#selec-horaire15").addClass('selec-horaire');
			film_debut = "15:00:00";
			film_fin = "17:00:00";
		} else if (film_heure < 19) {
			$("#selec-horaire17").addClass('selec-horaire');
			film_debut = "17:00:00";
			film_fin = "19:00:00";
		} else if (film_heure < 21) {
			$("#selec-horaire19").addClass('selec-horaire');
			film_debut = "19:00:00";
			film_fin = "21:00:00";
		} else {
			$("#selec-horaire21").addClass('selec-horaire');
			film_debut = "21:00:00";
			film_fin = "23:59:59";
		}
		
		
		heure_debut = film_debut;
		heure_fin = film_fin;
		
		film_debut = film_jour + " " + film_debut;
		film_fin = film_jour + " " + film_fin;
			
//		$("#sauver_adresse").html("aujourd'hui: " + film_debut + " / " + film_fin);

		$("#villes").load("spip.php?page=villes");

		load();


		
		$("#bandeau-bas-films").load("?page=pave-bandeau-films");
		
	});	
	
function changer_jour (num) {
		maintenant = new Date();

		
		
		if (num < 3) num = num + 7;
		
		jour_semaine = maintenant.getDay();

		if (jour_semaine < 3) jour_semaine = jour_semaine + 7;		
			

		
		decal = jour_semaine - num;

		maintenant.setDate(maintenant.getDate()-decal);

		film_jour = maintenant.getFullYear() + "-" + (maintenant.getMonth()+1) + "-" + (maintenant.getDate() );
		film_debut = film_jour + " " + heure_debut;
		film_fin = film_jour + " " + heure_fin;
		
		$("#sauver_adresse").html("aujourd'hui: " + film_debut + " / " + film_fin);

		
		if ($("#pave-cinema"+cinema_popup).is(":visible")) {
			slideur_left = parseInt($("#slide"+cinema_popup).css("left"));
		} else {
			slideur_left = 0;
		}
		$.getScript("?page=afficher_films&film_debut="+film_debut+"&film_fin="+film_fin+"&afficher_vovf="+afficher_vovf);
		ouvrir_film(afficher_film);
		pageTracker._trackEvent('Onglet', 'Changer jour');	

}

	
	function charger_horaire(debut, fin) {
		heure_debut = debut;
		heure_fin = fin;
	
		film_debut = film_jour + " " + debut;
		film_fin = film_jour + " " + fin;
		
		$("#sauver_adresse").html("aujourd'hui: " + film_debut + " / " + film_fin);

		
		if ($("#pave-cinema"+cinema_popup).is(":visible")) {
			slideur_left = parseInt($("#slide"+cinema_popup).css("left"));
		} else {
			slideur_left = 0;
		}
		$.getScript("?page=afficher_films&film_debut="+film_debut+"&film_fin="+film_fin+"&afficher_vovf="+afficher_vovf);
		ouvrir_film(afficher_film);
		pageTracker._trackEvent('Onglet', 'Changer horaire');	
			
	}

	function charger_vovf (vovf) {
		afficher_vovf = vovf;
		cinema_popup = false;
//			alert("?page=afficher_films&film_debut="+film_debut+"&film_fin="+film_fin+"&afficher_vovf="+afficher_vovf);
		$.getScript("?page=afficher_films&film_debut="+film_debut+"&film_fin="+film_fin+"&afficher_vovf="+afficher_vovf);
		
		$("#onglet-film").load("?page=onglet-film&id_film="+afficher_film+"&afficher_vovf="+afficher_vovf);
		ouvrir_film(afficher_film);
	}

	function charger_genre(genre) {
//		alert("?page=pave-bandeau-films&genre="+genre.replace(" ","."));
		$("#bandeau-bas-films").load("?page=pave-bandeau-films&genre="+genre.replace(" ","."));
//		document.location = "?page=pave-bandeau-films&genre="+genre;
		pageTracker._trackEvent('Onglet', 'Changer genre', genre);	
	}
	
	
	var timeFermer;
	
	function time_fermer_bas() {
		$("#choisir-genre").css("overflow", "hidden");
		$('#bandeau-bas-films').slideUp('slow');
	}
	function time_ouvrir_bas() {
		$("#choisir-genre").css("overflow", "visible");
		$('#bandeau-bas-films').slideDown('fast');
	}
	
	function fermer_bas() {
		clearTimeout(timeFermer);
		timeFermer = setTimeout("time_fermer_bas()", 500);
	}
	function ouvrir_bas() {
		clearTimeout(timeFermer);
		time_ouvrir_bas();
	}


var onglet_actif = "film";
function afficher_onglet (onglet) {


	if (onglet == onglet_actif) return false;

	$(".onglet-droite").removeClass("onglet-droite-sel");
	$("#selecteur-"+onglet).addClass("onglet-droite-sel");
	 

	$("#onglet-"+onglet_actif).fadeOut();
	$("#onglet-"+onglet).fadeIn();
	onglet_actif = onglet;
}


function ouvrir_film (id_film) {
	afficher_onglet ("film");
	$("#selecteur-cinema").hide();
	$("#selecteur-seance").hide();
	pageTracker._trackEvent('Onglet', 'Ouvrir', "Film", id_film);	
}

function ouvrir_cinema(id_cinema) {
	$("#onglet-cinema").load("spip.php?page=onglet-cinema&id_cinema="+id_cinema+"&id_film="+afficher_film+"&afficher_vovf="+afficher_vovf + "&film_debut=" + escape(film_debut) + "&film_fin=" + escape(film_fin));
	afficher_onglet ("cinema");

	$("#selecteur-cinema").show();
	$("#selecteur-seance").hide();
	pageTracker._trackEvent('Onglet', 'Ouvrir', "Cinema", id_cinema);	
}

function ouvrir_seance(id_seance) {
	afficher_onglet ("seance");
	$("#selecteur-seance").show();
	$("#onglet-seance").load("spip.php?page=onglet-seance&id_seance="+id_seance);
	pageTracker._trackEvent('Onglet', 'Ouvrir', "Seance", id_seance);	
}
	
$(window).bind("resize", function() {
	fixer_hauteur_map();
	afficher_cinemas();
});


$(window).bind("mousemove", function() {
});
$(window).bind("mouseup", function() {
});

