﻿//------GLOBAL VARS-----------//
var MAPCONTROL = "";

var ADMIN_UNIT = "";

var jg_poi_features;
var jg_dynamic;
var jg_fix;
var jg_features;

var resizeTimeoutId;

function dmPOI(poiId, coordX, coordY, codClass, codSubClass)
{
	this.id=poiId;
	this.x=coordX;
	this.y=coordY;
	this.codClass=codClass;
	this.codSubClass=codSubClass;
	this.html="";
}
var dmPoiList=new Array();
var dmPOISelectedList=new Array();

//---------------------------//

$(document).ready(function(){

    panels[panels.length] = new Panel("main", false, "", null);
    panels[panels.length] = new Panel("legend", true, "", function () { $("#sidebar").css("background-color","white"); $("#img_legend").attr("src",gMC.legendImageUrl); }); 
    panels[panels.length] = new Panel("help", true, "", null);        
    panels[panels.length] = new Panel("locations", false, "", function () { $("#searchArea3").css("display","block"); });
    panels[panels.length] = new Panel("events", false, "", function () { $("#searchArea1").css("display","block"); } );    
    panels[panels.length] = new Panel("itineraries", false, "", null);
    panels[panels.length] = new Panel("meteo",false,"", function () { showFirstDayMeteo(); } );   
    panels[panels.length] = new Panel("print", false, "", null);
    panels[panels.length] = new Panel("link", false, "", null);
    panels[panels.length] = new Panel("coordinates", true, "", function () { DoTransCoords(); } );
    panels[panels.length] = new Panel("smita", true, "", function () { window.open("http://www.infoalgarve.mobi"); } );
    panels[panels.length] = new Panel("geostat", true, "", function () { window.open("http://geostat.algarvedigital.pt"); } );

    $('#JT').hide();
    
    doWaitingSearch("mapLoadingBar");
    
    setElementsPositions(false);
    
    setCurrentLanguage();
    
    initMap();
    
    $(window).wresize(window_resize);
        
    $("#mapToc").bind("mouseout", function() { $("#mapToc").css("filter","alpha(opacity=70)"); $("#mapToc").css("opacity",".7") });
    $("#mapToc").bind("mouseover", function() { $("#mapToc").css("filter","alpha(opacity=90)"); $("#mapToc").css("opacity",".9") });
    
    $("#mapReference").bind("mouseout", function() { $("#mapReference").css("filter","alpha(opacity=70)"); $("#mapReference").css("opacity",".7") });
    $("#mapReference").bind("mouseover", function() { $("#mapReference").css("filter","alpha(opacity=90)"); $("#mapReference").css("opacity",".9") });    
    
    $("#btnMapReference").bind("click", function() { DoShowHideMapReference(); });
    $("#btnMapToc").bind("click", function() { DoShowHideMapToc(); });    
    
    $("#mapReference").bind("click", function (e) { mapReference_onclick(e); });        
                              
    var tt = document.getElementById("divMeasure");

	tt.onmousedown = moveme_onmousedown;
	tt.onmouseup = moveme_onmouseup;
	tt.onmousemove = moveme_onmousemove;
	checkZIndex=false;

   $("#divNews").css("display","block");
	  	    
});

function setMapSize(w, h)
{
    $("#map").width(w);
    $("#map").height(h);
    
    $("#mapImage").width(w);
    $("#mapImage").height(h);    
    
    $("#mapContent").width( $("#map").width() );
    $("#mapContent").height( $("#map").height() );                    
    
    $("#mapFeatures").width( $("#map").width() );
    $("#mapFeatures").height( $("#map").height() );
    
    $("#mapHotFeatures").width( $("#map").width() );
    $("#mapHotFeatures").height( $("#map").height() );    

    $("#mapTmpFeatures").width( $("#map").width() );
    $("#mapTmpFeatures").height( $("#map").height() );    
        
    $("#mapDrawLayer").width( $("#map").width() );
    $("#mapDrawLayer").height( $("#map").height() );
    
    $("#mapAcetateLayer").width( $("#map").width() );
    $("#mapAcetateLayer").height( $("#map").height() );    
    
    $("#mapLoadingBar").css("left", ($("#map").width() - $("#mapLoadingBar").width())/2 + "px");  
    $("#mapLoadingBar").css("top", ($("#map").height()- $("#mapLoadingBar").height())/2 + "px");                                           
}
function setElementsPositions(init)
{   
    var resize = false;
    
    var windowWidth = 900;
    var windowHeight = 600;
    
    if (init) resize = true;
    
    if ($(window).outerWidth() > windowWidth)
    {
        windowWidth = $(window).outerWidth();
        
        resize= true;
    }
    
    if ($(window).outerHeight() > windowHeight)
    {
        windowHeight = $(window).outerHeight();
        
        resize= true;
    }    
    
    if (resize)
    {
        var h = $("#header").outerHeight()+ $("#footer").outerHeight();
        var s = windowHeight - 20;

        $("#sidebar").height( s - h );
        
        $("#main").css("left", "0px");
        $("#main").css("top", "0px");   

        var w = windowWidth - $("#sidebar").outerWidth();
        
        setMapSize(w - 52, $("#sidebar").height() - $("#toolbar").outerHeight() ); 

        $("#main").width($("#map").width());
        $("#main").height($("#sidebar").height());;
        
        $("#container").width( windowWidth - 45);
    }
    
    return resize;                                     
}

function window_resize(e) { 
     window.clearTimeout(resizeTimeoutId); 
     
     ChangeToLoading();
     
     resizeTimeoutId = window.setTimeout('doWindowResize();', 500); 
}
function doWindowResize()
{    
    var resize = false;
    
    resize = setElementsPositions();
    
    if (resize)
    {
        var width = $("#map").width();
        var height = $("#map").height(); 
        
        gMC.Initialize(width, height, "mapImage", "mapContent", null);
        
        window.clearTimeout(resizeTimeoutId);
                       
	    var mapState = "";
    	
	    if( document.getElementById(MAPCONTROL + "_map_state") != null)
		    mapState = document.getElementById(MAPCONTROL + "_map_state").value;
		    
		ChangeToLoading();		    		
        
        AjaxMap.MapRequests.Resize(width, height, mapState, DoInitMap_CallBack);
    } else {
        ChangeToMain();
    }       
}
function initMap()
{   
    var width = $("#map").width();
    var height = $("#map").height();   
    
    //Inicialize Map
    MAPCONTROL = "map";
    
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenMapWidth' type='hidden' value='' />");
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenMapHeight' type='hidden' value='' />");
    
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenRange' type='hidden' value='' />");
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenScale' type='hidden' value='' />");
    
    $("#map").append("<input id='" + MAPCONTROL + "_txtVisibleLayers' type='hidden' value='' />");
    
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenDynX' type='hidden' value='' />");
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenDynY' type='hidden' value='' />");
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenDynPoint' type='hidden' value='' />");
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenDynLine' type='hidden' value='' />");
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenDynPolygon' type='hidden' value='' />");
    
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenFeatures' type='hidden' value='' />");
    
    $("#map").append("<input id='" + MAPCONTROL + "_txtHiddenRangeLatLon' type='hidden' value='' />");
    
    $("#map").append("<input id='" + MAPCONTROL + "_map_state' type='hidden' value='' />");         
    
	//Inicializar Toolbar
    TBInitialize();
    
    //Inicializar TOC Mapa    
    TOCInitialize();   
       
    gMC.Initialize(width, height, "mapImage", "mapContent", "#ff0000");
    
	gMC.CallBackZoomBox = onZoomBox;
	gMC.CallBackPan = onPan;
	gMC.SetZoomBoxLineWidth( 2 );
	gMC.SetZoomBoxColor( "#ff0000" );    
	
	gMC.SetGraphicsColor("#3cb371");
	gMC.SetGraphicsWidth(2);
	
	gMC.SetDrawingColor("#ffff99");
	gMC.SetDrawingWidth(2);
	                
    jg_dynamic = new jsGraphics("mapDrawLayer");
	jg_fix = new jsGraphics("mapAcetateLayer");         
	
    //Desenhar os POIs    
    jg_hot_poi_features = new jsGraphics("mapFeatures");
    jg_poi_features = new jsGraphics("mapFeatures");
    jg_meteo = new jsGraphics("mapTmpFeatures");       
        	
    feaCol = new FeatureCollection("Meteo", new Array, jg_meteo, _doDrawMeteoFeatures, _doClearMeteoFeatures, false);
    gMC.FeaturesCollection[gMC.FeaturesCollection.length] = feaCol;     	
        	
	feaCol = new FeatureCollection("POI", new Array(), jg_poi_features, _doDrawFeatures, _doClearFeatures, false);
	gMC.FeaturesCollection[gMC.FeaturesCollection.length] = feaCol;
	
	var feaCol = new FeatureCollection("HotPOI", new Array(), jg_hot_poi_features, _doDrawFeaturesHotPOI, null, true);
	gMC.FeaturesCollection[gMC.FeaturesCollection.length] = feaCol;				
							
	DoInitPage();
	
	if (document.getElementById("map_hot_poi_features") != null)
	{
	    DoShowHotPOIFeatures(document.getElementById("map_hot_poi_features").value);
    }	    
}
function DoShowHotPOIFeatures(data)
{
	//Desenhar Hot POIs
	var pois = data;
	
	var vpois = pois.split("#");
	
	var features = new Array();    
    
    var num = vpois.length
    
    features.length = num;                         
	
	for (i=0; i < num; i++)
	{
	    sData =  vpois[i].split("|");	
	    
	    var feature = new Feature(sData[1], sData[2], sData[5], drawHotPOIFeature, sData[0], sData);
        
        features[i] = feature;
    }
    
    var feaCol = gMC.doGetFeaturesCollectionById("HotPOI");
    
    feaCol.Features = features;
    
    var MapRange = DoGetMapRange();                         
    
    var tlp = new Tooltips();
    
	tlp.width = 250;
	tlp.height = 250;        
    tlp.showPage = "infoHotPOI.aspx?ID=";
    tlp.showFunction = showTooltipHotPOI;
    tlp.hideFunction = hideTooltipHotPOI;    
    tlp.title = "Algarve Visto do Céu";
    
    feaCol.Tooltip = tlp;
}

function DoInitPOI(id, x, y)
{
	var classCod = "";
	var subclassCod = "";
	var poiName = "";
	var poiAddress = "";
	var adminUnit = "";
	var geometry = "";

	var lang = "";
	
	if (document.getElementById("language") != null && document.getElementById("language").value!= "")
	{	
	    lang = document.getElementById("language").value
	}
	
	var page = 1;
	var controlUpdate = "pnl_Lista";
	
	$("#searchArea3").css("display","block");
       
    if (ADMIN_LEVEL == 1)
    {
        Geo.AjaxRequests.panelLocations.DoSearchPOI(id, classCod, subclassCod, poiName, poiAddress, adminUnit, "", geometry, lang, page, PAGE_RECORDS, controlUpdate, DoSearchPOI_CallBack);        
    } else {
        Geo.AjaxRequests.panelLocations.DoSearchPOI(id, classCod, subclassCod, poiName, poiAddress, "", adminUnit, geometry, lang, page, PAGE_RECORDS, controlUpdate, DoSearchPOI_CallBack);
    }
    
    var minx = x - ZOOM_BUFFER_POI;
    var miny = y - ZOOM_BUFFER_POI;
    var maxx = x + ZOOM_BUFFER_POI;
    var maxy = y + ZOOM_BUFFER_POI;    
    
    DoInitMap("poi", id, minx, miny, maxx, maxy);  
}
function DoInitStreet(id, minx, miny, maxx, maxy)
{
    var streetName = "";
    var streetNumber = "";
    var placeName = "";
    var CP4 = "";
    var CP3 = "";
    var adminUnit = "";
    var geometry = "";
	var lang = "";
	
	if (document.getElementById("language") != null && document.getElementById("language").value!= "")
	{	
	    lang = document.getElementById("language").value
	}
	
	var page = 1;
	var controlUpdate = "pnl_Lista";
	
	$("#searchArea2").css("display","block");
       
	if (ADMIN_LEVEL == 1)
    {
        ChangePanelStatusToLoading();
        
	    Geo.AjaxRequests.panelLocations.DoSearchStreets(id, streetName, streetNumber, adminUnit, "", placeName, CP4, CP3, geometry, page, PAGE_RECORDS, lang, controlUpdate, DoSearchStreets_CallBack);
	} else {
	    ChangePanelStatusToLoading();
	
        Geo.AjaxRequests.panelLocations.DoSearchStreets(id, streetName, streetNumber, "", adminUnit, placeName, CP4, CP3, geometry, page, PAGE_RECORDS, lang, controlUpdate, DoSearchStreets_CallBack);	    	 	    
	}		
    
    minx = minx - ZOOM_BUFFER_POI;
    miny = miny - ZOOM_BUFFER_POI;
    maxx = maxx + ZOOM_BUFFER_POI;
    maxy = maxy + ZOOM_BUFFER_POI;
    
    DoInitMap("street", id, minx, miny, maxx, maxy); 
}
function DoInitPlace(id, x, y)
{   
	var placeName = "";
	var adminUnit = "";
	var geometry = "";	
	var lang = "";
	
	if (document.getElementById("language") != null && document.getElementById("language").value!= "")
	{	
	    lang = document.getElementById("language").value
	}
	
	var page = 1;
	var controlUpdate = "pnl_Lista";
		
	$("#searchArea1").css("display","block");
	
    if (ADMIN_LEVEL == 1)
    {
         ChangePanelStatusToLoading();
        
        Geo.AjaxRequests.panelLocations.DoSearchPlaces(id, placeName, adminUnit, "", geometry, page, PAGE_RECORDS, lang, controlUpdate, DoSearchPlaces_CallBack);
	} else {
	     ChangePanelStatusToLoading();
	    
	    Geo.AjaxRequests.panelLocations.DoSearchPlaces(id, placeName, "", adminUnit, geometry, page, PAGE_RECORDS, lang, controlUpdate, DoSearchPlaces_CallBack);
	}	      

    var minx = x - ZOOM_BUFFER_POI;
    var miny = y - ZOOM_BUFFER_POI;
    var maxx = x + ZOOM_BUFFER_POI;
    var maxy = y + ZOOM_BUFFER_POI;
 
    DoInitMap("place", id, minx, miny, maxx, maxy);
}

function DoShowHideMapReference()
{
    if ($('#mapReference').css('display') == "none")
    {
        $("#mapReference").show(1000, function () {$("#mapScalebar").css("right","120");} );
        $("#btnMapReference").attr("class","btnMapReferenceClose");
    } else {
        $("#mapReference").hide(1000, function () {$("#mapScalebar").css("right","20");});
        $("#btnMapReference").attr("class","btnMapReferenceOpen");
    }
}
function DoShowHideMapToc()
{
    if ($('#mapToc').css('display') == "none")
    {
        $("#mapToc").show(1000);
        $("#btnMapToc").attr("class","btnMapTocClose");
    } else {
        $("#mapToc").hide(1000);
        $("#btnMapToc").attr("class","btnMapTocOpen");
    }
}

function getCurrentLanguage()
{	
	var lang = "";
	
	if (document.getElementById("language") != null && document.getElementById("language").value!= "")
	{	
	    lang = document.getElementById("language").value
	}
    
    return lang;	
}
function selectCurrentLanguage(lang)
{
    if (document.getElementById("language") != null)
    {
        document.getElementById("language").value = lang;

        document.form1.submit();
    }
    
    return false;
}
function setCurrentLanguage()
{
    var lang = document.getElementById("language").value;

    var obj = document.getElementById("imgLang-" + lang);
    
    if (obj != null)
    {
        obj.className = "languageAreaImageSelected";
    }
    
}

function viewImage(image, title)
{
	var url = "forms/imgLocalizacao.aspx?image=" + image + "&title=" + title;
	
	if (document.getElementById("language") != null & document.getElementById("language").value != "")
	{
	    url += "&lang=" + document.getElementById("language").value;
	}
				
	window.open(url, "", "status=0, location=0, menubar=0, toolbar=0, scrollbars=1, resizable=1");
}



function setUpCalendarMain()
{
//    Calendar.setup(
//    {
//        inputField : "txtTeste", // ID of the input field
//        daFormat : "%d/%m/%Y",
//        ifFormat : "%d/%m/%Y",        
//        button : "trigger" // ID of the button
//        //eventName : "focus"
//        }
//    );
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}
// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}
// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(control, id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  //_dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
  _dynarch_popupCalendar.showAtElement(control, "Br");        // show the calendar  

  return false;
}




////////////////////////////////////////////////////////////////////////
//Meteorologia
////////////////////////////////////////////////////////////////////////
function showFirstDayMeteo()
{
	ChangeToLoading();
	
	var mapState = "";
	
	if( document.getElementById(MAPCONTROL + "_map_state") != null)
		mapState = document.getElementById(MAPCONTROL + "_map_state").value;
					
	AjaxMap.MapRequests.zoomExtent(EXTENT_LEFT, EXTENT_TOP, EXTENT_RIGHT, EXTENT_BOTTOM, mapState, showFirstDayMeteo_CallBack);	

}
function showFirstDayMeteo_CallBack(response)
{
    zoomExtent_CallBack(response);
    
    updateMeteo("meteo0",0)
}

function updateMeteo(id, shiftDay)
{    

    ChangeToLoading();
        
    if( shiftDay <= 0)        
    {
        Geo.AjaxRequests.panelMeteo.DoShowNow("pt", "", updateMeteoNow_callBack);   
        //$.get("http://geo.algarvedigital.pt/meteo_now.php", function(data){updateMeteoNow_callBack(data);});
    } else {
        Geo.AjaxRequests.panelMeteo.DoShowDays(shiftDay, "pt", "",updateMeteo_callBack);
        //$.get("http://geo.algarvedigital.pt/meteo.php?shiftDay=" + shiftDay, function(data){updateMeteo_callBack(data);});
    }

    function updateMeteoNow_callBack(data)
    {
            
        ChangeToMain();
        
        $(".meteoitem").attr("style","");
        $(".meteoitem").attr("selected","false");
        $("#" + id).attr("style","border: solid 1px black");
        $("#" + id).attr("selected","true");
               
        var txtResponse = "";
        
        if (data.value != null)
        {
            txtResponse = data.value;
        } else {
            txtResponse = data;
        }        
        
        var arrMeteoPoints = txtResponse.split("#");
        
        var feaCol = gMC.doGetFeaturesCollectionById("Meteo");        
        var features = new Array();        
    	
        // maprange... for get x y pixels------------------------------------
	    if(gIsBusy) return;
	    var MapRange = DoGetMapRange();
	    var X0, X1, Y0, Y1;
        
        X0 = MapRange[0];
	    Y0 = MapRange[1];
	    X1 = MapRange[2];
	    Y1 = MapRange[3];

        //--------------------------------------------------------------
        for (i=0; i<(arrMeteoPoints.length-1);i++)
        {
            var arrSinglePoint = arrMeteoPoints[i].split("|");

            var zx = 0; var zy=0;            
            
            zx= arrSinglePoint[8];
            zy= arrSinglePoint[9];        
           
            // check pts in range
            if ((zx < gMC.mMapRange[0]) || (zx > gMC.mMapRange[2])) {continue}
            if ((zy < gMC.mMapRange[1]) || (zy > gMC.mMapRange[3])) {continue}
        
            // get coords in pixel
	        pixelX = getPixelX(gMC.mMapWidth, X0, X1,zx);
	        pixelY = getPixelY(gMC.mMapHeight, Y0, Y1,zy);

	        // get time 
	        stamp = new Date();  	   
	        stamp_h = stamp.getHours();  	
    	    	   	   
	        // get sunrise and sunset  	   
	        var sunr = arrSinglePoint[6].split(":");
	        var suns = arrSinglePoint[7].split(":");

   	        // get temperature   	 
   	        var tempe = arrSinglePoint[1] + "º";
       	 
	        // find icon (day vs moon)  	   
            if ((stamp_h < (sunr[0] - 1)) || (stamp_h > (suns[0] + 2)))
            {
                var simboloPath = "images/meteo/icons32/" + arrSinglePoint[3] + ".gif";
            }
            else
            {
                var simboloPath = "images/meteo/icons32/" + arrSinglePoint[2] + ".gif";
            }
    	   	   	   	  	   	   
	        var simbolo = new FeatureSymbol(simboloPath, 32, 32);
            var feature = new Feature(zx, zy, simbolo, drawMeteoFeature, 0, tempe);
            
            features[i] = feature;                     
        }
        
        feaCol.Features = features;      
                 
        DoDrawFeatures();       	
    }
    function updateMeteo_callBack(data)
    {
        ChangeToMain();
        
        $(".meteoitem").attr("style","");
        $(".meteoitem").attr("selected","false");
        $("#" + id).attr("style","border: solid 1px black");
        $("#" + id).attr("selected","true");        

        var txtResponse = "";
        
        if (data.value != null)
        {
            txtResponse = data.value;
        } else {
            txtResponse = data;
        }
        var arrMeteoPoints = txtResponse.split("#");
        
        var feaCol = gMC.doGetFeaturesCollectionById("Meteo");        
        var features = new Array();          
    	
        // maprange... for get x y pixels------------------------------------
        if(gIsBusy) return;
        var MapRange = DoGetMapRange();
        var X0, X1, Y0, Y1;
        
        X0 = MapRange[0];
        Y0 = MapRange[1];
        X1 = MapRange[2];
        Y1 = MapRange[3];                              
    
        //--------------------------------------------------------------      	   
        for (i=0; i<(arrMeteoPoints.length-1);i++)
        {
            var arrSinglePoint = arrMeteoPoints[i].split("|");

            var zx = 0; var zy=0;
            
            //zx= arrSinglePoint[6];
            //zy= arrSinglePoint[7];        
            if (arrSinglePoint[0] == "far") {zx=7000 ; zy=-289000}
            if (arrSinglePoint[0] == "vrsa") {zx=61000 ; zy=-284000}
            if (arrSinglePoint[0] == "olh") {zx=33000 ; zy=-302000}
            if (arrSinglePoint[0] == "ptm") {zx=-36000 ; zy=-289000}
            if (arrSinglePoint[0] == "sag") {zx=-71670 ; zy=-300000}
            if (arrSinglePoint[0] == "sms") {zx=-20200 ; zy=-260750}
            if (arrSinglePoint[0] == "tav") {zx=42800 ; zy=-269000}        
           
            // check pts in range
            if ((zx < gMC.mMapRange[0]) || (zx > gMC.mMapRange[2])) {continue}
            if ((zy < gMC.mMapRange[1]) || (zy > gMC.mMapRange[3])) {continue}
    	
	        pixelX = getPixelX(gMC.mMapWidth, X0, X1,zx);
	        pixelY = getPixelY(gMC.mMapHeight, Y0, Y1,zy);
    		
   	        // get temperature   	 
   	        var tempe = arrSinglePoint[1] + "/" + arrSinglePoint[2] + "º";
    	   	   
	        var simboloPath = "images/meteo/icons32/" + arrSinglePoint[3] + ".gif";

	        var simbolo = new FeatureSymbol(simboloPath, 32, 32);
            var feature = new Feature(zx, zy, simbolo, drawMeteoFeature, 0, tempe);
            
            features[i] = feature;           
        }
        
        feaCol.Features = features;         
	    	    
	    DoDrawFeatures();       	                
    }
}
