Studio.Attacher = 
{
    attach : function(itemData)
    {
        var oLayer           = new Studio.Layer();
        oLayer.oObject       = new Studio.Object();
        oLayer.oObject.sType = itemData.oObject.sType;
        oLayer.bVisible      = itemData.bVisible;
        oLayer.iDepth        = itemData.iDepth;
        oLayer.iId           = itemData.iId;
        oLayer.sName         = itemData.sName;

        switch (itemData.oObject.sType)
        {
            case 'rect':
                oLayer.oObject.oShape              = new Studio.Shape.Rect();
                oLayer.oObject.oShape.x            = itemData.oObject.oShape.x;
                oLayer.oObject.oShape.y            = itemData.oObject.oShape.y;
                oLayer.oObject.oShape.width        = itemData.oObject.oShape.width;
                oLayer.oObject.oShape.height       = itemData.oObject.oShape.height;
                oLayer.oObject.oShape.color_fill   = itemData.oObject.oShape.color_fill;
                oLayer.oObject.oShape.color_stroke = itemData.oObject.oShape.color_stroke;
                oLayer.oObject.oShape.width_stroke = itemData.oObject.oShape.width_stroke;
            break;
            
            case 'ellipse':
                oLayer.oObject.oShape              = new Studio.Shape.Ellipse();
                oLayer.oObject.oShape.x            = itemData.oObject.oShape.x;
                oLayer.oObject.oShape.y            = itemData.oObject.oShape.y;
                oLayer.oObject.oShape.width        = itemData.oObject.oShape.width;
                oLayer.oObject.oShape.height       = itemData.oObject.oShape.height;
                oLayer.oObject.oShape.color_fill   = itemData.oObject.oShape.color_fill;
                oLayer.oObject.oShape.color_stroke = itemData.oObject.oShape.color_stroke;
                oLayer.oObject.oShape.width_stroke = itemData.oObject.oShape.width_stroke;
            break;
            
            case 'image':
                oLayer.oObject.oShape            = new Studio.Shape.Image();
                oLayer.oObject.oShape.x          = itemData.oObject.oShape.x;
                oLayer.oObject.oShape.y          = itemData.oObject.oShape.y;
                oLayer.oObject.oShape.width      = itemData.oObject.oShape.width;
                oLayer.oObject.oShape.height     = itemData.oObject.oShape.height;
                oLayer.oObject.oShape.origwidth  = itemData.oObject.oShape.origwidth;
                oLayer.oObject.oShape.origheight = itemData.oObject.oShape.origheight;
                oLayer.oObject.oShape.url        = itemData.oObject.oShape.url;
                oLayer.oObject.oShape.filename   = itemData.oObject.oShape.filename;
            break;
            
            case 'text':
                oLayer.oObject.oShape            = new Studio.Shape.Text();
                oLayer.oObject.oShape.x          = itemData.oObject.oShape.x;
                oLayer.oObject.oShape.y          = itemData.oObject.oShape.y;
                oLayer.oObject.oShape.dwidth     = itemData.oObject.oShape.dwidth;
                oLayer.oObject.oShape.dheight    = itemData.oObject.oShape.dheight;
                oLayer.oObject.oShape.font       = itemData.oObject.oShape.font;
                oLayer.oObject.oShape.size       = itemData.oObject.oShape.size;
                oLayer.oObject.oShape.align      = itemData.oObject.oShape.align;
                oLayer.oObject.oShape.bold       = itemData.oObject.oShape.bold;
                oLayer.oObject.oShape.underlined = itemData.oObject.oShape.underlined;
                oLayer.oObject.oShape.italic     = itemData.oObject.oShape.italic;
                oLayer.oObject.oShape.text       = itemData.oObject.oShape.text;
                oLayer.oObject.oShape.shape      = (null != itemData.oObject.oShape.shape) ? itemData.oObject.oShape.shape : "";
                oLayer.oObject.oShape.color      = itemData.oObject.oShape.color;
                Studio.ImgHandler.bPositionLayerNull = true;
            break;
        }
        
        // copying effects
        
        // SHADOW
        if (null != itemData.aEffects[Studio.Effect.iShadow])
        {
            oLayer.aEffects[Studio.Effect.iShadow] = new Studio.Effect.Shadow();
            oLayer.aEffects[Studio.Effect.iShadow].iSize  = itemData.aEffects[Studio.Effect.iShadow].iSize;
            oLayer.aEffects[Studio.Effect.iShadow].iAngle = itemData.aEffects[Studio.Effect.iShadow].iAngle;
        } else 
        {
            oLayer.aEffects[Studio.Effect.iShadow] = null;
        }
        
        // GRADIENT
        if (null != itemData.aEffects[Studio.Effect.iGradient])
        {
            oLayer.aEffects[Studio.Effect.iGradient] = new Studio.Effect.Gradient();
            oLayer.aEffects[Studio.Effect.iGradient].sColor1 = itemData.aEffects[Studio.Effect.iGradient].sColor1;
            oLayer.aEffects[Studio.Effect.iGradient].sColor2 = itemData.aEffects[Studio.Effect.iGradient].sColor2;
            oLayer.aEffects[Studio.Effect.iGradient].iAngle  = itemData.aEffects[Studio.Effect.iGradient].iAngle;
        } else 
        {
            oLayer.aEffects[Studio.Effect.iGradient] = null;
        }
        
        // OPACITY
        if (null != itemData.aEffects[Studio.Effect.iOpacity])
        {
            oLayer.aEffects[Studio.Effect.iOpacity] = new Studio.Effect.Opacity();
            oLayer.aEffects[Studio.Effect.iOpacity].iOpacity = itemData.aEffects[Studio.Effect.iOpacity].iOpacity;
        } else 
        {
            oLayer.aEffects[Studio.Effect.iOpacity] = null;
        }
        
        // OUTLINES
        if (null != itemData.aEffects[Studio.Effect.iOutlines])
        {
            oLayer.aEffects[Studio.Effect.iOutlines] = new Studio.Effect.Outlines();
            oLayer.aEffects[Studio.Effect.iOutlines].aColor     = itemData.aEffects[Studio.Effect.iOutlines].aColor;
            oLayer.aEffects[Studio.Effect.iOutlines].aThickness = itemData.aEffects[Studio.Effect.iOutlines].aThickness;
        } else 
        {
            oLayer.aEffects[Studio.Effect.iOutlines] = null;
        }
        
        return oLayer;
    }
};