function TGCircle(middle,radius,  strokeColor,  strokeWeight,  strokeOpacity,  fillColor,  fillOpacity)
{
    this.middle = middle;
    this.radius = radius;
    this.points = null;
    
    if(strokeColor)
    {
       this.strokeColor = strokeColor;
    }
    else
    {
        this.strokeColor = "#FFFFFF";
    }
    
    if(strokeWeight)
    {
        this.strokeWeight = strokeWeight;
    }
    else
    {
        this.strokeWeight = 1;
    }
    
    if(strokeOpacity)
    {
        this.strokeOpacity = strokeOpacity;
    }
    else
    {
        this.strokeOpacity = 1.0;    
    }
    
    if(fillColor)
    {
        this.fillColor = fillColor;
    }
    else
    {
        this.fillColor = "#000000";
    }
    
    if(fillOpacity)
    {
        this.fillOpacity = fillOpacity;        
    }
    else
    {
        this.fillOpacity = 1.0;        
    }
}

TGCircle.prototype = new GOverlay();

TGCircle.prototype.initialize = function(map) 
{
   this.map = map;
   this.createPoints();
   this.polygon = new GPolygon(this.points,this.strokeColor,this.strokeWeight,this.strokeOpacity,this.fillColor,this.fillOpacity);
   map.addOverlay(this.polygon);
}

TGCircle.prototype.remove = function()
{
    this.map.removeOverlay(this.polygon);
    this.polygon = null;
}

TGCircle.prototype.copy = function()
{
    return new TGCircle(this.middle,this.radius,this.strokeColor,this.strokeWeight,this.strokeOpacity,this.fillColor,this.fillOpacity);
}

TGCircle.prototype.redraw = function()
{
    return;
}

TGCircle.prototype.createPoints = function()
{
    var latConv = this.middle.distanceFrom(new GLatLng(this.middle.lat()+0.1, this.middle.lng()))/100;
	var lngConv = this.middle.distanceFrom(new GLatLng(this.middle.lat(), this.middle.lng()+0.1))/100;

	this.points = new Array();
	var step = parseInt(360/36)||10;
	for(var i=0; i<=360; i+=step)
	{
	   var pint = new GLatLng(parseFloat(this.middle.lat() + (this.radius/latConv * Math.cos(i * Math.PI/180))),parseFloat( this.middle.lng() + (this.radius/lngConv * Math.sin(i * Math.PI/180))));
	   this.points[this.points.length] = pint;
	}
}

TGCircle.prototype.getBounds = function()
{
    if(this.polygon)
    {
       return this.polygon.getBounds();
    }
    
    return null;
}

TGCircle.prototype.toJSON = function()
{
    var json = '{"lat":' + this.middle.lat() + ',"lon":' + this.middle.lng() + ',"radius":' + this.radius + ',"strokecolor":"' + this.strokeColor + '","strokeweight":' + this.strokeWeight + ',"strokeopacity":' + this.strokeOpacity + ',"fillcolor":"' + this.fillColor + '","fillopacity":' + this.fillOpacity + "}";
    return json;
}
