var YAHOO=window.YAHOO||{};
YAHOO.namespace=function(_1){
        if(!_1||!_1.length){
                return null;
        }
        var _2=_1.split(".");
        var _3=YAHOO;
        for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){
                _3[_2[i]]=_3[_2[i]]||{};
                _3=_3[_2[i]];
        }
return _3;
};
YAHOO.namespace("util");
YAHOO.namespace("widget");
YAHOO.namespace("example");

var YMAPPID = "20sq_WbV34HTvrE7UrJXii7jh4buZu.m5Nx5tBsW8JOPs99yhfDWaJYusf5bXEDxlDG2doER";
function _ywjs(inc) { var o='<'+'script src="'+inc+'"'+' type="text/javascript"><'+'/script>'; document.write(o); }_ywjs('http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/dom_2.0.1-b2.js');
_ywjs('http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/event_2.0.0-b2.js');
_ywjs('http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/dragdrop_2.0.1-b4.js');
_ywjs('http://us.js2.yimg.com/us.js.yimg.com/lib/common/utils/2/animation_2.0.1-b2.js');
_ywjs('http://us.js2.yimg.com/us.js.yimg.com/lib/map/js/api/ymapapi_3_4_1_7.js');<!-- xm5.maps.re3.yahoo.com compressed/chunked Thu Nov 20 09:04:58 PST 2008 -->


var map = null;
var nbpoints = 0;
var points = [];

function carte_commerces(idEl) 
{   
  map = new YMap(document.getElementById(idEl)); 
  var cPT = new YGeoPoint(44.582205,-0.036509);
  map.addZoomLong();
  //map.addTypeControl();
  map.drawZoomAndCenter(cPT,2);
}

/*** Création Point (imagefile, geopoint, label, info) ***/
function _draw_point (imagefile, geopoint, label, info) 
{
  var _img = new YImage();
  _img.src = imagefile;
  nbpoints++;
  points[nbpoints] = new YMarker(geopoint,_img);
  points[nbpoints].addLabel(label);
  var _txt = info;
  points[nbpoints].addAutoExpand(_txt);
  map.addOverlay(points[nbpoints]);
}

/*** Création Point Orange (commerce) ***/
function draw_orange_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt) 
{
  var _myPoint = new YGeoPoint(latitude,longitude);
  var _lab = "<b style='color:white;'>" + labeltxt + "</b>";
  var _info = '<span style="width:160px;height:35px;background-color : #ff6600;">' + titre + '</span><br>' + infotxt;
  if (www_url != '')
    {
      _info += "<br/><a href=\"" + www_url + "\">" + www_label + "</a>";
    }
  _draw_point ('images/orange.png', _myPoint, _lab, _info);
}

/*** Création Point Bleu (parking) ***/
function draw_blue_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt) 
{
  var _myPoint = new YGeoPoint(latitude,longitude);
  var _lab = "<b style='color:white;'>" + labeltxt + "</b>";
  var _info = '<span style="width:160px;height:35px;background-color : #019cff;">' + titre + '</span><br>' + infotxt;
  if (www_url != '')
    {
      _info += "<br/><a href=\"" + www_url + "\">" + www_label + "</a>";
    }
  _draw_point ('images/blue.png', _myPoint, _lab, _info);
}

/*** Création Point Vert (service) ***/
function draw_green_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt) 
{
  var _myPoint = new YGeoPoint(latitude,longitude);
  var _lab = "<b style='color:white;'>" + labeltxt + "</b>";
  var _info = '<span style="width:160px;height:35px;background-color : #2fdc00;">' + titre + '</span><br>' + infotxt;
  if (www_url != '')
    {
      _info += "<br/><a href=\"" + www_url + "\">" + www_label + "</a>";
    }
  _draw_point ('images/green.png', _myPoint, _lab, _info);
}

/*** Création point ***/
function draw_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt, kind)
{
  if (kind == "commerce") return draw_orange_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt);
  if (kind == "parking") return draw_blue_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt);
  if (kind == "service") return draw_green_point (latitude, longitude, labeltxt, titre, www_url, www_label, infotxt);
}

/*** code inutilisé ***/
var setupMarker = function(p,d) {
var m = new YMarker(p);
m.addAutoExpand(d);
return m;
};
var searchF = function(e) {
var _p = [];
if (e.Data) {
for (var a in e.Data.ITEMS) {
var l = e.Data.ITEMS[a];
// YLog.print(l);
if (l.TITLE) {
var p = new YGeoPoint(l.LATITUDE,l.LONGITUDE);
_p.push(p);
var m = setupMarker(p,l.TITLE);
map.addOverlay(m);
}
}
}
};

// recherche d'informations
// YGeoPoint , query/search/recherche , rayon , nbResultats
//map.searchLocal(cPT,'pizza',3,5);
// capture de la fin de récupération d'informations locales
// et branchement sur la méthode 'searchF'
//YEvent.Capture(map,EventsList.onEndLocalSearch,searchF);
/*** Fin code inutilisé **/


function exporterCarteYahoo () {

	// GeoRSS formtatted string
	var GeoRSSString = map.exportFormat('GEORSS');
	
	if (GeoRSSString) { 
		
		$('exportXML').value = GeoRSSString;
		$('exportXML').style.display = "inline";
		
	}
	else return false;
}

function centrersurunpoint(latitude,longitude) {
	var _pt = new YGeoPoint(latitude,longitude);
	map.drawZoomAndCenter(_pt,2);
}

