﻿		if(!globalActivite)
		{
			var globalActivite = 'ALL';
		}
		var debutChargement = 0;
				
		//worldurl = "/lib_central/flash/ONEWEB/xml/map_world/ammap_data.xml"
		//countriesurl = "/lib_central/flash/ONEWEB/xml/map_countries/ammap_data.xml"
		

				var so = new SWFObject("/lib_central/flash/ONEWEB/ammap.swf", "flashMovie", "766", "388", "8", "#FFFFFF");
				so.addVariable("path", "/lib_central/flash/ONEWEB/");
				so.addVariable("settings_file", escape("/lib_central/flash/ONEWEB/xml/map_world/ammap_settings.xml"));
				// you can set two or more different settings files here (separated by commas)
				so.addParam("wmode","transparent");
				so.addVariable("data_file", escape("/lib_central/flash/ONEWEB/xml/map_world/ammap_data.xml"));
				so.write("ammapContent");
				loadGlobalWordl()
				var globalXmlData = worldurl;
				function loadGlobalWordl()
				{

								filterXml('country','ALL',worldurl,'BusinessGroup',globalActivite);
								debutChargement = 1;
		  		}

		
		// Affichage par ordre alphabétique des sociétés
		function parseCorpo()
		{
			$('.alphaContent ul').hide();
			keywordFirst  = $('.alphaList li.active a').text();
			$('.alphaContent ul.'+keywordFirst+'classe').show();
		}
		var	firstLetter = $('#ammamp_popinCorporations_main .alphaContent li:first').text().substr(0,1);
		$('#ammamp_popinCorporations_main .alphaContent li').each(function()
		{
			if($(this).text().substr(0,1)!=firstLetter)
			{
				$('.alphaContent').append('<ul class="temp classe'+firstLetter+'"></ul>');
				$('.alphaList').append('<li><a href="javascript:;">'+firstLetter.toUpperCase()+'</a></li>')
				firstLetter = $(this).text().substr(0,1);
			}
			
		});
		$('.alphaContent').append('<ul class="temp classe'+firstLetter+'"></ul>');
		$('.alphaList').append('<li class"active"><a href="javascript:;">'+firstLetter.toUpperCase()+'</a></li>')
		$('.alphaList li:first').addClass('active');
		$('#ammamp_popinCorporations_main .alphaContent li').each(function()
		{
			$('.alphaContent .classe'+$(this).text().substr(0,1)).append($(this));
		});
		$('#ammamp_popinCorporations_main .alphaContent ul.temp').each(function()
			{
				var qtite = parseInt(($(this).find('li').length-1)/3);
				var keyword = $(this).find('li').text().substr(0,1).toUpperCase();
				$(this).addClass(keyword+'classe');
				if(qtite>5)
				{
					$('<ul class="'+keyword+'classe SecondContainer"></ul><ul class="'+keyword+'classe ThirdContainer">').insertAfter($(this))
					$(this).find('li').each(function(i)
					{
						if(i>qtite&&i<=(qtite*2)+1)
						$('#ammamp_popinCorporations_main .'+keyword+'classe.SecondContainer').append($(this));
						else if (i>(qtite*2))
						$('#ammamp_popinCorporations_main .'+keyword+'classe.ThirdContainer').append($(this));
					});
				}
			});
		$('#ammamp_popinCorporations_main .alphaList li').click(function()
			{
				$('#ammamp_popinCorporations_main .alphaList li').removeClass('active');
				$(this).addClass('active');
				parseCorpo();
			});
			$('#ammamp_popinCorporations_main .close').click(function()
			{
				$('#ammamp_popinCorporations_main').hide();
			});
			$('#ammamp_popinCorporations_main .alphaContent ul li').hover(function()
			{
				$(this).css('text-decoration','underline');
			},
			function()
			{
				$(this).css('text-decoration','none');
			});
			$('#ammamp_popinCorporations_main .alphaContent ul li').click(function()
			{
				$('#ammamp_popinCorporations_main').hide();
				$('input#steImplantation').val($(this).text());
				$('#steImplantationText').text($(this).text());
			});

		//Afficher la popin de choix des sociétés :
		$('.ammap_chooseSte').click(function()
		{
			parseCorpo();
			$('#ammamp_popinCorporations_main').show();
		});
		
		var showCountryLayer=1;
		
		// fichier .swf de la carte en cours;
		var globalContinent='';
		var globalCountry='';
		var globalContinentSwf='';
		var globalContinentUrl='';
		var globalCountrySwf='';
		var globalCountryUrl='';
		var globalContinentTl_long='';
		var globalContinentTl_lat='';
		var globalContinentBr_long='';
		var globalContinentBr_lat='';
		var globalCountryTl_long='';
		var globalCountryTl_lat='';
		var globalCountryBr_long='';
		var globalCountryBr_lat='';
		
		var stockArevaText = $('b.legendAreva:first').text();
		
		function loadWorld()
		{
			globalContinent = ''; 
			globalCountry = '';
			$('#ammapContinentViews').hide();
			$('#ammapZoomView').hide();
			$('#ammapLegend').show();
			$('.ammapBreadCrumb .inner1').hide();
			$('.ammapBreadCrumb .inner2').hide();
			$('.ammapBreadCrumb .titWorld').html($('.ammapBreadCrumb .titWorld').text()).addClass('ammapLast');
			$('.ammapBreadCrumb .titContinent').empty();
			$('.ammapBreadCrumb .titCountry').empty();
			loadGlobalWordl();
			//flashMovie.reloadData(worldurl);
			//flashMovie.setZoom("100","80","0", false); 
		}
		
			UTF8 = {
			encode: function(s){
				for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
					s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
				);
				return s.join("");
			},
			decode: function(s){
				for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
					((a = s[i][c](0)) & 0x80) &&
					(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
					o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
				);
				return s.join("");
			}
		};
		
		// Recharger le flash
		function newData(xmlData)
		{
			if(debutChargement==1)
			{
			so.addVariable("map_data",escape(UTF8.encode(xmlData)));
			so.write("ammapContent");
			debutChargement=0;
			} else {
			flashMovie.setData(xmlData);
			}
		}
		
		function newData2(xmlData)
		{
			so.addVariable("map_data", escape(UTF8.encode(xmlData)));
			so.write("ammapContent");
			//flashMovie.setData(xmlData);
		}


 function formatDate(chaine)
 {
	 jour = chaine.substr(5,2);
	 mois = (/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/).exec(chaine);
	 annee = (/\b[0-9]{4}\b/).exec(chaine);
	 jour = parseInt(jour);
	 if(jour<10) { jour = '0'+jour; }
	 mois = mois[0];
	 mois = mois.replace('Jan','01');
	 mois = mois.replace('Feb','02');
	 mois = mois.replace('Mar','03');
	 mois = mois.replace('Apr','04');
	 mois = mois.replace('May','05');
	 mois = mois.replace('Jun','06');
	 mois = mois.replace('Jul','07');
	 mois = mois.replace('Aug','08');
	 mois = mois.replace('Sep','09');
	 mois = mois.replace('Oct','10');
	 mois = mois.replace('Nov','11');
	 mois = mois.replace('Dec','12');
	 dateFormatee = annee+'/'+mois+'/'+jour;
	 return dateFormatee;
	}



	var offset = $('body').offset();
	$('.ammapLayer').prependTo($('body'));
	function followPopup() {
		$('body').bind('mousemove',function(e)
		{
			$('.ammapLayer').css({
				'left':(e.pageX - offset.left + 10)+'px',
				'top':(e.pageY - offset.top + 10)+'px'
			});
		});
	}
	function stopPopup()
	{
		$('body').unbind('mousemove');
	}
	
/* function parseXml(xml) {  
    if (jQuery.browser.msie) {  
   var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
   xmlDoc.loadXML(xml);  
  	xml = xmlDoc;  
   }  
   return xml;  
   }  */
  
  var varxhr;
  // Fonction unique pour tous les affichages de popin
  	function showAmmapLayer(theme,pageId,rssFlux)
	{
		theme= unescape(theme);
		pageId = pageId.replace('show.asp','ammap/pageInfo.asp')
		pageId= unescape(pageId);
		$('.ammapLayer').show();
		$('.innerLayer').hide();
		//stopPopup();
		$('.ammapLayer .ammapLayerText').empty();
		$('.ammapLayer .ammapLayerHead em').empty();
		$('#layer_'+theme+' .ammapLayerText').html($('.ammapLoading01').clone());
		$('#layer_'+theme).show();
		followPopup(theme);
		
		varhxr = $.ajax({
		  type: "GET",
		  url: pageId,
		  dataType: "xml",
		  processData: 'true',
		  success: function(xml){
			  if(rssFlux!=null)
			  { 
			   $('#layer_'+theme+' .ammapLayerText').html(
			 	'<h1 class="bigTitle">'+$(xml).find('title:first').text()+'</h1>'
				+$(xml).find('item').find('description').text());
				if($(xml).find('pubDate').length>0)
				{
					$('#layer_'+theme+' .ammapLayerHead em').text(formatDate($(xml).find('pubDate:first').text()))
				} else {
					$('#layer_'+theme+' .ammapLayerHead em').empty();
				}
			  } else {
				  $('#layer_'+theme+' .ammapLayerText').empty()
				 .html('<h1>'+$(xml).find('title').text()+'</h1>'+$(xml).find('headline').text());
				 if(!$(xml).find('imageUrl').is(':empty'))
				 {
					 $('#layer_'+theme+' .ammapLayerText').prepend('<img src="'+$(xml).find('imageUrl').text()+'" />')
				 }
			  }
			  
		   },
		   error:function (xhr, ajaxOptions, thrownError)
		   {
			    $('#layer_'+theme+' .ammapLayerText').empty();
           		$('#layer_'+theme+' .ammapLayerText').text('Error: '+xhr.status);
             }

		});
	}
	// Si flux rss
	function showAmmapLayerRSS(theme,pageId)
	{
		showAmmapLayer(theme,pageId,1)
	}
	
	function hideAmmapLayer(theme)
	{
		$.ajax().abort();
		$('.ammapLayer').hide();
		stopPopup();
	}
	
	$('.ammapContainer').mouseout(function()
	{
		$('.ammapLayer').hide();
		stopPopup();
	});
	
	// Reconstruire le fichier XML (pour IE)
	function rebuiltXMLforIE(doc)
	{

		newXmlData = doc.replace(/[\r\n]/g,'');
		newXmlData = newXmlData.replace(/MAP/g,'map');
		newXmlData = newXmlData.replace(/AREAAS/g,'areaas');
		newXmlData = newXmlData.replace(/AREAA/g,'areaa');
		newXmlData = newXmlData.replace(/LABELS/g,'labels');
		newXmlData = newXmlData.replace(/LABEL/g,'label');
		newXmlData = newXmlData.replace(/TEXT/g,'text');
		newXmlData = newXmlData.replace(/DESCRIPTION/g,'description');
		newXmlData = newXmlData.replace(/LINES/g,'lines');
		newXmlData = newXmlData.replace(/LINE/g,'line');
		newXmlData = newXmlData.replace(/MOVIES/g,'movies');
		newXmlData = newXmlData.replace(/MOVIE/g,'movie');
		newXmlData = newXmlData.replace(/areaa/g,'area');
		newXmlData = newXmlData.replace(/\<\!\-\-\[CDATA\[/g,'');
		newXmlData = newXmlData.replace(/\<\!\[CDATA\[/g,'');
		newXmlData = newXmlData.replace(/\]\]\-\-\>/g,']]>');
		newXmlData = newXmlData.replace(/\&gt\;/g,'>');
		newXmlData = newXmlData.replace(/\<text\>/g,'<text><![CDATA[');
																	
		return newXmlData;
	}
	
	// Reconstruire les attributs title (pour IE)
	function parseTitles()
	{
		$('#xmlStorage').find('areaa').each(function()
		{
			stockTitle = $(this).attr('title');
			$(this).removeAttr('title');
			$(this).attr('title'," "+stockTitle+" ");
		});
	}
	
	//Détecter un paramètre dans une url
	function gup( name,currentURL )
	{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( currentURL );
	  if( results == null )
		return "";
	  else
		return results[1];
	}
	
	//Revenir à la carte du monde
	$('.SearchEngineInner .return a').click(function()
	{
		loadWorld();
	});
	$('.ammapBreadCrumb .titWorld').click(function()
	{
		if($(this).find('a').length>0)
		{
			showCountryLayer = 1;
			loadWorld()
		}
	});
	$('.ammapBreadCrumb .titContinent').click(function()
	{
		if($(this).find('a').length>0)
		{
			showCountryLayer = 1;
			filterContinent($(this).find('a').text(),globalContinentSwf,globalContinentUrl);
		}
	});
	
	
	// Filtre pastille filtre formulaire du haut de page
	$('.formAmmapFilter .action:first').click(function()
	{
		var param1 = $(this).parent('form').find('#steImplantation').val();
		filterImplantation(param1,countriesurl);
	});
	$('.formAmmapFilter .action:last').click(function()
	{
		if(globalCountry!=''||globalContinent!='')
		{
			var xmlUrl = countriesurl;
		} else {
			var xmlUrl = worldurl;
		}
		var attribute1 = 'country';
		var attribute2 = $(this).parent('form').find('.data').attr('id');
		var param1 = $(this).parent('form').find('.pays').val();
		var param2 = $(this).parent('form').find('.data').val();
		// Si on demande le pays, le zoom est chargé directement
		if(param1&&param1=='ALL')
		{
			filterXml(attribute1,param1,xmlUrl,attribute2,param2);
		} else {
			filterXml(attribute1,param1,countriesurl,attribute2,param2,param1);
		}
		globalActivite = param2;
	});
	
	// Filtre pastille fonctions
	$('#ammapZoomView .selectContent').click(function()
	{
		var attribute = 'theme';
		var param = $(this).val();
		var xmlUrl = countriesurl;
		filterXml(attribute,param,xmlUrl,'BusinessGroup',$('#ammapContinentViews li.active a').attr('title'));
	});
	
	// Filtre vue
	$('#ammapContinentViews li').click(function()
	{
		$('#ammapContinentViews li').removeClass('active');
		$(this).addClass('active');
		var attribute = 'BusinessGroup';
		var param = $(this).find('a').attr('title');
		globalActivite = param;
		var xmlUrl = countriesurl;
		filterXml('theme',$('#ammapZoomView .selectContent:checked').val(),xmlUrl,attribute,param);
	});
	
	//Fonction pour les implantations
	function filterImplantation(param,xmlUrl)
	{
		param = param.replace(/\'/,'').replace(/\&/,'').replace(/\s+/g,' ');
		$('#ammapLayerLoading').show();
		$.ajax({
		  type: 'get',
		  url: xmlUrl,
		  dataType: 'html',
		  processData: 'true',
		  success: function(xml){ 
		  		$('#ammapLayerLoading').hide();
		  		areaReplace = xml.replace(/area/g,'areaa');
				// Stockage temporaire du xml pour traitement DOM
				$('#xmlStorage').html(areaReplace);
					var countryImplantation = null;
					var themeImplantation = null;
					var urlImplantation = null;
					param = param.replace(/\s+$/g,'');
					$('#xmlStorage').find('movie').each(function()
					{
						$(this).attr('file',$(this).attr('file').replace(/\'/g,'').replace(/\s+$/g,'').replace(/\s+/g,' '))
						if((gup('steImplantation',$(this).attr('file'))!=param))
						{
							$(this).removeAttr('file');
						} else {
							countryImplantation = gup('country',$(this).attr('file'));
							globalActivite = gup('BusinessGroup',$(this).attr('file'));
							themeImplantation = gup('theme',$(this).attr('file'));
							urlImplantation = gup('pageUrl',$(this).attr('file'));
						}
					});
					if(countryImplantation!=null)
					{
						$('#xmlStorage').find('areaa').each(function()
						{
							if($(this).attr('url')&&$(this).attr('url').toLowerCase().match(countryImplantation.toLowerCase()))
							{
								countryParams = ("',"+(/(\()(.*)(\))/).exec($(this).attr('url'))[2]+",'").split("','");
								countryContinent = ($(this).attr('continent')).split(',');
							}
						});
						
						returnContinent(countryContinent[0],countryContinent[1],countryContinent[2]);
						breadCrumb(countryContinent[0],'continent');
						breadCrumb(countryImplantation,'country');
						$('#ammapContinentViews li').removeClass('active');
						if(globalActivite!='')
						{ $('#ammapContinentViews li a[title='+globalActivite+']').parent('li').addClass('active');
						$('#BusinessGroup').val(globalActivite);}
						else { $('#ammapContinentViews li:first').addClass('active'); }
						globalCountry = countryParams[1];
						globalCountrySwf = countryParams[2];
						globalContinent = '';
						globalCountryTl_long = countryParams[3];
						globalCountryTl_lat = countryParams[4];
						globalCountryBr_long = countryParams[5];
						globalCountryBr_lat = countryParams[6];	
						globalCountryUrl = countryParams[9];
						
						if(countryParams[2]=='maps/usa_mercator.swf')
						{
							globalZoom = '195%'
						} else {
							globalZoom = '85%'
						}
						$('#xmlStorage').find('areaas').empty();
						$('#xmlStorage').find('map').attr({'map_file':countryParams[2],'tl_long':countryParams[3],'tl_lat':countryParams[4],'br_long':countryParams[5],'br_lat':countryParams[6],'zoom_x':countryParams[7],'zoom_y':countryParams[8],'zoom':globalZoom});
					}
				parseTitles();
				newXmlData = rebuiltXMLforIE(String($('#xmlStorage').html()))
				if(urlImplantation!='')
				{ ammapAjaxCall(themeImplantation,urlImplantation,countryImplantation); }
				newData(newXmlData);
		}
		  });
	}
	
	// Fonction globale pour les filtres pastille
	function filterXml(attribute1,param1,xmlUrl,attribute2,param2,zoomCountry)
	{
		$('#ammapLayerLoading').show();
		attribute1 = attribute1.replace(/\'/,'').replace(/\&/,'');
		param1 = param1.replace(/\'/,'').replace(/\&/,'');
		attribute2 = attribute2.replace(/\'/,'').replace(/\&/,'');
		param2 = param2.replace(/\'/,'').replace(/\&/,'');
		$.ajax({
		  type: 'get',
		  url: xmlUrl,
		  dataType: 'html',
		  processData: 'true',
		  success: function(xml){ 
		  		$('#ammapLayerLoading').hide();
		  		areaReplace = xml.replace(/area/g,'areaa');
				// Stockage temporaire du xml pour traitement DOM
				$('#xmlStorage').html(areaReplace);
				// Zoom sur le pays si nécessaire
				if(zoomCountry)
				{
					zoomCountry = zoomCountry.replace(/\'/,'').replace(/\&/,'').replace(/\s+$/g,'');
					$('#xmlStorage').find('areaa').each(function()
					{
						if($(this).attr('url')&&$(this).attr('url').match(zoomCountry))
						{
							countryParams = ("',"+(/(\()(.*)(\))/).exec($(this).attr('url'))[2]+",'").split("','");
							countryContinent = ($(this).attr('continent')).split(',');
						}
					});
					if(countryParams)
					{
						globalActivite = param2;
						returnContinent(countryContinent[0],countryContinent[1],countryContinent[2]);
						breadCrumb(countryContinent[0],'continent');
						breadCrumb(zoomCountry,'country');
						$('#ammapContinentViews li').removeClass('active');
						if(globalActivite!='')
						{ $('#ammapContinentViews li a[title='+globalActivite+']').parent('li').addClass('active');
						$('#BusinessGroup').val(globalActivite);}
						else { $('#ammapContinentViews li:first').addClass('active'); }
						globalCountry = countryParams[1];
						globalCountrySwf = countryParams[2];
						globalContinent = '';
						globalCountryTl_long = countryParams[3];
						globalCountryTl_lat = countryParams[4];
						globalCountryBr_long = countryParams[5];
						globalCountryBr_lat = countryParams[6];	
						globalCountryUrl = countryParams[9];
						if(countryParams[2]=='maps/usa_mercator.swf')
						{
							globalZoom = '195%'
						} else {
							globalZoom = '85%'
						}
						$('#xmlStorage').find('areaas').empty();
						$('#xmlStorage').find('map').attr({'map_file':countryParams[2],'tl_long':countryParams[3],'tl_lat':countryParams[4],'br_long':countryParams[5],'br_lat':countryParams[6],'zoom_x':countryParams[7],'zoom_y':countryParams[8],'zoom':globalZoom});
						ammapAjaxCall('country', countryParams[9], countryParams[1])
					}

				} else {
					if(globalCountry!='')
					{
						$('#xmlStorage').find('map').attr({'map_file':globalCountrySwf,'tl_long':globalCountryTl_long,'tl_lat':globalCountryTl_lat,'br_long':globalCountryBr_long,'br_lat':globalCountryBr_lat});
					}
					if(globalContinent!='')
					{
						$('#xmlStorage').find('map').attr({'map_file':globalContinentSwf,'tl_long':globalContinentTl_long,'tl_lat':globalContinentTl_lat,'br_long':globalContinentBr_long,'br_lat':globalContinentBr_lat});
					}
				}
				var count = 0;
				var stockOneItem

				if(attribute1=='continent')
				{ returnContinent(param1,globalContinentSwf,countriesurl); }

				var stockColor = $('#xmlStorage').find('areaa[color]').attr('color');
				$('#xmlStorage').find('areaa[oid!=borders]').removeAttr('color');
				$('#ammapContinentViews li').removeClass('active');
				$('#ammapContinentViews li a[title='+param2+']').parent('li').addClass('active');
				$('#BusinessGroup').val(param2);
				if(param2=='ALL')
				{ $('#ammapZoomView .legendAreva').html(stockArevaText);$('#ammapLegend .legendAreva').html(stockArevaText); }
				else if(param2!='ALL') { $('#ammapZoomView .legendAreva').text(param2);$('#ammapLegend .legendAreva').text(param2); }
				
				$('#xmlStorage').find('movie').each(function()
				{
				
				$(this).attr('file',$(this).attr('file').replace(/\'/,'').replace(/\s+$/g,''))
				if(((gup(attribute1,$(this).attr('file'))!=param1&&param1!='ALL')||(gup(attribute2,$(this).attr('file'))!=param2&&param2!='ALL')))
					{
						$(this).removeAttr('file');						
					}else{
						count++;
						currentCountry = gup('country',$(this).attr('file'));
						if(count==1){
							var stockCurrentCountry=currentCountry;
							$('#xmlStorage').find('areaa[title^='+currentCountry+']').attr('color',stockColor);
							$('#xmlStorage').find('areaa[country='+currentCountry+']').attr('color',stockColor);
						}
						if(currentCountry!=''&&currentCountry!=stockCurrentCountry)
						{
							$('#xmlStorage').find('areaa[title^='+currentCountry+']').attr('color',stockColor);
							$('#xmlStorage').find('areaa[country='+currentCountry+']').attr('color',stockColor);
						}
						stockCurrentCountry=currentCountry;
						stockOneItem = $(this);
					}
				  if( (globalContinent!=''&&(gup('continent',$(this).attr('file'))!=globalContinent||!gup('display',$(this).attr('file')).match(/continent/)))
				   ||
				   (globalCountry!=''&&(gup('country',$(this).attr('file'))!=globalCountry||!gup('display',$(this).attr('file')).match(/country/)))
				   ||
				   (xmlUrl==worldurl&&(gup('theme',$(this).attr('file'))!='news'&&gup('theme',$(this).attr('file'))!='projets')&&!gup('display',$(this).attr('file')).match(/world/))
				  )
					{
						$(this).removeAttr('file');
					}else{
						count++;
						stockOneItem = $(this);
					}
					});
				/*if(count==1)
				{
					ammapAjaxCall(gup('theme',stockOneItem.attr('file')),gup('pageUrl',stockOneItem.attr('file')),gup('country',stockOneItem.attr('file')));
				}*/

				parseTitles($('#xmlStorage').html());

				newXmlData = rebuiltXMLforIE(String($('#xmlStorage').html()))

					newData(newXmlData);
				//console.log(newXmlData)
			  }
		  });
	}
	
	//Afficher le fil d'Ariane
	function breadCrumb(param,type)
	{
		$('.ammapBreadCrumb .inner1').show();
		if(type=='continent')
		{
			$('.ammapBreadCrumb .inner2').hide();
			$('.ammapBreadCrumb .titContinent').html($('.ammapBreadCrumb .titContinent a').text())
			$('.ammapBreadCrumb span').each(function()
			{
				$(this).removeClass('ammapLast');
			});
			$('.ammapBreadCrumb .titContinent').text(param).addClass('ammapLast');
			$('.ammapBreadCrumb .titCountry').empty();
			($('.ammapBreadCrumb .titWorld')).wrapInner('<a href="javascript:;"></a>');
			$('#ammapLegend').hide();
			$('#ammapContinentViews').fadeIn('slow');
			$('#ammapZoomView').fadeIn('slow');
			$('#ammapZoomView input#all').attr('checked','checked');
		} else if(type=='country') {
			$('.ammapBreadCrumb .inner2').show();
			$('.ammapBreadCrumb span').each(function()
			{
				$(this).removeClass('ammapLast');
			});
			if($('.ammapBreadCrumb .titContinent').is(':empty'))
			{ $('.ammapBreadCrumb .inner1').hide(); }
			$('.ammapBreadCrumb .titCountry').text(param).addClass('ammapLast');
			($('.ammapBreadCrumb .titContinent')).wrapInner('<a href="javascript:;"></a>');
			$('#ammapZoomView input#all').attr('checked','checked');
		}
	}
	
	// Afficher des continents sans fichier swf
	function returnContinent(param,swf,url)
	{
		if(swf=='maps/africa.swf'||swf=='africa')
		{
			$('#xmlStorage').find('map').attr({'map_file':'maps/africa.swf','tl_long':'-25.333','tl_lat':'37.224','br_long':'51.32','br_lat':'-34.62','zoom_x':'77.99%','zoom_y':'6.44%','zoom':'75%'});
			globalContinentTl_long = '-25.333';
			globalContinentTl_lat = '37.224';
			globalContinentBr_long = '51.32';
			globalContinentBr_lat = '-34.62';
		} else if(swf=='maps/south_america.swf') {
			$('#xmlStorage').find('map').attr({'map_file':'maps/south_america.swf','tl_long':'-92.25','tl_lat':'26.95','br_long':'-35.04','br_lat':'-55.5','zoom_x':'172.91%','zoom_y':'5.67%','zoom':'75%'});
			globalContinentTl_long = '-92.25';
			globalContinentTl_lat = '26.95';
			globalContinentBr_long = '-35.04';
			globalContinentBr_lat = '-55.5';
		} else if(swf=='maps/oceanica.swf') {
			$('#xmlStorage').find('map').attr({'map_file':'maps/oceanica.swf','tl_long':'95.43','tl_lat':'5.6','br_long':'188','br_lat':'-50.8','zoom_x':'50.16%','zoom_y':'11.6%','zoom':'75%'});
			globalContinentTl_long = '95.43';
			globalContinentTl_lat = '5.6';
			globalContinentBr_long = '188';
			globalContinentBr_lat = '-50.8';
		} else if(swf=='maps/asia.swf') {
			$('#xmlStorage').find('map').attr({'map_file':'maps/asia.swf','tl_long':'34','tl_lat':'55.3','br_long':'145.73','br_lat':'1.474','zoom_x':'33.75%','zoom_y':'7.13%','zoom':'75%'});
			globalContinentTl_long = '34';
			globalContinentTl_lat = '55.3';
			globalContinentBr_long = '145.73';
			globalContinentBr_lat = '1.474';
		} else if(swf=='maps/europe.swf') {
			$('#xmlStorage').find('map').attr({'map_file':'maps/europe.swf','tl_long':'-28.7153','tl_lat':'80.48514','br_long':'69.0402','br_lat':'27.61925','zoom_x':'47%','zoom_y':'-67%','zoom':'171%'});
			globalContinentTl_long = '-28.7153';
			globalContinentTl_lat = '80.48514';
			globalContinentBr_long = '69.0402';
			globalContinentBr_lat = '27.61925';
		} else if(swf=='maps/north_america.swf') {
			$('#xmlStorage').find('map').attr({'map_file':'maps/north_america.swf','tl_long':'-167.29','tl_lat':'85.63','br_long':'-17.43','br_lat':'15.23','zoom_x':'43%','zoom_y':'-67%','zoom':'160%'});
			globalContinentTl_long = '-167.29';
			globalContinentTl_lat = '85.63';
			globalContinentBr_long = '-17.43';
			globalContinentBr_lat = '15.23';
		} else if(swf=='world') {
			$('#xmlStorage').find('map').attr({'map_file':'maps/world.swf', 'tl_long=':'168.49','tl_lat':'83.63','br_long':'190.3','br_lat':'-55.58','zoom_x':'20%','zoom_y':'0%','zoom':'100%'});
		}
		globalContinent = param;
		globalCountry = '';
		globalContinentSwf = swf;
		globalContinentUrl = url;
	}
	
	
	// Fonction globale pour les vues continents
	function filterContinent(param,swf,loadUrl)
	{
		showCountryLayer=1;
		$('#ammapLayerLoading').show();
		breadCrumb(param,'continent');
		$('#ammapContinentViews li').removeClass('active');
		if(globalActivite!='')
		{ $('#ammapContinentViews li a[title='+globalActivite+']').parent('li').addClass('active');
		$('#BusinessGroup').val(globalActivite);}
		else { $('#ammapContinentViews li:first').addClass('active'); }
		keepActivite = $('#ammapContinentViews li.active a').attr('title');
		//globalContinentSwf = swf;
		//filterXml('continent',param,countriesurl,'BusinessGroup',keepActivite);
		$.ajax({
		  type: 'get',
		  url: countriesurl,
		  dataType: 'html',
		  processData: 'true',
		  success: function(xml){
			  $('#ammapLayerLoading').hide();
		  		areaReplace = xml.replace(/area/g,'areaa');
				$('#xmlStorage').html(areaReplace);
		  		returnContinent(param,swf,loadUrl);
				count=0;
				var stockColor = $('#xmlStorage').find('areaa[color]').attr('color');
				$('#xmlStorage').find('areaa[oid!=borders]').removeAttr('color');
				if(keepActivite=='ALL')
				{ $('#ammapZoomView .legendAreva').html(stockArevaText);$('#ammapLegend .legendAreva').html(stockArevaText); }
				else { $('#ammapZoomView .legendAreva').html(keepActivite);$('#ammapLegend .legendAreva').html(keepActivite); }
				$('#xmlStorage').find('movie').each(function()
				{
				$(this).attr('file',$(this).attr('file').replace(/\'/,''))
				if(((gup('continent',$(this).attr('file'))!=param)||(gup('BusinessGroup',$(this).attr('file'))!=keepActivite&&keepActivite!='ALL')))
					{
						$(this).removeAttr('file');						
					}else{
						count++;
						currentCountry = gup('country',$(this).attr('file'));
						if(count==1){
							var stockCurrentCountry=currentCountry;
							$('#xmlStorage').find('areaa[title^='+currentCountry+']').attr('color',stockColor);
						}
						if(currentCountry!=''&&currentCountry!=stockCurrentCountry)
						{
							$('#xmlStorage').find('areaa[title^='+currentCountry+']').attr('color',stockColor);
						}
						stockCurrentCountry=currentCountry;
						stockOneItem = $(this);
					}
				  if( (globalContinent!=''&&(gup('continent',$(this).attr('file'))!=globalContinent||!gup('display',$(this).attr('file')).match(/continent/)))
				  )
					{
						$(this).removeAttr('file');
					}else{
						count++;
						stockOneItem = $(this);
					}
					});
				parseTitles();
				newXmlData = rebuiltXMLforIE(String($('#xmlStorage').html()))
				newData2(newXmlData);
				ammapAjaxCall('continent',loadUrl,param);
		   }
		  });
	}
	
	//Fonction pour les pays
	function filterCountry(param,swf,tl_long,tl_lat,br_long,br_lat,zoom_x,zoom_y,countryPage)
	{
		showCountryLayer = 0;
		$('#ammapLayerLoading').show();
		breadCrumb(param,'country');
		$('#ammapContinentViews li').removeClass('active');
		if(globalActivite!='')
		{ $('#ammapContinentViews li a[title='+globalActivite+']').parent('li').addClass('active');
			$('#BusinessGroup').val(globalActivite);
		}
		else { $('#ammapContinentViews li:first').addClass('active'); }
		keepActivite = $('#ammapContinentViews li.active a').attr('title');
 
		  		$.ajax({
		  type: 'get',
		  url: countriesurl,
		  dataType: 'html',
		  processData: 'true',
		  success: function(xml){ 
		  		$('#ammapLayerLoading').hide();
		  		globalCountry = param;
		  		globalCountrySwf = swf;


				globalContinent = '';
		  		globalCountryTl_long = tl_long;
		  		globalCountryTl_lat = tl_lat;
		  		globalCountryBr_long = br_long;
		  		globalCountryBr_lat = br_lat;
				globalCountryUrl = countryPage;
				areaReplace = xml.replace(/area/g,'areaa');
				$('#xmlStorage').html(areaReplace);
				if(swf=='maps/usa_mercator.swf')
				{ var globalZoom = '195%' }
				else { var globalZoom = '85%' }
				$('#xmlStorage').find('map').attr({'map_file':swf,'tl_long':tl_long,'tl_lat':tl_lat,'br_long':br_long,'br_lat':br_lat,'zoom_x':zoom_x,'zoom_y':zoom_y,'zoom':globalZoom});
				$('#xmlStorage').find('areaas').empty();
				$('#xmlStorage').find('movie').each(function()
				{
					$(this).attr('file',$(this).attr('file').replace(/\'/,''))
					if(gup('country',$(this).attr('file'))!=param&&param!='ALL')
					{
						$(this).removeAttr('file');
					}
					if(keepActivite!='ALL'&&gup('BusinessGroup',$(this).attr('file'))!=keepActivite)

					{
						$(this).removeAttr('file');
					}
				});
				ammapAjaxCall('country', countryPage, param)
				parseTitles();
				newXmlData = rebuiltXMLforIE(String($('#xmlStorage').html()))
				newData2(newXmlData);
		   }
		  });
	}
	
	
	function amRegisterHover(map_id, object_id, title, value)
	{
		if(showCountryLayer==1)
		{
			if (title!='null')
			{ 
				valeur = title.split(',');
				if(valeur[1]!=null)
				{
					showAmmapLayer('country',valeur[1]);

				}
			}	
		}
	}
	
	
	
	function ammapAjaxCall(theme, pageUrl, country)
	{
		pageUrl = unescape(pageUrl);
		$('#ajaxCallContent').empty();
		$('#ajaxCallContent').html($('.ammapLoading02').clone());
		$('#ajaxCallContainer').show();
		$('.titleAmmap').hide();
		$.ajax({
		  type: "get",
		  url: pageUrl,
		  dataType: "html",
		  success: function(html){
				$('#ajaxCallContent').html(html);
				$('#ajaxCallContainer #'+theme+'Ammap').show();
				$('#ajaxCallContainer #'+theme+'Ammap h2 span em').text(country);
				pageUrl=pageUrl.replace('show.asp','ammap/pageInfo.asp')
				if($('#ajaxCallContent h1').length==0)
				{
				$.ajax({
				  type: "get",
				  url: pageUrl,
				  dataType: "xml",
				  success: function(xml){
					  $('<div class="pageTitle"><h1>'+$(xml).find('title').text()+'</h1></div>').prependTo($('#ajaxCallContent'))
				 	 }
				 });
				}
				if($('#ajaxCallContent').find('.box\\[js\\=generic-tab\\]').size()){
			      var js = box.dom('.box\\[js\\=generic-tab\\]').getBoxDatas('js');
    			  $.ajax({
                        type: 'GET',
                        url: l10n.url.jsFolder + js + '.js',
                        dataType: 'script',
                        cache: false,
                        success: function() {
                            // cool
                        }
                    });
              }
				//$('#ajaxCallContainer .newsAmmap h2 span').text(theme+' : '+country)
		   },
		   error:function (xhr, ajaxOptions, thrownError)
		   {
			   $('#ajaxCallContent').empty();
           		 //$('#ajaxCallContent').text('Error: '+xhr.status);
             }
		});
	}
	
	
	
	
	
//////////////////////////////////////////////////////////////////////////////////////////
    // Functions that control the map ////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////
  	var flashMovie = window.document['flashMovie'];
	
	  
    // SET DATA //////////////////////////////////////////////////////////////////////////////
    // flashMovie.setData(data)
    // This function can be used for setting the maps's data on the fly.
    function setData() {
      // gets data from the text area with id "data"
      var data = document.getElementById("data").value;
      // sets data
      flashMovie.setData(data);
    }
    
    // RELOAD DATA ///////////////////////////////////////////////////////////////////////////
    // flashMove.reloadData([file_name])
    // This function will reload the data. The file_name variable is optional, if you do not
    // set it here, data from the original file will be reloaded.       
    function reloadData(file) {
      flashMovie.reloadData(file); 
    }
    
    // SET PARAM /////////////////////////////////////////////////////////////////////////////
    // flashMovie.setParam(param, value)
    // This function lets you change a single setting. The parameter names are formed using 
    // the section name and the parameter name, separated with a period. For example: 
    // background.alpha or zoom.enabled 
    function setParam() {
      // gets param name from a field with id "param"
      var param = document.getElementById("param").value;
      // gets param value from a field with id "value"
      var value = document.getElementById("value").value;
      // sets param
      flashMovie.setParam(param, value);
    }
          
    // GET PARAM /////////////////////////////////////////////////////////////////////////////
    // flashMovie.getParam(param)
    // This function will ask Flash to return the value of a setting. The parameter name is
    // formed in the same way as the setParam function (described above). When you call this
    // function to return the setting value, Flash will return the value by calling the 
    // amReturnParam(chart_id, param_value) function
    function getParam() {
      // get the param name from a field with id "getparam"
      var param = document.getElementById("getparam").value;            
      flashMovie.getParam(param);
    } 
    
    // GET DATA //////////////////////////////////////////////////////////////////////////////
    // flashMovie.getData()
    // This function will ask Flash to return the whole data. When you call this function to
    // return the data, Flash will call the amReturnData(map_id, data) function.
    function getData() {
      flashMovie.getData();
    }   
          
  
    // SET ZOOM
    // flashMovie.setZoom(zoom_level,zoom_x,zoom_y,instant);
    // This function will set the new zoom level and position for the map. "instant" can be
    // "true" or "false". If set to "true", the map will change the zoom position instantly,
    // without animation. The default value is "false".
    function setZoom() {
      var zoom_level = document.getElementById("zoom_level").value;    
      var zoom_x = document.getElementById("zoom_x").value;
      var zoom_y = document.getElementById("zoom_y").value;
      flashMovie.setZoom(zoom_level,zoom_x,zoom_y, false); 
    }
    
    // SET ZOOM
    // flashMovie.setZoomLongLat(zoom_level,longitude,latitude,instant);
    // This function will set the new zoom level and position for the map using longitude and
    // latitude. "instant" can be "true" or "false". If set to "true", the map will change
    // the zoom position instantly, without animation. The default value is "false".
    function setZoomLongLat(zoom_level,longitude,latitude,d) {
      flashMovie.setZoomLongLat(zoom_level,longitude,latitude, d); 
    }    
         
    
    // ZOOM-IN
    // flashMovie.zoomIn()
    // the map will zoom-in by one step. You can call this function on mouseWheel event. 
    // amMap has a possibility to zoom-in and out with mouseWheel, however it is not working
    // properly with wmode set to "transparent" or "opaque"
    function zoomIn(){
      flashMovie.zoomIn()
    }
    // ZOOM-OUT
    // flashMovie.zoomOut()
    // the map will zoom-in by one step. You can call this function on mouseWheel event. 
    // amMap has a possibility to zoom-in and out with mouseWheel, however it is not working
    // properly with wmode set to "transparent" or "opaque"
    function zoomOut(){
      flashMovie.zoomOut()
    }    
    
    
    //////////////////////////////////////////////////////////////////////////////////////////
    // Functions that are called by the chart ////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////  
        function handle(delta) {
        if (delta < 0)
            flashMovie.zoomOut();
        else
        flashMovie.zoomIn();
    }
   
    function wheel(event){
        var delta = 0;
        if (!event) event = window.event;
        if (event.wheelDelta) {
            delta = event.wheelDelta/120;
            if (window.opera) delta = -delta;
        } else if (event.detail) {
            delta = -event.detail/3;
        }
        if (delta)
            handle(delta);
            if (event.preventDefault)
                    event.preventDefault();
            event.returnValue = false;
    }
	$('.ammapContainer, #ammapContent').mouseenter(function()
	{
		if (window.addEventListener)
		{	
			window.addEventListener('DOMMouseScroll', wheel, false);
		}
		if (window.attachEvent)
		{	
			//window.attachEvent('onmousewheel', wheel)
			document.attachEvent('onmousewheel', wheel)
		}
		$(document).bind('mousewheel',wheel)
		$(window).bind('mousewheel',wheel)
		//window.onmousewheel = document.onmousewheel = wheel;
	});
	$('.ammapContainer, #ammapContent').mouseout(function()
	{
		if (window.addEventListener)
		{	
			window.removeEventListener('DOMMouseScroll', wheel, false);
		}
		if (document.attachEvent)
		{	
			//window.detachEvent('onmousewheel')
			window.document.detachEvent('onmousewheel', wheel)
		}
		$(document).unbind('mousewheel',wheel)
		$(window).unbind('mousewheel',wheel)
	});
 
   

	
    // MAP COMPLETED /////////////////////////////////////////////////////////////////////////   
    //amMapCompleted('ammapContent')
    // This function is called when the map is fully loaded and initialized.
    function amMapCompleted(map_id){
      // get the flash object into "flashMovie" variable   
    //flashMovie = document.getElementById(map_id);
	flashMovie = window.document['flashMovie'];
	}
    
    // PROCESS COMPLETED /////////////////////////////////////////////////////////////////////   
    // amProcessCompleted(map_id, process_name)
    // This function is called when the map finishes doing some task triggered by another 
    // JavaScript function 
    function amProcessCompleted(map_id, process_name){
      document.getElementById("processcompleted").value = process_name;           
    }  
    

