var languages=new Array();languages['en']='English';languages['fr']='French';languages['de']='German';languages['it']='Italian';languages['ja']='Japanese';languages['pt']='Portuguese';languages['ru']='Russian';languages['es']='Spanish';languages['vi']='Vietnamese';var zMap = null, zMarkerManager = null, zPanel = null, zCategoriesManager = null, gDirections = null, search_category = '', search_keyword = '', sText = '', sCategory = '', visible_only = true, user_logged = false, is_saving = false, force_list_open = true, _mSvgForced = true, _mSvgEnabled = true; var reasons=[]; reasons[G_GEO_SUCCESS] = "Success"; reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value."; reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address."; reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons."; reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given"; reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded."; reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed."; reasons[G_GEO_BAD_REQUEST] = "A directions request could not be successfully parsed."; reasons[G_GEO_MISSING_QUERY] = "No query was specified in the input."; reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points."; function init() { if (GBrowserIsCompatible()) { // {"defaultLocation":{lat:38,lng:-97,zoom:5,type:G_NORMAL_MAP}, zMap = new ZMap( 'myMap', { "defaultLocation":{lat:48.661943,lng:14.677734,zoom:5,type:G_NORMAL_MAP}, "onMouseMoveFn":infoPosition, "onMoveEndFn":loadPOI, "onZoomEndFn":myZoomEndEvent, "onClickFn":myClickEvent, "onLoadFn":myLoadEvent, "onInfoWindoOpenFn":fitInfoWindowInMap } ); zMarkerManager = new ZMarkerManager( zMap, {"maxMarkers":200, "positionMarkerImage":"http://artabsolument.zoomolocal.com/img/pos_actuel.gif", "countryCode":"US", "lblGeoList":"Geolocalisation", "lblNoResult":"No result", "lblMaxResults":"Max : 200 results returned", "markerOptions":{lblEditLink:"Edit", addPhotosLink:"pictures.php", lblAddPhotosLink:"Add pictures", lblMoreImagesLink:"Display more images", lblLessImagesLink:"Back", lblNewWindowLink:"Open in a new window", lblDirectionsLink:"Directions", lblFlagLink:"Flag this", lblMorePhotosLabel:"Click for more photos", formLabels:{ directions:"Directions", address:"Address", to:"To this place", from:"From this place", startAddress:"Start address", endAddress:"End address", car:"By car", foot:"By foot", back:"Back" }, lblLanguages:languages, loadDataUrl:'scripts/load_poitext.php', postFormFn:computeDirections, imageContainer:{maxWidth:370, maxHeight:277} }, "tempMarkerOptions":{title:'New POI', cancelLabel:'Cancel', saveLabel:'Save', cancelFn:function(){zMap.closeInfoWindow()}, saveFn:savePOI, lang:['en']} } ); GEvent.addListener( zMarkerManager, "loaded", onMarkersLoaded); GEvent.addListener( zMarkerManager, "geolocalized", searchText); zPanel = new ZPanel(zMap, zMarkerManager, {onCloseFn:resetSearchCriteria}); zCategoriesManager = new ZCategoriesManager([0,1,2,3,4], {onUpdateFn : loadPOI}); zCategoriesManager.setSelected([2]); ZForm.languages=languages; ZForm.labels={name:'Name',nameTitle:'Name of the point of interest', category:'Categories',categoryTitle:'Category of the point of interest',categFirstOpt:'Choose...', address:'Contact',addressTitle:'Contact', description:'Description',descriptionTitle:'Description', link:'Link',linkTitle:'Associated link', langFirstOpt:'Choose...',addButton:'Add', languagesTableTitle:'Remove a language',aDelTitle:'Remove' }; ZForm.categories=''; ZForm.lblLanguages='Languages'; ZForm.languagesTableCols=7; zMap.initialize(); gDirections = new GDirections(zMap, document.getElementById('list_directions_content')); GEvent.addListener(gDirections, "error", function() { var code = gDirections.getStatus().code; var reason="Code "+code; if (reasons[code]) { reason = reasons[code] } alert("Failed to obtain directions, "+reason); } ); GEvent.addListener( gDirections, "addoverlay", function() { zMap.closeInfoWindow(); zMarkerManager.removeGeocodedMarkers(); if(!zPanel.isOpen()) zPanel.display(); else zPanel.buildList(); zPanel.displayDirectionsPanel(); } ); var a = document.getElementById('ul-groups').getElementsByTagName('a'); for( var i = 0; i < a.length; i++) { GEvent.addDomListener(a[i], 'mouseover', function(e) { var zEvent = new ZEvent(e); document.getElementById('ul-category-' + this.id.replace(/a-group-/,'')).style.display = 'inline'; if(zMap && zMarkerManager) { if(zMap.zMarkerWithInfoWindow() && zMarkerManager.markers[zMap.zMarkerWithInfoWindow()].embedDisplayed) zMarkerManager.markers[zMap.zMarkerWithInfoWindow()].displayZM(); } } ); GEvent.addDomListener(a[i], 'mouseout', function(e) { var zEvent = new ZEvent(e); if( zEvent.relatedTarget ) { if( zEvent.relatedTarget.className != 'ul-category' ) { document.getElementById('ul-category-' + this.id.replace(/a-group-/,'')).style.display = 'none'; } } } ); var group = a[i].id.replace(/a-group-/,''); var elt = document.getElementById('ul-category-' + group); elt.group = group; GEvent.addDomListener(elt, 'mouseover', function(e) { this.style.display = 'inline'; } ); GEvent.addDomListener(elt, 'mouseout', function(e) { var zEvent = new ZEvent(e); var relatedTarget = zEvent.relatedTarget; if( relatedTarget.id != 'header' && relatedTarget.id != 'a-group-' + this.group ) { while( relatedTarget != this && relatedTarget.nodeName.toLowerCase() != 'body' && relatedTarget.nodeName.toLowerCase() != 'html' ) { relatedTarget = relatedTarget.parentNode; } if( relatedTarget != this ) this.style.display = 'none'; } } ); } } else alert('Incompatible Browser'); } function infoPosition(position){ var events ="Position WGS84 : " + position.lng + " ; " + position.lat +". Zoom : "+position.zoom; document.getElementById('position').innerHTML = events; } function myClickEvent( overlay, point ) { if(overlay) { if(overlay.isZMarker || overlay.isZMarkerGeocoded) overlay.openZInfoWindow({maxWidth:650,pixelOffset: new GSize(100,100),suppressMapPan:true}); } else zMarkerManager.setPositionMarker( point ); } function myZoomEndEvent(map,zoom_level){ if(map.zMarkerTempWithInfoWindow() || (map.zMarkerWithInfoWindow() && zMarkerManager.markers[map.zMarkerWithInfoWindow()].draggable() && zMarkerManager.markers[map.zMarkerWithInfoWindow()].draggingEnabled())){ if(map.zMarkerTempWithInfoWindow()){ if(map.isOutOfBounds(zMarkerManager.tempMarker.getPoint())) zMarkerManager.resetMarker(); } else if(map.zMarkerWithInfoWindow()){ if(map.isOutOfBounds(zMarkerManager.markers[map.zMarkerWithInfoWindow()].getPoint())) zMarkerManager.resetMarker(); } } } function myLoadEvent(categ, keyword, category){ if(keyword != '') sText = keyword; if(category != '') sCategory = category; zCategoriesManager.init(categ); } function fitInfoWindowInMap() { var opts = {"paddingTop":50, "paddingLeft":80, "paddingRight":30, "paddingBottom":70, "offsetX":45, "offsetY":105 }; zMap.fitInfoWindow(opts); } function getDirections() { if(document.getElementById('transport_mode').value == 'foot') var transport_mode = G_TRAVEL_MODE_WALKING; else var transport_mode = G_TRAVEL_MODE_DRIVING; computeDirections( document.getElementById('txtFrom').value, document.getElementById('txtTo').value, transport_mode ); } function computeDirections( from, to, travelMode ) { document.getElementById('txtFrom').value = from; document.getElementById('txtTo').value = to; if(from && to) { if(computeDirections.arguments.length > 2) var opts = { travelMode : travelMode, locale : "en" }; else var opts = { travelMode : G_TRAVEL_MODE_DRIVING, locale : "en" }; gDirections.clear(); gDirections.load( 'from: '+from+' to: '+ to, opts ); } } function doSearch(button_id){ sText = ''; sCategory = ''; if(button_id=='bt_fast_search'){ zPanel.resetSearchForm(); document.getElementById('txtMot').value=document.getElementById('txtFsMot').value.trim(); document.getElementById('txtLieu').value=document.getElementById('txtFsLieu').value.trim(); document.getElementById('chk_all_map').checked=true; visible_only=false; zPanel.display(); document.getElementById('form_fast_search').style.visibility="hidden"; document.getElementById('txtFsMot').value=''; document.getElementById('txtFsLieu').value=''; } zMarkerManager.removeGeocodedMarkers(); var lieu=document.getElementById('txtLieu').value.trim(); if(lieu!='') geolocalize(lieu); else searchText(false); } function geolocalize(lieu) { loading(true); zMarkerManager.geolocalize(lieu, {postFormFn : computeDirections, labels : { title : 'Address', directions : 'Directions', to : 'To this place', from : 'From this place', startAddress : 'Start address', endAddress : 'End address', ok : 'Ok' } } ); } function searchText(geolocalized){ query_db=true; search_keyword=document.getElementById('txtMot').value.trim(); zCategoriesManager.updateAll('off'); if(search_keyword!=''){ geolocalized=false; search_category=document.getElementById('listCateg').value.trim(); } else if(document.getElementById('listCateg').value.trim()!=''){ geolocalized=false; search_category=document.getElementById('listCateg').value.trim(); } else if(document.getElementById('listCateg').value.trim()==''){ document.getElementById('chk_all_map').checked=false; search_category=''; if(!geolocalized){ unloadPOI(); query_db=false; } } if(geolocalized){ document.getElementById('chk_all_map').checked=false; visible_only=true; loadPOI(true); } else{ if(document.getElementById('chk_all_map').checked) visible_only=false; else visible_only=true; if(query_db) loadPOI(true); } } function newPOI(){ if(user_logged) { if(!zMarkerManager.addTempMarker()) alert('Click to set a location on the Map'); } } function savePOI() { if( !is_saving ){ var id_poi = document.getElementById('hidIdPoi').value.trim(); if( id_poi != '' ) id_poi = parseInt( id_poi ); else id_poi = 0; if( !zMarkerManager.markerExists(id_poi) ) id_poi = 0; var alerte = ZForm.alertsOn( ['txtNom','selCateg_1','txtAdresse','txtDesc'] ); if( alerte=='txtNom' ) { ZForm.dialog('You have to type the name of your POI for this language',false); return false; } else if( alerte=='selCateg_1' ) { ZForm.dialog('You have to choose at least one category for your POI',false); return false; } else if( alerte=='txtAdresse' ) { ZForm.dialog('You have to type the address of your POI for this language',false); return false; } else if( alerte=='txtDesc' ) { ZForm.dialog('You have to type the description of your POI for this language',false); return false; } if( id_poi ) var point = zMarkerManager.markers[id_poi].getPoint(); else var point = zMarkerManager.tempMarker.getPoint(); var data = "id=" + id_poi + "&lat=" + point.lat() + "&lng=" + point.lng() + "&clat=" + zMap.getCenter().lat() + "&clng=" + zMap.getCenter().lng() + ZForm.getPostData( ['txtNom','selCateg','txtAdresse','txtDesc','txtLien'] ) + "&langue=en"; //GLog.write(data); is_saving = true; ZForm.proccessingDialog( 'Saving, please wait...' ); var xhr = new ZHTTPRequest("POST","xml",true); xhr.setCompleteCallback( function(xml_doc) { var success = false; var editable = false; var new_id = 0; if( xml_doc != null ) { var markers = xml_doc.getElementsByTagName("item"); if(markers.length) { new_id = parseInt(markers[0].getAttribute('id')); editable = markers[0].getAttribute('editable'); if(editable == 'true' && !isNaN(new_id) && new_id > 0) { success=true; zMarkerManager.addMarker( markers[0] ); GEvent.clearListeners(zMap, "infowindowbeforeclose"); } } } if(success) { ZForm.resetDialog(); ZForm.dialog('Your POI has been saved',true); } else if(editable=='false' && !isNaN(new_id) && new_id>0) { alert('You must be logged in to do this operation',false); zMarkerManager.resetMarker(); } else { ZForm.dialog('An error occured while trying to save your POI, please try again',false); } is_saving=false; } ); xhr.setFailureCallback( function(){alert("Request failed, please try again later")} ); xhr.query('scripts/new_poi.php',data); } } function unloadPOI(){ zMarkerManager.unloadMarkers(); zPanel.buildList(); } function loadPOI( fromDB ) { zMarkerManager.drawGeocodedMarkers(); if(fromDB || zMarkerManager.visibleMarkers == zMarkerManager.maxMarkers) { loading(true); var bounds = zMap.getBounds(); var SW = bounds.getSouthWest(); var NE = bounds.getNorthEast(); var data = "min_lng="+SW.lng()+"&max_lng="+NE.lng()+"&min_lat="+SW.lat()+"&max_lat="+NE.lat()+"&langue=en"; data += "&level="+zMap.getZoom(); if(visible_only) data += "&visible="+visible_only; else visible_only=true; if(zCategoriesManager.getSelected()!='') data += "&categories="+zCategoriesManager.getSelected(); if(search_keyword!=''){ data += "&search_keyword="+search_keyword; sText = search_keyword; search_keyword=''; } if(sText!=''){ data += "&search_keyword="+sText; } if(search_category!=''){ data += "&search_category="+search_category; sCategory = search_category; search_category=''; } if(sCategory!=''){ data += "&search_category="+sCategory; } //GLog.write(data); if(zMarkerManager.positionMarker != null && !bounds.contains(zMarkerManager.positionMarker.getPoint())) zMarkerManager.positionMarker = zMarkerManager.positionMarker.removeFromMap(); zMarkerManager.loadMarkers( 'scripts/load_poi.php', data ); } else{ zMarkerManager.updateMarkersVisibility(); onMarkersLoaded(); } } function onMarkersLoaded() { var position = zMap.getCurrentPosition(); if( position.marker ) zMarkerManager.openMarkerZInfoWindow( parseInt( position.marker ) ); zPanel.buildList(); if( zMarkerManager.visibleMarkers < zMarkerManager.maxMarkers ) force_list_open = true; if( force_list_open && !zPanel.isOpen() && ( zMarkerManager.visibleMarkers == zMarkerManager.maxMarkers || sText !='' || sCategory != '' ) ) zPanel.display(); loading(false); } function editPOI(id){ id=parseInt(id); if( zMarkerManager.markerExists(id) ){ loading(true); zMap.closeInfoWindow(); zMap.resetInfoWindowState() var data = "id="+id+"&langue=en"; var xhr = new ZHTTPRequest("POST","xml",true); xhr.setCompleteCallback( function(xml_doc) { if( xml_doc != null ) { var markers = xml_doc.getElementsByTagName("item"); if( markers.length ) { var id_poi = parseInt( markers[0].getAttribute('id').trim() ); var editable = markers[0].getAttribute('editable').trim(); if( editable == 'true' && id == id_poi ) { zMarkerManager.markers[id].setEditMode(true); zMarkerManager.markers[id].openZInfoWindow({maxWidth:650,suppressMapPan:true}, {cancelLabel:'Cancel', saveLabel:'Save', cancelFn:function(){zMap.closeInfoWindow()}, saveFn:savePOI} ); var selectedLanguages = markers[0].getElementsByTagName('textes')[0].getElementsByTagName('languages')[0].firstChild.nodeValue.trim().split(';'); ZForm.initialize(document.getElementById('info_forms'),selectedLanguages); ZForm.setFieldValue('hidIdPoi', id_poi); var id_categs=markers[0].getElementsByTagName('categorie'); var texts = markers[0].getElementsByTagName('textes')[0].getElementsByTagName('texte'); for( var i = 0; i < texts.length; i++ ) { var lang=texts[i].getAttribute('langue'); for( var j = 0; j < id_categs.length; j++ ) { ZForm.setFieldValueForLanguage('selCateg_'+(j+1),lang,id_categs[j].getAttribute('id')); } if( texts[i].getElementsByTagName('titre').length && texts[i].getElementsByTagName('titre')[0].firstChild ) ZForm.setFieldValueForLanguage('txtNom',lang,texts[i].getElementsByTagName('titre')[0].firstChild.nodeValue); if( texts[i].getElementsByTagName('adresse').length && texts[i].getElementsByTagName('adresse')[0].firstChild ) ZForm.setFieldValueForLanguage('txtAdresse',lang,texts[i].getElementsByTagName('adresse')[0].firstChild.nodeValue); if( texts[i].getElementsByTagName('description').length && texts[i].getElementsByTagName('description')[0].firstChild ) ZForm.setFieldValueForLanguage('txtDesc',lang,texts[i].getElementsByTagName('description')[0].firstChild.nodeValue); if( texts[i].getElementsByTagName('lien').length && texts[i].getElementsByTagName('lien')[0].firstChild ) ZForm.setFieldValueForLanguage('txtLien',lang,texts[i].getElementsByTagName('lien')[0].firstChild.nodeValue); } GEvent.addListener(zMap, "infowindowbeforeclose", function(){zMarkerManager.resetMarker()}); } else { if(editable=='false' && id==id_poi) alert('You must be logged in to do this operation',false); zMarkerManager.resetMarker(); } } } loading(false); } ); xhr.setFailureCallback( function(){alert("Request failed, please try again later")} ); xhr.query('scripts/edit_poi.php',data); } } function loading(on){ if(on) document.getElementById('loading_state').style.visibility='visible'; else document.getElementById('loading_state').style.visibility='hidden'; } function getCurrentUrl(){ var link=window.location; if(zCategoriesManager.getSelected()!='') link += "&view="+zCategoriesManager.getSelected(); if(zMap.zMarkerWithInfoWindow()) link += "&marker="+zMap.zMarkerWithInfoWindow(); if(sText != '') link += "&keyword="+encodeURIComponent(sText); if(sCategory != '') link += "&category="+sCategory; return link; } function openDisplayUrlDiv(){ var input = document.getElementById('i_url'); var div = document.getElementById('display_url'); var div_content = document.getElementById('content'); input.value=getCurrentUrl(); /*if (input.setSelectionRange) return this.value.substring(this.selectionStart, this.selectionEnd); else if (document.selection) { this.focus(); return document.selection.createRange().text; }*/ if(div.offsetHeight && div_content.offsetHeight){ var div_height=div.offsetHeight; var content_height=div_content.offsetHeight; } else{ var div_height=100; var content_height=document.documentElement.clientHeight-document.getElementById('header').style.height-document.getElementById('footer').style.height; } var ombre=document.getElementById('shadow_url'); if(!ombre.offsetHeight || !ombre.offsetWidth){ ombre.style.height="95px"; ombre.style.width="450px"; } div.style.top=((content_height-div_height)/2)+"px"; div.style.left=(((div_content.offsetWidth-div.offsetWidth)/2>0)?(div_content.offsetWidth-div.offsetWidth)/2:0)+"px"; div.style.visibility = "visible"; input.focus(); input.select(); } function closeDisplayUrlDiv(){ document.getElementById('display_url').style.visibility = "hidden"; } function login(isLogged){ var url = encodeURIComponent(getCurrentUrl()); if(isLogged) document.location='http://artabsolument.zoomolocal.com/logout.php?url='+url; else document.location='http://artabsolument.zoomolocal.com/login.php?url='+url; } function flag_poi(){ if(zMap.zMarkerWithInfoWindow()) openPopUp('ads/flag.php?id='+zMap.zMarkerWithInfoWindow(),'zm_popup',400,450); } function sizeOf(associative_array){ var cpt=0; for(var i in associative_array){ cpt++; } return cpt; } function meterToKM(number,precision){ return (Math.round((number/1000)*Math.pow(10,precision))/Math.pow(10,precision)); } function htmlEntities(s){ if(typeof(s)=='string' && s!=''){ var temp=''; while(temp!=s){ if(temp!='') s=temp; temp = s.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } delete temp; } return s; } function nl2br(text){ if(typeof(text)=='string' && text!=''){ text = text.replace(/\r\n/g,'
'); text = text.replace(/\n/g,'
'); } return text; } function getTextNodes(text){ var res = []; if(typeof(text)=='string' && text!=''){ var temp = text.split("\r\n"); if(temp.length==1) temp = text.split("\n"); for(var i=0;i numChar ) { text = text.substring(0,numChar); var idx = text.lastIndexOf(' '); if( idx >= 0) text = text.substring(0, idx); text += '...'; } return text; } Array.prototype.search = function(element) { var i = 0, res = -1; while(res == -1 && i < this.length) { if(this[i] == element) res = i; else i++; } return res; } function maxlength(text,nbChar){ if(text.lengthdeltaX) x=deltaX; if(y>deltaY) y=deltaY; if(this.position_=='TOP_RIGHT' || this.position_=='BOTTOM_RIGHT') x-=(this.div_.offsetWidth+this.offsetX_); else if(this.position_=='TOP_LEFT' || this.position_=='BOTTOM_LEFT') x+=this.offsetX_; if(this.position_=='BOTTOM_LEFT' || this.position_=='BOTTOM_RIGHT') y-=(this.div_.offsetHeight+this.offsetY_); else if(this.position_=='TOP_LEFT' || this.position_=='TOP_RIGHT') y+=this.offsetY_; if(xthis.maxElements_){ this.menu_.getElementsByTagName('ul')[0].style.height=this.maxHeight_+'px'; this.menu_.getElementsByTagName('ul')[0].style.overflowY='scroll'; } this.div_.style.visibility = "visible"; } ZContextMenu.prototype.mouseoverEvent = function(e){ var zEvent = new ZEvent(e); if(zEvent.type=='mouseout'){ zEvent.source.style.cursor='auto' zEvent.source.style.background='#ffffff' } else if(zEvent.type=='mouseover'){ zEvent.source.style.cursor='pointer' zEvent.source.style.background='#2d3ccd' } zEvent.consume(); } ZContextMenu.prototype.addListEventHandler = function(event,handler){ var li = this.menu_.getElementsByTagName('ul')[0].getElementsByTagName('li'); for(var i=0;i 0 && typeof( this.markers[id] ) != 'undefined' && typeof( this.markers[id] ) == 'object' ) res = true; return res; } ZMarkerManager.prototype.openMarkerZInfoWindow = function( id ) { if( this.markerExists( id ) ) GEvent.trigger( this.markers[id],"click" ); } ZMarkerManager.prototype.loadMarkers = function( loadURL, data ) { var ZMarkerManager_ = this; var map_ = this.map_; var xhr = new ZHTTPRequest("POST","xml",true); xhr.setCompleteCallback( function(xml_doc) { if( xml_doc != null ) { var temp = []; var markers = xml_doc.getElementsByTagName("item"); var cpt=0; for( var i = 0; i < markers.length; i++ ) { var id_marker = parseInt(markers[i].getAttribute("id")); var id_categ = parseInt(markers[i].getAttribute("id_categ")); if( ZMarkerManager_.markerExists( id_marker ) && id_categ == ZMarkerManager_.markers[id_marker].getCategoryId()) { temp[id_marker] = ZMarkerManager_.markers[id_marker]; temp[id_marker].isOnMap = parseInt( markers[i].getAttribute('visible') ); if(temp[id_marker].isOnMap) cpt++; temp[id_marker].setDistanceToCenter( markers[i].getAttribute('distance') ); ZMarkerManager_.markers[id_marker]=null; delete ZMarkerManager_.markers[id_marker]; } else { var coords = new GLatLng( markers[i].getAttribute('lat'), markers[i].getAttribute('lng') ); temp[id_marker]= new ZMarker( coords, ZMarkerManager_.markerOptions_, markers[i]); if(temp[id_marker].isOnMap) cpt++; map_.addOverlay( temp[id_marker] ); } } ZMarkerManager_.visibleMarkers = cpt; if(ZMarkerManager_.markers.length) { var mapBounds = map_.getBounds(); var center = map_.getCenter(); for(var i in ZMarkerManager_.markers) { if(!isNaN(i)) { if( ZMarkerManager_.markerExists( i ) ) { if( !ZMarkerManager_.markers[i].inEditMode() ) { GEvent.clearInstanceListeners(ZMarkerManager_.markers[i]); ZMarkerManager_.markers[i] = ZMarkerManager_.markers[i].removeFromMap(); delete ZMarkerManager_.markers[i]; } else { temp[i] = ZMarkerManager_.markers[i]; temp[i].setDistanceToCenter( map_.getCenter().distanceFrom( temp[i].getPoint() ) ); if( map_.getBounds().contains( temp[i].getPoint() ) ) temp[i].isOnMap = true; delete ZMarkerManager_.markers[i]; } } else delete ZMarkerManager_.markers[i]; } } } ZMarkerManager_.markers = temp; GEvent.trigger( ZMarkerManager_, "loaded" ); } } ); xhr.setFailureCallback( function(){ alert("Request failed, please try again later"); } ); xhr.query( loadURL, data ); } ZMarkerManager.prototype.addMarker = function( node ) { var temp= new ZMarker( new GLatLng( node.getAttribute('lat'), node.getAttribute('lng') ), this.markerOptions_, node ); this.map_.addOverlay(temp); var ZMarkerManager_ = this; window.setTimeout( function() { var id_marker = temp.idZMarker; if(!ZMarkerManager_.tempMarker) { ZMarkerManager_.markers[id_marker] = ZMarkerManager_.markers[id_marker].removeFromMap(); delete ZMarkerManager_.markers[id_marker]; } else ZMarkerManager_.tempMarker = ZMarkerManager_.tempMarker.removeFromMap(); ZMarkerManager_.markers[id_marker] = temp; window.setTimeout( function(){ GEvent.trigger( ZMarkerManager_.markers[id_marker], "click" ); }, 500 ); }, 2000); } ZMarkerManager.prototype.addTempMarker = function() { var point = this.getCurrentPoint(); if(point) { if(this.tempMarker != null) this.tempMarker.setPoint(point); else { this.tempMarker = new ZMarkerTemp( point, this.tempMarkerOptions_ ); this.map_.addOverlay( this.tempMarker ); } this.tempMarker.openZInfoWindow({maxWidth:650,suppressMapPan:true}); var ZMarkerManager_ = this; GEvent.addListener(this.map_, "infowindowbeforeclose", function(){ZMarkerManager_.resetMarker()}); } return point != null; } ZMarkerManager.prototype.resetMarker = function() { var old_id=ZForm.getFieldValue('hidIdPoi'); if( this.markerExists(old_id) ) this.markers[old_id].setEditMode(false); if(this.tempMarker != null) this.tempMarker = this.tempMarker.removeFromMap(); GEvent.clearListeners(this.map_, "infowindowbeforeclose"); } ZMarkerManager.prototype.updateMarkersVisibility = function() { var mapBounds = this.map_.getBounds(); var center = this.map_.getCenter(); var cpt = 0; for( var i in this.markers ) { if(!isNaN(i)) { this.markers[i].setDistanceToCenter( center.distanceFrom( this.markers[i].getPoint() ) ); if( mapBounds.contains( this.markers[i].getPoint() ) ) { this.markers[i].isOnMap = true; cpt++; } else this.markers[i].isOnMap = false; } } this.visibleMarkers = cpt; } ZMarkerManager.prototype.removeMarkersForCategory = function(id) { if( this.markers.length ) { for( var i in this.markers ) { if(!isNaN(i) && this.markers[i].getCategoryId() == id ) { GEvent.clearInstanceListeners( this.markers[i] ) this.markers[i] = this.markers[i].removeFromMap(); delete this.markers[i]; } } } } ZMarkerManager.prototype.geocodedMarkerExists = function( id ) { var res = false; if(id > 0 && typeof( this.geocodedMarkers[id] ) != 'undefined' && typeof( this.geocodedMarkers[id] ) == 'object' && this.geocodedMarkers[id].isDrawn()) res = true; return res; } ZMarkerManager.prototype.geolocalize = function( place, markersOptions ) { var ZMarkerManager_ = this; var map_ = this.map_; this.zGeocoder.getLocations( place, function(response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); var geolocalized = false; } else { var temp = []; for( var i = 0; i < response.Placemark.length; i++ ) { temp.push( new ZMarkerGeocoded( response.Placemark[i], ZMarkerManager_.zGeocoder.getZoomLevel( response.Placemark[i] ), markersOptions ) ); } temp.sort( function( a, b ) { var center = map_.getCenter(); return center.distanceFrom(a.getPoint()) - center.distanceFrom(b.getPoint()); } ); for( var i = 0; i < temp.length; i++ ) { ZMarkerManager_.geocodedMarkers[(i+1)] = temp[i] ZMarkerManager_.geocodedMarkers[(i+1)].setId( (i+1) ); } delete temp; var geolocalized = true; } GEvent.trigger( ZMarkerManager_, "geolocalized", geolocalized ); } ); } ZMarkerManager.prototype.drawGeocodedMarkers = function() { if(this.geocodedMarkers.length) { var canBeMoved=false; var mapBounds = this.map_.getBounds(); var on_screen=false; for(var i in this.geocodedMarkers) { if(!isNaN(i)) { if(!canBeMoved && !this.geocodedMarkers[i].drawn) canBeMoved=true; if(!this.geocodedMarkers[i].isDrawn()) this.map_.addOverlay(this.geocodedMarkers[i]); if(canBeMoved && !on_screen && this.geocodedMarkers[i].isDrawn() && mapBounds.contains(this.geocodedMarkers[i].getPoint())) on_screen=true; } } if(canBeMoved) { GEvent.trigger(this.geocodedMarkers[1],'click'); } } } ZMarkerManager.prototype.removeGeocodedMarkers = function() { if(this.geocodedMarkers.length) { for(var i in this.geocodedMarkers) { if(!isNaN(i) && this.geocodedMarkers[i].isDrawn()) { GEvent.clearInstanceListeners( this.geocodedMarkers[i] ) this.geocodedMarkers[i] = this.geocodedMarkers[i].removeFromMap(); } } this.geocodedMarkers.splice(0,this.geocodedMarkers.length); } } ZMarkerManager.prototype.setPositionMarker = function( point ) { if (point != null) { if (this.positionMarker != null) this.positionMarker.setPoint(point); else { this.positionMarker = new ZIcon(point, this.positionMarkerImage_, G_MAP_MAP_PANE); this.map_.addOverlay(this.positionMarker); } } } ZMarkerManager.prototype.getCurrentPoint = function() { var point = null; if(this.positionMarker) point = this.positionMarker.getPoint(); else if(this.geocodedMarkers.length) { var id=false; var mapBounds = this.map_.getBounds(); for(var i in this.geocodedMarkers) { if(!isNaN(i)) { if(this.geocodedMarkers[i].isDrawn() && mapBounds.contains(this.geocodedMarkers[i].getPoint())) { if(this.map_.zMarkerGeoWithInfoWindow()==i) { id=i; break; } else if(!id) id=i; } } } if(id) { point = this.geocodedMarkers[id].getPoint(); this.map_.closeInfoWindow(); } } return point; } ZMarkerManager.prototype.unloadMarkers = function() { this.map_.clearOverlays(); this.markers.splice( 0, this.markers.length ); this.geocodedMarkers.splice( 0, this.geocodedMarkers.length ); if(this.positionMarker != null) this.positionMarker = this.positionMarker.removeFromMap(); } function ZMarker(point,options,xml_doc) { this.isZMarker=true; this.descNbChar_=400; this.draggable_ = false; this.srcIcon_= options.srcIcon || "img/marker_edit.png"; this.srcIconHighlight_= options.srcIconHighlight || "img/marker_edit.png"; this.srcIconShadow_= options.srcIconShadow || "img/marker_shadow.png"; this.srcIconTransparent_=options.srcIconTransparent || "img/marker_transparent.png"; this.srcEditIcon_ = options.srcEditIcon || "img/marker_edit.png"; this.loadDataUrl_ = options.loadDataUrl || null; this.postFormFn_ = options.postFormFn || null; this.listId_='list_zmarker'; this.listEltName_ = 'list_elt'; this.lblEditLink_ = options.lblEditLink || ""; this.lblAddPhotosLink_ = options.lblAddPhotosLink || ""; this.addPhotosLink_ = options.addPhotosLink || ""; this.lblMoreImagesLink_ = options.lblMoreImagesLink || ""; this.lblLessImagesLink_ = options.lblLessImagesLink || ""; this.lblNewWindowLink_ = options.lblNewWindowLink || ""; this.lblDirectionsLink_ = options.lblDirectionsLink || ""; this.lblFlagLink_ = options.lblFlagLink || ""; this.lblMorePhotosLabel_ = options.lblMorePhotosLabel || ""; this.lblLanguages_ = options.lblLanguages || null; this.formLabels_ = options.formLabels || null; this.imageContainer_ = options.imageContainer || null; this.moreInfoLink_ = ""; this.zInfoBulle_ = null; this.icon_=null; this.contextMenu_=null; this.maxLanguagesTabs_=3; this.img_ = null; this.lang_=''; this.loadingLang_=''; this.isLoadingLang_=false; this.title_=[]; this.desc_=[]; this.address_=[]; this.link_=[]; this.selectedLanguages_=[]; this.availableLanguages_; this.originalPos_=null; this.embedDisplayed = false; this.idZMarker=parseInt(xml_doc.getAttribute('id')) || 0; if(xml_doc.getAttribute('editable') == 'true') this.draggable_=true; if(xml_doc.getAttribute('distance')!='') this.distance_=parseFloat(xml_doc.getAttribute('distance')); else this.distance_=0; this.isOnMap=parseInt(xml_doc.getAttribute('visible')) || 0; if(xml_doc.getElementsByTagName('page_zooming')[0].firstChild && xml_doc.getElementsByTagName('page_zooming')[0].firstChild.nodeValue!='') this.moreInfoLink_=xml_doc.getElementsByTagName('page_zooming')[0].firstChild.nodeValue.trim(); this.categorie_={id:xml_doc.getElementsByTagName('categorie')[0].getAttribute('id'), name:xml_doc.getElementsByTagName('categorie')[0].firstChild.nodeValue, color:xml_doc.getElementsByTagName('categorie')[0].getAttribute('color')} || 0; if(xml_doc.getElementsByTagName('vignette').length) { var vignette = xml_doc.getElementsByTagName('vignette')[0]; this.img_={src:vignette.getAttribute('src'), title:[], width:vignette.getAttribute('width'), height:vignette.getAttribute('height')}; this.setImgTitles(vignette); } else this.img_=null; this.setTextFields(xml_doc.getElementsByTagName('textes')[0]) if(xml_doc.getElementsByTagName('external_data').length) this.getExternalData(xml_doc.getElementsByTagName('external_data')[0]); this.srcIcon_= "img/marker_"+this.getCategoryId()+".png"; this.srcIconHighlight_= "img/marker_"+this.getCategoryId()+"_roll.png"; this.icon_=this.getMarkerIcon(); // Bug Safari : var arguments ref�rence sur le tableau GMarker.apply(this,new Array(point, {icon:this.icon_, dragCrossMove:false, clickable:true, draggable:this.draggable_, bouncy:false})); this.setEditMode(false); } ZMarker.prototype = new GMarker(new GLatLng(0, 0)); ZMarker.prototype.initialize = function(map) { GMarker.prototype.initialize.call(this, map); this.map_ = map; } ZMarker.prototype.redraw = function(force) { GMarker.prototype.redraw.call(this, this.map_); } ZMarker.prototype.remove = function() { GMarker.prototype.remove.call(this); } ZMarker.prototype.removeFromMap = function() { if(this.zInfoBulle_!=null) this.zInfoBulle_=this.zInfoBulle_.removeFromMap(); this.map_.removeOverlay(this); return null; } ZMarker.prototype.getId = function() { return this.id_; } ZMarker.prototype.getLanguage = function() { return this.lang_; } ZMarker.prototype.getLoadingLanguage = function() { return this.loadingLang_; } ZMarker.prototype.isLoadingLanguage = function(){ return this.isLoadingLang_; } ZMarker.prototype.reset = function() { this.isInfoWindowOpen_ = false; this.setEditMode(false); } ZMarker.prototype.setImgTitles = function(textNode){ if(textNode.hasChildNodes() && textNode.getElementsByTagName('title').length){ var titles = textNode.getElementsByTagName('title'); for(var i=0;i0) { var element = document.getElementById(this.listEltName_+this.idZMarker); if ( element ) { element.style.background='#fdf06a'; element.style.cursor='pointer'; } } if(this.map_.getBounds().contains(this.getPoint())){ if(this.zInfoBulle_!=null) this.zInfoBulle_.setPoint(this.getPoint()); else{ if(this.map_.hasHoveredZMarker()) GEvent.trigger(this.map_.getHoveredZMarker(),'mouseout'); this.zInfoBulle_ = new ZInfoBulle(this.getPoint(),this.getZInfoBulleDOMContent()); this.map_.addOverlay(this.zInfoBulle_); this.map_.setHoveredZMarker(this); } } } ); GEvent.addListener(this,'mouseout',function(){ this.setImage(this.srcIcon_); if(parseInt(document.getElementById(this.listId_).style.width)>0){ var element = document.getElementById(this.listEltName_+this.idZMarker); if ( element ) { element.style.background='#ffffff'; element.style.cursor='auto'; } } if(this.zInfoBulle_!=null){ if(this.map_.hasHoveredZMarker() && this.map_.getHoveredZMarker().idZMarker!=this.idZMarker) GEvent.trigger(this.map_.getHoveredZMarker(),'mouseout'); this.zInfoBulle_=this.zInfoBulle_.removeFromMap(); this.map_.setHoveredZMarker(null); } } ); } } } ZMarker.prototype.getZInfoBulleContent= function(){ return '

'+this.categorie_.name+'
'+this.title_[this.lang_]+'

'; } ZMarker.prototype.getZInfoBulleDOMContent= function(){ var p = document.createElement('p'); p.id = 'infobulle_'+this.getCategoryId(); p.appendChild(document.createTextNode(this.categorie_.name)); p.appendChild(document.createElement('br')); var span = document.createElement('span'); span.setAttribute("class","titre"); span.setAttribute("className","titre"); span.appendChild(document.createTextNode(this.title_[this.lang_])); p.appendChild(span); return p; } ZMarker.prototype.getZInfoWindowDOMContent = function(optForm) { if( !this.inEditMode() ) { var info_window = document.createElement('div'); info_window.id = 'info_window'; var div = document.createElement('div'); div.id = 'info_image'; div.appendChild(this.buildImageNode()); info_window.appendChild(div); div = document.createElement('div'); div.id = 'info_text'; var element = document.createElement('div'); element.setAttribute( "class", "titre categ_" + this.getCategoryId() ); element.setAttribute( "className", "titre categ_" + this.getCategoryId() ); element.appendChild( document.createTextNode('\u00a0') ); div.appendChild(element); element = document.createElement('h5'); element.setAttribute( "class", "categ_"+this.categorie_.color ); element.setAttribute( "className", "categ_"+this.categorie_.color ); element.appendChild( document.createTextNode(this.categorie_.name) ); div.appendChild(element); var div2 = document.createElement('div'); div2.id = 'if_text'; element = document.createElement('h4'); element.id = 'if_title'; element.appendChild(document.createTextNode(this.title_[this.lang_])); div2.appendChild( element ); element = document.createElement('p'); element.id = 'if_address'; var texts = getTextNodes( this.address_[this.lang_] ); if(texts.length) { for( var i = 0; i < texts.length; i++ ) { element.appendChild(texts[i]); } } if( typeof(this.link_[this.lang_]) == 'string' && this.link_[this.lang_] != '' ) { element.appendChild(document.createElement('br')); texts = document.createElement('a'); texts.setAttribute('href',(this.link_[this.lang_].match(/^(http:\/\/)/i)?'':'http://')+this.link_[this.lang_]); texts.setAttribute('target','_blank'); texts.appendChild(document.createTextNode(this.link_[this.lang_].truncate(40))); element.appendChild(texts); } div2.appendChild(element); element = document.createElement('p'); element.id='if_desc'; texts = getTextNodes(this.desc_[this.lang_]); if( texts.length ) { for( var i=0;ithis.selectedLanguages_.length) element.appendChild(this.buildMoreLanguageTab()); for(var i=this.selectedLanguages_.length-1;i>=0;i--){ element.appendChild(this.buildTabForLanguage(this.selectedLanguages_[i])); } info_window.appendChild(element); } else{ var info_window = document.createElement('div'); info_window.id='info_window'; var element = document.createElement('h4'); element.appendChild(document.createTextNode(this.title_[this.lang_])); info_window.appendChild(element); element = document.createElement('p'); element.id='form_res'; element.appendChild(document.createTextNode('\u00a0')); info_window.appendChild(element); element = document.createElement('input'); element.id='hidIdPoi'; element.setAttribute('name','hidIdPoi'); element.setAttribute('type','hidden'); info_window.appendChild(element); element = document.createElement('div'); element.id='info_forms'; info_window.appendChild(element); element = document.createElement('div'); element.id='buttons'; var button = document.createElement('input'); button.id='annuler'; button.setAttribute('type','button'); button.setAttribute('value',optForm.cancelLabel); GEvent.addDomListener(button,'click',optForm.cancelFn); element.appendChild(button); button = document.createElement('input'); button.id='valider'; button.setAttribute('type','button'); button.setAttribute('value',optForm.saveLabel); GEvent.addDomListener(button,'click',optForm.saveFn); element.appendChild(button); info_window.appendChild(element); } return info_window; } ZMarker.prototype.buildImageNode = function(){ var node = document.createElement('div'); node.id = 'image_container'; if(this.img_){ var img = document.createElement('img'); img.setAttribute('src',this.img_.src); if(this.imageContainer_) { var width, height; if(this.img_.width > this.img_.height) { width = this.imageContainer_.maxWidth; height = Math.ceil( width * (this.img_.height / this.img_.width) ); if(height > this.imageContainer_.maxHeight) { height = this.imageContainer_.maxHeight; width = Math.ceil( height * (this.img_.width / this.img_.height) ); if( width > this.imageContainer_.maxWidth ) width = this.imageContainer_.maxWidth; } else if(height < this.imageContainer_.maxHeight) { var marginTop = Math.ceil((this.imageContainer_.maxHeight - height) / 2); img.setAttribute('style','margin-top:'+marginTop+'px;'); } } else { height = this.imageContainer_.maxHeight; width = Math.ceil( height * (this.img_.width / this.img_.height) ); } img.setAttribute('width', width); img.setAttribute('height', height); } else { img.setAttribute('width',this.img_.width); img.setAttribute('height',this.img_.height); } /*if(typeof(this.img_.title[this.lang_])!='undefined') img.setAttribute('title',htmlEntities(this.img_.title[this.lang_]));*/ if(this.moreInfoLink_!=''){ var elt = document.createElement('a'); elt.id='a-img'; elt.setAttribute('href','javascript:zMarkerManager.markers['+this.idZMarker+'].displayZM()'); elt.appendChild(img); node.appendChild(elt); elt = document.createElement('p'); elt.id = 'p-zoom-warning'; elt.appendChild(document.createTextNode(this.lblMorePhotosLabel_)); node.appendChild(elt); } else node.appendChild(img); } return node; } ZMarker.prototype.buildEmbedNode = function() { var flashvars = {indexURL : window.location.protocol + '//' + window.location.hostname + '/scripts/buildZML.php?id=' + this.idZMarker + '%26langue=' +this.lang_}; var params = { menu: "false", quality:"high", salign:"", play:"true", loop:"false", scale:"noscale", wmode:"window", // window devicefont:"false", bgcolor:"#ffffff", allowfullscreen:"true", allowscriptaccess:"always" }; var attributes = { id: "ZMBrowser", name: "ZMBrowser", align:"middle" }; swfobject.embedSWF( "http://content.zoomorama.net/static/app/browser/zoomolocal@zoomorama.com/release/latest/browser.swf", "image_container", "370", "277", "9.0.28", "http://content.zoomorama.net/static/app/assets/swfobject-2.1/expressInstall.swf", flashvars, params, attributes ); } ZMarker.prototype.displayZM = function() { var infoWindow = document.getElementById('info_image'); var a = document.getElementById('a-more-images'); if(infoWindow && infoWindow.hasChildNodes()) { if( infoWindow.firstChild.id == 'if_directions_form' || this.embedDisplayed) { infoWindow.replaceChild( this.buildImageNode(), infoWindow.firstChild ); if(a) a.replaceChild( document.createTextNode( this.lblMoreImagesLink_ ), a.firstChild ); this.embedDisplayed = false; } else if( !this.embedDisplayed ) { this.buildEmbedNode(); if(a) a.replaceChild( document.createTextNode( this.lblLessImagesLink_ ), a.firstChild ); this.embedDisplayed = true; } } } ZMarker.prototype.displayDirectionsForm = function() { var infoWindow = document.getElementById('info_image'); if(infoWindow && infoWindow.hasChildNodes() && infoWindow.firstChild.id != 'if_directions_form') { var div = document.createElement('div'); div.id = 'if_directions_form'; var element = document.createElement('h4'); element.appendChild( document.createTextNode(this.formLabels_.directions)); div.appendChild(element); element = document.createElement('h5'); element.appendChild( document.createTextNode(this.formLabels_.address + ' : ' ) ); div.appendChild( element ); var address = this.address_[this.lang_].replace(/([0-9\(\)]{2,}\s?){3,}/g, ''); var address = address.replace(/T(e|é)l\s?:\s?/g, ''); var address = address.replace(/Fax\s?:\s?/g, ''); element = document.createElement('span'); element.appendChild( document.createTextNode( address ) ) div.appendChild( element ); element = document.createElement('div'); element.id = 'if_directions_toform'; var span = document.createElement('span'); span.appendChild( document.createTextNode( this.formLabels_.to ) ); element.appendChild( span ); element.appendChild( document.createTextNode( ' | ' ) ); var a = document.createElement('a'); a.setAttribute( 'href', 'javascript:zMarkerManager.markers['+this.idZMarker+'].switchForm();' ); a.appendChild( document.createTextNode( this.formLabels_.from ) ); element.appendChild( a ); element.appendChild( document.createElement('br') ) span = document.createElement('label'); span.setAttribute('for', 'txtIfDirFrom'); span.appendChild( document.createTextNode( this.formLabels_.startAddress ) ); element.appendChild( span ); var input = document.createElement('input'); input.id = 'txtIfDirFrom'; input.setAttribute('type', 'text'); element.appendChild( input ); div.appendChild(element); element = document.createElement('div'); element.id = 'if_directions_fromform'; a = document.createElement('a'); a.setAttribute( 'href', 'javascript:zMarkerManager.markers['+this.idZMarker+'].switchForm();' ); a.appendChild( document.createTextNode( this.formLabels_.to ) ); element.appendChild( a ); element.appendChild( document.createTextNode( ' | ' ) ); span = document.createElement('span'); span.appendChild( document.createTextNode( this.formLabels_.from ) ); element.appendChild( span ); element.appendChild( document.createElement('br') ) span = document.createElement('label'); span.setAttribute('for', 'txtIfDirTo'); span.appendChild( document.createTextNode( this.formLabels_.endAddress ) ); element.appendChild( span ); var input = document.createElement('input'); input.id = 'txtIfDirTo'; input.setAttribute('type', 'text'); element.appendChild( input ); div.appendChild(element); element = document.createElement('select'); element.id = 'selIfDirMode'; var option = document.createElement('option'); option.setAttribute('value', 'car'); option.appendChild( document.createTextNode(this.formLabels_.car)); element.appendChild(option); option = document.createElement('option'); option.setAttribute('value', 'foot'); option.appendChild( document.createTextNode(this.formLabels_.foot)); element.appendChild(option); div.appendChild(element); element = document.createElement('input'); element.id = 'bt_if_directions_form'; element.setAttribute('type', 'button'); element.setAttribute('value', this.formLabels_.directions); div.appendChild( element ); var zMarker_ = this; GEvent.addDomListener(element, 'click', function(e) { zMarker_.postForm(); } ); element = document.createElement('a'); element.setAttribute( 'href', 'javascript:zMarkerManager.markers['+this.idZMarker+'].displayZM();' ); element.appendChild( document.createTextNode( '<< ' + this.formLabels_.back ) ); div.appendChild( element ); infoWindow.replaceChild( div, infoWindow.firstChild ); a = document.getElementById('a-more-images'); if( a ) a.replaceChild( document.createTextNode( this.lblLessImagesLink_ ), a.firstChild ); } } ZMarker.prototype.switchForm = function() { var fromForm = document.getElementById('if_directions_fromform'); var toForm = document.getElementById('if_directions_toform'); if(fromForm && toForm) { if(fromForm.style.display != 'block') { toForm.style.display = 'none'; fromForm.style.display = 'block'; } else { fromForm.style.display = 'none'; toForm.style.display = 'block'; } } } ZMarker.prototype.postForm = function() { var from, to; var fromForm = document.getElementById('if_directions_fromform'); var toForm = document.getElementById('if_directions_toform'); if(fromForm && toForm) { if(fromForm.style.display != 'block') { to = this.getPoint().y + ',' + this.getPoint().x; from = document.getElementById('txtIfDirFrom').value; } else { to = document.getElementById('txtIfDirTo').value; from = this.getPoint().y + ',' + this.getPoint().x; } if(document.getElementById('selIfDirMode').value == 'foot') var transport_mode = G_TRAVEL_MODE_WALKING; else var transport_mode = G_TRAVEL_MODE_DRIVING; if(from && to && this.postFormFn_) this.postFormFn_(from, to, transport_mode); } } ZMarker.prototype.displayLanguageTab = function(langue) { if( !this.draggingEnabled() && this.lang_!=langue && !this.isLoadingLang_ && this.availableLanguages_.search(langue) >= 0 ) { if( typeof(this.title_[langue]) == 'undefined' && this.loadDataUrl_ ) { this.isLoadingLang_ = true; this.loadingLang_ = langue; var data = "id=" + this.idZMarker + "&langue=" + langue; var ZMarker_ = this; var xhr = new ZHTTPRequest("POST","xml",true); xhr.setCompleteCallback( function(xml_doc) { if( xml_doc != null ) { if( zMarkerManager.markerExists( ZMarker_.idZMarker ) ) { ZMarker_.setImgTitles(xml_doc.getElementsByTagName("vignette")[0]); ZMarker_.setTextFields(xml_doc.getElementsByTagName("textes")[0]); ZMarker_.displayLanguageTab(ZMarker_.getLoadingLanguage()) } } } ); xhr.setFailureCallback( function(){alert("Request failed, please try again later")} ); xhr.query( this.loadDataUrl_, data ); } else if( typeof(this.title_[langue])!='undefined' ) { this.lang_ = langue; if(this.loadingLang_ == langue) this.loadingLang_ = ''; if( this.selectedLanguages_.search(langue) == -1 ) this.addLanguageTab( this.lang_ ); this.displayTextForLanguage( this.lang_ ); this.setSelectedTab( this.lang_ ); } } } ZMarker.prototype.addLanguageTab = function(langue) { var new_tab = this.buildTabForLanguage(langue); var container = document.getElementById('langue_selector'); var as = container.getElementsByTagName('a'); if( as[0].id != 'bt_lng_sel_more' ) container.replaceChild(as[0]); else container.removeChild(as[1]); container.appendChild(new_tab); var temp = []; temp.push(langue); var i = 0; while( temp.length < this.maxLanguagesTabs_ && i < this.selectedLanguages_.length ) { temp.push( this.selectedLanguages_[i] ); i++; } this.selectedLanguages_ = temp delete temp; } ZMarker.prototype.displayTextForLanguage = function(langue) { var element = document.getElementById('if_title'); element.removeChild(element.firstChild); element.appendChild(document.createTextNode(this.title_[langue])); element = document.getElementById('if_address'); while(element.hasChildNodes()) { element.removeChild(element.firstChild); } var texts = getTextNodes(this.address_[langue]); if(texts.length) { for(var i=0;i1?optForm:null)),optInfoWindow); this.map_.setZMarkerWithInfoWindow(this.idZMarker); } ZMarker.prototype.setZInfoWindowPosition = function(){ this.map_.getInfoWindow().reset(this.getPoint(),null,new GSize(620,280),new GSize(0,-this.getIcon().iconSize.height-this.getIcon().maxHeight)); } ZMarker.prototype.fitZInfoWindow = function(){ var offsetHeight=this.getIcon().maxHeight; while(offsetHeight>0){ offsetHeight--; setTimeout( 'zMap.getInfoWindow().reset( zMarkerManager.markers['+this.idZMarker+'].getPoint(), null, new GSize(620,280), new GSize(0,' + (-this.getIcon().iconSize.height-offsetHeight) + '))',(500/this.getIcon().maxHeight)); } } ZMarker.prototype.getCategoryId = function(){ return this.categorie_.id; } ZMarker.prototype.getDistanceToCenter = function(){ return this.distance_; } ZMarker.prototype.setDistanceToCenter = function(distance){ this.distance_=distance; } ZMarker.prototype.inEditMode = function(){ return (this.draggable_ && this.draggingEnabled()); } ZMarker.prototype.drawLineToCenter = function(){ if(this.zPolyline) this.removeLineToCenter(); this.zPolyline = new ZPolyline(new Array(this.map_.getCenter(),this.getPoint()), '#'+this.categorie_.color, 3, 0.7, null, 'dash'); this.map_.addOverlay(this.zPolyline); } ZMarker.prototype.removeLineToCenter = function(){ if(this.zPolyline){ this.map_.removeOverlay(this.zPolyline); delete this.zPolyline; } } ZMarker.prototype.getMarkerIcon = function(){ var icon = new GIcon(); icon.image = this.srcIcon_; icon.iconSize = new GSize(37, 51); icon.shadow = this.srcIconShadow_; icon.shadowSize = new GSize(57, 51); icon.iconAnchor = new GPoint(18, 51); icon.infoWindowAnchor = new GPoint(17,1); icon.maxHeight=13; icon.transparent=this.srcIconTransparent_; icon.imageMap=[1,1,1,33,13,33,14,37,15,41,16,49,17,50,19,50,20,49,21,41,35,33,35,1]; //icon.imageMap=[0,0,36,0,36,33,22,33,18,48,14,33,0,33]; /*icon.printImage=''; icon.mozPrintImage=''; icon.printShadow=''; */ return icon; } function ZMarkerTemp(point,options) { this.isZMarkerTemp=true; this.srcIcon_= options.srcIcon || "img/marker_edit.png"; this.srcIconShadow_= options.srcIconShadow || "img/marker_shadow.png"; this.srcIconTransparent_ = options.srcIconTransparent || "img/marker_transparent.png"; this.icon_= this.getMarkerIcon(); //this.icon_=new GIcon(G_DEFAULT_ICON); this.title_ = options.title || ''; this.cancelLabel_ = options.cancelLabel || ""; this.saveLabel_ = options.saveLabel || ""; this.cancelFn_ = options.cancelFn || ""; this.saveFn_ = options.saveFn || ""; this.lang_ = options.lang || ""; //var arguments = new Array(point, {icon:this.icon_, dragCrossMove:false, clickable:true, draggable:true, bouncy:false, bounceGravity:1}); GMarker.apply(this,new Array(point, {icon:this.icon_, dragCrossMove:false, clickable:true, draggable:true, bouncy:false, bounceGravity:1})); GEvent.addListener(this,'drag',this.setZInfoWindowPosition); GEvent.addListener(this,'dragend',this.fitZInfoWindow); } ZMarkerTemp.prototype = new GMarker(new GLatLng(0, 0)); ZMarkerTemp.prototype.initialize = function(map) { GMarker.prototype.initialize.call(this, map); this.map_ = map; } ZMarkerTemp.prototype.redraw = function(force) { GMarker.prototype.redraw.call(this, this.map_); } ZMarkerTemp.prototype.remove = function() { GMarker.prototype.remove.call(this); } ZMarkerTemp.prototype.removeFromMap = function() { this.map_.removeOverlay(this); return null; } ZMarkerTemp.prototype.getZInfoWindowContent = function(){ var info_window = document.createElement('div'); info_window.id='info_window'; var element = document.createElement('h4'); element.appendChild(document.createTextNode(this.title_)); info_window.appendChild(element); element = document.createElement('p'); element.id='form_res'; element.appendChild(document.createTextNode('\u00a0')); info_window.appendChild(element); element = document.createElement('input'); element.id='hidIdPoi'; element.setAttribute('name','hidIdPoi'); element.setAttribute('type','hidden'); info_window.appendChild(element); element = document.createElement('div'); element.id='info_forms'; info_window.appendChild(element); ZForm.initialize(element,this.lang_); element = document.createElement('div'); element.id='buttons'; var button = document.createElement('input'); button.id='annuler'; button.setAttribute('type','button'); button.setAttribute('value',this.cancelLabel_); GEvent.addDomListener(button,'click',this.cancelFn_); element.appendChild(button); button = document.createElement('input'); button.id='valider'; button.setAttribute('type','button'); button.setAttribute('value',this.saveLabel_); GEvent.addDomListener(button,'click',this.saveFn_); element.appendChild(button); info_window.appendChild(element); return info_window; } ZMarkerTemp.prototype.openZInfoWindow = function(options){ options.pixelOffset=new GSize(0,-this.getIcon().iconSize.height); this.map_.setZMarkerTempWithInfoWindow(); this.openInfoWindow(this.getZInfoWindowContent(),options); } ZMarkerTemp.prototype.setZInfoWindowPosition = function(){ this.map_.getInfoWindow().reset(this.getPoint(), null, new GSize(620,280),new GSize(0,-this.getIcon().iconSize.height-this.getIcon().maxHeight)); } ZMarkerTemp.prototype.fitZInfoWindow = function(){ var offsetHeight=this.getIcon().maxHeight; while(offsetHeight>0){ offsetHeight--; setTimeout('zMap.getInfoWindow().reset(zMarkerTemp.getPoint(), null, new GSize(620,280),new GSize(0,'+(-this.getIcon().iconSize.height-offsetHeight)+'))',(500/this.getIcon().maxHeight)); } } ZMarkerTemp.prototype.getMarkerIcon = function(){ var icon = new GIcon(); icon.image = this.srcIcon_; icon.shadow = this.srcIconShadow_; icon.iconSize = new GSize(37, 51); icon.maxHeight=13; icon.shadowSize = new GSize(57, 51); icon.iconAnchor = new GPoint(18, 51); icon.infoWindowAnchor = new GPoint(17,1); icon.transparent=this.srcIconTransparent_; icon.imageMap=[1,1,1,33,13,33,14,37,15,41,16,49,17,50,19,50,20,49,21,41,35,33,35,1]; return icon; } function ZMarkerGeocoded( placemark, zoomolevel, options ) { this.isZMarkerGeocoded = true; this.idZMarkerGeocoded = null; this.drawn = false; this.isDrawn_ = false; this.zoomLevel_ = zoomolevel; this.labels_ = options ? ( options.labels || null ) : null; this.postFormFn_ = options ? ( options.postFormFn || null ) : null; this.srcIcon_ = options?(options.srcIcon || "img/marker_geoloc.png"):"img/marker_geoloc.png"; this.srcIconShadow_ = options?(options.srcIconShadow || "img/marker_geolocshadow.png"):"img/marker_geolocshadow.png"; this.srcIconHighlight_ = options?(options.srcIconHighlight || "img/marker_geolocroll.png"):"img/marker_geolocroll.png"; this.srcIconTransparent_ = options?(options.srcIconTransparent || "img/marker_geoloctransparent.png"):"img/marker_geoloctransparent.png"; this.listId_='list_zmarker'; this.listEltName_ = 'list_eltg'; if(this.srcIcon_!="") this.icon_= this.getMarkerIcon(); else this.icon_= G_DEFAULT_ICON; this.placemark_ = placemark; if(this.placemark_.Point) this.point_ = new GLatLng(this.placemark_.Point.coordinates[1],this.placemark_.Point.coordinates[0]); else this.point_ = new GLatLng(0,0); if(this.placemark_.address) this.location_=this.placemark_.address; else this.location_=''; GMarker.apply(this,new Array(this.point_, {title:this.location_,icon:this.icon_})); } ZMarkerGeocoded.prototype = new GMarker(new GLatLng(0,0)); ZMarkerGeocoded.prototype.initialize = function(map) { GMarker.prototype.initialize.call(this, map); this.map_ = map; this.drawn=true; } ZMarkerGeocoded.prototype.redraw = function(force) { GMarker.prototype.redraw.call(this, this.map_); } ZMarkerGeocoded.prototype.remove = function() { GMarker.prototype.remove.call(this); } ZMarkerGeocoded.prototype.removeFromMap = function() { this.map_.removeOverlay(this); return null; } ZMarkerGeocoded.prototype.getLocation = function() { return this.location_; } ZMarkerGeocoded.prototype.getZoomLevel = function() { return this.zoomLevel_; } ZMarkerGeocoded.prototype.setId = function(id){ this.idZMarkerGeocoded=id; this.addMouseEvents(); } ZMarkerGeocoded.prototype.getId = function(){ return this.idZMarkerGeocoded; } ZMarkerGeocoded.prototype.setIsDrawn = function(value){ this.isDrawn_=value; } ZMarkerGeocoded.prototype.isDrawn = function(){ return this.isDrawn_; } ZMarkerGeocoded.prototype.openZInfoWindow = function(options) { options.pixelOffset=new GSize(0,-this.getIcon().iconSize.height); var div = document.createElement('div'); div.id = 'info_geocoded'; var h5 = document.createElement('h5'); h5.appendChild( document.createTextNode( this.labels_.title + ' : ' ) ); div.appendChild( h5 ); div.appendChild(document.createTextNode(this.location_)); var formDiv = document.createElement('div'); formDiv.id = 'info_geocoded_toform'; formDiv.appendChild( document.createTextNode( this.labels_.directions + ' : ') ); var span = document.createElement('span'); span.appendChild( document.createTextNode( this.labels_.to ) ); formDiv.appendChild( span ); formDiv.appendChild( document.createTextNode( ' - ' ) ); var a = document.createElement('a'); a.setAttribute( 'href', 'javascript:zMarkerManager.geocodedMarkers['+this.idZMarkerGeocoded+'].switchForm();' ); a.appendChild( document.createTextNode( this.labels_.from ) ); formDiv.appendChild( a ); formDiv.appendChild( document.createElement('br') ) span = document.createElement('label'); span.setAttribute('for', 'txtIfFrom'); span.appendChild( document.createTextNode( this.labels_.startAddress ) ); formDiv.appendChild( span ); var input = document.createElement('input'); input.id = 'txtIfFrom'; input.setAttribute('type', 'text'); formDiv.appendChild( input ); input = document.createElement('input'); input.id = 'bt_txtFrom'; input.setAttribute('type', 'button'); input.setAttribute('value', this.labels_.ok); formDiv.appendChild( input ); div.appendChild(formDiv); var zMarkerGeocoded_ = this; GEvent.addDomListener(input, 'click', function(e) { zMarkerGeocoded_.postForm(); } ); formDiv = document.createElement('div'); formDiv.id = 'info_geocoded_fromform'; formDiv.appendChild( document.createTextNode( this.labels_.directions + ' : ' ) ); a = document.createElement('a'); a.setAttribute( 'href', 'javascript:zMarkerManager.geocodedMarkers['+this.idZMarkerGeocoded+'].switchForm();' ); a.appendChild( document.createTextNode( this.labels_.to ) ); formDiv.appendChild( a ); formDiv.appendChild( document.createTextNode( ' - ' ) ); span = document.createElement('span'); span.appendChild( document.createTextNode( this.labels_.from ) ); formDiv.appendChild( span ); formDiv.appendChild( document.createElement('br') ) span = document.createElement('label'); span.setAttribute('for', 'txtIfTo'); span.appendChild( document.createTextNode( this.labels_.endAddress ) ); formDiv.appendChild( span ); var input = document.createElement('input'); input.id = 'txtIfTo'; input.setAttribute('type', 'text'); formDiv.appendChild( input ); input = document.createElement('input'); input.id = 'bt_txtTo'; input.setAttribute('type', 'button'); input.setAttribute('value', this.labels_.ok); formDiv.appendChild( input ); div.appendChild(formDiv); GEvent.addDomListener(input, 'click', function(e) { zMarkerGeocoded_.postForm(); } ); this.openInfoWindow( div, options); this.map_.setZMarkerGeoWithInfoWindow(this.getId()); } ZMarkerGeocoded.prototype.switchForm = function() { var fromForm = document.getElementById('info_geocoded_fromform'); var toForm = document.getElementById('info_geocoded_toform'); if(fromForm && toForm) { if(fromForm.style.display != 'block') { toForm.style.display = 'none'; fromForm.style.display = 'block'; } else { fromForm.style.display = 'none'; toForm.style.display = 'block'; } } } ZMarkerGeocoded.prototype.postForm = function() { var from, to; var fromForm = document.getElementById('info_geocoded_fromform'); var toForm = document.getElementById('info_geocoded_toform'); if(fromForm && toForm) { if(fromForm.style.display != 'block') { to = this.location_; from = document.getElementById('txtIfFrom').value; } else { to = document.getElementById('txtIfTo').value; from = this.location_; } if(from && to && this.postFormFn_) this.postFormFn_(from, to); } } ZMarkerGeocoded.prototype.drawLineToCenter = function(){ if(this.zPolyline) this.removeLineToCenter(); this.zPolyline = new ZPolyline(new Array(this.map_.getCenter(),this.getPoint()), '#ff2020', 3, 0.7, null, 'dash'); this.map_.addOverlay(this.zPolyline); } ZMarkerGeocoded.prototype.removeLineToCenter = function(){ if(this.zPolyline){ this.map_.removeOverlay(this.zPolyline); delete this.zPolyline; } } ZMarkerGeocoded.prototype.getMarkerIcon = function(){ var icon = new GIcon(); icon.image = this.srcIcon_; icon.shadow = this.srcIconShadow_; icon.iconSize = new GSize(21, 47); icon.shadowSize = new GSize(35, 47); icon.iconAnchor = new GPoint(9, 45); icon.infoWindowAnchor = new GPoint(10,0); icon.transparent=this.srcIconTransparent_; icon.imageMap=[2,2,2,28,8,28,8,47,11,47,11,28,18,28,18,2]; return icon; } ZMarkerGeocoded.prototype.addMouseEvents = function(){ if(this.srcIconHighlight_!=""){ GEvent.clearListeners(this,'mouseover'); GEvent.clearListeners(this,'mouseout'); GEvent.addListener(this,'mouseover',function(){ this.setImage(this.srcIconHighlight_); if(parseInt(document.getElementById(this.listId_).style.width)>0){ document.getElementById(this.listEltName_+this.idZMarkerGeocoded).style.background='#fdf06a'; document.getElementById(this.listEltName_+this.idZMarkerGeocoded).style.cursor='pointer'; } } ); GEvent.addListener(this,'mouseout',function(){ this.setImage(this.srcIcon_); if(parseInt(document.getElementById(this.listId_).style.width)>0){ document.getElementById(this.listEltName_+this.idZMarkerGeocoded).style.background='#ffffff'; document.getElementById(this.listEltName_+this.idZMarkerGeocoded).style.cursor='auto'; } } ); } } function ZPolyline(points, color, weight, opacity, tooltip, dash) { this.tooltip_ = tooltip; this.dash_ = (dash != null) ? dash : "solid"; this.color_ = color; this.weight_ = weight; this.opacity_ = opacity; this.domId_='zpolyline'; this.usesVml = (navigator.userAgent.indexOf("MSIE") != -1); GPolyline.call(this,points,color,weight,opacity); } ZPolyline.prototype = new GPolyline(new Array(new GLatLng(0,0))); ZPolyline.prototype.initialize = function(map) { GPolyline.prototype.initialize.call(this,map); } ZPolyline.prototype.remove = function() { GPolyline.prototype.remove.call(this); } ZPolyline.prototype.redraw = function(force) { GPolyline.prototype.redraw.call(this,force); var elt=null; if(this.usesVml){ var shps = document.getElementsByTagName("shape"); if(shps.length){ elt = shps[shps.length-1]; if(this.tooltip != null){ elt.style.cursor = "help"; elt.title = this.tooltip; } if(this.domId_) elt.id = this.domId_; } } else{ var shps = document.getElementsByTagName("path"); if(shps.length){ elt = shps[shps.length-1]; if(this.tooltip != null){ elt.style.cursor = "help"; elt.setAttribute("title",this.tooltip); } elt.setAttribute("id",this.domId_); elt.setAttribute("pointer-events","stroke"); } } if(elt!=null){ this.setColor(this.color_); this.setDash(this.dash_); this.setOpacity(this.opacity_); this.setWeight(this.weight_); } } ZPolyline.prototype.setColor = function(color){ this.color_ = color; var elt = document.getElementById(this.domId_); if(this.usesVml) elt.stroke.color = this.color_; else elt.setAttribute("stroke",this.color_); } ZPolyline.prototype.getColor = function(){ return this.color_; } ZPolyline.prototype.setDash = function(dash) { this.dash_ = dash; var elt = document.getElementById(this.domId_); if(this.usesVml){ if(this.dash_ == "dash") elt.stroke.dashstyle = "dash"; else if (this.dash_ == "dot") elt.stroke.dashstyle = "dot"; else elt.stroke.dashstyle = ""; } else{ if(this.dash_ == "dash") elt.setAttribute("stroke-dasharray","10,10"); else if (this.dash_ == "dot") elt.setAttribute("stroke-dasharray","3,17"); else elt.setAttribute("stroke-dasharray",""); } } ZPolyline.prototype.getDash = function() { return this.dash_; } ZPolyline.prototype.setWeight = function(weight) { this.weight_ = weight; var elt = document.getElementById(this.domId_); if(this.usesVml) elt.stroke.weight = this.weight_+"px"; else elt.setAttribute("stroke-width",this.weight_+"px"); } ZPolyline.prototype.getWeight = function() { return this.weight_; } ZPolyline.prototype.setOpacity = function(opacity) { this.opacity_ = opacity; var elt = document.getElementById(this.domId_); if(this.usesVml) elt.stroke.opacity = this.opacity_; else elt.setAttribute("stroke-opacity",this.opacity_); } ZPolyline.prototype.getOpacity = function() { return this.opacity_; } ZPolyline.prototype.setDOMId = function(id) { this.domId_=id; } function ZForm(){} ZForm.prototype=ZForm; ZForm.prototype.buildOnglet = function(codeLangue, selected){ var onglet = document.createElement('div'); onglet.setAttribute('id','onglet_'+codeLangue); if(ZForm.languages[codeLangue]) onglet.setAttribute('title',ZForm.languages[codeLangue]); if (isIE()){ onglet.setAttribute("className","div-onglet"); onglet.onmouseover=function(){this.style.cursor='pointer'}; onglet.onmouseout=function(){this.style.cursor='auto'}; onglet.onclick=ZForm.showOnglet; } else{ onglet.setAttribute("class","div-onglet"); onglet.setAttribute("onclick","ZForm.showOnglet('"+codeLangue+"')"); onglet.setAttribute("onmouseover","this.style.cursor='pointer'"); onglet.setAttribute("onmouseout","this.style.cursor='auto'"); } onglet.setAttribute("title",ZForm.languages[codeLangue]); onglet.innerHTML=codeLangue; if(selected) onglet.style.fontWeight='bold'; return onglet; } ZForm.prototype.buildForm = function(codeLangue,labels, selected){ var corps = document.createElement('div'); corps.setAttribute('id','form_'+codeLangue); corps.setAttribute("class","div-form"); corps.setAttribute("className","div-form"); //corps.innerHTML='
'+ZForm.languages[codeLangue]+'
' html = '
' + ''; for( var i = 1; i <= 5; i++ ) { html += ''; } html += '
' +'
' + '' + '' + '' + '' + '' + '' +'
' +'
' + '' + '' +'
'; corps.innerHTML = html; if(selected) corps.style.display='block'; else corps.style.display='none'; return corps; } ZForm.prototype.buildFormPicture = function(codeLangue,labels, seleted){ var corps = document.createElement('div'); corps.setAttribute('id','form_'+codeLangue); corps.setAttribute("class","div-form"); corps.setAttribute("className","div-form"); var html = '
'+ZForm.languages[codeLangue]+'
'; for(var i=0;i<9;i++){ reste=i-(Math.floor(i/2)*2); html +='
' +'' +'
'; } corps.innerHTML=html; if(selected) corps.style.display='block'; else corps.style.display='none'; return corps; } ZForm.prototype.buildOngletLangue = function(){ var onglet = document.createElement('div'); onglet.setAttribute('id','onglet_lang'); if (isIE()){ onglet.onmouseover=function(){this.style.cursor='pointer'}; onglet.onmouseout=function(){this.style.cursor='auto'}; onglet.onclick=ZForm.showOnglet; } else{ onglet.setAttribute("onclick","ZForm.showOnglet('lang')"); onglet.setAttribute("onmouseover","this.style.cursor='pointer'"); onglet.setAttribute("onmouseout","this.style.cursor='auto'"); } onglet.innerHTML=ZForm.lblLanguages; return onglet; } ZForm.prototype.buildFormLangue = function(selLang){ var corps = document.createElement('div'); corps.setAttribute('id','form_lang'); corps.setAttribute("class","div-form"); corps.setAttribute("className","div-form"); var element = document.createElement('select'); element.setAttribute('id','selLangue'); element.setAttribute('name','selLangue'); element.setAttribute("title","Ajouter une langue"); var option = document.createElement('option'); option.setAttribute('id','selLangue_0'); option.setAttribute('value',''); option.innerHTML=ZForm.labels.langFirstOpt; element.appendChild(option); for(var codeLangue in ZForm.languages){ option = document.createElement('option'); option.setAttribute('id','selLangue_'+codeLangue); option.setAttribute('value',codeLangue); option.innerHTML=ZForm.languages[codeLangue]; element.appendChild(option); } delete option; corps.appendChild(element); var element= document.createElement('input'); element.setAttribute('type','button'); element.setAttribute("name","add_langue"); element.setAttribute("id","add_langue"); element.setAttribute("value",ZForm.labels.addButton); if (isIE()) element.onclick=ZForm.addLanguage; else element.setAttribute("onclick","ZForm.addLanguage()"); corps.appendChild(element); var element= document.createElement('h6'); element.innerHTML=ZForm.labels.languagesTableTitle; corps.appendChild(element); var element= document.createElement('table'); element.setAttribute("id","list_lang"); element.setAttribute("cellspacing","0"); var tbody=document.createElement('tbody'); ZForm.buildListLanguages(tbody,selLang); element.appendChild(tbody); delete tbody; corps.appendChild(element); delete element; return corps; } ZForm.prototype.initialize = function(parentDiv,selLang,labels){ if(parentDiv) { var divOnglets=document.createElement('div'); divOnglets.setAttribute('id','onglets'); var divForms=document.createElement('div'); divForms.setAttribute('id','forms'); for(var i=0;i'+ZForm.languages[codeLangue]+''; tr.appendChild(td); td_count++; reste=td_count-(Math.floor(td_count/cols)*cols); if(reste==0) parent.appendChild(tr); } i++; } if(!td_count){ tr = document.createElement('tr'); td = document.createElement('td'); td.innerHTML='Aucune'; tr.appendChild(td); parent.appendChild(tr); } //return tbody; } ZForm.prototype.languageExists = function(codeLangue){ var exists=false, divOnglets=document.getElementById('onglets'), i=0; while(!exists && i2 && document.getElementById('onglet_'+codeLangue) && document.getElementById('onglet_'+codeLangue).parentNode.getAttribute('id')=='onglets'){ divOnglets.removeChild(document.getElementById('onglet_'+codeLangue)); divForms.removeChild(document.getElementById('form_'+codeLangue)); ZForm.clearListLanguages(); ZForm.listLanguages(); } } } ZForm.prototype.addForm = function(codeLangue) { var divOnglets=document.getElementById('onglets'); var divForms=document.getElementById('forms'); divOnglets.insertBefore(ZForm.buildOnglet(codeLangue),divOnglets.childNodes[divOnglets.childNodes.length-1]); if(divForms.parentNode.getAttribute('id')=='titles') divForms.insertBefore(ZForm.buildFormPicture(codeLangue),divForms.childNodes[divForms.childNodes.length-1]); else divForms.insertBefore(ZForm.buildForm(codeLangue),divForms.childNodes[divForms.childNodes.length-1]); } ZForm.prototype.setFieldValueForLanguage = function(id_field,codeLangue,value){ if(document.getElementById(id_field+'_'+codeLangue)){ document.getElementById(id_field+'_'+codeLangue).value=value; return true; } else return false; } ZForm.prototype.getFieldValueForLanguage = function(id_field,codeLangue){ if(document.getElementById(id_field+'_'+codeLangue)) return document.getElementById(id_field+'_'+codeLangue).value.trim(); else return ''; } ZForm.prototype.setFieldValue = function(id_field,value){ if(document.getElementById(id_field)){ document.getElementById(id_field).value=value; return true; } else return false; } ZForm.prototype.getFieldValue = function(id_field){ if(document.getElementById(id_field)) return document.getElementById(id_field).value.trim(); else return ''; } ZForm.prototype.setValuesFor = function(name,value){ var div=document.getElementById('forms'); for(var i=0;i0) dLanguages+=';'; dLanguages+=lang; var j=0; while(j'+text+''; } ZForm.prototype.resetDialog = function(){ document.getElementById('form_res').style.background='none'; document.getElementById('form_res').innerHTML=' '; } ZForm.prototype.proccessingDialog = function(text){ document.getElementById('form_res').style.background='url(img/loading_16x16.gif) 5px 0px no-repeat'; document.getElementById('form_res').innerHTML=text; } ZForm.prototype.lock = function(on){ if(on) ZForm.locked=true; else ZForm.locked=false; var forms=document.getElementById('forms').getElementsByTagName('div'); for(var i=0;i this.minWidth_; } ZPanel.prototype.displayDirectionsPanel = function() { this.searchPanel_.style.display = 'none'; this.directionsPanel_.style.display = 'inline'; } ZPanel.prototype.displaySearchPanel = function() { gDirections.clear(); this.directionsPanel_.style.display = 'none'; this.searchPanel_.style.display = 'inline'; } ZPanel.prototype.swapDirectionsFormValues = function() { var temp = document.getElementById('txtFrom').value; document.getElementById('txtFrom').value = document.getElementById('txtTo').value; document.getElementById('txtTo').value = temp; } ZPanel.prototype.display = function() { if( this.isOpen() ) { this.resetSearchForm(); this.resetFastSearchForm(); var offset = (this.maxWidth_ - this.minWidth_) / 2; this.container_.style.width = this.minWidth_ + 'px'; this.tab_.style.right = this.minWidth_ + 'px'; this.tab_.style.backgroundImage='url(img/show-arrow.png)'; if(isIE6()) this.map_.getContainer().style.width = ((document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth) - this.minWidth_) + 'px'; else this.map_.getContainer().style.right = this.minWidth_ + 'px'; this.fastSearchForm_.style.visibility="visible"; this.markerManager_.removeGeocodedMarkers(); this.centerCross_.style.display = 'none'; this.displaySearchPanel(); if(this.onCloseFn_) this.onCloseFn_(); } else { this.buildList(); var offset = (this.minWidth_ - this.maxWidth_) / 2; this.container_.style.width = this.maxWidth_ + 'px'; this.tab_.style.right = this.maxWidth_ + 'px'; this.tab_.style.backgroundImage='url(img/hide-arrow.png)'; if(isIE6()) this.map_.getContainer().style.width = ((document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth) - this.maxWidth_) + 'px'; else this.map_.getContainer().style.right = this.maxWidth_ + 'px'; this.fastSearchForm_.style.visibility="hidden"; this.centerCross_.style.display = 'block'; if(this.onOpenFn_) this.onOpenFn_(); } this.map_.checkResize() this.map_.panBy(new GSize(offset,0)); } ZPanel.prototype.buildList = function() { var idCateg=0; var dt=null; var dd=null; var span = null; this.emptyList(); if(this.markerManager_.geocodedMarkers.length) { var center = this.map_.getCenter(); dt = document.createElement('dt'); if(isIE()) dt.style.setAttribute('cssText','color:#ff2020;'); else dt.setAttribute('style','color:#ff2020;'); dt.appendChild( document.createTextNode( this.markerManager_.listGeolocalisationLabel ) ); this.listContainer_.appendChild(dt); for(var i in this.markerManager_.geocodedMarkers) { if(!isNaN(i)) { dd = document.createElement('dd'); dd.setAttribute('id','list_eltg' + this.markerManager_.geocodedMarkers[i].getId()); dd.setAttribute('zmarkergeoid',this.markerManager_.geocodedMarkers[i].getId()); if(isIE()) dd.style.setAttribute('cssText','color:#000000;'); else dd.setAttribute('style','color:#000000;'); span = document.createElement('span'); if(isIE()) span.style.setAttribute('cssText','color:#ff2020;'); else span.setAttribute('style','color:#ff2020;'); span.appendChild( document.createTextNode(meterToKM(center.distanceFrom(this.markerManager_.geocodedMarkers[i].getPoint()),2)+' km') ); dd.appendChild( document.createTextNode(this.markerManager_.geocodedMarkers[i].getLocation()+' ') ); dd.appendChild( span ); ZEvent.addEventListener(dd, 'mouseout', this.listElementMouseEvent,false); ZEvent.addEventListener(dd, 'mouseover', this.listElementMouseEvent,false); ZEvent.addEventListener(dd, 'click', this.listElementMouseEvent,false); this.listContainer_.appendChild( dd ); } } } if(this.markerManager_.markers.length) { for(var i in this.markerManager_.markers) { if(!isNaN(i) && this.markerManager_.markers[i].isOnMap) { if(idCateg != this.markerManager_.markers[i].categorie_.id) { dt=document.createElement('dt'); if(isIE()) dt.style.setAttribute('cssText','color:#'+this.markerManager_.markers[i].categorie_.color+';'); else dt.setAttribute('style','color:#'+this.markerManager_.markers[i].categorie_.color+';'); dt.appendChild(document.createTextNode(this.markerManager_.markers[i].categorie_.name)); this.listContainer_.appendChild(dt); idCateg = this.markerManager_.markers[i].categorie_.id; } var dd=document.createElement('dd'); dd.setAttribute('id','list_elt'+this.markerManager_.markers[i].idZMarker); dd.setAttribute('zmarkerid',this.markerManager_.markers[i].idZMarker); span = document.createElement('span'); if(isIE()) span.style.setAttribute('cssText','font-weight:bold;'); else span.setAttribute('style','font-weight:bold;'); span.appendChild( document.createTextNode(this.markerManager_.markers[i].title_[this.markerManager_.markers[i].lang_]+' ') ); dd.appendChild( span ); span = document.createElement('span'); if(isIE()) span.style.setAttribute('cssText','color:#'+this.markerManager_.markers[i].categorie_.color+';'); else span.setAttribute('style','color:#'+this.markerManager_.markers[i].categorie_.color+';'); span.appendChild( document.createTextNode(meterToKM(this.markerManager_.markers[i].getDistanceToCenter(),2)+' km') ); dd.appendChild(span); dd.appendChild(document.createElement('br')); dd.appendChild(document.createTextNode( this.markerManager_.markers[i].address_[this.markerManager_.markers[i].lang_]) ); ZEvent.addEventListener(dd, 'mouseout', this.listElementMouseEvent,false); ZEvent.addEventListener(dd, 'mouseover', this.listElementMouseEvent,false); ZEvent.addEventListener(dd, 'click', this.listElementMouseEvent,false); this.listContainer_.appendChild( dd ); } } } this.addResultWarning(); } ZPanel.prototype.emptyList = function() { while(this.listContainer_.hasChildNodes()) { ZEvent.dispatchEvent(this.listContainer_.firstChild, 'MouseEvents', 'mouseout'); ZEvent.removeEventListener(this.listContainer_.firstChild, 'mouseout', this.listElementMouseEvent,false); ZEvent.removeEventListener(this.listContainer_.firstChild, 'mouseover', this.listElementMouseEvent,false); ZEvent.removeEventListener(this.listContainer_.firstChild, 'click', this.listElementMouseEvent,false); this.listContainer_.removeChild(this.listContainer_.firstChild); } } ZPanel.prototype.addResultWarning = function() { if( this.markerManager_.visibleMarkers == 0 || this.markerManager_.visibleMarkers == this.markerManager_.maxMarkers ) { var dt = document.createElement('dt'); if(isIE()) dt.style.setAttribute('cssText','color:#bf282d;'); else dt.setAttribute('style','color:#bf282d;'); if( this.markerManager_.visibleMarkers ==0 ) { dt.appendChild(document.createTextNode(this.markerManager_.listNoResultLabel)); this.listContainer_.appendChild(dt); } else { dt.appendChild(document.createTextNode(this.markerManager_.listMaxResultsLabel)); this.listContainer_.insertBefore(dt,this.listContainer_.firstChild); } } } ZPanel.prototype.resetSearchForm = function() { this.resetForm( this.searchForm_ ) } ZPanel.prototype.resetFastSearchForm = function() { this.resetForm( this.fastSearchForm_ ) } ZPanel.prototype.resetForm = function( form ) { var inputs = form.getElementsByTagName('input'); for(var i = 0; i < inputs.length; i++) { if(inputs[i].getAttribute('type') != 'button') { if(inputs[i].getAttribute('type') == 'radio' || inputs[i].getAttribute('type')=='checkbox') inputs[i].checked = false; else inputs[i].value = inputs[i].getAttribute('default_value') ? inputs[i].getAttribute('default_value') : ''; } } var selects = form.getElementsByTagName('select'); for(var i = 0; i < selects.length; i++) { selects[i].value = selects[i].getAttribute('default_value') ? selects[i].getAttribute('default_value') : ''; } } function ZCategoriesManager(categories, options) { this.categories_ = categories || []; this.selected_ = []; this.idPrefix_ = options.id_Prefix || 'a-category-'; this.classPrefix_ = options.classPrefix || 'cl-category-'; this.onUpdateFn_ = options.onUpdateFn || null; } ZCategoriesManager.prototype.update = function( id ) { var elt = document.getElementById( this.idPrefix_ + id ); var exp = new RegExp('^'+this.classPrefix_+'(\\d+)-(on|off)$'); exp.exec(elt.className); var state = RegExp.$2; if( state == 'on' ) { elt.className = this.classPrefix_ + id + '-off'; this.removeFromSelected( id ); } else if( state == 'off' ) { elt.className = this.classPrefix_ + id + '-on'; this.addToSelected( id ); } this.setGroup( this.categories_[id] ); if( this.onUpdateFn_ ) this.onUpdateFn_(true); } ZCategoriesManager.prototype.setGroup = function( id ) { var a = document.getElementById('ul-category-' + id).getElementsByTagName('a'); var selected = false, i = 0, exp = new RegExp('^'+this.classPrefix_+'(\\d+)-(on|off)$'); while( !selected && i < a.length ) { exp.exec(a[i].className); if( RegExp.$2 == 'on' ) selected = true; i++; } if( selected ) document.getElementById('a-group-' + id).className = "cl-groups-" + id; else document.getElementById('a-group-' + id).className = "cl-groups-off"; } ZCategoriesManager.prototype.updateGroup = function( id ) { var group = document.getElementById('a-group-' + id); var a = document.getElementById('ul-category-' + id).getElementsByTagName('a'); var select, i = 0, exp = new RegExp('^'+this.classPrefix_+'(\\d+)-(on|off)$'); if( group.className != "cl-groups-off" ) { group.className = "cl-groups-off"; select = false; } else { group.className = "cl-groups-" + id; select = true; } while( i < a.length ) { exp.exec(a[i].className); if( !select && RegExp.$2 == 'on' ) { a[i].className = this.classPrefix_ + RegExp.$1 + '-off'; this.removeFromSelected( RegExp.$1 ); } else if( select && RegExp.$2 == 'off' ) { a[i].className = this.classPrefix_ + RegExp.$1 + '-on'; this.addToSelected( RegExp.$1 ); } i++; } if( this.onUpdateFn_ ) this.onUpdateFn_(true); } ZCategoriesManager.prototype.getSelected = function(){ return this.selected_.join(';'); } ZCategoriesManager.prototype.setSelected = function( arr ){ this.selected_ = arr; } ZCategoriesManager.prototype.addToSelected = function( id ) { this.selected_.push(id); } ZCategoriesManager.prototype.removeFromSelected = function( id ) { var idx = this.selected_.search(id); while( idx != -1 ) { this.selected_.splice(idx, 1); idx = this.selected_.search(id); } } ZCategoriesManager.prototype.init = function(str_categ) { var values = str_categ.split(';'); this.setSelected( values ); var ul = document.getElementById('header').getElementsByTagName('ul'); var exp = new RegExp('^'+this.classPrefix_+'(\\d+)-(on|off)$');; for( var i = 0; i < ul.length; i++ ) { if(ul[i].id.indexOf('ul-category') >= 0) { var a = ul[i].getElementsByTagName('a'); for( var j = 0; j < a.length; j++ ) { exp.exec(a[j].className); if( values.search( RegExp.$1 ) >= 0 ) a[j].className = this.classPrefix_ + RegExp.$1 + '-on'; else a[j].className = this.classPrefix_ + RegExp.$1 + '-off'; this.setGroup( this.categories_[RegExp.$1] ); } } } delete values; } ZCategoriesManager.prototype.updateAll = function( state ) { this.setSelected( [] ); var ul = document.getElementById('header').getElementsByTagName('ul'); var exp = new RegExp('^'+this.classPrefix_+'(\\d+)-(on|off)$');; for( var i = 0; i < ul.length; i++ ) { if(ul[i].id.indexOf('ul-category') >= 0) { var a = ul[i].getElementsByTagName('a'); for( var j = 0; j < a.length; j++ ) { exp.exec(a[j].className); a[j].className = this.classPrefix_ + RegExp.$1 + '-' + state; this.setGroup( this.categories_[RegExp.$1] ); if(state == 'on') this.addToSelected( RegExp.$1 ); } } } } function resetSearchCriteria() { if(sText != '' || sCategory != '') { sText = ''; sCategory = ''; loadPOI(true); } }