function Canvas()
{
	var self = this;
	
	this.strokeColor;
	this.fillColor;
	this.isFill = false;
		
	this.drawPolygon = drawPolygon;
	this.drawRectangle = drawRectangle;
	this.drawPolyline = drawPolyline;
	this.drawLine = drawLine;
	this.clear = clear;
	this.setStrokeColor = setStrokeColor;
	this.getStrokeColor = getStrokeColor;
	this.setFillColor = setFillColor;
	this.getFillColor = getFillColor;
	
	function drawPolygon()
	{
		
	}
	
	function drawRectangle(x1, y1, x2, y2)
	{
		var canvas = document.getElementById("myCanvas");
		var context = canvas.getContext("2d");
		context.clearRect(0, 0, map.MapWidth, map.MapHeight);
		context.fillStyle = self.getFillColor();
		context.globalAlpha = "0.45";
		context.beginPath();
		context.moveTo(x1, y1);
		context.lineTo(x1, y2);
		context.lineTo(x2, y2);
		context.lineTo(x2, y1);
		context.closePath();
		context.fill();
	}
	
	function drawPolyline(pts, currentX, currentY)
	{
		var canvas = document.getElementById("myCanvas");
		var context = canvas.getContext("2d");
		context.clearRect(0, 0, map.MapWidth, map.MapHeight);
		context.fillStyle = self.getFillColor();
		context.globalAlpha = "0.45";
		context.beginPath();
			
		// use first point for moveTo
		var pt = pts[0];
		context.moveTo(pt.split(',')[0], pt.split(',')[1]);
		
		for( var i = 1; i < pts.length; i++ )
		{
			pt = pts[i];
			context.lineTo(pt.split(',')[0], pt.split(',')[1]);
		}
		
		// add current mouse position
		if( currentX != null && currentY != null )
			context.lineTo(currentX, currentY);
			
		context.closePath();
		context.fill();
	}
	
	function drawLine(x1, y1, x2, y2)
	{
		var canvas = document.getElementById("myCanvas");
		var context = canvas.getContext("2d");
		context.clearRect(0, 0, map.MapWidth, map.MapHeight);
		context.fillStyle = self.getFillColor();
		context.globalAlpha = "0.45";
		context.beginPath();
		context.moveTo(x1, y1);
		context.lineTo(x2, y2);
		context.closePath();
		context.stroke();
	}
	
	function clear()
	{
		var canvas = document.getElementById("myCanvas");
		var context = canvas.getContext("2d");
		context.clearRect(0, 0, map.MapWidth, map.MapHeight);
	}
	
	function getStrokeColor() { return self.strokeColor; }
	function setStrokeColor(strokeColor) { self.strokeColor = strokeColor; }
	
	function getFillColor() { return self.fillColor; }
	function setFillColor(fillColor) { self.fillColor = fillColor; }
}
