	//<![CDATA[
		pro = {
			debugMode	: false, // Mettre true pour avoir les erreurs
			map_id : 'proGmaps',
			wait_id : 'proWait',
			wide_id : 'proMap',
			wide_sav : 0,
			wide_fullscreen : 0,
			map : null,	
			re_split : null,
			bounds : null,
			url_kml : '/include/getProduit.php?mode=kml',
			content_kml : null,
			url_pi : '/include/getItineraire.php?mode=pi',
			liste_pi : null,
			pro_id : 0,
						
			initialize : function (pro_id) {
				var myLatLng = new google.maps.LatLng(45.4673, 5.9951);
	        	var myOptions = {
	          		zoom: 3,
	          		center: myLatLng,
	          		mapTypeId: google.maps.MapTypeId.TERRAIN,
	          		backgroundColor:'#9CB2CE'
	        	};

	        	pro.map = new google.maps.Map(document.getElementById(pro.map_id), myOptions);
	        	pro.map.oInfowindow = new google.maps.InfoWindow({content: ''});
	        	
	        	pro.pro_id = pro_id;
		    	pro.url_kml += '&proid=' + pro_id;
		    	pro.url_pi += '&proid=' + pro_id;
		    	pro.re_split = new RegExp('[\t| |\r]*','g');

		    	// Chargement xml
		    	if (pro.content_kml === null ) {
			    	_xml.downloadUrl(pro.url_kml, function (xml) {
						try {
							pro.createItineraire(xml);
							pro.content_kml = xml;
						} catch (ex) {
							pro.debug(ex, 'downloadUrl');
						}		
					});
		    	} else {
		    		pro.createItineraire(pro.content_kml);		    		
		    	}
		    	pro.isWait(false);
			},
			
			createItineraire : function (oXML) {
				try {
					if (oXML === null) {
						return false;						
					}
					pro.isWait(true);
					cPM = oXML.getElementsByTagName('Placemark');
					if (cPM.length > 0) {
						for (i=0;cPM[i];i++) {
							cLineString = cPM[i].getElementsByTagName('LineString');
							if (cLineString[0]) {
								coor = cPM[i].getElementsByTagName('coordinates')[0];
							 	aLatlng = pro.getLatLngFromCoordinates(coor);
								if (aLatlng != null) {
									weight = pro.getTextContent(cPM[i].getElementsByTagName('width')[0]);
									/*color = pro.getTextContent(cPM[i].getElementsByTagName('rgbcolor')[0]);
									if (color == '') {
										color = '#000000';
									} else if (color.replace('#', '') == color) {
										color = '#' + color;
									}*/
									color = '#000000';
									var flightPath = new google.maps.Polyline({
				                           path: aLatlng,
				                           strokeColor: color,
				                           strokeOpacity: 1.0,
				                           strokeWeight: weight
				                     });
									flightPath.setMap(pro.map);
								}
							} else {
								aLatlng = pro.getLatLngFromCoordinates(cPM[i].getElementsByTagName('coordinates')[0]);
								if (aLatlng != null) {
									var image = new google.maps.MarkerImage(
											pro.getTextContent(cPM[i].getElementsByTagName('href')[0]),
									      // This marker is 20 pixels wide by 32 pixels tall.
									      new google.maps.Size(32, 32),
									      // The origin for this image is 0,0.
									      new google.maps.Point(0,0),
									      // The anchor for this image is the base of the flagpole at 0,32.
									      new google.maps.Point(32, 32));
									
									var tmpMarker = new google.maps.Marker({
										clickable: false,
								        position: aLatlng[0], 
								        map: pro.map,
								        title: '',
								        icon: image
								    });
								}
							}
						}
				  	}
					
					if (pro.bounds) {
						pro.map.fitBounds(pro.bounds);
					}
					
					pro.isWait(false);					
				  	return true;					
				} catch (ex) {
					pro.debug(ex, 'createItineraire');
					return false;
				}
				
				pro.isWait(false);
			},			
			
			getLatLngFromCoordinates : function(oNode){
				try {
					if (!pro.bounds) {
						pro.bounds = new google.maps.LatLngBounds();
					}
				
					var aP = [];
					aTxt = pro.getTextContent(oNode).split('\n');
					lIndex = aTxt.length;
					for (j=0;j<lIndex;j++) {
						if (aTxt[j] != '') {
							var m = aTxt[j].replace(pro.re_split, '').split(',');
							if (m != null) {
								if (!isNaN(m[0]) && !isNaN(m[1])) {
									
									var p = new google.maps.LatLng(m[1], m[0]);
									pro.bounds.extend(p);
									aP.push(p);
								}
							}
						}
					}
					return (aP.length >0 ? aP : null);
				} catch (ex) {
					pro.debug(ex, 'getLatLngFromCoordinates');
					return null;
				}
				
			},
			
			isWait : function(blnWait) {
				document.getElementById(pro.wait_id).style.display = (blnWait ? 'block' : 'none');
			},

			
			showWide : function(oInput) {
				if (oInput.checked) {
					pro.wide_sav = $('#' + pro.map_id).css('height');
					$('#' + pro.wide_id).addClass('wideScreen');
					$('#' + pro.map_id).css('height', $(window).height() - 40);
					pro.initialize(pro.pro_id);
				} else {
					$('#' + pro.wide_id).removeClass('wideScreen');
					$('#' + pro.map_id).css('height', pro.wide_sav);
				}				
			},
			
			showWideLien : function() {
				if (pro.wide_fullscreen == 0) {
					pro.wide_fullscreen = 1;
					pro.wide_sav = $('#' + pro.map_id).css('height');
					$('#' + pro.wide_id).addClass('wideScreen');
					$('#' + pro.map_id).css('height', $(window).height() - 40);
					$('#proWideSpan').text('');
					$('#proWideLien').text('Retour');
					$('#proWideLien').addClass('proWideLien');
					pro.initialize(pro.pro_id);
				} else {
					pro.wide_fullscreen = 0;
					$('#' + pro.wide_id).removeClass('wideScreen');
					$('#' + pro.map_id).css('height', pro.wide_sav);
					$('#proWideSpan').text('Afficher :  ');
					$('#proWideLien').text('Plein écran');
					$('#proWideLien').removeClass('proWideLien');
				}				
			},
			
			showPI : function(oInput) {
				pro.isWait(true);
				
				if (pro.liste_pi === null) {
					pro.liste_pi = new Array();
				
					// Chargement xml
			    	_xml.downloadUrl(pro.url_pi, function (xml) {
						try {
							pro.createPI(xml);
						} catch (ex) {
							pro.debug(ex, 'downloadUrl');
						}		
					});
				} else {
					for (var i=0;pro.liste_pi[i];i++) {
						pro.liste_pi[i].setMap(oInput.checked ? pro.map : null);
					}
				}
		    	
		    	pro.isWait(false);				
			},
				
			createPI : function (oXML) {	
				try {
					if (oXML === null) {
						return false;						
					}
					pro.isWait(true);
					cKML = oXML.getElementsByTagName('kml_pi');
					if (cKML.length > 0) {
						for (i=0;cKML[i];i++) {
							// kid = cKML[i].getAttribute('kid');
							// kurl = cKML[i].getAttribute('kurl');
							// kname = GXml.value(cKML[i].getElementsByTagName('name')[0]);
				      		
			      			var lat = cKML[i].getAttribute('lat');
			      			var lng = cKML[i].getAttribute('lng');
			      			if (!isNaN(lat) && !isNaN(lng)) {
			      				var image = new google.maps.MarkerImage(
					      				cKML[i].getAttribute('icon'),
									      // This marker is 20 pixels wide by 32 pixels tall.
									      new google.maps.Size(32, 32),
									      // The origin for this image is 0,0.
									      new google.maps.Point(0,0),
									      // The anchor for this image is the base of the flagpole at 0,32.
									      new google.maps.Point(32, 32));
					      			
				      			var tmpMarker = new google.maps.Marker({
									clickable: true,
							        position: new google.maps.LatLng(lat, lng), 
							        map: pro.map,
							        title: pro.getTextContent(cKML[i].getElementsByTagName('name')[0]),
							        icon: image,
							        _textInfo : pro.getTextContent(cKML[i].getElementsByTagName('desc')[0])
							    });
				      			
				            	google.maps.event.addListener(tmpMarker, 'click', 
		    					function() {
		    	            		pro.map.oInfowindow.setContent(this._textInfo);
		    	            		pro.map.oInfowindow.open(pro.map, this);
		    					});		
				            	
				            	// Mémorisation marker
				            	pro.liste_pi.push(tmpMarker);			      				
			      			}
						}
					}
				} catch (ex) {
					pro.debug(ex, 'createPI');
					return false;
				}
				pro.isWait(false);
			},
			
			
			/**
	    	 * Retourne le contenu textuel d'une arborescence DOM de manière identique à ce que retourne la propriété "textContent" de l'interface Node du DOM.3-Core
	    	 * @param  Node    oNode           Noeud à partir duquel retourner le contenu textuel
	    	 * @return string  _textContent    Chaine représentant le contenu textuel du noeud source
	    	 */
	        getTextContent: function (oNode) {
	        	if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
	        	switch (oNode.nodeType) {
	        		case 3: // TEXT_NODE
	        		case 4: // CDATA_SECTION_NODE
	        			return oNode.nodeValue;
	        			break;
	        		case 7: // PROCESSING_INSTRUCTION_NODE
	        		case 8: // COMMENT_NODE
	                    
	        			if (this.getTextContent.caller!=this.getTextContent) {
	        				return oNode.nodeValue;
	        			}
	        			break;
	        		case 9: // DOCUMENT_NODE
	        		case 10: // DOCUMENT_TYPE_NODE
	        		case 12: // NOTATION_NODE
	        			return null;
	        			break;
	        	}
	        	var _textContent="";
	        	oNode=oNode.firstChild;
	        	while (oNode) {
	        		_textContent += this.getTextContent(oNode);
	        		oNode = oNode.nextSibling;
	        	}
	        	return _textContent;
	        },
				
			debug : function(o, libelle) {
				if (pro.debugMode) {
					try {
						if (o) {
							s = 'Erreur : ' + libelle;
							cpt = 0;
							for (t in o) {
								s += "\n" + t + " : " + o[t];
								if (++cpt > 10) {
									alert(s);
									s = 'Erreur : ' + libelle;
									cpt = 0;
								}
							}
							if (cpt > 0) alert(s);
						}
					} catch (ex) {
						alert("debugCatch" + ex);
					}
				}
			}
		};
		
		
		_xml = {
				/**
				* Returns an XMLHttp instance to use for asynchronous
				* downloading. This method will never throw an exception, but will
				* return NULL if the browser does not support XmlHttp for any reason.
				* @return {XMLHttpRequest|Null}
				*/
				createXmlHttpRequest : function () {
				 try {
				   if (typeof ActiveXObject != 'undefined') {
				     return new ActiveXObject('Microsoft.XMLHTTP');
				   } else if (window["XMLHttpRequest"]) {
				     return new XMLHttpRequest();
				   }
				 } catch (e) {
				   changeStatus(e);
				 }
				 return null;
				},

				/**
				* This functions wraps XMLHttpRequest open/send function.
				* It lets you specify a URL and will call the callback if
				* it gets a status code of 200.
				* @param {String} url The URL to retrieve
				* @param {Function} callback The function to call once retrieved.
				*/
				downloadUrl : function (url, callback) {
					var status = -1;
					var request = _xml.createXmlHttpRequest();
					if (!request) {
						return false;
					};
					request.onreadystatechange = function() {
						if (request.readyState == 4) {
							try {
								status = request.status;
							} catch (e) {
								// Usually indicates request timed out in FF.
							}
							if (status == 200) {
								callback(request.responseXML, request.status);
								request.onreadystatechange = function() {};
							}
						}
					}
					request.open('GET', url, true);
					try {
						request.send(null);
					} catch (e) {
						changeStatus(e);
					}
				},

				/**
				 * Parses the given XML string and returns the parsed document in a
				 * DOM data structure. This function will return an empty DOM node if
				 * XML parsing is not supported in this browser.
				 * @param {string} str XML string.
				 * @return {Element|Document} DOM.
				 */
				xmlParse : function (str) {
					if (typeof ActiveXObject != 'undefined' && typeof GetObject != 'undefined') {
						var doc = new ActiveXObject('Microsoft.XMLDOM');
						doc.loadXML(str);
						return doc;
					}
				
					if (typeof DOMParser != 'undefined') {
						return (new DOMParser()).parseFromString(str, 'text/xml');
					}
				
					return createElement('div', null);
				}
			}		
	//]]>
