Studio.Shape.Rect = function(){};

Studio.Shape.Rect.prototype = 
{
    x               : "",
    y               : "",
    width           : "",
    height          : "",
    color_fill      : "",
    color_stroke    : "",
    width_stroke    : 0,
    
    createDetails : function(oElement)
    {
        if (null != oElement)
        {
            this.x              = parseInt(oElement.style.left);
            this.y              = parseInt(oElement.style.top);
            this.width          = parseInt(oElement.style.width);
            this.height         = parseInt(oElement.style.height);
            this.color_fill     = new RGBColor(dojo.style(oElement, 'backgroundColor')).toHex();
            this.color_stroke   = new RGBColor(dojo.style(oElement, 'borderLeftColor')).toHex();
            this.width_stroke   = dojo.style(oElement, 'borderWidth');
        }
    },

    getUrlAttach : function()
    {
        var sUrl = '';
        sUrl += 'shapetype/'        + 'rect'                 + '/';
        sUrl += 'x/'                + this.x                 + '/';
        sUrl += 'y/'                + this.y                 + '/';
        sUrl += 'width/'            + this.getWidth()        + '/';
        sUrl += 'height/'           + this.getHeight()       + '/';
        sUrl += 'color_fill/'       + this.color_fill        + '/';
        sUrl += 'color_stroke/'     + this.color_stroke      + '/';
        sUrl += 'width_stroke/'     + this.width_stroke      + '/';
        return sUrl;
    },
    
    getPostArray : function()
    {
    	return null;
    },
    
    getProperties : function()
    {
        var aProps = new Array();
        aProps['x']            = this.x;
        aProps['y']            = this.y;
        aProps['width']        = this.width;
        aProps['height']       = this.height;
        aProps['color_fill']   = this.color_fill;
        aProps['color_stroke'] = this.color_stroke;
        aProps['width_stroke'] = this.width_stroke;
        return aProps;
    },
    
    setProperties : function(aProps)
    {
        this.x            = aProps['x'];
        this.y            = aProps['y'];
        this.width        = aProps['width'];
        this.height       = aProps['height'];
        this.color_fill   = aProps['color_fill'];
        this.color_stroke = aProps['color_stroke'];
        this.width_stroke = aProps['width_stroke'];
    },
    
    getX : function()
    {
        var iX, iStartX;
        iX = this.x;
        if (Studio.Zoom.iX > 0 && Studio.Zoom.iY > 0)
        {
            iStartX = Math.min(Studio.Canvas.iWidth - Studio.Canvas.iWidth / Studio.Zoom.iZoom, Math.max(Studio.Zoom.iX - Studio.Canvas.iWidth / ( 2 * Studio.Zoom.iZoom ), 0));
            iX = Math.max(  (this.x - iStartX) * Studio.Zoom.iZoom, 0  );
        }
        return iX;
    },
    
    getY : function()
    {
        var iY, iStartY;
        iY = this.y;
        if (Studio.Zoom.iX > 0 && Studio.Zoom.iY > 0)
        {
            iStartY = Math.min(Studio.Canvas.iHeight - Studio.Canvas.iHeight / Studio.Zoom.iZoom, Math.max(Studio.Zoom.iY - Studio.Canvas.iHeight / ( 2 * Studio.Zoom.iZoom ), 0));
            iY = Math.max(  (this.y - iStartY) * Studio.Zoom.iZoom, 0  );
        }
        return iY;
    },
    
    getWidth : function()
    {
        return Number(this.width);// + Number(this.width_stroke) * 2 * Studio.Zoom.iZoom;
    },
    
    getHeight : function()
    {
        return Number(this.height);// + Number(this.width_stroke) * 2 * Studio.Zoom.iZoom;
    },
    
    getCanvasWidth : function()
    {
        return Number(this.getWidth()) + Number(this.width_stroke) * 2 * Studio.Zoom.iZoom;
    },
    
    getCanvasHeight : function()
    {
        return Number(this.getHeight()) + Number(this.width_stroke) * 2 * Studio.Zoom.iZoom;
    }

};