
//document.write("<script type='text/javascript' src='js/slide_show2.js'></script>");

// The variable to point to the created map
var map=null;
var onloadMap ='Y';
var poiTypeList =[];
var partnerIdList=[];
var long=null;
var lat=null;
var currentPoiType=null;
// The poiData associated with the map
var poiData=null;
// A variable to hold a passed URL parameter to determine whether to display
// the debug DIV
var debugFlag = false;
// The width and height of the map.  This example can vary these variable
// via the URL line
var width = 1400;
var height = 900;
// The club information.  This example takes it from the URL line
var associationID ="CAA";
var clubCode = "285";
var branch = "1";
var isValid= new Boolean(false);
var zoomLevelGlobal=13;
var controllevel=3;
//le tableau html qui conteint tous les centres caa au canada, quebec et usa 
var htmlCaaDiv ="";
var isYourSearchHide= new Boolean(false);
/** 
 * A function to pull the URL variables
 * @param  : 
 * @return
 */
function parseParams()
{
    height = getParam("height", height) * 1;
    width = getParam("width", width) * 1;

    associationID = getParam("association", "CAA");
    clubCode = getParam("club", "285");
    branch = getParam("branch", "1");

    zoomLevel = getParam("zl",0) * 1;
}
/** 
 * cette fonction crée une carte pour un point de destination donné avec son long et lat
 * @param  : long:logitude, lat:latitude et le niveau de zoom
 * @return
 */
function createMap(long,lat,zoomLevel)
{
	// Pull the URL variables
    parseParams();
    // zoomLevelGlobal=zoomLevel;
	// Create the club information
    var clubStuff = [];
    clubStuff["association"] = associationID;
    clubStuff["clubCode"] = clubCode;
    clubStuff["branch"] = branch;
    clubStuff["club"] = "285";
    // clubStuff["profileID"]="DCB6D3CD-AEB9-4D5B-81EB-A6CB573F1976";
    clubStuff["mapPath"] = "http://PublishingWebServices.aaa.com/maps/";
  
    
    var h=null;
	var w=null;

	// Create the new map passing the club information
    map = new ttp_Map(clubStuff);
    if (window.innerHeight != null)
	{
         w =window.innerWidth;
    	 h =window.innerHeight;	 
	}
    else 
	{ 
	     h = document.body.clientHeight;
		 w = document.body.clientWidth;
	
	}   
	// pour FFox : 400->401 pour IE7/8 67->64
	// Sets the upper left corner of the map
	// Sets the width and height
     
    if(browser=='Microsoft Internet Explorer'){
    	  map.setViewOrigin(400,64);
    	  map.setViewSize(w-411,h-85);    	
	 }else{
		 map.setViewOrigin(401,67);		 		 
		 map.setViewSize(w-411,h-92);
	 }
	// Set various map attributes
         map.setBorderWidth(0);
         map.setBorderColor("#000000");    
	// Enables the use of the POI data
    map.enableUserPOIData();    
	// Allows for pan and zoom up to level 7
    map.enablePanZoomTool("DEFAULT");
    
    panZoomToolsHTML();     
	// Pulls the POI data associated with the map.
    poiData = map.getPOIData();
	// Creates the actual map with the center x and y with zoom leve 3
	// as default
    map.newMap(long2Mercx(long),lat2Mercy(lat), zoomLevel);
	// Sets the user function to be called when a pan or zoom event happens
    map.enableUserPOIs(userEventCreateMap);
}
/** 
 *  The user function call after a pan or zoom event
 * @param  
 * @return
 */     
function userEventCreateMap(xMin, yMin, xMax, yMax, zoomLevel)
{
	zoomLevelGlobal=zoomLevel;
	var panZoomLong= (xMin+xMax)/2 ;
	var panZoomLat = (yMin+yMax)/2 ;	
	var gisExist='false';	
	if(zoomLevel <= 7){		
		
		for(i=0;i<poiTypeList.length;i++){			
		    if(TypeTdrOrGisHashTable.get(poiTypeList[i])=='TDR' || TypeTdrOrGisHashTable.get(poiTypeList[i])=='GIS'){
				
		    	 
		    	  currentPoiType=poiTypeList[i];		
		    	  if(poiTypeList[i]=='off_caa_qc'){		    		 
						getCentersServiceInMap(xMin,yMin,xMax,yMax); 
					}else{
						findNearEventSearchSendRequest(poiTypeList[i],xMin, yMin, xMax, yMax);
					}
				
				
			}else if(TypeTdrOrGisHashTable.get(poiTypeList[i])=='CAADB'){
				// il faut tjrs garder la trace sur le type de poi
				currentPoiType=poiTypeList[i];
				getPartnersInMap(poiTypeList[i],xMin, yMin, xMax, yMax);
			}else if(TypeTdrOrGisHashTable.get(poiTypeList[i])=='CAAIPR'){
				currentPoiType=poiTypeList[i];
				RegionVincitySearchInMap(xMin, yMin, xMax, yMax);
			}else{
				gasvicinitySearchSendRequest();
				gisExist='true';
			}
		}
		

		userEventBubbleInMap();
	}else{		 
		 map.userPOIService.removeAll(); 
		 addPrincipalLocalisation();
		 map.userPOIService.update();
		 map.show();
	}	
	
	
}
/**
 * This function will be called on a mouseOver and mouseOut event to cause
 * POI bubble to display wheN the end user is outside the map 
 * @param  : id du POI 
 * @return
 */ 
function linkMouseEvent(id, selected)
{
	
	map.showBubble(id, selected);
  
}
/**
 * The mouse over event for a our example POI 
 * @param  : id du POI 
 * @return
 */  
function over(id)
{
	
	var idTR ='poiInMap_'+id+'_TR';
	 if($(idTR)!=null){
		$(idTR).addClassName('selected') ;
	 }	
}
/**
 *  The mouse out event for a our example POI 
 * @param  : id du POI 
 * @return
 */
function out(id)
{

poiInMapHashTable.each(function(pair){	

if(pair.value.length>0){
			
	for(var i=0 ; i< pair.value.length; i++){
					// Creating the POI information.  This POI has several tabs
			if(TypeTdrOrGisHashTable.get(pair.key)=='TDR' || TypeTdrOrGisHashTable.get(pair.key)=='GIS'){							
				if(pair.key=='off_caa_qc' ){
					var p =  pair.value[i].servicecenter_id;	
					 var idTR ='poiInMap_'+p+'_TR';	
						if($(idTR)!=null){
							$(idTR).removeClassName('selected');
						}
				}else{
				 var p =  pair.value[i].TRAVEL_ITEM_ID.content;	
				 var idTR ='poiInMap_'+p+'_TR';	
					if($(idTR)!=null){
						$(idTR).removeClassName('selected');
					}
				}
			}else if(TypeTdrOrGisHashTable.get(pair.key)=='CAADB'){
			  	 var p =pair.value[i].partnercenter_id;
			  	 var idTR ='poiInMap_'+p+'_TR';	
					if($(idTR)!=null){
						$(idTR).removeClassName('selected');
					}		    			   
			}else if(TypeTdrOrGisHashTable.get(pair.key)=='GIS_CAADB'){
			  	 var p =pair.value[i].poiID;
			  	 var idTR ='poiInMap_'+p+'_TR';	
					if($(idTR)!=null){
						$(idTR).removeClassName('selected');
					}		    			   
			}
	}
 }
});
}

/**
 * The click event for a our example POI 
 * @param  : id du POI 
 * @return
 */    
function clk(id)
{
	var idTR ='poiInMap_'+id+'_TR';	
	 if($(idTR)!=null){
		$(idTR).addClassName('selected') ;
	 }
	return false;
	
}

/********************************************* Notre code ******************************************/
/**
 * fonction pour avoir le code html d'une bubble selon son type poi 
 * @param  : un type de poi soit restaurant, lodging ou autres 
 * @return
 */

function getTemplateBubble(poiType,index){	
	
	if(TypeTdrOrGisHashTable.get(poiType)=='TDR' || TypeTdrOrGisHashTable.get(poiType)=='GIS'){
		
		if (poiType == 'off_caa_qc') {
			if (poiInMapHashTable.get(poiType).length > 0) {
				template_off_caa_qc = "<div class=\"bubbleTitleline\"><span>"
						+ (poiInMapHashTable.get(poiType)[index].branch == null || trim(poiInMapHashTable.get(poiType)[index].branch," ")=='' ? poiTypeHashTable.get(poiType):poiInMapHashTable.get(poiType)[index].branch)
						+ "</span></div><div class=\"bubbleInfo\">"
						+ poiInMapHashTable.get(poiType)[index].adressnumber
						+ " "
						+ poiInMapHashTable.get(poiType)[index].street
						+ "<br/>"
						+ poiInMapHashTable.get(poiType)[index].city
						+ ", "
						+ poiInMapHashTable.get(poiType)[index].postalcode
						+ "<br/>"
						+ poiInMapHashTable.get(poiType)[index].phone
						+ "<br/>"
						+ (poiInMapHashTable.get(poiType)[index].hours == null ? ''
								: 'Horaires: ' + poiInMapHashTable.get(poiType)[index].hours)
						+ "<br/><p align=\"center\">"
						+ ressourceLang.get('click_tokip_open') + "</p></div>";
			}
		} else {
			
			if (poiInMapHashTable.get(poiType).length > 0) {				
				var directPhone = (poiInMapHashTable.get(poiType)[index].GENS.GEN.DIRECT_PHONE == null ? ''
						: poiInMapHashTable.get(poiType)[index].GENS.GEN.DIRECT_PHONE.content);
				var priceRangeCode = (poiInMapHashTable.get(poiType)[index].GENS.GEN.PRICE_RANGE_CODE == null ? ''
						: getPricePoiHtmlImage(poiInMapHashTable.get(poiType)[index].GENS.GEN.PRICE_RANGE_CODE.content));
				var ratingCode = (poiInMapHashTable.get(poiType)[index].GENS.GEN.RATING_CODE == null ? ''
						: getClassementPoiHtmlImage(
								poiInMapHashTable.get(poiType)[index].GENS.GEN.RED_SAVE_STATUS_IND.content,
								poiInMapHashTable.get(poiType)[index].GENS.GEN.RATING_CODE.content,poiType));				
				var gemInd = (poiInMapHashTable.get(poiType)[index].GENS.GEN.GEM_IND == null ? ''
						: getGemHtmlImage(poiInMapHashTable.get(poiType)[index].GENS.GEN.GEM_IND.content));
				var physicalLine = (poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_LINE1_ADR == null ? ''
						: poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_LINE1_ADR.content);
				var physicalCity = (poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_CITY_DISPLAY_NAME == null ? ''
						: poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_CITY_DISPLAY_NAME.content);
				var physicalState = (poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_STATE_PROVINCE_CODE == null ? ''
						: poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_STATE_PROVINCE_CODE.content);
				var physicalZipCode = (poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_ZIP_CODE == null ? ''
						: poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_ZIP_CODE.content);
				var saveStatus = (poiInMapHashTable.get(poiType)[index].GENS.GEN.SAVE_STATUS_IND == null ? ''
						: getSaveHtmlImage(poiInMapHashTable.get(poiType)[index].GENS.GEN.SAVE_STATUS_IND.content));
				
				if (poiType == 'restaurant' || poiType == 'lodging') {
					template_lodging = "<div class=\"bubbleTitleline\"><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class=\"bubbleInfo\">"
							+ ratingCode + saveStatus + priceRangeCode
							+ "<br/>" + physicalLine + "<br/>" + physicalCity
							+ ", " + physicalState + " " + physicalZipCode
							+ "<br/>" + directPhone
							+ "<br/><p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_restaurant = "<div class=\"bubbleTitleline\"><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class=\"bubbleInfo\">"
							+ ratingCode
							+ " "
							+ priceRangeCode
							+ "<br/>"
							+ physicalLine
							+ "<br/>"
							+ physicalCity
							+ ", "
							+ physicalState
							+ " "
							+ physicalZipCode
							+ "<br/>"
							+ directPhone
							+ "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
				} else if (poiType == 'lmrch') {
					template_lmrch = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode
							+ "<p><a href='#' onclick='addPoiItinerary(\""
							+ poiType + "\",\"" + index + "\");'>"
							+ ressourceLang.get('itinerary_to_partner')
							+ "</a></p><p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
				} else if (poiType == 'attraction') {
					template_attraction = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ (saveStatus!='' ||  gemInd!='' ?  gemInd+saveStatus+"<br/>":'')
							+ physicalLine + "<br/>"
							+ physicalCity + ", " + physicalState + " "
							+ physicalZipCode + "<br/>" + directPhone
							+ "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					
				}else if(poiType == 'event'){					
					template_event = "<div class='bubbleTitleline'><span>"
						+ poiTypeHashTable.get(poiType)
						+ "</span></div><div class='bubbleInfo'>"
						+ physicalLine + "<br/>" + physicalCity + ", "
						+ physicalState + " " + physicalZipCode + "<br/>"
						+ "<p align=\"center\">"+ressourceLang.get('bubble_event_date_from')+poiInMapHashTable.get(poiType)[index].OPERATING_DATES.OPERATING_DATE[0].FROM_DATE.content +ressourceLang.get('bubble_event_date_to')+poiInMapHashTable.get(poiType)[index].OPERATING_DATES.OPERATING_DATE[0].TO_DATE.content+ "</p>" 
						+ directPhone + "<p align=\"center\">"
						+ ressourceLang.get('click_tokip_open')
						+ "</p></div>";         
				} else {
					template_airport = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";

					template_aar = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_aaaOffice = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_sycs = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_campground = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ (ratingCode==''? '':ratingCode+"<br/>")
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_coe = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_hertz = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_off_caa = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";

					template_dnc = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					template_scenic = "<div class='bubbleTitleline'><span>"
							+ poiTypeHashTable.get(poiType)
							+ "</span></div><div class='bubbleInfo'>"
							+ physicalLine + "<br/>" + physicalCity + ", "
							+ physicalState + " " + physicalZipCode + "<br/>"
							+ directPhone + "<p align=\"center\">"
							+ ressourceLang.get('click_tokip_open')
							+ "</p></div>";
					
				}

			}
		}
			
	}else if( TypeTdrOrGisHashTable.get(poiType)=='CAADB'){//test si different du point de recherche principale
		if(poiInMapHashTable.get(poiType).length >0){
			 var city = (poiInMapHashTable.get(poiType)[index].city==null ? '':poiInMapHashTable.get(poiType)[index].city);
			 var zipcode= (poiInMapHashTable.get(poiType)[index].zipcode==null ? '':poiInMapHashTable.get(poiType)[index].zipcode);  
			 var partnercenter_id =(poiInMapHashTable.get(poiType)[index].partnercenter_id==null ? '':poiInMapHashTable.get(poiType)[index].partnercenter_id);
			 var longitude=(poiInMapHashTable.get(poiType)[index].longitude==null ? 0:poiInMapHashTable.get(poiType)[index].longitude);
			 var latitude = (poiInMapHashTable.get(poiType)[index].latitude==null ? 0:poiInMapHashTable.get(poiType)[index].latitude);
			 var addressnumber=(poiInMapHashTable.get(poiType)[index].addressnumber==null ? '':poiInMapHashTable.get(poiType)[index].addressnumber);  
			 var addressstreet =(poiInMapHashTable.get(poiType)[index].addressstreet==null ? '':poiInMapHashTable.get(poiType)[index].addressstreet);  
			 var state =(poiInMapHashTable.get(poiType)[index].state==null ? '':poiInMapHashTable.get(poiType)[index].state);
			 var imagepub =(poiInMapHashTable.get(poiType)[index].imagepub==null || poiInMapHashTable.get(poiType)[index].imagepub=='' ? '':trim(poiInMapHashTable.get(poiType)[index].imagepub," "));
			template_couchetard_tous ="<div class='bubbleInfo'><p><img src='css/images/bubleCoucheTard.jpg' alt='' width='37' height='34' align='left' />"+addressnumber+" "+addressstreet+", "+zipcode+"<br/>"+city+", "+state+"</p><p>"+getPartnersImagePub(imagepub)+"<strong>"+getCoucheTardOptionsDetails(poiInMapHashTable.get(poiType)[index].open24hours,poiInMapHashTable.get(poiType)[index].gasoline,poiInMapHashTable.get(poiType)[index].diesel,poiInMapHashTable.get(poiType)[index].restaurant)+"</strong></p><p><a href='#' onclick='addPoiItinerary(\""+poiType+"\",\""+index+"\");'>"+ressourceLang.get('itinerary_to_partner')+"</a></p><p style=\"margin-top:5px; color:#044d91\">"+ressourceLang.get('click_tokip_open')+"</p></div>";
			template_circle_k ="<div class='bubbleInfo'><p><img src='css/images/bublecircle_k.png' alt='' width='37' height='34' align='left' />"+addressnumber+" "+addressstreet+", "+zipcode+"<br/>"+city+", "+state+"</p><p>"+getPartnersImagePub(imagepub)+"<strong>"+getCoucheTardOptionsDetails(poiInMapHashTable.get(poiType)[index].open24hours,poiInMapHashTable.get(poiType)[index].gasoline,poiInMapHashTable.get(poiType)[index].diesel,poiInMapHashTable.get(poiType)[index].restaurant)+"</strong></p><p><a href='#' onclick='addPoiItinerary(\""+poiType+"\",\""+index+"\");'>"+ressourceLang.get('itinerary_to_partner')+"</a></p><p style=\"margin-top:5px; color:#044d91\">"+ressourceLang.get('click_tokip_open')+"</p></div>";
			template_couchetard_essence ="<div class='bubbleInfo'><p><img src='css/images/bubleCoucheTard.jpg' alt='' width='37' height='34' align='left' />"+addressnumber+" "+addressstreet+", "+zipcode+"<br/>"+city+", "+state+"</p><p>"+getPartnersImagePub(imagepub)+"<strong>"+getCoucheTardOptionsDetails(poiInMapHashTable.get(poiType)[index].open24hours,poiInMapHashTable.get(poiType)[index].gasoline,poiInMapHashTable.get(poiType)[index].diesel,poiInMapHashTable.get(poiType)[index].restaurant)+"</strong></p><p><a href='#' onclick='addPoiItinerary(\""+poiType+"\",\""+index+"\");'>"+ressourceLang.get('itinerary_to_partner')+"</a></p><p style=\"margin-top:5px; color:#044d91\">"+ressourceLang.get('click_tokip_open')+"</p></div>";								
			template_familiprix ="<div class='bubbleInfo'>"+addressnumber+" "+addressstreet+", "+zipcode+"<br/>"+city+", "+state+"<p>"+getPartnersImagePub(imagepub)+"<a href='#' onclick='addPoiItinerary(\""+poiType+"\",\""+index+"\");'>"+ressourceLang.get('itinerary_to_partner')+"</a></p><p style=\"margin-top:5px; color:#044d91\">"+ressourceLang.get('click_tokip_open')+"</p></div>";	
		}
	}else if(TypeTdrOrGisHashTable.get(poiType)=='GIS_CAADB'){
	 
		var regular= (poiInMapHashTable.get(poiType)[index].regular==""  || poiInMapHashTable.get(poiType)[index].regular==undefined || poiInMapHashTable.get(poiType)[index].regular==null ? '':poiInMapHashTable.get(poiType)[index].regular);
		var premium=(poiInMapHashTable.get(poiType)[index].premium=="" || poiInMapHashTable.get(poiType)[index].premium==undefined || poiInMapHashTable.get(poiType)[index].premium==null ? '':poiInMapHashTable.get(poiType)[index].premium);
		var midgrade=(poiInMapHashTable.get(poiType)[index].midgrade=="" || poiInMapHashTable.get(poiType)[index].midgrade==undefined || poiInMapHashTable.get(poiType)[index].midgrade==null ? '':poiInMapHashTable.get(poiType)[index].midgrade);
		var diesel=(poiInMapHashTable.get(poiType)[index].diesel=="" || poiInMapHashTable.get(poiType)[index].diesel==undefined || poiInMapHashTable.get(poiType)[index].diesel==null ? '':poiInMapHashTable.get(poiType)[index].diesel);
		var bioDiesel=(poiInMapHashTable.get(poiType)[index].bioDiesel=="" || poiInMapHashTable.get(poiType)[index].bioDiesel==undefined || poiInMapHashTable.get(poiType)[index].bioDiesel==null ? '':poiInMapHashTable.get(poiType)[index].bioDiesel);		
		var dateRegular= (poiInMapHashTable.get(poiType)[index].dateRegular==""  || poiInMapHashTable.get(poiType)[index].dateRegular==undefined || poiInMapHashTable.get(poiType)[index].dateRegular==null ? '':poiInMapHashTable.get(poiType)[index].dateRegular);
		var datePremium=(poiInMapHashTable.get(poiType)[index].datePremium=="" || poiInMapHashTable.get(poiType)[index].datePremium==undefined || poiInMapHashTable.get(poiType)[index].datePremium==null ? '':poiInMapHashTable.get(poiType)[index].datePremium);
		var dateMidgrade=(poiInMapHashTable.get(poiType)[index].dateMidgrade=="" || poiInMapHashTable.get(poiType)[index].dateMidgrade==undefined || poiInMapHashTable.get(poiType)[index].dateMidgrade==null ? '':poiInMapHashTable.get(poiType)[index].dateMidgrade);
		var dateDiesel=(poiInMapHashTable.get(poiType)[index].dateDiesel=="" || poiInMapHashTable.get(poiType)[index].dateDiesel==undefined || poiInMapHashTable.get(poiType)[index].dateDiesel==null ? '':poiInMapHashTable.get(poiType)[index].dateDiesel);
		var dateBioDiesel=(poiInMapHashTable.get(poiType)[index].dateBioDiesel=="" || poiInMapHashTable.get(poiType)[index].dateBioDiesel==undefined || poiInMapHashTable.get(poiType)[index].dateBioDiesel==null ? '':poiInMapHashTable.get(poiType)[index].dateBioDiesel);
		
		
		template_gas ="<div class='bubbleTitleline'><span>"
			+ poiTypeHashTable.get(poiType)			
			+ "</span></div><div class='bubbleInfo'>"
			+"<table>"
			+"<tr>"
			+(regular=='' ?'' :'<td><b>'+ressourceLang.get('gas_regular')+'</b></td><td><b>:</b> $'+regular+'&nbsp;['+dateRegular.replace(trim(dateRegular.replace(/[0-9]*$/,"")),DateConverterHashTable.get(trim(dateRegular.replace(/[0-9]*$/,""))))+']</td>')
			+"</tr>"
			+"<tr>"
			+(premium=='' ?'' :'<td><b>'+ressourceLang.get('gas_premium')+'</b></td><td><b>:</b> $'+premium+'&nbsp;['+datePremium.replace(trim(datePremium.replace(/[0-9]*$/,"")),DateConverterHashTable.get(trim(datePremium.replace(/[0-9]*$/,""))))+']</td>')
			+"</tr>"
			+"<tr>"
			+(midgrade=='' ?'':'<td><b>'+ressourceLang.get('gas_diesel')+'</b></td><td><b>:</b> $'+midgrade+'&nbsp;['+dateMidgrade.replace(trim(dateMidgrade.replace(/[0-9]*$/,"")),DateConverterHashTable.get(trim(dateMidgrade.replace(/[0-9]*$/,""))))+']</td>')
		    +"</tr>"
			+"<tr>"		
			+(diesel=='' ?''  :'<td><b>'+ressourceLang.get('gas_midgrade')+'</b></td><td><b>:</b> $'+diesel+'&nbsp;['+dateDiesel.replace(trim(dateDiesel.replace(/[0-9]*$/,"")),DateConverterHashTable.get(trim(dateDiesel.replace(/[0-9]*$/,""))))+']</td>')
			+"</tr>"
			+"<tr>"		
			+(bioDiesel==''?'':'<td><b>'+ressourceLang.get('gas_bioDiesel')+'</b></td><td><b>:</b> $'+bioDiesel+'&nbsp;['+dateBioDiesel.replace(trim(dateBioDiesel.replace(/[0-9]*$/,"")),DateConverterHashTable.get(trim(dateBioDiesel.replace(/[0-9]*$/,""))))+']</td>')
			+"</tr>"
			+"</table>"
		
			+ unescape(poiInMapHashTable.get(poiType)[index].poiAddress)+"<br/>"			
			+ '<br/>'
			+ poiInMapHashTable.get(poiType)[index].phone+'<br/>'			
			+ "<p align=\"center\">"
			+ ressourceLang.get('click_tokip_open')
			+ "</p></div>";
		
	}else if(TypeTdrOrGisHashTable.get(poiType)=='CAAIPR'){		
		var obj=poiInMapHashTable.get(poiType)[index];		
		var address=(obj.addressstreet!='' && obj.addressstreet!=null ? obj.addressnumber+' '+ obj.addressstreet:"Sur "+obj.inaddressstreet+" entre "+obj.betweenaddressstreet+" et "+obj.andaddressstreet);
		template_info="<div class='bubbleTitleline'><span> Adresse"			
			+ "</span></div><div class='bubbleInfo'>"
			+ address + "<br/>" + obj.city 
			+ "<p align=\"center\">"
			+ ressourceLang.get('click_tokip_open')
			+ "</p></div>";		
	}else{
			template_principal =gePrincipalePoiBubbleHTML(0);
	}
	return eval ("template_"+poiType);
	 
} 

function getImageHtmlPoiType(poiType){
	return "css/images/icones/"+poiType+".png";
}
/****************************************** Find POIs near a location  *******************************************/
function setCheckedPartners(poiType){
	if(poiType=="couchetard_essence" && $('couchetard_tousCheckbox').checked){
		$('couchetard_tousCheckbox').checked=false;		 
		 poiSearchInCard("couchetard_tous");		 
	}else if(poiType=="couchetard_tous" && $('couchetard_essenceCheckbox').checked){
		$('couchetard_essenceCheckbox').checked=false;
		 poiSearchInCard("couchetard_essence");
	}
}
/**
 * cette fonction est la premiere à appeler pour detecter quel checkbox est choisi et si checkbox (le type de poi)
 * est selectionné on appelle la fonction pour chercher l'ensemble des informations. si le checkbox est decocher on supprime
 * son code html de la vue.   
 * @param  : un type de poi soit restaurant, lodging ou autres 
 * @return
 */
function poiSearchInCard(poiType){	
	var poiTypeId = poiType+'Checkbox';
	if($(poiTypeId).checked){	
        setCheckedPartners(poiType);
		$(poiType + 'DIV').style.display='block';		
		if(TypeTdrOrGisHashTable.get(poiType)=='TDR' || TypeTdrOrGisHashTable.get(poiType)=='GIS'){			
			
				var xMin = map.scale.xScreen2Merc(map.view.left);
				var yMin = map.scale.yScreen2Merc(map.view.bottom);
				var xMax = map.scale.xScreen2Merc(map.view.right);
				var yMax = map.scale.yScreen2Merc(map.view.top);				
				poiTypeList.push(poiType);				
				if(zoomLevelGlobal <=7){
					if(poiType=='off_caa_qc'){						
						  getCentersServiceInMap(mercx2long(xMin),mercy2lat(yMin),mercx2long(xMax),mercy2lat(yMax)); 
					}else{						
					findNearEventSearchSendRequest(poiType,mercx2long(xMin), mercy2lat(yMin), mercx2long(xMax),mercy2lat(yMax));
					}
					 		
				}
			
			
		}else if(TypeTdrOrGisHashTable.get(poiType)=='CAADB'){
			
			var xMin = map.scale.xScreen2Merc(map.view.left);
			var yMin = map.scale.yScreen2Merc(map.view.bottom);
			var xMax = map.scale.xScreen2Merc(map.view.right);
			var yMax = map.scale.yScreen2Merc(map.view.top);	
			
			
			partnerIdList.push(poiType); 
			poiTypeList.push(poiType);			
			if(zoomLevelGlobal <=7){				
				getPartnersInMap(poiType,mercx2long(xMin), mercy2lat(yMin), mercx2long(xMax),mercy2lat(yMax));
				
			}
			
		}else if(TypeTdrOrGisHashTable.get(poiType)=='CAAIPR'){
			
			var xMin = map.scale.xScreen2Merc(map.view.left);
			var yMin = map.scale.yScreen2Merc(map.view.bottom);
			var xMax = map.scale.xScreen2Merc(map.view.right);
			var yMax = map.scale.yScreen2Merc(map.view.top);
			poiTypeList.push(poiType);			
			if(zoomLevelGlobal <=7){
				RegionVincitySearchInMap(mercx2long(xMin), mercy2lat(yMin), mercx2long(xMax),mercy2lat(yMax));
			}
			
		}else{
						
				poiTypeList.push(poiType);
				gasvicinitySearchSendRequest();
				//userEventBubbleInMap();
			
		}	
	}else{
		if(TypeTdrOrGisHashTable.get(poiType)!='CAADB'){
			$(poiType + 'DIV').update();
		}
		$(poiType + 'DIV').style.display='none';
		if($('partnerBoxMin'+poiType)!=null){
			$('partnerBoxMin'+poiType).style.display='none';
		}
		for (i = 0; i < poiTypeList.size(); i++) {
			if (TypeTdrOrGisHashTable.get(poiType) == 'CAADB' && poiTypeList[i] == poiType) {
				for (j = 0; j < partnerIdList.size(); j++) {
					if(partnerIdList[j] == poiType){
						partnerIdList.splice(j, 1);
					}
				}
			}			
			if (poiTypeList[i] == poiType) {				
				poiTypeList.splice(i, 1);
				removePoiTypeFromMap(poiType);
				return;
			}
			
			
		}
				
	}
}
function verifyCheckedPartnerDollars(){
	
	var sizeList= partnerIdList.length;	
	for (i = 0; i < sizeList; i++) {	
		
		var poiTypeId = partnerIdList[i]+'Checkbox';
		if($(poiTypeId)!=null){
			$(poiTypeId).checked = false;
		}
		for (j = 0; j < poiTypeList.size(); j++) {			
			if (poiTypeList[j] == partnerIdList[i]){
				poiTypeList.splice(j, 1);
				poiInMapHashTable.get(partnerIdList[i]).clear();
				break;				
			}
			
		}
	    
	    $(partnerIdList[i]+'DIV').update();
	    if($('partnerBoxMin'+partnerIdList[i])!=null){
	    	$('partnerBoxMin'+partnerIdList[i]).style.display='none';
	    }
	}
	removePoiTypeFromMap('circle_k');
	partnerIdList.clear();
	userEventBubbleInMap();
}
/**
 * fonction AJAX qui cherche un ensemble des informations a l'entourage d'une destination donnée 
 * @param  : un type de poi soit restaurant, lodging ou autres 
 * @return
 */
function vicinitySearchSendRequest(poiType){
	var i=0;
	var distance ='15';
	var location=[];
		
	
	if(locationTypeHashTable.get(requestRows[i].LOCATION_TYPE)=='Address'){
	
		var countryName =states.get(requestRows[i].STATE)[1].toLowerCase();
		location.push({
						ADDRESS:[
						{
							location:(requestRows[i].ADDRESS=='' ? '-':requestRows[i].ADDRESS),
							CITY:[{
								name:requestRows[i].CITY_POSTALCODE,
								STATE:[{
									abbr:requestRows[i].STATE,
									COUNTRY:{
										name:countryName
									}
								}]									
							}]
						}
						]});
	
	}else if(locationTypeHashTable.get(requestRows[i].LOCATION_TYPE)=='Poi') {		
		var countryAbbr =(states.get(requestRows[i].STATE)[1].toLowerCase()=='ca' ? 'can':'usa');		
		location.push( {POI:[{ id:requestRows[i].POI_ID,
			   type: requestRows[i].LOCATION_TYPE,
			   countryAbbr:countryAbbr
		}]}
		);
	}
	
	var vicinitysearch = new vicinitysearchREQUEST();
	
		vicinitysearch = {
								type:'vicinity search',
								LOCATION:location,
								PROXIMITY:[
										{
											distance:distance // if the distance is  too big, the WS return success, but with an empty list, that means a zoom in has to be 
											                  //made, smaller distance.
										}
									],
									SEARCH_ITEMS:[
							              {
							            	  SEARCH_ITEM:[
				            	               	{
				            	               		type: poiType
				            	               	}
							            	  ]
							              }
									],
									RETURN_ITEMS:{
										RETURN_ITEM:[
											{
												type:'all'
											}
						
										]
									}
									,
									REQUEST_ATTRIBUTES:
									{
										REQUEST_ATTRIBUTE:[
											{
												type:'kilometers'
						           			}	
						           		]
									}	
							};		
		isForm=false;	
		GisVicinitySearchService.doRequest(vicinitysearch,handleGetDataPoiList);		
}
/**
 * cette fonction affiche le html selon le type du poi GIS 
 * @param  : une liste des POI.  
 * @return
 */
function manageTableHtmlPoiInMap(poiList,poiType){
	 
	var tablePoiListHtml ='';
	var dontExistPoi='';
	var nbrPoi='';
	if(poiList.length ==0){
		dontExistPoi = "<tr><td>" + ressourceLang.get('no_poi_in_zone')
		+ "</td></tr>";
	}else{
		nbrPoi=" ("+poiList.length+")";
	}
	
	if(poiType=='gas'){
		
		tablePoiListHtml="<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>" +
		 "<tr>" +
		 "<th><img src='css/images/icones/"+poiType+".png' alt='attraction' width='18' height='18' />"
		 +poiTypeHashTable.get(poiType)
		 + nbrPoi
		 "</th>" +		 
		 "</tr>"+ dontExistPoi;
		if(poiList.length >0){
			for(var i=0; i< poiList.length; i++){
			   tablePoiListHtml+="<tr id='poiInMap_"+poiList[i].poiID+"_TR' h='#' onMouseOver=\"linkMouseEvent('"+poiList[i].poiID+"', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"+poiList[i].poiID+"', 'off'); return false;\">" +
						"<td>" +
						unescape(poiList[i].poiName)+
						"</td>" +
						"</tr>";		    
			}
		}

		tablePoiListHtml+="</table>";

		$(poiType+'DIV').innerHTML=tablePoiListHtml;
		

	}	
}

function manageTableHtmlPoiCenterServiceCaaDB(list,poiType){	
	var tablePoiListHtml ='';
	var dontExistPoi='';
	var nbrPoi='';
	if(list.length ==0){
		
	}else{
		nbrPoi=" ("+list.length+")";
	}
	if(list.length >0){
		for(var i=0; i< list.length; i++){
			tablePoiListHtml+="<tr id='poiInMap_"+list[i].servicecenter_id+"_TR' h='#' onMouseOver=\"linkMouseEvent('"+list[i].servicecenter_id+"', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"+list[i].servicecenter_id+"', 'off'); return false;\">" +
					"<td>" +					
					ressourceLang.get('caa_qc')+list[i].servicecentername+					
					"</td>" +					
					"</tr>";			
    		}
		}	
	htmlCaaDiv=tablePoiListHtml;	
}

/**
 * cette fonction affiche le tableau html selon le type du poi TDR 
 * @param  : une liste des POI.  
 * @return
 */
function manageTableHtmlPoiEventInMap(tdrList,poiType){
	var tablePoiListHtml = '';
	var dontExistPoi = '';
	var nbrPoi = '';
	if (tdrList.length == 0) {
		dontExistPoi = "<tr><td>" + ressourceLang.get('no_poi_in_zone')
				+ "</td></tr>";
	} else {
		nbrPoi = " (" + tdrList.length + ")";
	}
	

	if (poiType == 'lodging') {

		tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
				+ "<tr>"
				+ "<th><img src='css/images/icones/"
				+ poiType
				+ ".png' alt='"
				+ poiTypeHashTable.get(poiType)
				+ "' width='18' height='18' />"
				+ poiTypeHashTable.get(poiType)
				+ nbrPoi
				+ "</th>"
				+ "<th><img src='css/images/icones/photo_header.gif' alt='Photos' width='17' height='17' /></th>"
				+ "<th>Classement</th>" + "</tr>" + dontExistPoi;

		if (tdrList.length > 0) {
			for ( var i = 0; i < tdrList.length; i++) {
				var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
				tablePoiListHtml += "<tr id='poiInMap_"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "_TR' h='#' onclick=\"clk('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "'); return false;\" onMouseOver=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'off'); return false;\" onclick=\"clk('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "');\" >"
						+ "<td>"
						+poiId+unescape(tdrList[i].TRAVEL_ITEM_DISPLAY_NAME.content)
						+ "</td>"
						+ "<td>"
						+"<a class='greybox_general' onclick=\"greyboxAide('Aide','media/aide/reponses/reponse16.html');\" href='#'>"
						+ "<img src='css/images/icones/"
						+ (tdrList[i].GENS.GEN.PHOTO_AD_IND.content == 'N' ? 'noPhoto.png'
								: 'photo.png')
						+ "' alt='Voir les photos' width='17' height='17' />"
						+"</a>"
						+ "</td>"
						+ "<td>"
						+ getClassementPoiHtmlImage(
								tdrList[i].GENS.GEN.RED_SAVE_STATUS_IND.content,
								tdrList[i].GENS.GEN.RATING_CODE.content,poiType);
				"</td>" + "</tr>";
			}

		}
		tablePoiListHtml += "</table>";
		$(poiType + 'DIV').update(tablePoiListHtml);

	} else if (poiType == 'restaurant') {

		tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
				+ "<tr>"
				+ "<th><img src='css/images/icones/"
				+ poiType
				+ ".png' alt='"
				+ poiTypeHashTable.get(poiType)
				+ "' width='18' height='18' />"
				+ poiTypeHashTable.get(poiType)
				+ nbrPoi
				+ "</th>"
				+ "<th>Classement</th>"
				+ "</tr>"
				+ dontExistPoi;

		if (tdrList.length > 0) {
			for ( var i = 0; i < tdrList.length; i++) {
				var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
				tablePoiListHtml += "<tr id='poiInMap_"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "_TR' h='#' onMouseOver=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'off'); return false;\">"
						+ "<td>"
						+poiId+unescape(tdrList[i].TRAVEL_ITEM_DISPLAY_NAME.content)
						+ "</td>"
						+ "<td>"
						+ getClassementPoiHtmlImage(
								tdrList[i].GENS.GEN.RED_SAVE_STATUS_IND.content,
								tdrList[i].GENS.GEN.RATING_CODE.content,poiType);
				"</td>" + "</tr>";
			}

		}

		tablePoiListHtml += "</table>";
		$(poiType + 'DIV').update(tablePoiListHtml);

	} else if (poiType == 'campground') {

		tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
				+ "<tr>"
				+ "<th><img src='css/images/icones/"
				+ poiType
				+ ".png' alt='"
				+ poiTypeHashTable.get(poiType)
				+ "' width='18' height='18' />"
				+ poiTypeHashTable.get(poiType)
				+ nbrPoi
				+ "</th>"
				+ "<th>Classement</th>"
				+ "</tr>"
				+ dontExistPoi;

		if (tdrList.length > 0) {
			for ( var i = 0; i < tdrList.length; i++) {
				var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
				tablePoiListHtml += "<tr id='poiInMap_"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "_TR' h='#' onMouseOver=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'off'); return false;\">"
						+ "<td>"
						+poiId+unescape(tdrList[i].TRAVEL_ITEM_DISPLAY_NAME.content)
						+ "</td>"
						+ "<td>"
						+ getClassementPoiHtmlImage(
								tdrList[i].GENS.GEN.RED_SAVE_STATUS_IND.content,
								tdrList[i].GENS.GEN.RATING_CODE.content,poiType);
				"</td>" + "</tr>";
			}

		}

		tablePoiListHtml += "</table>";
		$(poiType + 'DIV').update(tablePoiListHtml);
} else if (poiType == 'attraction') {

	tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
			+ "<tr>"
			+ "<th><img src='css/images/icones/"
			+ poiType
			+ ".png' alt='"
			+ poiTypeHashTable.get(poiType)
			+ "' width='18' height='18' />"
			+ poiTypeHashTable.get(poiType)
			+ nbrPoi
			+ "</th>"
			+ "<th>Classement</th>"
			+ "</tr>"
			+ dontExistPoi;

	if (tdrList.length > 0) {
		for ( var i = 0; i < tdrList.length; i++) {
			var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
			tablePoiListHtml += "<tr id='poiInMap_"
					+ tdrList[i].TRAVEL_ITEM_ID.content
					+ "_TR' h='#' onMouseOver=\"linkMouseEvent('"
					+ tdrList[i].TRAVEL_ITEM_ID.content
					+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
					+ tdrList[i].TRAVEL_ITEM_ID.content
					+ "', 'off'); return false;\">"
					+ "<td>"
					+poiId+unescape(tdrList[i].TRAVEL_ITEM_DISPLAY_NAME.content)
					+ "</td>"
					+ "<td>"
					+ getGemHtmlImage(tdrList[i].GENS.GEN.GEM_IND.content);
			"</td>" + "</tr>";
		}

	}

	tablePoiListHtml += "</table>";
	$(poiType + 'DIV').update(tablePoiListHtml);
} else if (poiType == 'lmrch') {
		tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
				+ "<tr>"
				+ "<th><img src='css/images/icones/"
				+ poiType
				+ ".png' alt='"
				+ poiTypeHashTable.get(poiType)
				+ "' width='18' height='18' />"
				+ poiTypeHashTable.get(poiType)
				+ nbrPoi + "</th>" + "</tr>" + dontExistPoi;

		if (tdrList.length > 0) {
			for ( var i = 0; i < tdrList.length; i++) {
				var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
				tablePoiListHtml += "<tr id='poiInMap_"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "_TR' h='#' onMouseOver=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'off'); return false;\">"
						+ "<td>"
						+poiId+tdrList[i].GENS.GEN.PHYSICAL_LINE1_ADR.content
						+ ", "
						+ tdrList[i].GENS.GEN.PHYSICAL_CITY_DISPLAY_NAME.content
						+ ", "
						+ tdrList[i].GENS.GEN.PHYSICAL_STATE_PROVINCE_CODE.content
						+ " " + tdrList[i].GENS.GEN.PHYSICAL_ZIP_CODE.content
						+ "</td>" + "</tr>";

			}

		}

		tablePoiListHtml += "</table>";
		$(poiType + 'DIV').update(tablePoiListHtml);

	} else if (poiType == 'off_caa') {
		var dontExistPoiCaa="";
		var nbrPoiCaa="";
		if (tdrList.length == 0 && poiInMapHashTable.get('off_caa_qc').length==0) {
			dontExistPoiCaa = "<tr><td>" + ressourceLang.get('no_poi_in_zone')
					+ "</td></tr>";
		} else {
			nbrPoiCaa = " (" + (tdrList.length+poiInMapHashTable.get('off_caa_qc').length) + ")";
		}
		
		tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
				+ "<tr>"
				+ "<th><img src='css/images/icones/"				
				+ "caa_aaa.png' alt='"
				+ poiTypeHashTable.get(poiType)
				+ "' width='24' height='24' />"
				+ poiTypeHashTable.get(poiType)
				+ nbrPoiCaa + "</th>" + "</tr>" + dontExistPoiCaa;
		
		tablePoiListHtml+=htmlCaaDiv;

		if (tdrList.length > 0) {	
			for ( var i = 0; i < tdrList.length; i++) {
				var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
				tablePoiListHtml += "<tr id='poiInMap_"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "_TR' href='#' onMouseOver=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'off'); return false;\">" + "<td>"
						+poiId+unescape(tdrList[i].TRAVEL_ITEM_DISPLAY_NAME.content)
						+ "</td>" + "</tr>";
				}

		}
		tablePoiListHtml += "</table>";
		$(poiType + 'DIV').innerHTML=tablePoiListHtml;
		

	}
 else {
		tablePoiListHtml = "<table border='0' cellspacing='0' cellpadding='0' class='filteredDataBox'>"
				+ "<tr>"
				+ "<th><img src='css/images/icones/"
				+ poiType
				+ ".png' alt='"
				+ poiTypeHashTable.get(poiType)
				+ "' width='18' height='18' />"
				+ poiTypeHashTable.get(poiType)
				+ nbrPoi + "</th>" + "</tr>" + dontExistPoi;

		if (tdrList.length > 0) {
			for ( var i = 0; i < tdrList.length; i++) {
				var poiId=(debugGisTdr !='Y' ? '':"T-"+tdrList[i].TRAVEL_ITEM_ID.content+" | ");
				tablePoiListHtml += "<tr id='poiInMap_"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "_TR' href='#' onMouseOver=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'on'); return false;\" onMouseOut=\"linkMouseEvent('"
						+ tdrList[i].TRAVEL_ITEM_ID.content
						+ "', 'off'); return false;\">" + "<td>"
						+poiId+unescape(tdrList[i].TRAVEL_ITEM_DISPLAY_NAME.content)
						+ "</td>" + "</tr>";
			}

		}
		tablePoiListHtml += "</table>";
		$(poiType + 'DIV').update(tablePoiListHtml);
	}
	
}


/**
 * cette fonction affiche le html selon le type du poi CAADB  
 * @param  : une liste des POI.  
 * @return
 */
function manageTableHtmlPoiPartnersCaaDB(caaDBList,poiType){
	
	var tablePoiListHtml = '';
	var dontExistPoi = '';
	var nbrPoi = '';
	if (caaDBList.length == 0) {
		dontExistPoi = ressourceLang.get('no_poi_in_zone');
	} else {
		nbrPoi = " (" + caaDBList.length + ")";
	}
	
	$('partnerBoxMin' + poiType).update(
			'<h2><a href="#" onclick="showHidePoi(\'partnerBoxFull' + poiType
					+ '\',\'partnerBoxMin' + poiType
					+ '\');" class="showHide">' + content_lang.display
					+ '</a><img src="css/images/icones/header_' + poiType
					+ '.jpg" alt="' + poiTypeHashTable.get(poiType) + '" />'
					+ poiTypeHashTable.get(poiType) + nbrPoi + '</h2>');

	tablePoiListHtml += '<div id="partnerBoxFull' + poiType
			+ '" class="partnerBox">'
			+ '<h2><a href="#" onclick="showHidePoi(\'partnerBoxMin' + poiType
			+ '\',\'partnerBoxFull' + poiType + '\');" class="showHide">'
			+ content_lang.hide + '</a><img src="css/images/icones/header_'
			+ poiType + '.jpg" alt="' + poiTypeHashTable.get(poiType)
			+ '"></img>' + poiTypeHashTable.get(poiType) + nbrPoi + '</h2>'
			+ dontExistPoi;
     
	if(caaDBList.length >0){
		 
		 
		 tablePoiListHtml += '<ul>';
		for ( var i = 0; i < caaDBList.length; i++) {
			
			 var city = (caaDBList[i].city==null ? '':caaDBList[i].city);
			 var zipcode= (caaDBList[i].zipcode==null ? '':caaDBList[i].zipcode);  
			 var partnercenter_id =(caaDBList[i].partnercenter_id==null ? '':caaDBList[i].partnercenter_id);
			 var longitude=(caaDBList[i].longitude==null ? 0:caaDBList[i].longitude);
			 var latitude = (caaDBList[i].latitude==null ? 0:caaDBList[i].latitude);
			 var addressnumber=(caaDBList[i].addressnumber==null ? '':caaDBList[i].addressnumber);  
			 var addressstreet =(caaDBList[i].addressstreet==null ? '':caaDBList[i].addressstreet);  
			 var state =(caaDBList[i].state==null ? '':caaDBList[i].state);
			 
			tablePoiListHtml += "<li id=\"poiInMap_" + partnercenter_id
					+ "_TR\" onMouseOver=\"linkMouseEvent('" + partnercenter_id
					+ "', 'on');\" onMouseOut=\"linkMouseEvent('"
					+ partnercenter_id + "', 'off');\">" + addressnumber + ' '
					+ addressstreet + ', ' + city + ', ' + zipcode + '</li>';
		}
           
           
		tablePoiListHtml+= '</ul>';		
	}

	tablePoiListHtml += '</div>';
	$(poiType + 'DIV').update(tablePoiListHtml);
	var idMin = 'partnerBoxMin' + poiType;
	var idFull = 'partnerBoxFull' + poiType;	
	var str = $(idMin).getStyle('display');
	if (str == 'none') {
		$(idMin).style.display = 'none';
		$(idFull).style.display = 'block';
	} else {
		$(idMin).style.display = 'block';
		$(idFull).style.display = 'none';

	}
	
}
function getTableHtmlPoi(poiType){	
	eval('manageTablePoi_'+poiType+'(listofPOI);');
}
/**
 * cette fonction retourne le html selon le nombre de diamonds pour les classements  
 * @param  : le nombre du diamonds  
 * @return
 */
function getClassementPoiHtmlImage(typeOfDiamands,NumberOfDiamands,poiType){
	var imgHtml='';
	if(poiType=='lodging' || poiType=='restaurant'){
			if(NumberOfDiamands!=null &&typeOfDiamands!=null){
				imgHtml += "<a class='greybox_general' onclick=\"greyboxAide('Aide','media/aide/reponses/reponse16.html');\" href='#'>"; //media/aide/reponses/reponse16.html' target='_blank
					if(typeOfDiamands=='Y')	{
						
								for(var i=0 ; i< NumberOfDiamands;i++){
								imgHtml+="<img src='css/images/icones/diamant.png' alt='diamant' width='13' height='10' />";
								}
					}else{
						for(var i=0 ; i< NumberOfDiamands;i++){
							imgHtml+="<img src='css/images/icones/diamant_black.png' alt='diamant' width='13' height='10' />";
							}
					}
					imgHtml += "</a>"; 
			}
	}
	else if(poiType=='campground'){
		if(NumberOfDiamands!=null && NumberOfDiamands!='N'){
			imgHtml += "<a class='greybox_general' onclick=\"greyboxAide('Aide','media/aide/reponses/reponse16.html');\" href='#'>"; //media/aide/reponses/reponse16.html' target='_blank
			imgHtml+="<img src='css/images/icones/ratingcp"+NumberOfDiamands+".gif' alt='Classement' width='16' height='16' />";				
			imgHtml += "</a>"; 
		}
		
	}
	return imgHtml;
}

function getPricePoiHtmlImage(priceNumber){
	var imgHtml='';
	
	if(priceNumber!=null){
		imgHtml += "<a class='greybox_general' onclick=\"greyboxAide('Aide','media/aide/reponses/reponse16.html');\" href='#' >"; 
		for(var i=0 ; i< priceNumber;i++){
		imgHtml+="$";
		}
		imgHtml += "</a>"; 
	}
	return imgHtml;
}
function getSaveHtmlImage(isSave){
	var imgHtml='';
	if(isSave!=null && isSave=='Y'){
		imgHtml += "<a class='greybox_general' onclick=\"greyboxAide('Aide','media/aide/reponses/reponse16.html');\" href='#' >"; 
		imgHtml+="<img src='css/images/icones/rabais.gif' alt='save' />";
		imgHtml += "</a>"; 
	}
	return imgHtml;
}

function getGemHtmlImage(isGem){
	var imgHtml='';
	if(isGem!=null && isGem=='Y'){
		imgHtml += "<a class='greybox_general' onclick=\"greyboxAide('Aide','media/aide/reponses/reponse16.html');\" href='#' >"; 
		imgHtml+="<img src='css/images/icones/diamondgem.gif' alt='Classement' />";
		imgHtml += "</a>"; 
	}
	return imgHtml;
}

function getPartnersImagePub(imagepub){
	if(imagepub!=''){
		return "<img src='/caa-ttp/media/photos_partenaires_caa/"+imagepub+"' alt='' width='87' height='75' align='right'/>";
	}else{
		return "";
	}
}
function getDetailsBubbleHTML(poiType, index) {
	
	if (poiInMapHashTable.get(poiType)[index].AD_ITEMS.AD_ITEM.length > 0) {
		for (i = 0; i < poiInMapHashTable.get(poiType)[index].AD_ITEMS.AD_ITEM.length; i++) {
			if (poiInMapHashTable.get(poiType)[index].AD_ITEMS.AD_ITEM[i].AD_ITEM_TYPE.content == "SLIDESHOW_AD") {
				if (poiInMapHashTable.get(poiType)[index].AD_ITEMS.AD_ITEM[i].FILE_NAME != null) {
					var id = poiInMapHashTable.get(poiType)[index].AD_ITEMS.AD_ITEM[i].DIRECTORY.content
							+ "/"
							+ poiInMapHashTable.get(poiType)[index].AD_ITEMS.AD_ITEM[i].FILE_NAME.content;	
			
					return "<p align=\"center\"><a href=\"#\" id='bubbleGreyBox' class=\"greybox\" title=\""
                    + poiInMapHashTable.get(poiType)[index].TRAVEL_ITEM_DISPLAY_NAME.content
                    + "\" onclick=\"greyboxBubble('"
                    + poiInMapHashTable.get(poiType)[index].TRAVEL_ITEM_DISPLAY_NAME.content
                    + "','/caa-ttp/photos?id="
                    + id
                    + "&isone=N');document.getElementById('iframebubble').style.display='none';\">"
                    + ressourceLang.get('bubble_view_photos')
                    + "</a></p>" +      
                    "<iframe name='iframebubble' id='iframebubble' style=\"background-color: transparent; background: transparent; filter: alpha(opacity=20); border-width:0px; margin : 0px;padding : 0px;\" src =\"/caa-ttp/photos?id="
                    + id
                    + "&isone=Y\"  FRAMEBORDER='0' SCROLLING='no' MARGINWIDTH='0' MARGINHEIGHT='0' WIDTH='133px' HEIGHT='133px' ALLOWTRANSPARENCY='true' ></iframe>";
				}
			}
		}

	} else {
		return "N'est pas disponible";
	}	
}
/**
 * The user function call after a pan or zoom event 
 * @param   
 * @return
 */
function userEventBubbleInMap()
{
// Removes all the existing POI information
map.userPOIService.removeAll();     
var	poiInMap={
			label:'',
			id:'',
			y:'',
			x:'',
			text:''			
	};

var poiInMapArray =[];
if(zoomLevelGlobal <= 7){
poiInMapHashTable.each(function(pair){	

	if(pair.value.length>0){		
		
	
		   for(var i=0 ; i< pair.value.length; i++){
			// Creating the POI information.  This POI has several tabs		
					  if(TypeTdrOrGisHashTable.get(pair.key)=='TDR' || TypeTdrOrGisHashTable.get(pair.key)=='GIS'){
						  
						  var pt =null;
						  var p =null;
						  var urlImage="";
						 if(pair.key=='off_caa_qc' ){
							  pt = new ttp_point(pair.value[i].longitude,pair.value[i].latitude, "Geo");
					    	  p = new ttp_userPOI(pt,String.interpret(pair.value[i].servicecenter_id),ressourceLang.get('caa_qc')+unescape(pair.value[i].servicecentername));
					    	  urlImage="css/images/mapIcones/"+pair.key+".png";
						 }else{	
							 var poiId=(debugGisTdr !='Y' ? '':"T-"+pair.value[i].TRAVEL_ITEM_ID.content+" | ");
						     pt = new ttp_point(pair.value[i].GENS.GEN.LONGITUDE.content,pair.value[i].GENS.GEN.LATITUDE.content, "Geo");
				    	     p = new ttp_userPOI(pt, pair.value[i].TRAVEL_ITEM_ID.content,poiId+unescape(pair.value[i].TRAVEL_ITEM_DISPLAY_NAME.content));
				    	     if( pair.value[i].GENS.GEN.PHYSICAL_COUNTRY_NAME.content !='CANADA' && pair.key=='off_caa'){
								 urlImage="css/images/mapIcones/off_aaa.png";
							 }else{
								 urlImage="css/images/mapIcones/"+pair.key+".png";
							 }
						    						
						 }
						 
						   var img = new ttp_image(urlImage,24,24);
						    p.addImage(img);						    
						    var bubbleText = getTemplateBubble(pair.key,i);						    
						    if(pair.key=='lodging' && pair.value[i].GENS.GEN.PHOTO_AD_IND!=null){
						    	if(pair.value[i].GENS.GEN.PHOTO_AD_IND.content!='N'){
						    		p.addBubbleTabs([new ttp_tab(ressourceLang.get('bubble_resume'),bubbleText ), new ttp_tab(ressourceLang.get('bubble_photos'), getDetailsBubbleHTML(pair.key,i))], 20);						    		
						    	}else{
						    		p.addBubbleText(bubbleText);
						    	}
						    	
						    }else{						       
						    	p.addBubbleText(bubbleText);
						    }					    
						    
						    map.userPOIService.addPOI(p);
						
							// Adding event listeners to a POI
						    map.addListener(p, "mouseOver", over);
						    map.addListener(p, "mouseOut", out);
						    map.addListener(p, "click", clk);
						  
					  }else if(TypeTdrOrGisHashTable.get(pair.key)=='GIS_CAADB'){   
			                  
					           var pt = new ttp_point(mercx2long(pair.value[i].long),mercy2lat(pair.value[i].lat), "Geo");
					    	   var p = new ttp_userPOI(pt, pair.value[i].poiID, pair.value[i].poiName);
							   var urlImage="css/images/mapIcones/"+pair.key+".png";
	
							   var img = new ttp_image(urlImage, 24,24);
							    p.addImage(img);
							    var bubbleText = getTemplateBubble(pair.key,i);							    
							    p.addBubbleText(bubbleText);							    
							    map.userPOIService.addPOI(p);							
								// Adding event listeners to a POI
							    map.addListener(p, "mouseOver", over);
							    map.addListener(p, "mouseOut", out);
							    map.addListener(p, "click", clk);
							    
					  }else if(TypeTdrOrGisHashTable.get(pair.key)=='CAADB'){
						  
				           var pt = new ttp_point(pair.value[i].longitude,pair.value[i].latitude, "Geo");
				    	   var p = new ttp_userPOI(pt,String.interpret(pair.value[i].partnercenter_id), pair.value[i].centername);
				    	   var urlImage="";
				    	   if(pair.key=="couchetard_tous" && pair.value[i].gasoline=="Y" ){
				    		    urlImage="css/images/icones/mapcouchetard_essence.png";
				    	    }else{
				    		    urlImage="css/images/icones/map"+pair.key+".png";   
				    	     }  
	
						   var img = new ttp_image(urlImage, 18, 18);
						    p.addImage(img);
						    var bubbleText = getTemplateBubble(pair.key,i);
						    p.addBubbleText(bubbleText);
						    
						    map.userPOIService.addPOI(p);
						
							// Adding event listeners to a POI
						    map.addListener(p, "mouseOver", over);
						    map.addListener(p, "mouseOut", out);
						    map.addListener(p, "click", clk);
				  }else if(TypeTdrOrGisHashTable.get(pair.key)=='CAAIPR'){
					  
					  var pt = new ttp_point(pair.value[i].longitude,pair.value[i].latitude, "Geo");
			    	   var p = new ttp_userPOI(pt,String.interpret(pair.value[i].info_id), pair.value[i].type_id_object.typenamefr);
			    	   var urlImage="css/images/mapIcones/"+pair.key+".png";
			    	   var img = new ttp_image(urlImage, 18, 18);
					   p.addImage(img);
					   var bubbleText = getTemplateBubble(pair.key,i);
					   p.addBubbleText(bubbleText);					    
					   map.userPOIService.addPOI(p);					
						// Adding event listeners to a POI
					    map.addListener(p, "mouseOver", over);
					    map.addListener(p, "mouseOut", out);
					    map.addListener(p, "click", clk);
				  }
		   }
		
	}	
	
	});
}
// créer le points de destination recherchée
   addPrincipalLocalisation();
// Update the map with the OPOI information
    map.userPOIService.update();
 //   poiInMapArray.clear();   
    map.show();    

}
/**
 * cette fonction pour effacer les poi choisies de la carte 
 * @param : le type du poi soit restaurant, lodging ou autres 
 * @return
 */
function removePoiTypeFromMap(poiType) {
	if(poiType=='couchetard_tous'){
		poiInMapHashTable.get('circle_k').clear();
	}
	poiInMapHashTable.get(poiType).clear();
	userEventBubbleInMap();
}
/** *************************************************************************************************** */

/**
* Cette fonction gnere un seul fieldset soit ouvert ou fermé dans le cas de la localisation     
* @param :  
* @return :
*/
function generateLocalisationForm(){
	var i=0; 
	$('quickRoute').update(); //FAUT VIDER LE FORMULAIRE POUR NE PLUS AVOIR LE MEME  ID FIELDSET DANS LE CAS LOCALISATION
	$('localisationDiv').update();	
	$('localisationDiv').update(getDestinationFieldset(requestRows[i],i));			
		if(requestRows[i].SHOW_DETAIL == 'false'){
			$('moveUp_dsbl_0').remove();
			$('moveDown_0').remove();
			$('delete_0').remove();
		}				
}
/**
* Cette fonction cherche la localisation dans la carte      
* @param :  
* @return :
*/
function getCardLocalisation(){		
    	var i=0;
    	isInfo=false;
    	onloadMap = 'N'; 
    	
    	
    	// verifier si la localisation est valide avant de creer la carte
    		if(requestRows[i].SHOW_DETAIL=='true'){	    			
    			 saveItinerary($('response').value,$('stat').value,$('city').value,$('destination_type').value,$('address').value,$('city_postalCode').value,'false',i,'modifier',$('response').selectedIndex,$('city').selectedIndex,$('eventDate').value, $('eventDateto').value); 			
    		}
    		
    	   	if((requestRows[i].LOCATION_TYPE=='Address' || requestRows[i].LOCATION_TYPE=='Ville')&& (requestRows[i].CITY_POSTALCODE!='' || requestRows[i].ADDRESS!='')){    				
    	   		
    	   		    if(requestRows[i].CITY_POSTALCODE!='' && requestRows[i].CITY_POSTALCODE.match(/(\w\d\w) (\d\w\d)/)){    	   		    	
    	   		    	getLonLatFromPostalCode(requestRows[i].CITY_POSTALCODE.toUpperCase());
    	   		    }else{   
    	   		        currentIndexLocationValidation=i;
    	   		    	adressLocationValidationRequest(i);
    	   		    }
	  		}
    	   	else if(locationTypeHashTable.get(requestRows[i].LOCATION_TYPE)=='Poi'){
    	   		
				 if(TypeTdrOrGisHashTable.get(requestRows[i].LOCATION_TYPE)=='TDR'){	
					 
						if(requestRows[i].LONG==0 || (requestRows[i].LOCATION_TYPE=='event' && ($('eventDate').value=='' || $('eventDateto').value=='' ||  $('response').value==''))){
							alert(ressourceLang.get('error_message'));
							return false;
						}
					 
						 long=requestRows[i].LONG;
						 lat= requestRows[i].LAT;					
						 errorIsPresent='false';	
						 getMapLocPoi();
					
				 }else{
		           findNearPoiVicinitySearchSendRequestLoc(12);
				 }
				 
		     }else{
		    	 
		    	 alert(ressourceLang.get('error_message'));
					return false;
		     } 
    	   
		
}
function getLonLatFromPostalCode(CITY_POSTALCODE){
	isForm=false;
	CaaDbPostalCodeService.getPostalCodeGeo(CITY_POSTALCODE,{callback:handleGetDataPostalCode,async:false});
	
}


function getMapLocPoi() {

	if (errorIsPresent == 'false') {
		hideDetail();
		generateLocalisationForm();
		isYourSearchHide=true;
		if (map == null) {			
			createMap(long, lat, controllevel);
			showHidePoi('fullTopBox', 'minTopBox');
		} else {
			
			updateMap(long, lat, controllevel);
			showHidePoi('fullTopBox', 'minTopBox');
		}
		
	}
}

/**
 * fonction AJAX qui cherche un ensemble des informations a l'entourage d'une destination donnée 
 * @param  : longitude, latitude et une liste de type de poi 
 * @return
 */
function panZoomvicinitySearchSendRequest(panZoomLong,panZoomLat,poiTypeList){
	
	var i=0;
	var distance ='15';	
	var SearchItems =[];
	
	for(i=0; i< poiTypeList.length;i++){
	if(TypeTdrOrGisHashTable.get(poiTypeList[i])=='GIS'){
			SearchItems.push({ SEARCH_ITEM:[{type: poiTypeList[i]}]});
		}
	}	
	var vicinitysearch = new vicinitysearchREQUEST();
	
		vicinitysearch = {
								type:'vicinity search',
								LOCATION:[
										{
											GEOPOINT :
												{													
													Type:'World',
													long:panZoomLong,
													lat:panZoomLat
												}
											
										 }
									],
									PROXIMITY:[
										{
											distance:distance //if the distance is too big, the WS return success, but with an empty list, that means a zoom in has to be made, smaller distance. 
										}
									],
									SEARCH_ITEMS:SearchItems,
									RETURN_ITEMS:{
										RETURN_ITEM:[
											{
												type:'all'
											}
						
										]
									}
							};		
		isForm=false;	
		GisVicinitySearchService.doRequest(vicinitysearch,{callback:handleGetDataPanZoomPoiList,async:false});
		 
}

function updateMap(longitude, latitude, zoomLevel) {
	zoomLevelGlobal = zoomLevel;	
	if (zoomLevel <= 7) {
		map.newMap(long2Mercx(long), lat2Mercy(lat), zoomLevel);
		userEventBubbleInMap();
	}
}


function findNearPoiVicinitySearchSendRequest(distance){
	var j=0;	
	var location=[];		
		var countryAbbr =(states.get(requestRows[j].STATE)[1].toLowerCase()=='ca' ? 'can':'usa');		
		location.push( {POI:[{ id:requestRows[j].POI_ID,
			   type: requestRows[j].LOCATION_TYPE,
			   countryAbbr:countryAbbr
		}]}
		);
		
	var vicinitysearch = new vicinitysearchREQUEST();
	
		vicinitysearch = {
								type:'vicinity search',
								LOCATION:location,
								PROXIMITY:[
										{
											distance:0.01 //if the distance is too big, the WS return success, but with an empty list, that means a zoom in has to be made, smaller distance. 
										}
									],
									SEARCH_ITEMS:[
							              {
							            	  SEARCH_ITEM:[
							            	    {
							            	    	type: requestRows[j].LOCATION_TYPE
												}		            	               	
							            	  ]
							              }							             
									],
									RETURN_ITEMS:{
										RETURN_ITEM:[
											{
												type:'GEOPOINT'
											}
						
										]
									}
									
									
							};
		
		isForm=false;	
		GisVicinitySearchService.doRequest(vicinitysearch,{callback:handleGetDataFindNearPoi,async:false});		 
}
function validateVincitySearch(index){
	
	for(i=0;i <requestRows.length ;i++) {
		if(requestRows[i].SHOW_DETAIL=='true'){		
			
			saveItinerary($('response').value,$('stat').value,$('city').value,$('destination_type').value,$('address').value,$('city_postalCode').value,'false',i,'modifier',$('response').selectedIndex,$('city').selectedIndex,$('eventDate').value, $('eventDateto').value);
			
			if(($('destination_type').value=='Address' || $('destination_type').value=='Ville')&& ($('city_postalCode').value!='' || $('address').value!='')){
	
				currentIndexLocationValidation=i;	
				  adressLocationValidationRequest(index);
				 
			}else{
				
				 errorIsPresent='true'	; 
			}
	
			
			
			 if(showPage=='localisation' && locationTypeHashTable.get(requestRows[i].LOCATION_TYPE)=='Poi'){
				 
				 if(TypeTdrOrGisHashTable.get(requestRows[i].LOCATION_TYPE)=='TDR'){
					 
					 long=requestRows[i].LONG;
					 lat= requestRows[i].LAT;
					 errorIsPresent='false'	; 
				 }else{
		          findNearPoiVicinitySearchSendRequest(12);
				 }
		      } 
	
		 
		}else{
			 errorIsPresent='false'; 
		}	
	

		
	}
	if(requestRows[index].ERROORISPRESENT=='true' && requestRows[currentIndexLocationValidation].ERROORISPRESENT=='true'){
		requestRows[index].SHOW_DETAIL='false';
		var idError='errMsgItinerary'+currentIndexLocationValidation;				
		generateLocalisationForm();	
		$(idError).update(suggestionHtml);	 
		
	}
	
}
// traduire le HTML pan-zoom
function panZoomToolsHTML(){
	
	$('dZoomToolLabels').innerHTML ='<div class="cZLabel" style="top: 71px; left: -4px;">'+ressourceLang.get('pan_country')+'</div>'+
								    '<div class="cZLabel" style="top: 107px; left: 9px;">'+ressourceLang.get('pan_state')+'</div>'+
								    '<div class="cZLabel" style="top: 179px; left: 16px;">'+ressourceLang.get('pan_city')+'</div>'+
								    '<div class="cZLabel" style="top: 215px; left: 6px;">'+ressourceLang.get('pan_street')+'</div>';
	

$('dPanRight').innerHTML='<img height="25" width="21" title="'+ressourceLang.get('pan_right')+'" alt="'+ressourceLang.get('pan_right')+'" src="http://63.240.178.68/PublishingDynamicMap/I/panRight.gif" name="iPanRight"/>';     
$('dPanLeft').innerHTML= '<img height="25" width="20" title="'+ressourceLang.get('pan_left')+' " alt="'+ressourceLang.get('pan_left')+' " src="http://63.240.178.68/PublishingDynamicMap/I/panLeft.gif" name="iPanLeft"/>';    
$('dPanDown').innerHTML ='<img height="21" width="25" title="'+ ressourceLang.get('pan_down')+'" alt="'+ ressourceLang.get('pan_down')+'" src="http://63.240.178.68/PublishingDynamicMap/I/panDown.gif" name="iPanDown"/>';
$('dPanUp').innerHTML='<img height="20" width="25" title="'+ressourceLang.get('pan_up')+'" alt="'+ressourceLang.get('pan_up')+'" src="http://63.240.178.68/PublishingDynamicMap/I/panUp.gif" name="iPanUp"/>';     
$('dPanReset').innerHTML='<img height="20" width="20" title="'+ressourceLang.get('pan_reset')+' " alt="'+ressourceLang.get('pan_reset')+' " src="http://63.240.178.68/PublishingDynamicMap/I/panReset.gif" name="iPanReset"/>';

     for(var i=1; i<15 ;i++){
    	 
		$('dZbL'+i).down(0).title = ressourceLang.get('zoom_level')+i;
		$('dZbL'+i).down(0).alt = ressourceLang.get('zoom_level')+i;
     }
    
}
function findNearEventSearchSendRequest(poiType,xMin, yMin, xMax, yMax){
	
	var urlTdrEvent = new urlTdrHttpRequest();	
	urlTdrEvent = {				host:'',							    
							    profile:'',
							    dateFormat:'',
							    user:'',							    
							    database:'',
							    style:'',
							    var0:'',
							    type0:'', 
							    val0:'',
							    var1:'',
							    type1:'',
							    val1:'',
							    var2:'',
							    type2:'',
							    val2: '',
							    var3:'',
							    type3:'',
							    val3: '',
							    var4:'',
							    type4:'',
							    val4: '',
							    var5:'',
							    type5:'',
							    val5: '',
							    var6:'',
							    type6:'',
							    val6:'',
							    var7:'',
							    type7:'',
							    val7:'',
							    var8:'',
							    type8:'', 
							    val8:'',
							    var9:'',
							    type9:'',
							    val9:''			        
									
				  };
	   if(poiType=='event'){	
		   		   				
		    urlTdrEvent.profile = 'EVENTS_IN_LONGLAT';
		    urlTdrEvent.var0='MINDATE';
		    urlTdrEvent.type0='STRING'; 
		    urlTdrEvent.val0='';
		    urlTdrEvent.var1='MAXDATE';
		    urlTdrEvent.type1='STRING';
		    urlTdrEvent.val1= '';
		    urlTdrEvent.var2='LATMAX';
		    urlTdrEvent.type2='NUMBER';
		    urlTdrEvent.val2= yMax; 
		    urlTdrEvent.var3='LATMIN';
		    urlTdrEvent.type3='NUMBER';
		    urlTdrEvent.val3= yMin;
		    urlTdrEvent.var4='LONGMAX';
		    urlTdrEvent.type4='NUMBER';
		    urlTdrEvent.val4= xMax;
		    urlTdrEvent.var5='LONGMIN';
		    urlTdrEvent.type5='NUMBER';
		    urlTdrEvent.val5= xMin;	   
	   }else{	
		   var val0 ="";
		   if(poiType=='lodging'){
			   val0='ACCOMMODATION';
		   }else if(poiType=='off_caa'){
			   val0='CLUB%20OFFICE';
		   }else if(poiType=='hertz'){
			   val0='CAR%20RENTAL';
		   }else{
			   val0=poiType.toUpperCase();
		   }
		   
		    urlTdrEvent.profile = 'POI_IN_LONGLAT';
		    urlTdrEvent.var0='POINAME';
		    urlTdrEvent.type0='STRING'; 
		    urlTdrEvent.val0=val0;
		    urlTdrEvent.var1='';
		    urlTdrEvent.type1='';
		    urlTdrEvent.val1='';
		    urlTdrEvent.var2='LATMAX';
		    urlTdrEvent.type2='NUMBER';
		    urlTdrEvent.val2= yMax; 
		    urlTdrEvent.var3='LATMIN';
		    urlTdrEvent.type3='NUMBER';
		    urlTdrEvent.val3= yMin;
		    urlTdrEvent.var4='LONGMAX';
		    urlTdrEvent.type4='NUMBER';
		    urlTdrEvent.val4= xMax;
		    urlTdrEvent.var5='LONGMIN';
		    urlTdrEvent.type5='NUMBER';
		    urlTdrEvent.val5= xMin;	   
	   }
	   isForm=false;
	   if((TypeTdrOrGisHashTable.get(poiType)=='TDR' || TypeTdrOrGisHashTable.get(poiType)=='GIS')&& poiType!= 'off_caa_qc'){		 
	    TdrEventSearchService.doRequest(urlTdrEvent,{callback:eval(poiType+'HandleGetDataFindNearPoi')});		   
	   }		 
}
function getPartnersInMap(partnersID, longMin, latMin, longMax, latMax){	
	isForm = false;
	if(partnersID=='couchetard_tous'){
		CaaDbPartnersService.doRequest('circle_k', longMin, latMin, longMax,
				latMax, {
					callback : circle_kHandleGetDataPartnersCaa
				});
	}
	CaaDbPartnersService.doRequest(partnersID, longMin, latMin, longMax,
			latMax, {
				callback : eval(partnersID + 'HandleGetDataPartnersCaa')
			});

}
function getCentersServiceInMap(longMin, latMin, longMax, latMax) {
	isForm = false;
	CaaDbPartnersService.doRequestServiceCentersInMap(longMin, latMin, longMax,
			latMax, {
				callback : off_caaHandleGetDataCenterCaa,
				async : false
			});
}
function getPDFPartners() {

	var xMin = map.scale.xScreen2Merc(map.view.left);
	var yMin = map.scale.yScreen2Merc(map.view.bottom);
	var xMax = map.scale.xScreen2Merc(map.view.right);
	var yMax = map.scale.yScreen2Merc(map.view.top);	
	isForm = false;
	CaaDbPartnersService.pdfPartnerRequest(partnerIdList, mercx2long(xMin),
			mercy2lat(yMin), mercx2long(xMax), mercy2lat(yMax), {
				callback : handleGetDataPdfPartners,
				async : false
			});
}
function showHidePartners() {

	if ($('Partners').checked) {
		$('filtrepartenaire').style.display = 'block';
		$('partnerDiv').className= 'activeTab';
		$('couchetard_tousCheckbox').checked = true;
		$('familiprixCheckbox').checked = true;		
		poiSearchInCard('familiprix');
		poiSearchInCard('couchetard_tous');		
	}else {	
		verifyCheckedPartnerDollars();
		$('filtrepartenaire').style.display = 'none';
		$('partnerDiv').className= '';
	}
}
function getPoiPartnerInCard(poiType) {	
	partnerIdList.push(poiType);	
	poiTypeList.push(poiType);
}
function gePrincipalePoiBubbleHTML(index){
var data
	
    if (requestRows[index].RESPONSE != ''
			&& locationTypeHashTable.get(requestRows[index].LOCATION_TYPE) == 'Poi') {
		data = "<div class='bubbleTitleline'><span>"
				+ destinationTypeHashTable
						.get(requestRows[index].LOCATION_TYPE)
				+ "</span></div><div class='bubbleTitleline'><span>"
				+ (unescape(requestRows[index].RESPONSE)
						+ "</span></div><div class='bubbleInfo'>"
						+ requestRows[index].CITY + " " + states
						.get(requestRows[index].STATE)[0])
				+(requestRows[index].LOCATION_TYPE=='event' ? "<p align=\"center\">"+ressourceLang.get('bubble_event_date_from')+ requestRows[index].DATE_FROM+ressourceLang.get('bubble_event_date_to')+ requestRows[index].DATE_TO+"</p>":"")
				+ "<p align=\"center\">"+ressourceLang.get('click_tokip_open')+"</p></div>";
		
	} else if (requestRows[index].CITY_POSTALCODE != ''
			&& requestRows[index].ADDRESS == ''
			&& locationTypeHashTable.get(requestRows[index].LOCATION_TYPE) == 'Address') {
		data = "<div class='bubbleTitleline'><span>"
				+ destinationTypeHashTable
						.get(requestRows[index].LOCATION_TYPE)
				+ "</span></div><div class='bubbleInfo'>"
				//+ requestRows[index].CITY_POSTALCODE.replace(/(\w\d\w) (\d\w\d)/, '$1')
				+ requestRows[index].CITY_POSTALCODE
				+ (requestRows[index].CITY_POSTALCODE!=null && requestRows[index].CITY_POSTALCODE!='' ? ", ":"")
				+ requestRows[index].CITY
				+ ", "
				+ states.get(requestRows[index].STATE)[0]
				+ "<p align=\"center\">"+ressourceLang.get('click_tokip_open')+"</p></div>";

	} else if (requestRows[index].ADDRESS != ''
			&& locationTypeHashTable.get(requestRows[index].LOCATION_TYPE) == 'Address') {
		data = "<div class='bubbleTitleline'><span>"
				+ destinationTypeHashTable
						.get(requestRows[index].LOCATION_TYPE)
				+ "</span></div><div class='bubbleInfo'>"
				+ requestRows[index].ADDRESS
				+ ", "
				//+ requestRows[index].CITY_POSTALCODE.replace(/(\w\d\w) (\d\w\d)/, '$1')
				+ requestRows[index].CITY_POSTALCODE
				+ (requestRows[index].CITY_POSTALCODE!=null && requestRows[index].CITY_POSTALCODE!='' ? ", ":"")
				+ states.get(requestRows[index].STATE)[0]
				+ "<p align=\"center\">"+ressourceLang.get('click_tokip_open')+"</p></div>";

	}
	
	return data;
	
}


function addPoiItinerary(poiType,index){
	requestRows.push(getEmptyDestination());	
	if(TypeTdrOrGisHashTable.get(poiType)=='TDR' || TypeTdrOrGisHashTable.get(poiType)=='GIS'){		
	requestRows[(requestRows.length-1)].CITY = poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_CITY_NAME.content;
	requestRows[(requestRows.length-1)].STATE ='quebec';//poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_STATE_PROVINCE_CODE.content;
	requestRows[(requestRows.length-1)].RESPONSE =poiInMapHashTable.get(poiType)[index].ITEM_NAME.content;
	requestRows[(requestRows.length-1)].LOCATION_TYPE = poiType;
	requestRows[(requestRows.length-1)].ADDRESS =poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_LINE1_ADR.content;
	requestRows[(requestRows.length-1)].CITY_POSTALCODE = poiInMapHashTable.get(poiType)[index].GENS.GEN.PHYSICAL_ZIP_CODE.content;
	requestRows[(requestRows.length-1)].POI_ID =poiInMapHashTable.get(poiType)[index].GENS.GEN.TRAVEL_ITEM_ID.content;
	requestRows[(requestRows.length-1)].RESPONSE_SELECTED_INDEX = 0;
	requestRows[(requestRows.length-1)].CITY_SELECTED_INDEX = 0;
	requestRows[(requestRows.length-1)].LONG =poiInMapHashTable.get(poiType)[index].GENS.GEN.LONGITUDE.content;
	requestRows[(requestRows.length-1)].LAT = poiInMapHashTable.get(poiType)[index].GENS.GEN.LATITUDE.content;
	requestRows[(requestRows.length-1)].DATE = '';
	requestRows[(requestRows.length-1)].SHOW_DETAIL = 'false';
	requestRows[(requestRows.length-1)].ERROORISPRESENT = 'false';
	}else if(TypeTdrOrGisHashTable.get(poiType)=='CAADB'){
		
		 var city = (poiInMapHashTable.get(poiType)[index].city==null ? '':poiInMapHashTable.get(poiType)[index].city);
		 var city_postalcode= (poiInMapHashTable.get(poiType)[index].zipcode==null ? '':poiInMapHashTable.get(poiType)[index].zipcode);  
		 var poiid =(poiInMapHashTable.get(poiType)[index].partnercenter_id==null ? '':poiInMapHashTable.get(poiType)[index].partnercenter_id);
		 var longitude=(poiInMapHashTable.get(poiType)[index].longitude==null ? 0:poiInMapHashTable.get(poiType)[index].longitude);
		 var latitude = (poiInMapHashTable.get(poiType)[index].latitude==null ? 0:poiInMapHashTable.get(poiType)[index].latitude);
		 var addressNumber=(poiInMapHashTable.get(poiType)[index].addressnumber==null ? '':poiInMapHashTable.get(poiType)[index].addressnumber);  
		 var addressStreet =(poiInMapHashTable.get(poiType)[index].addressstreet==null ? '':poiInMapHashTable.get(poiType)[index].addressstreet); 
		
		requestRows[(requestRows.length-1)].CITY = city;
		requestRows[(requestRows.length-1)].STATE ='quebec';//poiInMapHashTable.get(poiType)[index].STATE;
		requestRows[(requestRows.length-1)].RESPONSE ='';
		requestRows[(requestRows.length-1)].LOCATION_TYPE='Address';
		requestRows[(requestRows.length-1)].ADDRESS =addressNumber+' '+ addressStreet;
		requestRows[(requestRows.length-1)].CITY_POSTALCODE =city_postalcode;
		requestRows[(requestRows.length-1)].POI_ID =poiid;
		requestRows[(requestRows.length-1)].RESPONSE_SELECTED_INDEX = 0;
		requestRows[(requestRows.length-1)].CITY_SELECTED_INDEX = 0;
		requestRows[(requestRows.length-1)].LONG =longitude;
		requestRows[(requestRows.length-1)].LAT = latitude;
		requestRows[(requestRows.length-1)].DATE = '';
		requestRows[(requestRows.length-1)].SHOW_DETAIL = 'false';
		requestRows[(requestRows.length-1)].ERROORISPRESENT = 'false';	
		
	}
	showHide('itineraire','localisation');	
	return true;
	
}
/**
 * fonction AJAX qui cherche un ensemble des informations a l'entourage d'une destination donnée 
 * @param  : longitude, latitude et une liste de type de poi 
 * @return
 */
function gasvicinitySearchSendRequest(){
	
	var i=0;
	var distance ='2';	
	var countryAbbr =(states.get(requestRows[i].STATE)[1].toLowerCase()=='ca' ? 'CAN':'USA');
	
		
	var vicinitysearch = new vicinitysearchREQUEST();
		
	var xMin = map.scale.xScreen2Merc(map.view.left);
  	var yMin = map.scale.yScreen2Merc(map.view.bottom);
  	var xMax = map.scale.xScreen2Merc(map.view.right);
  	var yMax = map.scale.yScreen2Merc(map.view.top);
	var panZoomLong= (xMin+xMax)/2 ;
	var panZoomLat = (yMin+yMax)/2 ;	
	
	if(long==0 && lat==0){
		panZoomLat=0;
		panZoomLong=0;
	} 
				vicinitysearch = {
						type : 'vicinity search',
						LOCATION : [	
							{
					           GEOPOINT:{
								long : mercx2long(panZoomLong),
								lat : mercy2lat(panZoomLat)					            	
							    }
							}],
						PROXIMITY : [ {
							distance : distance
						// if the distance is too big, the WS return success, but with an empty
						// list, that means a zoom in has to be made, smaller distance.
						} ],
						SEARCH_ITEMS : [ {
							SEARCH_ITEM : [ {
								 type:"gas"
							} ]
						} ],
						RETURN_ITEMS : {
							RETURN_ITEM : [ {
								type : 'all'
							}
			
							]
						}
			
					};
	
	
			/*		vicinitysearch = {
								type:'vicinity search',
								LOCATION:[
										{
											ADDRESS:[
											         {
											           location:"-", 
											           CITY:[
											             {
											               name:(requestRows[i].CITY==''? requestRows[i].STATE:requestRows[i].CITY), 
											               STATE:[
											                 {
											                   abbr:requestRows[i].STATE, 
											                   COUNTRY:{name:countryAbbr}
											                 }
											               ]
											             }
											           ]
											         }
											       ]

										 }
									],
									PROXIMITY:[
										{
											distance:distance //if the distance is too big, the WS return success, but with an empty list, that means a zoom in has to be made, smaller distance. 
										}
									],
									 SEARCH_ITEMS:[
									               {
									                 SEARCH_ITEM:[
									                   {
									                     type:"gas"
									                   }
									                 ]
									               }
									             ], 
									RETURN_ITEMS:{
										RETURN_ITEM:[
											{
												type:'all'
											}
						
										]
									}
							};	*/	
		isForm=false;	
		GisVicinitySearchService.doRequest(vicinitysearch,{callback:handleGetDataPanZoomPoiList});				 
}
//TODO: a voir la logique pour ne pas dupliquer la meme fonction
function findNearPoiVicinitySearchSendRequestLoc(distance) {
	var j = 0;
	var location = [];

	var countryAbbr = (states.get(requestRows[j].STATE)[1].toLowerCase() == 'ca' ? 'can'
			: 'usa');
	location.push( {
		POI : [ {
			id : requestRows[j].POI_ID,
			type : requestRows[j].LOCATION_TYPE,
			countryAbbr : countryAbbr
		} ]
	});

	var vicinitysearch = new vicinitysearchREQUEST();

	vicinitysearch = {
		type : 'vicinity search',
		LOCATION : location,
		PROXIMITY : [ {
			distance : 0.01
		// if the distance is too big, the WS return success, but with an empty
		// list, that means a zoom in has to be made, smaller distance.
		} ],
		SEARCH_ITEMS : [ {
			SEARCH_ITEM : [ {
				type : requestRows[j].LOCATION_TYPE
			} ]
		} ],
		RETURN_ITEMS : {
			RETURN_ITEM : [ {
				type : 'GEOPOINT'
			}

			]
		}

	};

	isForm = false;
	GisVicinitySearchService.doRequest(vicinitysearch, {
		callback : handleGetDataFindNearPoiLoc
	});

}

function handleGetDataFindNearPoiLoc(data) {
	
	if (data != null && typeof data == 'object') {
		var response = data.RESPONSE;
		var listofErrors = response.ERROR;
		if (listofErrors.length == 0) {
			var listFoundItems = response.FOUND_ITEMS;

			if (listFoundItems.length > 0) {
				listofPOI = listFoundItems[0].POI;				
				long = mercx2long(listofPOI[0].long);
				lat = mercy2lat(listofPOI[0].lat);
				errorIsPresent = 'false';
			} else {
				alert(ressourceLang.get('error_message'));
				errorIsPresent = 'true';				
			}
		} else {
			alert(ressourceLang.get('error_message'));
			errorIsPresent = 'true';
		}

	} else {
		errorIsPresent = 'true';
		alert(ressourceLang.get('error_message'));
	}
	isValid = true;	
	if(errorIsPresent == 'false')
	getMapLocPoi();

}
function addPrincipalLocalisation() {
	if (onloadMap == 'N' && long!=null) {
		var imageDir="";
		if(isInfo){
			imageDir="css/images/mapIcones/info.png";			
		}else{
			imageDir="css/images/icones/pinBleu.png";
		}
		
		var pt = new ttp_point(long, lat, "Geo");
		var p = new ttp_userPOI(pt, "000", ressourceLang.get('principal_poi'));
		
		var img = new ttp_image(imageDir, 24, 20);
		p.addImage(img);
		var bubbleText = getTemplateBubble('principal', 0);
		p.addBubbleText(bubbleText);
		map.userPOIService.addPOI(p);
		// Adding event listeners to a POI
		map.addListener(p, "click", clk);								
		if(isYourSearchHide==true){
			
			var orgX = map.scale.xMerc2Screen(long2Mercx(long));
			var orgY = map.scale.yMerc2Screen(lat2Mercy(lat));
			var xlong = map.scale.xScreen2Merc(orgX-65);//63			
			var ylat =  map.scale.yScreen2Merc(orgY+16);
			var longR= mercx2long(xlong);
	        var latR = mercy2lat(ylat);		        
			var ptR = new ttp_point(longR, latR, "Geo");
			var pR = new ttp_userPOI(ptR, "101", "");			
			var imgR = new ttp_image("css/images/icones/votreRecherche.gif",40, 107);
			pR.addImage(imgR);			
			map.userPOIService.addPOI(pR);
			map.addListener(pR, "click", clkHideSearch);
			
			
		}
	}

}
function clkHideSearch(id){
    map.userPOIService.removePOI(id);
    map.userPOIService.update();
    map.show();
    isYourSearchHide=false;	
}

function getCoucheTardOptionsDetails(open24hours,gasoline,diesel,restaurant){									
	
	if (open24hours == 'Y' && gasoline == 'Y' && diesel == 'Y' && restaurant == 'Y') {
		return ressourceLang.get('bubble_ct_open24hours') + '<br/>'
				+ ressourceLang.get('bubble_ct_with') + ' '
				+ ressourceLang.get('bubble_ct_essence') + ', '
				+ ressourceLang.get('bubble_ct_diesel') + ' '
				+ ressourceLang.get('bubble_ct_and') + '<br/>'
				+ ressourceLang.get('bubble_ct_restaurant');
	} else if(open24hours == 'Y' && gasoline != 'Y' && diesel != 'Y' && restaurant != 'Y') {
		return ressourceLang.get('bubble_ct_open24hours');
	} else if(open24hours == 'Y' && gasoline != 'Y' && diesel != 'Y' && restaurant == 'Y') {
		return ressourceLang.get('bubble_ct_open24hours') + '<br/>'
				+ ressourceLang.get('bubble_ct_with') + ' '
				+ ressourceLang.get('bubble_ct_restaurant');
	} else if(open24hours == 'Y' && gasoline != 'Y' && diesel == 'Y' && restaurant != 'Y') {
		return ressourceLang.get('bubble_ct_open24hours')+'<br/>'+ressourceLang.get('bubble_ct_diesel');
	} else if(open24hours == 'Y' && gasoline == 'Y' && diesel != 'Y' && restaurant != 'Y') {
		return ressourceLang.get('bubble_ct_open24hours')+'<br/>'+ressourceLang.get('bubble_ct_essence');
	} else if(open24hours != 'Y' && gasoline != 'Y' && diesel != 'Y' && restaurant != 'Y') {
		return '';
	} else if(open24hours != 'Y' && gasoline != 'Y' && diesel == 'Y' && restaurant != 'Y') {
		return ressourceLang.get('bubble_ct_with') + ' '
				+ ressourceLang.get('bubble_ct_diesel');
	} else if(open24hours != 'Y' && gasoline == 'Y' && diesel != 'Y' && restaurant != 'Y') {
		return ressourceLang.get('bubble_ct_with') + ' '
				+ ressourceLang.get('bubble_ct_essence');
	} else if(open24hours != 'Y' && gasoline != 'Y' && diesel != 'Y' && restaurant == 'Y') {
		return ressourceLang.get('bubble_ct_with') + ' '
				+ ressourceLang.get('bubble_ct_restaurant');
	} else{
		return (open24hours != 'Y' ? ressourceLang.get('bubble_ct_with') + ' '
				: ressourceLang.get('bubble_ct_open24hours') + '<br/>')
				+ (gasoline != 'Y' ? ressourceLang.get('bubble_ct_with')
						: ressourceLang.get('bubble_ct_essence'))
				+ (diesel != 'Y' ? ' ' + ressourceLang.get('bubble_ct_and')
						: ' ' + ressourceLang.get('bubble_ct_diesel'))
				+ (restaurant != 'Y' ? '' : ' ' + ressourceLang
						.get('bubble_ct_restaurant'));
	}
}	


function printMapLocalisation(){	
		
			 if(long!=0 && lat!=0 && requestRows[0].LOCATION_TYPE!='') {
					
					var LOCATION = new quickmapLOCATION();	
						var REQUEST ={
						type:'GEOPOINT',
						GEOPOINT:	
						[{
							long:long,
							lat:lat
							
						}]										
					};
					LOCATION=REQUEST;	
					var quickmap_request = new quickmapREQUEST();
					quickmap_request = {
							type : 'quick map',
							LOCATION: LOCATION	
							,
							/*PROXIMITY:{
						          distance:'20'
							},*/
							MAP_ATTRIBUTES:[{			
								MAP_ATTRIBUTE:[{
									width :'800',
									height:'800',
									level: zoomLevelGlobal
						                 }]
							}]
						};
				isForm=false;
				GisQuickMapService.pdfRequest(quickmap_request,{callback:handlePrintMapLocalisation,async:true});
				
					
				}else {	
					alert(ressourceLang.get('avertissement_printmap'));
					showHide('localisation','itineraire');
				}			 
			
			
			
	
		  		




}

