
function Formatdegre(val)
{
	return Round(val,2);
}
function Round(nombre, decimales) {
  if (isNaN(nombre)) return "";
  if (decimales == 0) {
     var n = Math.round(nombre);
     return n.toString();
  }
  else if (decimales > 0) {
     if (document.all) 
     var undefined; 
     var p10 = Math.pow(10, decimales);
     var n = Math.round(nombre * p10); 
     n = n.toString();
     var point = n.length - decimales;
     if (point >= 0) n = n.substring(0, point) + "." + n.substring(point);
     else n = "0." + formater(n, decimales);
  }
  else {
     var p10 = Math.pow(10, -decimales);
     var n = Math.round(nombre / p10) * p10;
     n = n.toString();
  }
  if (nombre.signe_decimal == undefined) return n;
  else return n.replace(".", nombre.signe_decimal);
}

function PrintOpen()
{
	window.print();
}

function EnableFunction(val)
{
	GetObj('toolzoomplus').src='images/maporama/tour_carte_recentrer_off.gif';
	GetObj('toolzoom').src='images/maporama/tour_carte_zoomer_off.gif';
	GetObj('tooldrag').src='images/maporama/tour_carte_deplacer_off.gif';
	if(val=='1'){GetObj('toolzoom').src='images/maporama/outil_carte/tour_carte_zoomer.gif';}
	if(val=='2'){GetObj('tooldrag').src='images/maporama/outil_carte/tour_carte_deplacer.gif';}
	if(val=='3'){GetObj('toolzoomplus').src='images/maporama/outil_carte/tour_carte_recentrer.gif';}
	SetDragAndZoom(val);
}
function FormatTime(val)
{
	var hour=parseInt(val);
	var minute=(val-parseInt(val))*60;
	var seconds=(minute-parseInt(minute))*60;
	if(parseInt(minute)<0){minute=60-parseInt(minute);}
	if(parseInt(minute)>60){minute=parseInt(minute)-60;}
	return  "("+parseInt(hour)+"\u00b0"+(parseInt(minute))+"')";
}

function _display(o,val)
{
  o.style.display=val;
}

function DisplayCustomise(e,size)
{
	var customise= GetObj('MaporamaMapcustomise');
	var personnalise=GetObj('LinkExport');
	SetTopPx(customise,(EventLayerPos(e?e:window.event)[1] + 20)+'px');
	SetLeftPx(customise,(size-310)+'px');
	if(customise.style.display=='none')
	{
	 if(IsDef(customise.filters)){customise.filters[0].Apply();} 
	 if(IsDef(customise.filters)){customise.filters[0].Play();}
	 _display(customise,'block');
	 M_Interface.oMap.style.filter="alpha(opacity=33)";	
	 }else{_display(customise,'none');M_Interface.oMap.style.filter="alpha(opacity=100)";	}	
}
function HideCustomise(o)
{
	var customise= GetObj('MaporamaMapcustomise');
	_display(customise,'none');
	M_Interface.oMap.style.filter="alpha(opacity=100)";
}

function UpdateInterface(logicalscale,lg,lt,lang)
{
	UpdatePosition(lg,lt);
	if(logicalscale>4){
	UpdateWeather(lg,lt,lang);}
}

function UpdatePosition(lg,lt)
{
	GetObj('maplong').innerHTML=Formatdegre(lg) + " " +FormatTime(lg);
	GetObj('maplat').innerHTML=Formatdegre(lt)+ " " +FormatTime(lt);
}
function UpdateWeather(lg,lt,lang)
{	
  return;
	GetObj('mapweather').innerHTML="";
	var req="weather.aspx?WT_lg="+lg +"&WT_lt="+lt+"&WT_lang="+lang+"&WT_unit=metric&xml=map&xsl=ajaxweather&error=weathererror&sessionid="+window.sessionid +"&Lang=" +lang;
	AjaxUpdater('mapweather',req,null);
	  
}
function UpdateItiWeather(lg,lt,lang)
{	
  return;	
  GetObj('mapweather').innerHTML="";
	
	 var req="weather.aspx?WT_lg="+lg +"&WT_lt="+lt+"&WT_lang="+lang+"&WT_unit=metric&xml=ajax&xsl=ajaxItiweather&error=weathererror&sessionid="+window.sessionid;
	 AjaxUpdater('mapweather',req,null);
}
function UpdateEspotting(Key)
{	
	 var req="espoting.aspx?sessionid="+window.sessionid+"&keyword="+ Key;
	 AjaxUpdater('espoting',req,null);
}
function GetEspottingContent(url)
{	
	 AjaxUpdater('mapweather',req,null);
}

function Get(objectId)
{
	// Compatible NN IE FIREFOX method
	if (document.getElementById && document.getElementById(objectId) != null)
		return document.getElementById(objectId);
	else if (document.layers && document.layers[objectId] != null)
		return document.layers[objectId];
	else if (document.all)
		return document.all[objectId];
}

function openclosepanel(wo)
{
	var wob = document.getElementById(wo+"container");
	wob.className=(wob.className=="open"?"closed":"open");
	
	var req= "PanelState.aspx?oc_Pnl="+wo +"&oc_State=" + ((wob.className=="open")?'open':'closed')+"&sessionid="+window.sessionid;
	//alert(req);
	AjaxUpdater(null,req, null);
}

function displayBlock(id)
{
	var Dtmp=Get(id);
	Dtmp.style.display=(Dtmp.style.display=='block')?'none':'block';
	
}

function displayItiOptions()
{
	var Dtmp=Get("fiti_optionblock");
	var sub = Get("fiti_submit");
	Dtmp.style.display=(Dtmp.style.display=='block')?'none':'block';
	sub.style.display = (Dtmp.style.display=='block')?'none':'block';	
}
function displayMapOptions()
{
	var Dtmp=Get("fmap_optionblock");
	var sub = Get("fmap_submit");
  
  if(Dtmp.filters)
  {
   Dtmp.style.filter='progid:DXImageTransform.Microsoft.gradientWipe(duration=0.2, gradientsize=0.5);';
   Dtmp.filters[0].apply();
   Dtmp.filters[0].play();
  }
  
	Dtmp.style.display=(Dtmp.style.display=='block')?'none':'block';
	sub.style.display = (Dtmp.style.display=='block')?'none':'block';	
	
}
/*
MAP NAVIGATION 
*/

var imgPath="images/maporama/Nav_carte/";
	function NW(state)
	{
		GetObj('Nw1').src=imgPath+"coin_HG_"+state+"2.gif";
		GetObj('Nw2').src=imgPath+"coin_HG_"+state+"1.gif";
		GetObj('Nw3').src=imgPath+"coin_HG_"+state+"3.gif";
	}
	function SW(state)
	{
		GetObj('Sw1').src=imgPath+"coin_BG_"+state+"1.gif";
		GetObj('Sw2').src=imgPath+"coin_BG_"+state+"2.gif";
		GetObj('Sw3').src=imgPath+"coin_BG_"+state+"3.gif";
	}
	function SE(state)
	{
		GetObj('Se1').src=imgPath+"coin_BD_"+state+"1.gif";
		GetObj('Se2').src=imgPath+"coin_BD_"+state+"2.gif";
		GetObj('Se3').src=imgPath+"coin_BD_"+state+"3.gif";
	}
	function NE(state)
	{
		GetObj('Ne1').src=imgPath+"coin_HD_"+state+"1.gif";
		GetObj('Ne2').src=imgPath+"coin_HD_"+state+"2.gif";
		GetObj('Ne3').src=imgPath+"coin_HD_"+state+"3.gif";
	}
	function N(state,o)
	{
		o.style.backgroundImage="url("+imgPath+"tour_carte_H_"+state+"4.gif)";
		GetObj('ImgNorth').src=imgPath+"tour_carte_H_"+state+"3.gif";
	}
	function E(state,o)
	{
		o.style.backgroundImage="url("+imgPath+"tour_carte_D_"+state+"4.gif)";
		GetObj('ImgEast').src=imgPath+"tour_carte_D_"+state+"3.gif";
	}
	function W(state,o)
	{
		o.style.backgroundImage="url("+imgPath+"tour_carte_G_"+state+"4.gif)";
		GetObj('ImgWest').src=imgPath+"tour_carte_G_"+state+"3.gif";
	}
	function S(state,o)
	{
		o.style.backgroundImage="url("+imgPath+"tour_carte_B_"+state+"4.gif)";
		GetObj('ImgSouth').src=imgPath+"tour_carte_B_"+state+"3.gif";
	}
	
	function ResizeNav(width,height)
	{
		var Mincoef=82;
		var Maxcoef=24;
		GetObj('North').style.width=GetObj('South').style.width=(width-Mincoef)+'px';
		GetObj('East').style.height=GetObj('West').style.height=(height-Mincoef)+'px';
		GetObj('MaporamaNav').style.width=(width+Maxcoef)+'px';
		//GetObj('infoAddress').style.width=(width)+'px';
		GetObj('MaporamaNav').style.height=(height+Maxcoef)+'px';
	}
	function HighlightPoi(id)
	{
		GetObj('ico'+id).className='PoiNumberMapover';
	}
	function unlightPoi(id)
	{
		unlight(id,'PoiNumberMap');
	}
	function unlight(id,stylename)
	{
		GetObj('ico'+id).className=stylename;
	}

