/**
 * This is the JavaScript draw library. Other draw libraries must implement the same
 * methods.
 * This is the base class which contains the best way to draw it, as other means are just too slow.
 * EG) Drawing a large of rectangles in VML is much slower than drawing same number of divs, hence
 * use divs to display snap points.
 */

function DrawLibBase() {

    DrawLibBase.prototype.addMarker = function(parentCanvas, id, left, top, width, height, zIndex, borderWidth, borderColor, fillColor, opacity) {
    
        var rectangleObj=document.createElement('div');
		parentCanvas.appendChild(rectangleObj);
		rectangleObj.id = id;
		rectangleObj.style.borderStyle = 'solid';
		rectangleObj.style.visibility = 'visible';
		rectangleObj.style.overflow = 'hidden';
		rectangleObj.style.position = 'absolute';
		rectangleObj.style.width = width + "px";
		rectangleObj.style.height = height + "px";
		rectangleObj.style.left = left + "px";
		rectangleObj.style.top = top + "px";
		
		if (zIndex) rectangleObj.style.zIndex = zIndex;
	    if (fillColor!=null && (opacity == 1 || rectangleObj.style.opacity != null)) rectangleObj.style.backgroundColor = fillColor;
		if (borderWidth>0) rectangleObj.style.borderWidth = borderWidth + "px";
		if (borderColor!=null) rectangleObj.style.borderColor = borderColor;
		if (opacity!=null && rectangleObj.style.opacity != null) rectangleObj.style.opacity = opacity;
		
		return rectangleObj;
    }
    
    DrawLib.prototype.moveShape = function(shape, x, y, center) {
        
        if (center) {
            var width = parseInt(shape.style.width);
            var height = parseInt(shape.style.height);
            x = x - (width/2);
            y = y - (height/2);
        }
        
		shape.style.left = x;
		shape.style.top = y;
    }
}