function GraphicSymbol()
{
    this.Color = "#ff0000";
    this.Width =  2;   
}
function Graphic(id, group, geometry, symbol)
{
    this.Id = id;
    this.Group = group;
    this.Geometry = geometry;
    this.Symbol = symbol;
}
/////////////////////////////////////////////////////////////////////////
function FeatureSymbol(path, width, height)
{
    this.Path = path;
    this.Height = height;
    this.Width = width;
}
/////////////////////////////////////////////////////////////////////////
function Feature(x, y, symbol, drawFunction, id, data)
{
	this.X=x;
	this.Y=y;
	this.Symbol = symbol;	
	this.Draw = drawFunction;    
	this.ID = id;
	this.Data = data;	
}
/////////////////////////////////////////////////////////////////////////
function FeatureCollection(id, features, graphicsLayer, drawFunction, clearFunction, persistent)
{
    this.Id = id;
    this.Features = features;
    this.GraphicsLayer=graphicsLayer;
    this.Draw = drawFunction;
    this.Clear = clearFunction;    
    this.Persistent = false;    
    if (persistent != null) this.Persistent = persistent;
    this.Tooltip = null;
}
//////////////////////////////////////////////////////////////////////
function getPixelY(height, miny, maxy, coordy)
{

	if (parseFloat(coordy) < parseFloat(miny) && parseFloat(coordy) > parseFloat(maxy))
		return -1;

	pixelY = ((parseFloat(maxy) - parseFloat(coordy)) * height) / (parseFloat(maxy)-parseFloat(miny));

	return pixelY;
}
function getPixelX(width, minx, maxx, coordx)
{

	if (parseFloat(coordx) < parseFloat(minx) && parseFloat(coordx) > parseFloat(maxx))
		return -1;

	pixelX = ((parseFloat(coordx) - parseFloat(minx)) * width) / (parseFloat(maxx)-parseFloat(minx));

	return pixelX;
}
///////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////
//Drawing Methods
////////////////////////////////////////////////////////////////////////
function drawFeature(pixelX, pixelY, graphicsLayer, groupId)
{
    var symbolWidth = 19;
    var symbolHeight = 23;
   
    var x = pixelX - symbolWidth/2;
    var y = pixelY- symbolHeight/2;

    graphicsLayer.drawImage2( this.ID, 
    groupId, "tipSource",
    "images/map/poi_search2.gif",
    x, y, symbolWidth, symbolHeight,
    "style='cursor: pointer; cursor: hand;'"); 	
}
function drawPOIFeature(pixelX, pixelY, graphicsLayer, groupId)
{  
    var symbolWidth = 19;
    var symbolHeight = 23;
       
    var x = pixelX - symbolWidth/2;
    var y = pixelY- symbolHeight/2;
    
    graphicsLayer.drawImage2( this.ID,
    groupId, "tipSource",
    "images/map/poi_search2.gif",
    x, y, symbolWidth, symbolHeight,
    "style='cursor: pointer; cursor: hand;'");   
}    
function drawHotPOIFeature(pixelX, pixelY, graphicsLayer, groupId)
{    
    var symbolWidth = 19;
    var symbolHeight = 23;
       
    var x = pixelX - symbolWidth/2;
    var y = pixelY- symbolHeight/2;    
    
    
    var data = this.Data;
    var minScale = data[3];
    var maxScale = data[4];
    var scale = parseInt(DoGetMapScale());
    
    if (minScale == "")
    {
        minScale = 0;
    } else { 
        minScale = parseInt(minScale);
    }
    if (maxScale == "") {maxScale = 0;} else {maxScale = parseInt(maxScale);}
    
    if ((scale <= minScale || minScale == 0) && (scale >= maxScale))
    {
	if (this.ID == "1000013")
	{
        	graphicsLayer.drawImage2( this.ID,
	        groupId, "tipSourceHotPOI",
        	"images/map/" + this.Symbol,
	        x, y, 29, 35,
        	"style='cursor: pointer; cursor: hand;'");                                
	} else {
        	graphicsLayer.drawImage2( this.ID,
	        groupId, "tipSourceHotPOI",
        	"images/map/evento.gif",
	        x, y, symbolWidth, symbolHeight,
        	"style='cursor: pointer; cursor: hand;'");	
	}
    }
}
function drawPOIItineraryFeature(pixelX, pixelY, graphicsLayer, groupId)
{  
    var symbolWidth = 19;
    var symbolHeight = 23;
       
    var x = pixelX - symbolWidth/2;
    var y = pixelY- symbolHeight/2;
    
    graphicsLayer.drawImage2( this.ID,
    groupId, "tpSource",
    "images/map/poi_search2.gif",
    x, y, symbolWidth, symbolHeight,
    "style='cursor: pointer; cursor: hand;' title='" + this.Data[3] + "'");
}

function drawPOISelectedFeature()
{
    jg_features.setColor("white");    
    jg_features.fillEllipse(parseInt(pixelX - 8), parseInt(pixelY - 8), 16, 16);
    jg_features.setColor("red");
    jg_features.fillEllipse(parseInt(pixelX - 5), parseInt(pixelY - 5), 10, 10);
}


function drawMeteoFeature(pixelX, pixelY, graphicsLayer)
{      
    var simbolo = this.Symbol;
    var data = this.Data;    
     
    graphicsLayer.setStroke(1);
    graphicsLayer.setColor("#ffffff");
    graphicsLayer.fillRect(parseInt(pixelX-simbolo.Width/2) - 2, parseInt(pixelY-simbolo.Height/2) - 2, simbolo.Width + 2, simbolo.Height + 2);
    graphicsLayer.drawImage(simbolo.Path, parseInt(pixelX-simbolo.Width/2), parseInt(pixelY-simbolo.Height/2), simbolo.Width, simbolo.Height);
    graphicsLayer.setColor("#000000");
    graphicsLayer.drawRect(parseInt(pixelX-simbolo.Width/2) - 2, parseInt(pixelY-simbolo.Height/2) - 2, simbolo.Width + 2, simbolo.Height + 2);

    // txt box
    graphicsLayer.setColor("#ffffff");
    graphicsLayer.fillRect(parseInt(pixelX-simbolo.Width/2) - 2, parseInt(pixelY+simbolo.Height/2) +2 , simbolo.Width +2, 12);
    
    graphicsLayer.setColor("#000000");
    
    graphicsLayer.drawRect(parseInt(pixelX-simbolo.Width/2) - 2, parseInt(pixelY+simbolo.Height/2) +2 , simbolo.Width +2, 12);
    
    graphicsLayer.setFont("arial","10px",Font.PALIN);
    graphicsLayer.drawStringRect(data,parseInt(pixelX-simbolo.Width/2) - 1, parseInt(pixelY+simbolo.Height/2) +2,simbolo.Width,"center");
}


function drawPolygon()
{
    var MapRange = DoGetMapRange();
    
    var minx = MapRange[0];
    var miny = MapRange[1];
    var maxx = MapRange[2];
    var maxy = MapRange[3];

    var vpnt = strPolygon.split(";");
    
    var xArray = Array(vpnt.length);
    var yArray = Array(vpnt.length);
    
    for (i=0;i<vpnt.length;i++)
    {
	    xArray[i] = getPixelX(gMC.mMapWidth, minx, maxx, vpnt[i].split(",")[0]);
	    yArray[i] = getPixelY(gMC.mMapHeight, miny, maxy, vpnt[i].split(",")[1]);
    }

	//design  the line by teh JS Class
	jg_features.setStroke(2);
	jg_features.setColor("#ff0000");
	jg_features.drawPolygon(xArray,yArray);
	jg_features.paint();
}