function Sua(suaXML, imgroot_in)
{    
    this.guid = suaXML.getAttribute("guid");
    this.date = suaXML.getAttribute("date");
    this.name = suaXML.getAttribute("name");
    this.code = suaXML.getAttribute("code");
    this.strokecolor = suaXML.getAttribute("strokecolor");
    this.strokeweight = suaXML.getAttribute("strokeweight");
    this.strokeopacity = suaXML.getAttribute("strokeopacity");
    this.fillcolor = suaXML.getAttribute("fillcolor");
    this.fillopacity = suaXML.getAttribute("fillopacity");
    this.loweralt = suaXML.getAttribute("loweralt");
    this.upperalt = suaXML.getAttribute("upperalt");
    this.efftimes = suaXML.getAttribute("efftimes");
    this.wx = suaXML.getAttribute("wx");
    this.commname = suaXML.getAttribute("commname");
    this.freq1 = suaXML.getAttribute("freq1");
    this.freq2 = suaXML.getAttribute("freq2");
    var coordinatesXMLElements = suaXML.getElementsByTagName("coordinates");
    this.airspaceStatus = suaXML.getAttribute("airspaceStatus");
    this.startTime = suaXML.getAttribute("startTime");
    this.endTime = suaXML.getAttribute("endTime");
    
    if (1 != coordinatesXMLElements.length)
    {
        alert('Improper number of <coordinates> elements in the Sua XML');
    }
    else
    {
        this.coordinatesXMLElement = coordinatesXMLElements[0];
    }
}

Sua.prototype.guid = null;
Sua.prototype.date = null;
Sua.prototype.name = null;
Sua.prototype.code = null;
Sua.prototype.visible = false;
Sua.prototype.strokecolor = null;
Sua.prototype.strokeweight = null;
Sua.prototype.strokeopacity = null;
Sua.prototype.fillcolor = null;
Sua.prototype.fillopacity = null;
Sua.prototype.coordinatesXMLElement = null;
Sua.prototype.points = null;
Sua.prototype.loweralt = null;
Sua.prototype.upperalt = null;
Sua.prototype.efftimes = null;
Sua.prototype.wx = null;
Sua.prototype.commname = null;
Sua.prototype.freq1 = null;
Sua.prototype.freq2 = null;
Sua.prototype.airspaceStatus = null;
Sua.prototype.startTime = null;
Sua.prototype.endTime = null;

Sua.prototype.show = function(b_show)
{
    //if (false == this.visible)
    //{
        this.createPointsArray();
        var sua = this.createsua();
        if (null != sua)
        {
            map.addOverlay(sua);
        }
        else
        {
            alert("In Sua.prototype.show:  the sua is null!");
        }
    //}
    this.visible = b_show;
}

Sua.prototype.createPointsArray = function()
{
    this.points = new Array();
    if (null == this.points)
    {
        alert('points is null in createPointsArray()');
    }
    
    if (this.coordinatesXMLElement != null)
    {
        var lat = null;
        var lng = null;
        var first_lat = null;
        var first_lng = null;
        var coordinateXMLElements = this.coordinatesXMLElement.getElementsByTagName("coordinate");
        for(var i = 0; i < coordinateXMLElements.length; i++)
        {
            coordinateXMLElement = coordinateXMLElements[i];
            if (null != coordinateXMLElement)
            {
                lat = parseFloat(coordinateXMLElement.getAttribute("lat"));
                lng = parseFloat(coordinateXMLElement.getAttribute("lng"));
                if (null != lat && null != lng)
                {
                    this.points.push(new GLatLng(lat, lng));
                    if (0 == i)
                    {
                        first_lat = lat;
                        first_lng = lng;
                    }
                }
                else
                {
                    alert('lat or lng is null');
                }
            }
        }
        // add first point again to close the polygon's border
        this.points.push(new GLatLng(first_lat, first_lng));
    }
    else
    {
        alert('coordinatesXMLElement is null in createPointsArray()');
    }
    
}

//add a new field to gpolygon to store the moa info
GPolygon.prototype.sua = null;

Sua.prototype.createsua = function()
{   
    var sua = null;            
	sua = new GPolygon(this.points, this.strokecolor, this.strokeweight, this.strokeopacity, this.fillcolor, this.fillopacity);
    
    if (sua_markers)
    {
        sua.sua = this;
		sua_markers[sua_markers.length] = sua;
		sua_guids[this.guid] = this.guid;
	}
		
    //show popup with sua data
//    GEvent.addListener(map, "click", function(overlay, point) {
//        if (point)
//        {
//            if (sua.Contains(point)) 
//            {
//                map.openInfoWindowHtml(point, "Sua html here");
//            }
//        }
//    }); 
    
    return sua;
}