String.prototype.trim=function() { return (this.replace(/\s+$/,"").replace(/^\s+/,"")); }; String.prototype.cut=function(len){ if(this.length>len){ var counter=0; var endpos=len-4; while(counter<len-4 && parseInt(this.substring(counter,this.length-counter).indexOf(" "))+parseInt(counter)<len-4){ endpos=parseInt(this.substring(counter,this.length-counter).indexOf(" "))+counter; counter+=1; } return this.substr(0,endpos+1) + " ..."; } else return this; }; function getDomainFromUrl(url){ if (url==null || url.length==0) return ""; var parts=url.split('/'); return parts[2]; } function getAbsolutePosX(obj) { var curleft=0; if (obj.offsetParent) { while (obj.offsetParent) { curleft +=obj.offsetLeft; obj=obj.offsetParent; } } else if (obj.x) curleft +=obj.x; return curleft; } function getAbsolutePosY(obj) { var curtop=0; if (obj.offsetParent) { while (obj.offsetParent) { curtop +=obj.offsetTop; obj=obj.offsetParent; } } else if (obj.y) curtop +=obj.y; return curtop; } function getObjectWidth(elem) { var result=0; if (elem.offsetWidth) { result=elem.offsetWidth; } else if (elem.clip && elem.clip.width) { result=elem.clip.width; } else if (elem.style && elem.style.pixelWidth) { result=elem.style.pixelWidth; } return parseInt(result); } function getObjectHeight(elem) { var result=0; if (elem.offsetHeight) { result=elem.offsetHeight; } else if (elem.clip && elem.clip.height) { result=elem.clip.height; } else if (elem.style && elem.style.pixelHeight) { result=elem.style.pixelHeight; } return parseInt(result); } function serialize(_obj) { switch (typeof _obj){ case 'number': case 'boolean': case 'function': return _obj; break; case 'string': return '"' + _obj + '"'; break; case 'object': var str; if (_obj.constructor===Array || typeof _obj.callee !=='undefined'){ str='['; var i, len=_obj.length; for (i=0; i < len-1; i++) { str +=serialize(_obj[i]) + ','; } str +=serialize(_obj[i]) + ']'; } else{ str='{'; var key; for (key in _obj) { str +='"' + key + '":' + serialize(_obj[key]) + ','; } str=str.replace(/\,$/, '') + '}'; } return str; break; default: return 'UNKNOWN'; break; } } function clone(myObj){ if(typeof(myObj) !='object') return myObj; if(myObj==null) return myObj; var myNewObj=new Object(); for(var i in myObj) myNewObj[i]=clone(myObj[i]); return myNewObj; } function GangoRequestObject(){ var MainObject=this; var RequestObject=null; try{ RequestObject=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ RequestObject=new ActiveXObject("MSXML2.XMLHTTP"); } catch(e){ try{ RequestObject=new XMLHttpRequest(); } catch(e){ alert("Your Browser doesn't support Ajax.\n" + "Please use another Browser:\n" + "Firefox, Internet Explorer, Opera, Safari"); } } } this.action=function(response){}; this.handleResponse=function(){ try{ if(RequestObject.readyState==4){ MainObject.action(RequestObject.responseText); } } catch(e){} }; this.sendRequest=function(url){ try{ RequestObject.open('get',url,true); RequestObject.onreadystatechange=this.handleResponse; RequestObject.send(null); } catch(e){} }; this.cancelRequest=function(){ try{ RequestObject.abort(); } catch(e){} }; }  function GangoIpLocator(language){ var scripts=document.getElementsByTagName("script"); for(var i=0; i<scripts.length; i++){ if(scripts[i].src.indexOf("GangoIpLocator.js")>-1){ this.domain=getDomainFromUrl(scripts[i].src); break; } } this.requestUrl="http:/" + "/" + document.domain + "/"; if (document.domain==this.domain) this.requestUrl +=GangoIpLocator.DATA_SOURCE; else if(document.domain=="localhost") this.requestUrl +=GangoIpLocator.DATA_SOURCE_LOCAL_PROXY; else this.requestUrl +=GangoIpLocator.DATA_SOURCE_HOST_PROXY; this.language=(language?language:""); this.ipGeolocationRequestObject=new GangoRequestObject(); this.getIpGeoLocation=function(ip, callback) { this.ipGeolocationRequestObject.callback=callback; var url=this.requestUrl + '?initcmd=iplocation' + '&ip=' + ip + '&language=' + this.language; this.ipGeolocationRequestObject.sendRequest(url); }; this.handleIpGeolocationResponse=function (response) { var exit=false; try{ if(parseInt(response)<0) exit=true; } catch(e){} if(!exit){ try{ var obj=eval('(' + response + ')'); } catch(e){ exit=true; } } this.callback((exit || !obj)?null:obj); }; this.ipGeolocationRequestObject.action=this.handleIpGeolocationResponse; } GangoIpLocator.DATA_SOURCE="gango/gogis/index.php"; GangoIpLocator.DATA_SOURCE_LOCAL_PROXY="ajaxproxi.asp"; GangoIpLocator.DATA_SOURCE_HOST_PROXY="ajaxproxy.aspx";  function GangoMapControl(id){ var scripts=document.getElementsByTagName("script"); for(var i=0; i<scripts.length; i++){ if(scripts[i].src.indexOf("GangoMapControl.js")>-1){ this.domain=getDomainFromUrl(scripts[i].src); break; } } this.requestUrl="http:/" + "/" + document.domain + "/"; if (document.domain==this.domain) this.requestUrl +=GangoMapControl.DATA_SOURCE; else if(document.domain=="localhost") this.requestUrl +=GangoMapControl.DATA_SOURCE_LOCAL_PROXY; else this.requestUrl +=GangoMapControl.DATA_SOURCE_HOST_PROXY; this.setMarker=function(lat, lon){ if(this.marker)this.markers.removeMarker( this.marker ); var p=new OpenLayers.LonLat(lon, lat); p=p.transform(this.latLonProjection, this.mapProjection); var size, offset, icon; if(arguments.length>=5){ size=new OpenLayers.Size(arguments[3], arguments[4]); offset=new OpenLayers.Pixel(-(size.w/2), -(size.h/2)); icon=new OpenLayers.Icon(this.imageUrl + arguments[2], size, offset); icon.setOpacity(0.7); } else{ size=new OpenLayers.Size(GangoMapControl.MARKER_DEFAULT_WIDTH, GangoMapControl.MARKER_DEFAULT_HEIGHT); offset=new OpenLayers.Pixel(-(size.w/2), -size.h); icon=new OpenLayers.Icon(this.imageUrl + GangoMapControl.MARKER_DEFAULT, size, offset); } this.marker=new OpenLayers.Marker(p, icon); this.markers.addMarker( this.marker ); }; this.id=id; this.mode=( (arguments.length>1 && arguments[1]!=null) ? arguments[1] : GangoMapControl.MODE_DEFAULT ); this.lat=( (arguments.length>3 && arguments[2]!=null) ? arguments[2] : null ); this.lon=( (arguments.length>3 && arguments[3]!=null) ? arguments[3] : null ); this.isStatic=( (arguments.length>4 && arguments[4]!=null) ? arguments[4] : false ); this.theme=( (arguments.length>5 && arguments[5]!=null) ? arguments[5] : "" ); this.imageUrl="http:/" + "/" + this.domain + "/" + GangoMapControl.IMAGE_PATH + (this.theme!=""?"theme/"+this.theme+"/":""); this.registeredGeoHandlers=new Array(); this.requestObject=new GangoRequestObject(); this.requestObject.parent=this; this.isRequesting=false; this.options={ projection: "EPSG:900913", units: "m", maxResolution: 156543.0339, maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34), controls: (this.isStatic?[]:null) }; this.map=new OpenLayers.Map(this.id, this.options); if(!this.isStatic){ this.layerSwitcher=new OpenLayers.Control.LayerSwitcher(); this.map.addControl(this.layerSwitcher); this.layerSwitcher.div.style.fontSize="10px"; this.layerSwitcher.div.style.fontWeight="normal"; } this.latLonProjection=new OpenLayers.Projection("EPSG:4326"); this.mapProjection=new OpenLayers.Projection("EPSG:900913"); this.geoJson=null; this.geoJsonFeatures=null; this.rss=null; this.rssFeatures=null; this.gmap=new OpenLayers.Layer.Google( "Google Streets", {'sphericalMercator': true} ); this.gsat=new OpenLayers.Layer.Google( "Google Satellite", {type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 22} ); this.ghyb=new OpenLayers.Layer.Google( "Google Hybrid", {type: G_HYBRID_MAP, 'sphericalMercator': true} ); this.gphy=new OpenLayers.Layer.Google( "Google Physical", {type: G_PHYSICAL_MAP, 'sphericalMercator': true} ); this.map.addLayers([this.gmap, this.gsat, this.ghyb, this.gphy]); if(this.mode==GangoMapControl.MODE_PICKER){ this.markers=new OpenLayers.Layer.Markers( "Markers" ); this.map.addLayer(this.markers); this.marker=null; var click=new OpenLayers.Control.Click(this); this.map.addControl(click); click.activate(); this.map.zoomToMaxExtent(); } else if(this.mode==GangoMapControl.MODE_GEOJSON){ this.geoJsonFormat=new OpenLayers.Format.GeoJSON( { 'internalProjection': this.mapProjection, 'externalProjection': this.latLonProjection } ); } else if(this.mode==GangoMapControl.MODE_GEORSS){ this.markers=new OpenLayers.Layer.Markers( "Location" ); this.map.addLayer(this.markers); this.marker=null; this.setMarker(this.lat, this.lon, GangoMapControl.MARKER_MYLOCATION, GangoMapControl.MARKER_MYLOCATION_WIDTH, GangoMapControl.MARKER_MYLOCATION_HEIGHT); } this.setGeoJson=function(params){ if(this.isRequesting==true) return false; if(this.geoJson && this.geoJsonFeatures && this.geoJsonFeatures.length>0){ for(var i=0; i<this.geoJsonFeatures.length; i++){ } this.geoJsonFeatures=null; } this.requestObject.action=this.handleGeoJsonResponse; this.isRequesting=true; this.requestObject.sendRequest(this.requestUrl+"?"+params); return true; }; this.handleGeoJsonResponse=function (response) { var exit=false; try{ if(!isNaN() && parseInt(response)<0){ exit=true; } } catch(e){ } if(!exit){ try{ this.parent.currentGeoJSON=eval('(' + response + ')'); } catch(e){ exit=true; } } if(exit || !this.parent.currentGeoJSON || typeof(this.parent.currentGeoJSON.features)=="undefined" || this.parent.currentGeoJSON.features.length<1){ this.parent.isRequesting=false; this.parent.currentGeoJSON=null; return false; } if(this.parent.geoJson==null){ var defaultStyle=new OpenLayers.Style({ 'pointRadius': 6, 'fill': true, 'fillColor': '#FD9E08', 'fillOpacity': 0.4, 'stroke': true, 'strokeColor': '#FD9E08', 'strokeWidth': 1, 'strokeOpacity': 1 }); var selectStyle=new OpenLayers.Style({ 'pointRadius': 7, 'fill': true, 'fillColor': '#426D94', 'fillOpacity': 0.4, 'stroke': true, 'strokeColor': '#426D94', 'strokeWidth': 1, 'strokeOpacity': 1 }); this.parent.geoJson=new OpenLayers.Layer.Vector( this.parent.currentGeoJSON.type, { 'styleMap': new OpenLayers.StyleMap({ 'default': defaultStyle, 'select': selectStyle }) } ); this.parent.map.addLayer(this.parent.geoJson); this.parent.select=new OpenLayers.Control.SelectFeature(this.parent.geoJson, {hover: true, onSelect: this.parent.handleGeoJsonSelect, onUnselect: this.parent.handleGeoJsonUnselect}); this.parent.map.addControl(this.parent.select); this.parent.select.activate(); } if(this.parent.geoJsonFeatures==null) this.parent.geoJsonFeatures=new Array(); var bounds=null; if(this.parent.currentGeoJSON.box && (this.parent.currentGeoJSON.box.length==4)){ bounds=new OpenLayers.Bounds(); var p1=new OpenLayers.LonLat(this.parent.currentGeoJSON.box[0],this.parent.currentGeoJSON.box[1]); p1=p1.transform(this.parent.latLonProjection,this.parent.mapProjection); bounds.extend(p1); var p2=new OpenLayers.LonLat(this.parent.currentGeoJSON.box[2],this.parent.currentGeoJSON.box[3]); p2=p2.transform(this.parent.latLonProjection,this.parent.mapProjection); bounds.extend(p2); if(this.parent.lon!=null && this.parent.lat!=null){ var p3=new OpenLayers.LonLat(this.parent.lon,this.parent.lat); p3=p3.transform(this.parent.latLonProjection,this.parent.mapProjection); bounds.extend(p3); } this.parent.currentGeoJSON.bounds=bounds; var tmpDx=parseFloat(bounds.getWidth()*GangoMapControl.GEOJSON_BOUNDS_FACTOR); var tmpDy=parseFloat(bounds.getHeight()*GangoMapControl.GEOJSON_BOUNDS_FACTOR); bounds.left=bounds.left - tmpDx; bounds.bottom=bounds.bottom - tmpDy; bounds.right=bounds.right + tmpDx; bounds.top=bounds.top + tmpDy; this.parent.map.zoomToExtent(bounds); } for(var i=0; i<this.parent.currentGeoJSON.features.length; i++){ this.parent.geoJsonFeatures.push(this.parent.geoJsonFormat.read(this.parent.currentGeoJSON.features[i].geometry)); this.parent.geoJsonFeatures[i][0].mapcontrol=this.parent; this.parent.geoJsonFeatures[i][0].attributes.id=this.parent.currentGeoJSON.features[i].id; this.parent.geoJsonFeatures[i][0].attributes.title=(this.parent.currentGeoJSON.features[i].name?this.parent.currentGeoJSON.features[i].name:""); this.parent.geoJsonFeatures[i][0].attributes.description=(this.parent.currentGeoJSON.features[i].description?this.parent.currentGeoJSON.features[i].description:""); this.parent.geoJson.addFeatures(this.parent.geoJsonFeatures[i]); } }; this.handleGeoJsonSelect=function (feature) { var popup=new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(20,20), "<p><b>"+feature.attributes.title + "</b></p><p><i>"+feature.attributes.description.replace(/\n/,"<br>") + "</i></p>", null, false, feature.mapcontrol.onPopupClose); feature.popup=popup; popup.feature=feature; feature.mapcontrol.map.addPopup(popup); }; this.handleGeoJsonUnselect=function (feature) { if (feature.popup) { feature.popup.feature=null; feature.mapcontrol.map.removePopup(feature.popup); feature.popup.destroy(); feature.popup=null; } if(feature.mapcontrol.currentGeoJSON.bounds){ feature.mapcontrol.map.zoomToExtent(feature.mapcontrol.currentGeoJSON.bounds); } }; this.onPopupClose=function(){ }; this.addRssMarker=function(rssFeedTitle, rssFeedEntry) { var p=new OpenLayers.LonLat(rssFeedEntry.georss_point.lon,rssFeedEntry.georss_point.lat); p=p.transform(this.latLonProjection,this.mapProjection); if(this.rss==null){ this.rss=new OpenLayers.Layer.Markers( rssFeedTitle ); this.map.addLayer(this.rss); } if(this.rssFeatures==null) this.rssFeatures=new Array(); var size=new OpenLayers.Size(GangoMapControl.MARKER_DEFAULT_WIDTH, GangoMapControl.MARKER_DEFAULT_HEIGHT); var offset=new OpenLayers.Pixel(-(size.w / 2), -size.h); var theIcon=theIcon=new OpenLayers.Icon(this.imageUrl + ((rssFeedEntry.content_type==1)?GangoMapControl.MARKER_RFO:GangoMapControl.MARKER_RFA), size, offset); var theSize=new OpenLayers.Size(GangoMapControl.POPUP_DEFAULT_WIDTH, GangoMapControl.POPUP_DEFAULT_HEIGHT); var htmlTitleLink="<p><a href='"+rssFeedEntry.link_alternate+"'>"+ rssFeedEntry.title.cut(GangoMapControl.GEORSS_MAX_TITLE_LENGTH)+"</a></p>"; var feature=new OpenLayers.Feature( this.rss, p, {icon: theIcon, popupSize: theSize, popupContentHTML: htmlTitleLink+this.decode(rssFeedEntry.content_html)} ); feature.mapcontrol=this; feature.rssEntryId=rssFeedEntry.id; this.rssFeatures.push(feature); feature.createMarker(); feature.createPopup(true); feature.popup.hide(); this.map.addPopup(feature.popup); this.rss.addMarker(feature.marker); feature.marker.events.register("mousedown", feature, function (evt) { feature.mapcontrol.hideAllInactiveRssPopups(feature); feature.popup.toggle(); OpenLayers.Event.stop(evt); }); }; this.hideAllInactiveRssPopups=function(activeFeature) { if(this.rss && this.rssFeatures && this.rssFeatures.length>0){ for(var i=0; i<this.rssFeatures.length; i++){ if(activeFeature!=this.rssFeatures[i])this.rssFeatures[i].popup.hide(); } } }; this.removeAllRssMarker=function() { if(this.rss && this.rssFeatures && this.rssFeatures.length>0){ for(var i=0; i<this.rssFeatures.length; i++){ this.rss.removeMarker(this.rssFeatures[i].marker); this.rssFeatures[i].popup.destroy(); } this.rssFeatures=null; } }; this.setRssContent=function(rssFeed) { this.removeAllRssMarker(); var box=lat=lon=null; if(arguments.length==2)box=arguments[1]; var bounds=null; if(box && (box.length==4)){ bounds=new OpenLayers.Bounds(); var p1=new OpenLayers.LonLat(box[0],box[1]); p1=p1.transform(this.latLonProjection,this.mapProjection); bounds.extend(p1); var p2=new OpenLayers.LonLat(box[2],box[3]); p2=p2.transform(this.latLonProjection,this.mapProjection); bounds.extend(p2); if(this.lon!=null && this.lat!=null){ var p3=new OpenLayers.LonLat(this.lon,this.lat); p3=p3.transform(this.latLonProjection,this.mapProjection); bounds.extend(p3); } this.map.zoomToExtent(bounds); } for(var i=0; i<rssFeed.entry.length; i++){ this.addRssMarker(rssFeed.title,rssFeed.entry[i]); } if(bounds!=null){ var zoomlevel=this.map.getZoomForExtent(bounds); this.map.zoomToExtent(bounds); if(zoomlevel>GangoMapControl.GEORSS_ZOOMLEVEL)this.map.zoomTo(GangoMapControl.GEORSS_ZOOMLEVEL); } }; this.setUrl=function(url) { OpenLayers.Util.getElement('url').value=url; this.addUrl(); var box=lat=lon=null; if(arguments.length==2)box=arguments[1]; if(box && (box.length==4)){ var bounds=new OpenLayers.Bounds(); var p1=new OpenLayers.LonLat(box[0],box[1]); p1=p1.transform(this.latLonProjection,this.mapProjection); bounds.extend(p1); var p2=new OpenLayers.LonLat(box[2],box[3]); p2=p2.transform(this.latLonProjection,this.mapProjection); bounds.extend(p2); if(this.lon!=null && this.lat!=null){ var p3=new OpenLayers.LonLat(this.lon,this.lat); p3=p3.transform(this.latLonProjection,this.mapProjection); bounds.extend(p3); } var zoomlevel=this.map.getZoomForExtent(bounds); this.map.zoomToExtent(bounds); if(zoomlevel>GangoMapControl.GEORSS_ZOOMLEVEL)this.map.zoomTo(GangoMapControl.GEORSS_ZOOMLEVEL); } }; this.addUrl=function() { var urlObj=OpenLayers.Util.getElement('url'); var value=urlObj.value; var parts=value.split("/"); if(this.rss!=null) { this.map.removeLayer(this.rss); this.rss=null; } this.rss=new OpenLayers.Layer.GeoRSS( parts[parts.length-1], value, { 'projection': new OpenLayers.Projection('EPSG:4326') } ); this.map.addLayer(this.rss); urlObj.value=""; }; this.reset=function(){ if(this.marker)this.markers.removeMarker( this.marker ); this.map.zoomToMaxExtent(); }; this.registerGeoHandler=function(geoObj){ this.registeredGeoHandlers.push(geoObj); }; this.applyGeoHandlers=function(lat, lon){ if(lat && lon){ for(var i=0; i<this.registeredGeoHandlers.length; i++){ this.registeredGeoHandlers[i].handleCoordinatesChanged(lat,lon); } } }; this.handleRssChanged=function(rssFeed){ var box=lat=lon=null; if(arguments.length==2)box=arguments[1]; this.setRssContent(rssFeed,box); }; this.handleRssContentHided=function(){ try{ this.hideAllInactiveRssPopups(null); } catch(e){ } }; this.handleRssContentShown=function(rssEntryId){ try{ this.hideAllInactiveRssPopups(null); if(this.rss && this.rssFeatures && this.rssFeatures.length>0){ for(var i=0; i<this.rssFeatures.length; i++){ if(rssEntryId==this.rssFeatures[i].rssEntryId)this.rssFeatures[i].popup.show(); } } } catch(e){ } }; this.handleNewsChanged=function(url){ var box=lat=lon=null; if(arguments.length==2)box=arguments[1]; this.setUrl(url.replace(/&output=json/,""),box); }; this.handleExtentChanged=function(box, lat, lon, id){ var bounds=new OpenLayers.Bounds(); var p1=new OpenLayers.LonLat(box[0],box[1]); var p2=new OpenLayers.LonLat(box[2],box[3]); p1=p1.transform(this.latLonProjection,this.mapProjection); p2=p2.transform(this.latLonProjection,this.mapProjection); bounds.extend(p1); bounds.extend(p2); var zoomlevel=this.map.getZoomForExtent(bounds); if(id=="country"){ if(zoomlevel<2){ zoomlevel=2; p1=new OpenLayers.LonLat(lon,lat); p1=p1.transform(this.latLonProjection,this.mapProjection); bounds=new OpenLayers.Bounds(); bounds.extend(p1); } } else if(id=="zip"){ if(zoomlevel>7){ zoomlevel=7; p1=new OpenLayers.LonLat(lon,lat); p1=p1.transform(this.latLonProjection,this.mapProjection); bounds=new OpenLayers.Bounds(); bounds.extend(p1); } } else if(id=="city"){ if(zoomlevel>7){ zoomlevel=7; p1=new OpenLayers.LonLat(lon,lat); p1=p1.transform(this.latLonProjection,this.mapProjection); bounds=new OpenLayers.Bounds(); bounds.extend(p1); } } else if(id=="street"){ if(zoomlevel>14){ zoomlevel=14; p1=new OpenLayers.LonLat(lon,lat); p1=p1.transform(this.latLonProjection,this.mapProjection); bounds=new OpenLayers.Bounds(); bounds.extend(p1); } } this.map.zoomToExtent(bounds); this.map.zoomTo(zoomlevel); this.setMarker(lat, lon); }; this.decode=function(html){ if(html && html>""){ return html.replace(new RegExp("&lt;","g"), "<").replace(new RegExp("&gt;","g"), ">").replace(new RegExp("&amp;","g"), "&"); } return null; }; } GangoMapControl.MODE_PICKER=1; GangoMapControl.MODE_GEORSS=2; GangoMapControl.MODE_GML=3; GangoMapControl.MODE_GEOJSON=4; GangoMapControl.MODE_DEFAULT=GangoMapControl.MODE_PICKER; GangoMapControl.GEORSS_ZOOMLEVEL=7; GangoMapControl.GEORSS_MAX_TITLE_LENGTH=120; GangoMapControl.GEOJSON_BOUNDS_FACTOR=1/16; GangoMapControl.IMAGE_PATH="gango/gogis/scripts/img/";GangoMapControl.DATA_SOURCE="gango/gogis/index.php";GangoMapControl.DATA_SOURCE_LOCAL_PROXY="ajaxproxi.asp";GangoMapControl.DATA_SOURCE_HOST_PROXY="ajaxproxy.aspx"; GangoMapControl.MARKER_DEFAULT='marker-gold.png';GangoMapControl.MARKER_DEFAULT_WIDTH=21;GangoMapControl.MARKER_DEFAULT_HEIGHT=25; GangoMapControl.MARKER_RFO='marker-blue.png';GangoMapControl.MARKER_RFA='marker-gold.png'; GangoMapControl.MARKER_MYLOCATION='mylocation.gif';GangoMapControl.MARKER_MYLOCATION_WIDTH=35;GangoMapControl.MARKER_MYLOCATION_HEIGHT=35; GangoMapControl.POPUP_DEFAULT_WIDTH=354;GangoMapControl.POPUP_DEFAULT_HEIGHT=216; OpenLayers.IMAGE_RELOAD_ATTEMPTS=3;OpenLayers.Util.onImageLoadErrorColor="transparent";OpenLayers.Feature.prototype.popupClass=OpenLayers.Popup.FramedCloud; OpenLayers.Popup.FramedCloud.prototype.maxSize=new OpenLayers.Size(GangoMapControl.POPUP_DEFAULT_WIDTH, GangoMapControl.POPUP_DEFAULT_HEIGHT); OpenLayers.Control.Click=OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { 'single': true, 'double': false, 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false }, initialize: function(mapcontrol) { this.mapcontrol=mapcontrol; this.handlerOptions=OpenLayers.Util.extend( {}, this.defaultHandlerOptions ); OpenLayers.Control.prototype.initialize.apply( this, arguments ); this.handler=new OpenLayers.Handler.Click( this, { 'click': this.trigger }, this.handlerOptions ); }, trigger: function(e) { var lonlat=this.mapcontrol.map.getLonLatFromViewPortPx(e.xy); lonlat=lonlat.transform(this.mapProjection,this.latLonProjection); this.mapcontrol.applyGeoHandlers(lonlat.lat, lonlat.lon) } });  function GangoNewsControl(id, language){ var scripts=document.getElementsByTagName("script"); for(var i=0; i<scripts.length; i++){ if(scripts[i].src.indexOf("GangoNewsControl.js")>-1){ this.domain=getDomainFromUrl(scripts[i].src); break; } } this.requestUrl="http:/" + "/" + document.domain + "/"; if (document.domain==this.domain) this.requestUrl +=GangoNewsControl.DATA_SOURCE; else if(document.domain=="localhost") this.requestUrl +=GangoNewsControl.DATA_SOURCE_LOCAL_PROXY; else this.requestUrl +=GangoNewsControl.DATA_SOURCE_HOST_PROXY; this.id=id; this.language=language; this.registeredNewsHandlers=new Array(); this.registeredRssHandlers=new Array(); this.registeredRssShowContentHandlers=new Array(); this.registeredRssHideContentHandlers=new Array(); this.container=document.getElementById(id); this.container.parent=this; this.scrollerContainer=null; this.sliderContainer=null; this.requestObject=new GangoRequestObject(); this.requestObject.parent=this; this.requestTimer=null; this.currentRssJsonUrl=(arguments.length>2?this.requestUrl+'?initcmd=georss&'+arguments[2]:null); this.currentRssBounds=null; this.currentFeed=null; this.currentSliderStep=0; this.sliderTimer=null; this.scrollerTimer=null; this.isRequesting=false; this.isReadyToScroll=false; GangoNewsControl.ROW_HEIGHT=parseInt(getObjectHeight(this.container)); this.registerRssShowContentHandler=function(obj){ this.registeredRssShowContentHandlers.push(obj); }; this.applyRssShowContentHandlers=function(){ try{ this.className=this.parent.id+"_feed_highlight"; if(this.parent.currentFeed){ for(var i=0; i<this.parent.registeredRssShowContentHandlers.length; i++){ this.parent.registeredRssShowContentHandlers[i].handleRssContentShown(this.rssEntryId); } } } catch(e){ } }; this.registerRssHideContentHandler=function(obj){ this.registeredRssHideContentHandlers.push(obj); }; this.applyRssHideContentHandlers=function(){ try{ this.className=this.parent.id+"_feed"; if(this.parent.currentFeed){ for(var i=0; i<this.parent.registeredRssHideContentHandlers.length; i++){ this.parent.registeredRssHideContentHandlers[i].handleRssContentHided(); } } } catch(e){ } }; this.registerRssHandler=function(geoObj){ this.registeredRssHandlers.push(geoObj); }; this.applyRssHandlers=function(){ if(this.currentFeed){ for(var i=0; i<this.registeredRssHandlers.length; i++){ this.registeredRssHandlers[i].handleRssChanged(this.currentFeed,this.currentRssBounds); } } }; this.registerNewsHandler=function(geoObj){ this.registeredNewsHandlers.push(geoObj); }; this.applyNewsHandlers=function(){ if(this.currentRssJsonUrl){ for(var i=0; i<this.registeredNewsHandlers.length; i++){ this.registeredNewsHandlers[i].handleNewsChanged(this.currentRssJsonUrl,this.currentRssBounds); } } }; this.start=function(){ if(this.requestTimer==null && this.currentRssJsonUrl!=null){ this.sendRssJsonRequest(); this.requestTimer=setInterval("document.getElementById('"+this.id+"').parent.sendRssJsonRequest();",GangoNewsControl.REFRESH_INTERVAL); } }; this.stop=function(){ if(this.requestTimer!=null){ clearInterval(this.requestTimer); this.requestTimer=null; } this.stopSlider(); this.stopScroller(); }; this.redraw=function(){ }; this.setup=function(){ this.isReadyToScroll=false; if(this.scrollerContainer!=null)this.container.removeChild(this.scrollerContainer); this.container.style.height=(parseInt(GangoNewsControl.ROW_HEIGHT*((this.currentFeed.entry.length>GangoNewsControl.MAX_ROWS)? GangoNewsControl.MAX_ROWS:this.currentFeed.entry.length))-1)+"px"; this.scrollerContainer=document.createElement("div"); this.scrollerContainer.id=this.id+"_scroller"; this.container.appendChild(this.scrollerContainer); this.scrollerContainer.style.height=(parseInt(GangoNewsControl.ROW_HEIGHT*((this.currentFeed.entry.length>GangoNewsControl.MAX_ROWS)? GangoNewsControl.MAX_ROWS:this.currentFeed.entry.length))-1)+"px"; this.sliderContainer=document.createElement("div"); this.sliderContainer.id=this.id+"_slider"; this.scrollerContainer.appendChild(this.sliderContainer); this.sliderContainer.style.height=(parseInt(GangoNewsControl.ROW_HEIGHT*((this.currentFeed.entry.length>GangoNewsControl.MAX_ROWS)? GangoNewsControl.MAX_ROWS:this.currentFeed.entry.length))-1)+"px"; var htmlFeed, htmlTitleLink; this.currentRssBounds=new Array(4); for(var i=0; i<this.currentFeed.entry.length; i++){ htmlFeed=document.createElement("div"); htmlFeed.id=this.id+"_feed_"+i; htmlFeed.parent=this; htmlFeed.rssEntryId=this.currentFeed.entry[i].id; htmlFeed.className=this.id+"_feed"; this.sliderContainer.appendChild(htmlFeed); htmlFeed.link_alternate=this.currentFeed.entry[i].link_alternate; htmlTitleLink="<p><a href='"+this.currentFeed.entry[i].link_alternate+"'>"+ this.currentFeed.entry[i].title.cut(GangoNewsControl.MAX_TITLE_LENGTH)+"</a></p>"; htmlFeed.innerHTML=htmlTitleLink+this.decode(this.currentFeed.entry[i].content_html); htmlFeed.style.height=GangoNewsControl.ROW_HEIGHT+"px"; htmlFeed.onmouseout=this.applyRssHideContentHandlers; htmlFeed.onmouseover=this.applyRssShowContentHandlers; htmlFeed.onclick=function(){window.location.href=this.link_alternate;return false;}; if(this.currentRssBounds[0]==null || this.currentRssBounds[0]>parseFloat(this.currentFeed.entry[i].georss_point.lon)) this.currentRssBounds[0]=parseFloat(this.currentFeed.entry[i].georss_point.lon); if(this.currentRssBounds[1]==null || this.currentRssBounds[1]>parseFloat(this.currentFeed.entry[i].georss_point.lat)) this.currentRssBounds[1]=parseFloat(this.currentFeed.entry[i].georss_point.lat); if(this.currentRssBounds[2]==null || this.currentRssBounds[2]<parseFloat(this.currentFeed.entry[i].georss_point.lon)) this.currentRssBounds[2]=parseFloat(this.currentFeed.entry[i].georss_point.lon); if(this.currentRssBounds[3]==null || this.currentRssBounds[3]<parseFloat(this.currentFeed.entry[i].georss_point.lat)) this.currentRssBounds[3]=parseFloat(this.currentFeed.entry[i].georss_point.lat); } if(this.currentFeed.entry.length>GangoNewsControl.MAX_ROWS) this.startScroller(); }; this.moveNext=function(){ var tmp; if(this.isReadyToScroll && this.sliderContainer!=null && this.sliderContainer.firstChild){ tmp=this.sliderContainer.removeChild(this.sliderContainer.firstChild); this.sliderContainer.appendChild(tmp); } this.isReadyToScroll=true; this.startSlider(); }; this.slide=function(){ this.currentSliderStep+=GangoNewsControl.SLIDER_STEP; if(this.currentSliderStep>GangoNewsControl.ROW_HEIGHT){ this.stopSlider(); return; } this.sliderContainer.style.top=(-this.currentSliderStep) + "px"; }; this.startSlider=function(){ if(this.sliderTimer==null && this.currentFeed!=null){ this.slide(); this.sliderTimer=setInterval("document.getElementById('"+this.id+"').parent.slide();",GangoNewsControl.SLIDER_INTERVAL); } }; this.stopSlider=function(){ if(this.sliderTimer!=null){ clearInterval(this.sliderTimer); this.sliderTimer=null; } this.currentSliderStep=0; }; this.startScroller=function(){ if(this.scrollerTimer==null && this.currentFeed!=null){ this.scrollerTimer=setInterval("document.getElementById('"+this.id+"').parent.moveNext();",GangoNewsControl.SCROLLER_INTERVAL); } }; this.stopScroller=function(){ if(this.scrollerTimer!=null){ clearInterval(this.scrollerTimer); this.scrollerTimer=null; } }; this.decode=function(html){ if(html && html>""){ return html.replace(new RegExp("&lt;","g"), "<").replace(new RegExp("&gt;","g"), ">").replace(new RegExp("&amp;","g"), "&"); } return null; }; this.sendRssJsonRequest=function(){ if(this.isRequesting==true) return false; this.requestObject.action=this.handleRssJsonResponse; this.isRequesting=true; this.requestObject.sendRequest(this.currentRssJsonUrl); return true; }; this.handleRssJsonResponse=function (response) { var exit=false; try{ if(!isNaN() && parseInt(response)<0){ exit=true; } } catch(e){ } if(!exit){ try{ this.parent.stopSlider(); this.parent.stopScroller(); this.parent.currentFeed=eval('(' + response + ')'); } catch(e){ exit=true; } } if(exit || !this.parent.currentFeed || typeof(this.parent.currentFeed.id)=="undefined" || typeof(this.parent.currentFeed.entry)=="undefined"){ this.parent.isRequesting=false; this.parent.currentFeed=null; return false; } if(this.parent.currentFeed.entry.length>0){ try{ this.parent.setup(); this.parent.applyRssHandlers(); this.parent.applyNewsHandlers(); } catch(e){ } } this.parent.isRequesting=false; return true; }; } GangoNewsControl.DATA_SOURCE="gango/gogis/index.php";GangoNewsControl.DATA_SOURCE_LOCAL_PROXY="ajaxproxi.asp";GangoNewsControl.DATA_SOURCE_HOST_PROXY="ajaxproxy.aspx"; GangoNewsControl.REFRESH_INTERVAL=120000;GangoNewsControl.SCROLLER_INTERVAL=7000;GangoNewsControl.SLIDER_INTERVAL=30;GangoNewsControl.SLIDER_STEP=2; GangoNewsControl.MAX_ROWS=5; GangoNewsControl.MAX_TITLE_LENGTH=42;