function echo(message) {
	if(typeof(console) == 'object'){
		console.log(message);
	} 
}

if ((navigator.appName == "Netscape")&&(navigator.appVersion.substring(0,4)>=4)){
	
	isNav="net";
} 
if (navigator.appName == "Microsoft Internet Explorer"){
	
	isNav="ie";
}

sto_hidelayer = 0;
sto_hidelayer2 = 0;

//change the mode of legend
function change_legend_image(div_id,checkbox_id){
	
	var arr_legend_img = div_id.split(",");
	
	var legend_checkbox = document.getElementById(checkbox_id);
	
	for(var l = 0;l < arr_legend_img.length;l++){
	
		var legend_img = document.getElementById(arr_legend_img[l]);
		if(legend_img.style.display == "block"){
			
			legend_img.style.display = "none";
			legend_checkbox.src = root_path + "/images/map/legende_checkbox.png";
		}
		else{
			
			legend_img.style.display = "block";
			legend_checkbox.src = root_path + "/images/map/legende_checkboxchekcked.png";
		}
	}
}

function big_hotel_poplayer_old(zipcode,city,g,f){
	
	hidelayer2_stop_timeout();
	hidelayer("div_hotel_pop_layer");
	
	var img_hotel_big = document.getElementById("img_hotel_big_"+g);
	
	var big_hotel_left = parseInt(img_hotel_big.style.left);
	var big_hotel_top = parseInt(img_hotel_big.style.top);
	
	var div_big_hotel_content = "";
	
	var big_poplayer_div_obj = document.getElementById("div_big_hotel_pop_layer");
	
	var div_left_init = parseInt(document.getElementById('div_result_map_content').style.left);
	var div_top_init = parseInt(document.getElementById('div_result_map_content').style.top);
	
	div_big_hotel_content  = "<table width='90%' height='100%' align='center'>";
	div_big_hotel_content += "	<tr>";
	div_big_hotel_content += "		<td valign='top' class='div_hotel_pop_lable'>"+f+" resultats dans le </br>"+city+"</td>";
	div_big_hotel_content += "	</tr>";
	div_big_hotel_content += "	<tr>";
	div_big_hotel_content += "		<td class='div_hotel_pop_layer_detail' align='left'><div style='width:150px'><a onclick='hidelayer(\"div_big_hotel_pop_layer\");generateResultByZipcode(\""+zipcode+"\");' style=\"cursor:pointer;\">Voir la liste de résultats</a></div></td>";
	div_big_hotel_content += "	</tr>";
	div_big_hotel_content += "</table>";
	
	big_poplayer_div_obj.innerHTML = div_big_hotel_content;
	
	big_poplayer_div_obj.style.left = big_hotel_left + div_left_init+ 28 + "px";
	big_poplayer_div_obj.style.top = big_hotel_top + div_top_init + 25 + "px";
	big_poplayer_div_obj.style.display = "block";
}


function big_hotel_poplayer(zipcode,city,f,g){

	hidelayer2_stop_timeout();
	hidelayer("div_hotel_pop_layer");
	
	var img_hotel_big = document.getElementById("img_hotel_big_"+g);
	
	var big_hotel_left = parseInt(img_hotel_big.style.left);
	var big_hotel_top = parseInt(img_hotel_big.style.top);
	
	var div_big_hotel_content = "";
	
	var big_poplayer_div_obj = document.getElementById("div_big_hotel_pop_layer");
	
	var div_left_init = parseInt(document.getElementById('div_result_map_content').style.left);
	var div_top_init = parseInt(document.getElementById('div_result_map_content').style.top);

	div_big_hotel_content  = "<table width='90%' height='100%' align='center'>";
	div_big_hotel_content += "	<tr>";
	div_big_hotel_content += "		<td valign='top' class='div_hotel_pop_lable'>"+f+" resultats dans le </br>"+city+"</td>";
	div_big_hotel_content += "	</tr>";
	div_big_hotel_content += "	<tr>";
	div_big_hotel_content += "		<td class='div_hotel_pop_layer_detail' align='left'><div style='width:150px'><a onclick='hidelayer(\"div_big_hotel_pop_layer\");generateResultByZipcode(\""+zipcode+"\");' style=\"cursor:pointer;\">Voir la liste de résultats</a></div></td>";
	div_big_hotel_content += "	</tr>";
	div_big_hotel_content += "</table>";

	$('#div_big_hotel_pop_layer').html(div_big_hotel_content);
	
	var scrollx=$('#div_result_map').scrollLeft();
  	var scrolly=$('#div_result_map').scrollTop();
	
	$('#div_big_hotel_pop_layer').css({
		'left' : (big_hotel_left-scrollx+20) +"px",
		'top' : (big_hotel_top-scrolly+20) + "px",
		'display' : 'block'
	});
}

function hotel_poplayer(div_id,n,cat){

	hidelayer_stop_timeout();
	hidelayer("div_big_hotel_pop_layer");
	var hotel_id = div_content_arr[n][0];
	var hotel_type_id = div_content_arr[n][1];
	var hotel_name = traite_chaine_inv(div_content_arr[n][2]);
	var hotel_class = traite_chaine_inv(div_content_arr[n][3]);
	var hotel_photo = traite_chaine_inv(div_content_arr[n][4]);
	var hotel_address = traite_chaine_inv(div_content_arr[n][5]);
	var hotel_picto = traite_chaine_inv(div_content_arr[n][6]);
	var hotel_tarifs = traite_chaine_inv(div_content_arr[n][7]);
	var hotel_contact = traite_chaine_inv(div_content_arr[n][8]);
	//var picto_type = traite_chaine_inv(div_content_arr[n][9]);
	var label_type = traite_chaine_inv(div_content_arr[n][10]);
	var xml_file = div_content_arr[n][11];
	if(div_content_arr[n][14]){cat = div_content_arr[n][14];}

	var img_hotel = document.getElementById("img_hotel_"+n);
	
	var hotel_left = parseInt(img_hotel.style.left);
	var hotel_top = parseInt(img_hotel.style.top);
	
	var div_content = "";
	
	var poplayer_div_obj = document.getElementById(div_id);
		
	var div_left_init = parseInt(document.getElementById('div_result_map_content').style.left);
	var div_top_init = parseInt(document.getElementById('div_result_map_content').style.top);
	
	var site = 'site';
	if(cat=='weekend')   {site = 'weekends';}
	else if(cat=='rando'){site = 'balades';}
	
	
	div_content  = "<div class=\"div_hotel_pop_layer_haut\"></div>";	
	div_content += "<div class=\"div_hotel_pop_layer_content\">";
  div_content += "<table width='95%' height='100%' align='center'>";
	div_content += "	<tr>";
	div_content += "		<td height='14px' class='div_hotel_pop_label'>"+
	               //"<img align=\"absmiddle\" src=\""+picto_type+"\" label=\""+label_type+"\">&nbsp;"+
			   "<b>"+label_type+"</b></td>";
	div_content += "		<td align='right'><div class='div_hotel_pop_layer_close' onclick='hidelayer(\"div_hotel_pop_layer\");'>Fermer&nbsp<img src='../../module/carto/images/close.gif' border=0></div></td>";
	div_content += "	</tr>"; 	
	div_content += "	<tr>";
	div_content += "		<td height='20px' colspan='2' class='div_hotel_pop_hotel_name'><a onclick=\"hidelayer('div_hotel_pop_layer');generateFiche('"+hotel_id+"','"+cat+"');if (valeur==1){stat('cdt27','','','FICHE;"+hotel_id+"','','','','"+site+"')}\" style=\"cursor:pointer;\">"+hotel_name+"</a>&nbsp;"+hotel_class+"</td>";
	div_content += "	</tr>";
  
  if(div_content_arr[n][14]=="rando") {
  
  div_content += '<tr>';
  div_content += '<td style="width:72px"><a onclick="hidelayer(\'div_hotel_pop_layer\');generateFiche(\''+hotel_id+'\',\''+cat+'\');if (valeur==1){stat(\'cdt27\',\'\',\'\',\'FICHE;'+hotel_id+'\',\'\',\'\',\'\',\''+site+'\')}" style="cursor:pointer;">'+hotel_photo+'</a></td>';
  div_content += '<td style="vertical-align:top"><strong>Commune départ :</strong><br />'+hotel_address+'<br /><div style="margin-top:5px;"><strong>Distance :</strong> '+hotel_picto+'km</div></td>';
  div_content += '</tr>';
  div_content += '<tr><td colspan="2">'+div_content_arr[n][15]+'</td></tr>';
  
  
  }
	else {	  
	div_content += "	<tr>";
	div_content += "		<td style=\"vertical-align:top\"><a onclick=\"hidelayer('div_hotel_pop_layer');generateFiche('"+hotel_id+"','"+cat+"');if (valeur==1){stat('cdt27','','','FICHE;"+hotel_id+"','','','','"+site+"')}\" style=\"cursor:pointer;\">"+hotel_photo+"</a></td>";
	div_content += "		<td style=\"vertical-align:top\">"+hotel_address+"</td>";
	div_content += "	</tr>";
	
	if(hotel_picto || hotel_tarifs){
	div_content += "	<tr>";
	div_content += "		<td height='40px'>"+hotel_picto+"</td>";
	div_content += "		<td>"+hotel_tarifs+"</td>";
	div_content += "	</tr>";
	}
	div_content += "	<tr>";
	div_content += "		<td height='20px' class='div_hotel_pop_layer_contact'>"+hotel_contact+"</td>";	
	}
	
	div_content += "		<td valign=\"bottom\" align=\"right\">"+
	               "			<div class=\"div_hotel_pop_layer_detail\" style=\"height:20px;\">"+
			   "				<a onclick=\"hidelayer('div_hotel_pop_layer');generateFiche('"+hotel_id+"','"+cat+"')\" style=\"cursor:pointer;\">Voir le d&eacute;tail</a><br />"+
	               //"				<a href=\"javascript:carnet_ajout('"+hotel_id+"','"+hotel_type_id+"','"+xml_file+"');\">Ajouter au carnet de voyages</a>&nbsp;"+
			   "			</div>"+
			   "		</td>";
	div_content += "	</tr>";
	div_content += "</table>";
	div_content += "</div>";
	div_content += "<div class=\"div_hotel_pop_layer_bas\"></div>";

	
	poplayer_div_obj.innerHTML = div_content;
	
	//poplayer_div_obj.style.left = hotel_left + div_left_init + "px";
	//poplayer_div_obj.style.top = hotel_top + div_top_init + 25 + "px";
	
	var scrollx=$('#div_result_map').scrollLeft();
  	var scrolly=$('#div_result_map').scrollTop();
	
	poplayer_div_obj.style.left = (hotel_left-scrollx+20) +"px";
	poplayer_div_obj.style.top = (hotel_top-scrolly+20) + "px";
	poplayer_div_obj.style.display = "block";
}

function hidelayer(div_id){
	
	var hidelayer_div_obj = document.getElementById(div_id);
	hidelayer_div_obj.style.display = "none";
}


function hidelayer_with_timeout() {
	
	var div_id = "div_hotel_pop_layer";
	sto_hidelayer = setTimeout("hidelayer('"+div_id+"')", 2000);
}
function hidelayer_stop_timeout() {
	
	clearTimeout(sto_hidelayer);
}


function hidelayer2_with_timeout() {
	
	var div_id = "div_big_hotel_pop_layer";
	sto_hidelayer2 = setTimeout("hidelayer('"+div_id+"')", 2000);
}
function hidelayer2_stop_timeout() {
	
	clearTimeout(sto_hidelayer2);
}

//for drag map
var obj_left_init = 0;
var obj_top_init = 0;

var mouse_begin_x = 0;
var mouse_begin_y = 0;

var mouse_end_x = 0;
var mouse_end_y = 0;

var mouse_down = false;
var div_obj = "";
var div_drag = "";

function map_move_init(e){
	
	e = e?e:(window.event?window.event:null);
	
	div_obj = document.getElementById('div_result_map_content');
	div_drag = document.getElementById('div_carto_pictos_hotel');
	
	if(div_drag.setCapture){
		
		div_drag.setCapture();
	} 
	else if(window.captureEvents){
		
		window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	}
	
	mouse_begin_x = e.clientX;
	mouse_begin_y = e.clientY;
	
	obj_left_init = parseInt(div_obj.style.left);
	obj_top_init = parseInt(div_obj.style.top);
	
	mouse_down = true;
} 

function map_move(e){
	e = e?e:(window.event?window.event:null);
	
	if(mouse_down){
		
		mouse_end_x = e.clientX;
		mouse_end_y = e.clientY;
		
		div_obj.style.left = mouse_end_x - mouse_begin_x + obj_left_init + "px";
		div_obj.style.top = mouse_end_y - mouse_begin_y + obj_top_init + "px";
	} 
} 

function map_move_stop(){
	
	mouse_down = false;
	
	if(parseInt(div_obj.style.left) > 0){
		
		div_obj.style.left = "0px";
	}
	if(parseInt(div_obj.style.top) > 0){
		
		div_obj.style.top = "0px";
	}
	if(parseInt(div_obj.style.left) < -(map_width_base - map_window_width)){
		
		div_obj.style.left = -(map_width_base - map_window_width) + "px";
	}
	if(parseInt(div_obj.style.top) < -(map_height_base - map_window_height)){
		
		div_obj.style.top = -(map_height_base - map_window_height) + "px";
	}
	
	if(div_drag.releaseCapture){
		
		div_drag.releaseCapture();
	}
	else if(window.captureEvents){
		
		window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	}
}

//for zoom in/out map
var zoom_max = 3;

var center_x = map_window_width / 2;
var center_y = map_window_height / 2;

var mouse_x = 0;
var mouse_y = 0;

var map_style_left = 0;
var map_style_top = 0;

var tab_image_size = new Array();

tab_image_size[1] = new Array();
tab_image_size[1][0] = 734;
tab_image_size[1][1] = 570;

tab_image_size[2] = new Array();
tab_image_size[2][0] = 1470;
tab_image_size[2][1] = 1008;

tab_image_size[3] = new Array();
tab_image_size[3][0] = 2942;
tab_image_size[3][1] = 2018;

var evn_tmp = "";

function map_zoom(i,act,evn){

  ratio['x']=$('#div_result_map').scrollLeft();
  ratio['y']=$('#div_result_map').scrollTop();
  
  oldzoom=zoom;
  zoom=i; 
  zooming(tab_image_size[i][2],tab_image_size[i][3]);  
  
	evn = evn?evn:(window.event?window.event:null);
	
	if(evn_tmp == "" || evn_tmp == null) evn_tmp = evn;
	
	var div_result_map_content = document.getElementById('div_result_map_content');
	var div_carto_pictos_hotel = document.getElementById('div_carto_pictos_hotel');
	var div_carto_map = document.getElementById('div_carto_map');
	
	var map_zoom_out_img = document.getElementById('map_zoom_out_img');
	var map_zoom_in_img = document.getElementById('map_zoom_in_img');
	var map_zoom_class_img = document.getElementById('map_zoom_class_img');
	
	var div_result_map_zoom = document.getElementById('div_result_map_zoom');
	var div_result_map_legend = document.getElementById('div_result_map_legend');
	
	/*
	var div_carto_cours_d_eau = document.getElementById('div_carto_cours_d_eau');
	var div_carto_agglomerations = document.getElementById('div_carto_agglomerations');
	var div_carto_foret_bri = document.getElementById('div_carto_foret_bri');
	var div_carto_foret_cou = document.getElementById('div_carto_foret_cou');
	var div_carto_foret_dom = document.getElementById('div_carto_foret_dom');
	var div_carto_foret_gav = document.getElementById('div_carto_foret_gav');
	var div_carto_foret_tou = document.getElementById('div_carto_foret_tou');
	var div_carto_foret_vio = document.getElementById('div_carto_foret_vio');
	*/
	var div_carto_routes = document.getElementById('div_carto_routes');
	var div_carto_villes = document.getElementById('div_carto_villes');
	//var div_carto_voies_ferrees = document.getElementById('div_carto_voies_ferrees');
	
	var hidden_zoom_class = document.getElementById('hidden_zoom_class');
	hidden_zoom_class.value = i;
	
	if(i == 1){
		map_zoom_in_img.src = root_path + "/images/map/legende_boutonsplusactif.png";
		map_zoom_in_img.onclick = Function("map_zoom(" + (i + 1) + ",\"in\")");
		map_zoom_out_img.src = root_path + "/images/map/legende_boutonmoins.png";
		map_zoom_out_img.onclick = Function("");
		
		div_carto_pictos_hotel.ondblclick = Function("map_zoom(" + (i + 1) + ",\"in\");");
	}
	else if(i == zoom_max){
		
		map_zoom_in_img.src = root_path + "/images/map/legende_boutonsplus.png";
		map_zoom_in_img.onclick = Function("");
		map_zoom_out_img.src = root_path + "/images/map/legende_boutonmoinsactif.png";
		map_zoom_out_img.onclick = Function("map_zoom(" + (i - 1) + ",\"out\")");
		
		div_carto_pictos_hotel.ondblclick = Function("");
	}
	else{
		
		map_zoom_in_img.src = root_path + "/images/map/legende_boutonsplusactif.png";
		map_zoom_in_img.onclick = Function("map_zoom(" + (i + 1) + ",\"in\")");
		map_zoom_out_img.src = root_path + "/images/map/legende_boutonmoinsactif.png";
		map_zoom_out_img.onclick = Function("map_zoom(" + (i - 1) + ",\"out\")");
		
		div_carto_pictos_hotel.ondblclick = Function("map_zoom(" + (i + 1) + ",\"in\");");
	}
	
	map_zoom_class_img.src = root_path + "/images/map/legende_boutonzoom" + i + ".png";
	
	if(i==1)     {var diviser=4.754545454545454545454545454545454545;}
	else if(i==2){var diviser=2;}
	else         {var diviser=1;}
	
	var count_picto = 0;
	var count_picto_big = 0;
	if(document.getElementById('hidden_count_picto')) count_picto = document.getElementById('hidden_count_picto').value;
	if(document.getElementById('hidden_count_picto_big')) count_picto_big = document.getElementById('hidden_count_picto_big').value;
	var img_hotel = "";
	var img_hotel_big = "";
	var div_carto_pictos_hotel_pop = ""
	
	if(act == "in"){
		
		/*
		map_width_base = map_width_base * 2 + 2;
		map_height_base = map_height_base * 2 + 2;
		*/
		map_width_base = tab_image_size[i][0];
		map_height_base = tab_image_size[i][1];
		
		map_style_left = parseInt(div_result_map_content.style.left);
		map_style_top = parseInt(div_result_map_content.style.top);
		
		
		if(evn_tmp.srcElement?evn_tmp.srcElement:evn_tmp.target == div_carto_pictos_hotel){
			
			mouse_x = evn_tmp.clientX - map_window_left;
			mouse_y = evn_tmp.clientY - map_window_top;
			
			//map_style_left = -(mouse_x + (mouse_x - center_x)) + map_style_left*2;
			//map_style_top = -(mouse_y + (mouse_y - center_y)) + map_style_top*2;
		}
		else{
			
			//map_style_left = -center_x + map_style_left*2;
			//map_style_top = -center_y + map_style_top*2;
		}
		
		
		//if(map_style_left > 0) map_style_left = 0;
		//else if(map_style_left < -(map_width_base - map_window_width)) map_style_left = -(map_width_base-map_window_width);
		
		//if(map_style_top > 0) map_style_top = 0;
		//else if(map_style_top < -(map_height_base - map_window_height)) map_style_top = -(map_height_base-map_window_height);
		
		/*
		if (document.getElementById('hidden_count_picto')){
			
			if (i==2) {
				var decalage_y = 0;
			}
			else {
				var decalage_y = 0;
			}
			
			for(var j = 0;j < count_picto;j++){
				
				img_hotel = document.getElementById('img_hotel_'+j);
				if(img_hotel){
					div_carto_pictos_hotel_pop = document.getElementById('div_hotel_pop_layer');
					//img_hotel.style.left = parseFloat(img_hotel.style.left)*2 + "px";
					//img_hotel.style.top = ((((parseFloat(img_hotel.style.top)+decalage_y)+9)*2) - 9) + "px";						
					
					img_hotel.style.left = parseFloat(div_content_arr[j][13]/diviser)+'px';
					img_hotel.style.top = parseFloat(div_content_arr[j][12]/diviser)+'px';					
					
				}
			}
		}*/	
		
		var decalage = 0;
		switch(i) {
			case  1 :
			break;
			case  2 :
				decalage = 20;
			break;
			case  3 :
				decalage = 20;
			break; 
		}
			
		$('div[id*=img_hotel_]:not(div[id*=img_hotel_big_])').each(function(){
		
			var id = $(this).attr('id');
			id = parseInt(id.replace(/img_hotel_/g,''));
			$(this).css({
				'left' : parseFloat(div_content_arr[id][13]/diviser)+'px',
				'top' : (parseFloat(div_content_arr[id][12]/diviser)-decalage)+'px'
			});
		
		
		});
		
		$('div[id*=img_hotel_big_]').each(function(){
		
			var id = $(this).attr('id');
			id = parseInt(id.replace(/img_hotel_big_/g,''));
			$(this).css({
				'left' : parseFloat(div_content_arr[id][13]/diviser)+'px',
				'top' : (parseFloat(div_content_arr[id][12]/diviser)-decalage)+'px'
			});
		
		
		});
		/*
		if(document.getElementById('hidden_count_picto_big')){
			
			
			for(var m = 0;m < count_picto_big;m++){
				
				img_hotel_big = document.getElementById('img_hotel_big_'+m);
				if(img_hotel_big) {
					//img_hotel_big.style.left = parseFloat(img_hotel_big.style.left)*2 + "px";
					//img_hotel_big.style.top = ((((parseFloat(img_hotel_big.style.top)+decalage_y)+9)*2) - 9) + "px";
					
					img_hotel_big.style.left = parseFloat(div_content_arr[m][13]/diviser)+'px';
					img_hotel_big.style.top = parseFloat(div_content_arr[m][12]/diviser)+'px';
					
					//console.log('big : '+img_hotel_big.style.left+' '+img_hotel_big.style.top);
					}
			}
		}*/
	}
	else if(act == "out"){
		
		//map_width_base = (map_width_base - 2)/2;
		//map_height_base = (map_height_base - 2)/2;
		map_width_base = tab_image_size[i][0];
		map_height_base = tab_image_size[i][1];
		
		//map_style_left = parseInt(div_result_map_content.style.left);
		//map_style_top = parseInt(div_result_map_content.style.top);
		
		if(map_style_left != 0){
			
			//map_style_left = (center_x + map_style_left)/2;
			
			if(map_style_left>0) map_style_left = 0;
			else if(map_style_left < -(map_width_base - map_window_width)) map_style_left = -(map_width_base - map_window_width);
		}
		if(map_style_top != 0){
			
			//map_style_top = (center_y + map_style_top)/2;
			
			//if(map_style_top>0) map_style_top = 0;
			//else if(map_style_top < -(map_height_base - map_window_height)) map_style_top = -(map_height_base - map_window_height);
		}
		if(document.getElementById('hidden_count_picto')){
			
			if (i==1) {
				var decalage_y = 0;
			}
			else {
				var decalage_y = 0;
			}
			
			var decalage = 20;
			
			$('div[id*=img_hotel_]:not(div[id*=img_hotel_big_])').each(function(){
		
				var id = $(this).attr('id');
				id = parseInt(id.replace(/img_hotel_/g,''));
				$(this).css({
					'left' : parseFloat(div_content_arr[id][13]/diviser)+'px',
					'top' : (parseFloat(div_content_arr[id][12]/diviser)-decalage)+'px'
				});
		
		
			});
			
			$('div[id*=img_hotel_big_]').each(function(){
			
				var id = $(this).attr('id');
				id = parseInt(id.replace(/img_hotel_big_/g,''));
				$(this).css({
					'left' : parseFloat(div_content_arr[id][13]/diviser)+'px',
					'top' : (parseFloat(div_content_arr[id][12]/diviser)-decalage)+'px'
				});
			
			
			});
		}
	}
	/*
	div_result_map_content.style.left = map_style_left + "px";
	div_result_map_content.style.top = map_style_top + "px";
	
	div_result_map_content.style.width = map_width_base + "px";
	div_result_map_content.style.height = map_height_base + "px";
	
	div_carto_pictos_hotel.style.width = map_width_base + "px";
	div_carto_pictos_hotel.style.height = map_height_base + "px";
	
	div_carto_map.style.width = map_width_base + "px";
	div_carto_map.style.height = map_height_base + "px";
	
	div_carto_map.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + ".jpg')";
	
	
	div_carto_cours_d_eau.style.width = map_width_base + "px";
	div_carto_agglomerations.style.width = map_width_base + "px";
	div_carto_foret_bri.style.width = map_width_base + "px";
	div_carto_foret_cou.style.width = map_width_base + "px";
	div_carto_foret_dom.style.width = map_width_base + "px";
	div_carto_foret_gav.style.width = map_width_base + "px";
	div_carto_foret_tou.style.width = map_width_base + "px";
	div_carto_foret_vio.style.width = map_width_base + "px";
	*/
	div_carto_routes.style.width = map_width_base + "px";
	div_carto_villes.style.width = map_width_base + "px";
	//div_carto_voies_ferrees.style.width = map_width_base + "px";
	
	/*
	div_carto_cours_d_eau.style.height = map_height_base + "px";
	div_carto_agglomerations.style.height = map_height_base + "px";
	div_carto_foret_bri.style.height = map_height_base + "px";
	div_carto_foret_cou.style.height = map_height_base + "px";
	div_carto_foret_dom.style.height = map_height_base + "px";
	div_carto_foret_gav.style.height = map_height_base + "px";
	div_carto_foret_tou.style.height = map_height_base + "px";
	div_carto_foret_vio.style.height = map_height_base + "px";
	*/
	div_carto_routes.style.height = map_height_base + "px";
	div_carto_villes.style.height = map_height_base + "px";
	//div_carto_voies_ferrees.style.height = map_height_base + "px";
	
	/*
	div_carto_cours_d_eau.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_cours_d_eau.png')";
	div_carto_agglomerations.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_agglomerations.png')";
	div_carto_foret_bri.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_foret_bri.png')";
	div_carto_foret_cou.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_foret_cou.png')";
	div_carto_foret_dom.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_foret_dom.png')";
	div_carto_foret_gav.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_foret_gav.png')";
	div_carto_foret_tou.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_foret_tou.png')";
	div_carto_foret_vio.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_foret_vio.png')";
	*/
	div_carto_routes.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/routes.png')";
	div_carto_villes.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/villes.png')";
	//div_carto_voies_ferrees.style.backgroundImage = "url('" + root_path + "/images/map/zoom" + i + "/Carte_Zoom_" + i + "_voies_ferrees.png')";
	
	document.getElementById('div_hotel_pop_layer').style.display = "none";
	
	viewports['x']='-1';
    viewports['y']='-1';
	setTimeout("viewport()",100);	
}

/*######################################################################
Update: 27/11/08
Author: Christophe R.
Comment: improve dragging method to scrolling method
######################################################################*/
jQuery.fn.extend({
  getPos : function() {
       obj = $(this).get(0);
       var curleft = obj.offsetLeft || 0;
       var curtop = obj.offsetTop || 0;
       while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                curtop += obj.offsetTop
       }
       return {x:curleft,y:curtop};
   }
});

var loading=new Array();
var zoom=1;
var oldzoom=1;
var begin=1;
var ratio=new Array();
var blocsize=256;
var viewports=new Array();
viewports['x']='-1';
viewports['y']='-1';

var tab_image_size=new Array();

tab_image_size[1]=new Array();
tab_image_size[1][0] = 660; //768
tab_image_size[1][1] = 440; //512
tab_image_size[1][2] = 3;
tab_image_size[1][3] = 2;

tab_image_size[2]=new Array();
tab_image_size[2][0] = 1536;
tab_image_size[2][1] = 1024;
tab_image_size[2][2] = 6;
tab_image_size[2][3] = 4;

tab_image_size[3]=new Array();
tab_image_size[3][0] = 3072;
tab_image_size[3][1] = 2048;
tab_image_size[3][2] = 12;
tab_image_size[3][3] = 8;


function Scroller() { 

$('#div_carto_map').css('backgroundImage','none');
var mapping=$('#div_carto_map');
var coord=new Array();
var move=false;

$('#div_carto_map').css('backgroundImage','none');

// make content div
zooming(tab_image_size[zoom][2],tab_image_size[zoom][3]);

$('#div_result_map')
    .mousedown(function(e){
        var left=$('#div_result_map').scrollLeft();
        var top=$('#div_result_map').scrollTop();
        var origineX = e.pageX+left;
        var origineY = e.pageY+top;
        $(this).bind('mousemove',function(e){            
            $('#div_result_map').scrollLeft(origineX-e.pageX);
            $('#div_result_map').scrollTop(origineY-e.pageY); 
            viewport();            
        }); 
        
        $(this).bind('mouseup',function(e){
            $(this).unbind('mouseup'); 
            $(this).unbind('mouseout');
            $(this).unbind('mousemove');   
        }); 
        
        $(this).bind('mouseout',function(e){
            $(this).unbind('mouseup'); 
            $(this).unbind('mouseout');
            $(this).unbind('mousemove');   
        });
           
    }).css('-Moz-User-Select','none');

setTimeout("viewport()",50);
} 

function zooming(xx,yy){

$('#div_carto_routes').css({'width':tab_image_size[zoom][0],'height':tab_image_size[zoom][1]});
$('#div_carto_villes').css({'width':tab_image_size[zoom][0],'height':tab_image_size[zoom][1]});
$('#div_carto_map').css({'width':tab_image_size[zoom][0],'height':tab_image_size[zoom][1]});
$('#div_carto_pictos_hotel').css({'width':tab_image_size[zoom][0],'height':tab_image_size[zoom][1]});
$('#div_result_map_content').css({'width':tab_image_size[zoom][0],'height':tab_image_size[zoom][1]});

var mapping=$('#div_carto_map');
mapping.html('');
for (y=1;y<=yy;y++)
   {
   for (x=1;x<=xx;x++)
      {
      var elem=document.createElement("div"); ;
      $(elem).attr('id','map'+y+'_'+x).addClass('bloc').appendTo(mapping).css({'width':(tab_image_size[zoom][0]/tab_image_size[zoom][2]),'height':(tab_image_size[zoom][1]/tab_image_size[zoom][3])});
      }
   }
   
ratio['glob']=tab_image_size[zoom][0]/tab_image_size[oldzoom][0];
   
$('#div_result_map').scrollLeft(ratio['glob']*ratio['x']+((ratio['glob']-1)*(parseInt($('#div_result_map').css('width'))/2)));
$('#div_result_map').scrollTop(ratio['glob']*ratio['y']+((ratio['glob']-1)*(parseInt($('#div_result_map').css('height'))/2)));
}

function viewport(){
if(begin==1){$('#div_result_map').scrollLeft('70');begin=0;}

var scroll=new Array();
scroll['x']=$('#div_result_map').scrollLeft();
scroll['y']=$('#div_result_map').scrollTop();

var size=new Array();
size['x']=$('#div_result_map').css('width');
size['y']=$('#div_result_map').css('height');

   var xx=parseInt(scroll['x'])/blocsize;
   var yy=parseInt(scroll['y'])/blocsize;
   
   var xxx=parseInt(size['x'])/blocsize+xx;
   var yyy=parseInt(size['y'])/blocsize+yy;
   
   if(parseInt(xxx)<xxx){xxx++;}
   if(parseInt(yyy)<yyy){yyy++;}
   
   xx++; // start at 1 not 0
   yy++; // start at 1 not 0
 
if(xx!=viewports['x'] || yy!=viewports['y'])
{ 
/*  
for(x=1;x<=4;x++)
  {
  for(y=1;y<=7;y++)
    {        
    $('#map'+y+'_'+x).css('background',"none");
    }
  }
*/
   viewports['x']=xx;
   viewports['y']=yy;  
   
   for(x=parseInt(xx);x<=parseInt(xxx);x++)
      {
      for(y=parseInt(yy);y<=parseInt(yyy);y++)
         {        
         $('#map'+y+'_'+x).css('background',"url('/module/carto/images/map/zoom"+zoom+"/"+y+'_'+x+".jpg') no-repeat");
         }
      }
}
}
$(document).ready(function(){
//if($('#legend_routes').length>0){change_legend_image("div_carto_routes","legend_routes");}

});
