/**
 * $Id: dropshadowinterface.js 66632 2009-04-09 21:44:43Z kchiu $
 * $Author: kchiu $
 * $Revision: 66632 $
 * $Name$
 * $Date: 2009-04-09 14:44:43 -0700 (Thu, 09 Apr 2009) $
 *
 * @jsRequire DomUtils
 * @jsRequire interfaces.Interface
 * @jsRequire classes.Browser
 * @jsRequire classes.EventManager
 * @jsRequire classes.ResourceManager
 *
 *
 * @version    $Revision: 66632 $
 * @author     Philip Snyder <philip@pricegrabber.com>
 * @copyright  Copyright &copy; 2006, Philip Snyder, PriceGrabber.com
 * @see        interfaces.Interface
 */

/**
 * DropShadowInterface Constructor / Definition
 *
 * This interface is built on top of the Interface object
 * and is NOT intended to be instantiated directly. See
 * documentation on interfaces.Interface for a complete
 * explanation.
 *
 * @access public
 * @since  v1.1
 * @return DropShadowInterface
 */
function DropShadowInterface(color, xOffset, yOffset, blur, opacity, xShrink, yShrink) {
    this.dropShadowId = null;
    this.elemId       = null;
    this.color        = null;
    this.xOffset      = null;
    this.yOffset      = null;
    this.xShrink      = null;
    this.yShrink      = null;
    this.blur         = null;
    this.opacity      = null;
    this.shadowStyle  = null;
    this.images       = new Array;
    this.draw         = DropShadowInterface_Draw;
    this.erase        = DropShadowInterface_Erase;
    this.init         = DropShadowInterface_Init;
    this.setBlur      = DropShadowInterface_SetBlur;
    this.alignElement = DropShadowInterface_AlignElement;
    return this;
} // End DropShadowInterface

// Setup DropShadowInterface prototype chain
DropShadowInterface.prototype             = new Interface;
DropShadowInterface.prototype.constructor = DropShadowInterface;
DropShadowInterface.superclass            = Interface.prototype;




/****** BEGIN EDIT SECTION ******/

/**
 * Drop shadow style definitions.
 *
 * This data structure allows for the definition of various different
 * drop shadow "styles" that can be applied by setting the shadowStyle
 * of the object implementing DropShadowInterface.
 *
 * Example:
 *
 *    <script language="JavaScript">
 *    var popup = new DropShadowPopup();
 *    popup.shadowStyle = 'Default';
 *    </script>
 *
 * You can also define a shadow style at any time after inclusion of
 * this file and then reference that style instead if you like.
 *
 * @access public
 * @since  v1.1
 * @var    DropShadowInterface.styles   struct
 */
DropShadowInterface.styles = {
    DefaultMenu: { color: 'rgb(0,0,0)', xOffset: 10, yOffset: 15, blur: { iRadius: 12, iSigma: 20}, opacity: .2, xShrink: 16, yShrink: 20 },
    Default:     { color: 'rgb(0,0,0)', xOffset: 17, yOffset: 17, blur: { iRadius: 20, iSigma: 20}, opacity: .2, xShrink: 29, yShrink: 24 },
    IEDefault:   { color: 'rgb(0,0,0)', xOffset:  7, yOffset: 10, blur: { iRadius: 10, iSigma: 20}, opacity: .2, xShrink:  9, yShrink: 10 },
    CheckAll:    { color: 'rgb(0,0,0)', xOffset:  7, yOffset:  7, blur: { iRadius: 10, iSigma: 10}, opacity: .2, xShrink:  9, yShrink:  4 },
    oldIe:       { color: 'rgb(0,0,0)', xOffset:  7, yOffset: 10, blur: { iRadius: 10, iSigma: 20}, opacity: .2, xShrink:  9, yShrink: 10 }
};

/**
 * engineUrl holds the path to the php gradient script.
 *
 * This value can be changed at any time after this file
 * is included as follows:
 *
 * <script>
 *  DropShadowInterface.engineUrl = '/any/url/you/want.php';
 * </script>
 *
 * @access public
 * @since  v1.1
 * @var    string
 */
DropShadowInterface.engineUrl = '/gfx/gradient.php';

/****** END EDIT SECTION ******/




/**
 * Internal image ids used for keeping track of image resources.
 *
 * !DO NOT MODIFY THIS!
 *
 * @access private
 * @since  v1.1
 * @var    DropShadowInterface.imgIds   struct
 */
//DropShadowInterface.imgIds = { top: 0, left: 1, bottom: 2, right: 3, topLeft: 4, bottomLeft: 5, bottomRight: 6, topRight: 7, callout: 8 };
DropShadowInterface.imgIds = { top: 0, left: 1, bottom: 2, right: 3, topLeft: 4, bottomLeft: 5, bottomRight: 6, topRight: 7 };






/**
 * Initializes an object that implements the DropShadowInterface.
 * Call this function prior to any draw() functions.
 *
 * @access public
 * @since  v1.1
 * @return void
 */
function DropShadowInterface_Init(color, xOffset, yOffset, blur, opacity, xShrink, yShrink) {
    //window.messageQueue.add( new Message('DropShadowInterface_Init', 'called') );

    if (!this.shadowStyle && DomUtils.browser.isIE()) this.shadowStyle = 'IEDefault';
    else if (!this.shadowStyle)              this.shadowStyle = 'Default';
    var shadowStyle  = DropShadowInterface.styles[this.shadowStyle];
    this.color       = (color)          ? color   : shadowStyle.color;
    this.xOffset     = !isNaN(xOffset)  ? xOffset : shadowStyle.xOffset;
    this.yOffset     = !isNaN(yOffset)  ? yOffset : shadowStyle.yOffset;
    this.blur        = isString(blur)   ? blur    : shadowStyle.blur;
    this.opacity     = isFloat(opacity) ? opacity : shadowStyle.opacity;
    this.xShrink     = !isNaN(xShrink)  ? xShrink : shadowStyle.xShrink;
    this.yShrink     = !isNaN(yShrink)  ? yShrink : shadowStyle.yShrink;

    /**
     * Handle color parameter
     */
    this.hexColor = '';
    this.rgbColor = '';
    var  rgbRegex = /^rgb\(\s?([0-9]{1,3})\s?\,\s?([0-9]{1,3})\s?\,\s?([0-9]{1,3})\s?\)/;
    var  hexRegex = /^\#?[0-9A-Fa-f]{3}$|\#[0-9A-Fa-f]{6}$/;
    if (hexRegex.test(this.color)) {
        var triplets = new Array;
        if (this.color.length > 4) {
            this.hexColor = this.color;
            for (var start=1; start+2<=this.color.length; start += 2) triplets[triplets.length] = this.color.substr(start, 2);
            for (var i=0;     i<triplets.length;          i++)        triplets[i] = parseInt(triplets[i], 16);
            this.rgbColor = triplets.join(',');
        } else if (this.color.length == 4) {
            for (var start=1; start+1<=this.color.length; start++) triplets[triplets.length] = this.color.substr(start, 1)+this.color.substr(start, 1);
            this.hexColor = '#'+triplets.join('');
            for (var i=0;     i<triplets.length;          i++)     triplets[i] = parseInt(triplets[i], 16);
            this.rgbColor = triplets.join(',');
        } else throw new Error('No valid color setting defined! color: '+this.color);
    } else {
        var matches = this.color.match(rgbRegex);
        if (matches && matches.length > 1) {
            matches.shift();
            for (var i=0; i<matches.length; i++) {
                if (parseInt(matches[i]) > 255) throw new Error('Invalid RGB color specified: '+this.color);
            }
            this.rgbColor = matches.join(',');
        } else throw new Error('No valid color setting defined! color: '+this.color);
    }
    /**
     * Handle blur parameter
     */
    if (isString(this.blur)) {
        var radius = parseInt(this.blur);
        var sigma  = 0;
        if (this.blur.indexOf('x') > 0) sigma = parseInt(this.blur.split('x')[1]);
        this.setBlur(radius, sigma);
    }
    
    this.images = new Array;
    this.images[DropShadowInterface.imgIds.top]         = DropShadowInterface.engineUrl+'?grad=linear&dir=btt&height='+this.blur.iRadius+
         '&width='+this.blur.iRadius+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma+'&opacity='+this.opacity;
    this.images[DropShadowInterface.imgIds.bottom]      = DropShadowInterface.engineUrl+'?grad=linear&dir=ttb&height='+this.blur.iRadius+
         '&width='+this.blur.iRadius+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma+'&opacity='+this.opacity;
    this.images[DropShadowInterface.imgIds.left]        = DropShadowInterface.engineUrl+'?grad=linear&dir=rtl&height='+this.blur.iRadius+
         '&width='+this.blur.iRadius+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma+'&opacity='+this.opacity;
    this.images[DropShadowInterface.imgIds.right]       = DropShadowInterface.engineUrl+'?grad=linear&dir=ltr&height='+this.blur.iRadius+
         '&width='+this.blur.iRadius+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma+'&opacity='+this.opacity;
    this.images[DropShadowInterface.imgIds.bottomRight] = DropShadowInterface.engineUrl+'?grad=radial&radius='+(this.blur.iRadius*2)+
         '&height='+this.blur.iRadius+'&width='+this.blur.iRadius+'&opacity='+this.opacity+
         '&x=0&y=0'+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma;
    this.images[DropShadowInterface.imgIds.topRight]    = DropShadowInterface.engineUrl+'?grad=radial&radius='+(this.blur.iRadius*2)+
         '&height='+this.blur.iRadius+'&width='+this.blur.iRadius+'&opacity='+this.opacity+
         '&x=0&y='+(this.blur.iRadius+1)+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma;
    this.images[DropShadowInterface.imgIds.bottomLeft]  = DropShadowInterface.engineUrl+'?grad=radial&radius='+(this.blur.iRadius*2)+
         '&height='+this.blur.iRadius+'&width='+this.blur.iRadius+'&opacity='+this.opacity+
         '&x='+(this.blur.iRadius+1)+'&y=0'+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma;
    this.images[DropShadowInterface.imgIds.topLeft]     = DropShadowInterface.engineUrl+'?grad=radial&radius='+(this.blur.iRadius*2)+
         '&height='+this.blur.iRadius+'&width='+this.blur.iRadius+'&opacity='+this.opacity+
         '&x='+(this.blur.iRadius+1)+'&y='+(this.blur.iRadius+1)+'&color='+this.rgbColor+'&gaussian='+this.blur.iRadius+'x'+this.blur.iSigma;
    //this.images[DropShadowInterface.imgIds.callout]     = '/images/callout_right.png';
    if (typeof(window.preloadImage) == 'function') {
        for (i=0; i<this.images.length; i++) {
            util.resourceManager.get(this.images[i]);
            //util.resourceManager.get(this.images[i], this.blur.iRadius, this.blur.iRadius);
        }
    }

    //window.messageQueue.add( new Message('DropShadowInterface_Init', 'finished') );
} // End DropShadowInterface_Init




/**
 * "Draws" the actual drop shadow by creating the necessary dom elements and applying them to
 * the object's element.
 *
 * @access public
 * @since  v1.1
 * @return void
 */
function DropShadowInterface_Draw() {
    //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'called') );
    var opacity = this.opacity;
    // remove the old drop shadow if it exists
    var dropShadow = document.getElementById(this.dropShadowId);
    if (dropShadow) {
        DomUtils.removeElement(dropShadow);
        dropShadow = null;
    }
    var elem = document.getElementById(this.elemId);
    if (elem) {
        // Clone the elem node now before any other draw changes it.
        var zIndex                       = parseInt(DomUtils.getZIndex(elem))-2;
        this.dropShadowId                = this.id+'_DropShadow';
        var dropShadow                   = elem.cloneNode(false);
        dropShadow.id                    = this.dropShadowId;
        dropShadow.style.visibility      = 'hidden';
        dropShadow.style.zIndex          = zIndex;
        dropShadow.className             = '';
        dropShadow.style.position        = 'absolute';
        dropShadow.style.backgroundColor = 'transparent';
        dropShadow.style.border          = 'none';
        dropShadow.style.left            = parseInt(DomUtils.getElementLeft(elem))+'px';
        dropShadow.style.top             = parseInt(DomUtils.getElementTop(elem))+'px';
        dropShadow.xOffset               = parseInt(this.xOffset);
        dropShadow.yOffset               = parseInt(this.yOffset);
        dropShadow.overflow              = 'visible !important';
        // DO NOT move this to the end since it messes up dimension calculations in IE
        //elem.parentNode.appendChild(dropShadow);
        document.getElementsByTagName('body')[0].appendChild(dropShadow);
/**
 * This is the BETTER / easier way to make the drop shadow follow
 * the element. However, this doesn't work on IE. Retain code for
 * possible future uses.
 */
//    if (!DomUtils.browser.isIE()) {
//        window.addEvent(this.elem, 'DOMAttrModified', function(e) {
//            if (e.type == 'DOMAttrModified' && e.attrName == 'style') {
//                dropShadow.setAttribute('style', e.newValue);
//                dropShadow.style.zIndex   = parseInt(this.style.zIndex)-2;
//                dropShadow.style.overflow = 'visible !important';
//                dropShadow.style.border   = 'none';
//                dropShadow.style.left     = DomUtils.getElementLeft(this)+'px';
//                dropShadow.style.top      = DomUtils.getElementTop(this)+'px';
//            }
//        }, this.elem, true);
//    }
//    this.elem.parentNode.insertBefore(this.dropShadow, this.elem.nextSibling);
        if (this.xShrink) {
            //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting drop shadow width') );
            dropShadow.style.width = parseInt(parseInt(DomUtils.getElementWidth(elem))+(parseInt(this.xShrink)/2))+'px';
        }
        if (this.yShrink) {
            //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting drop shadow height') );
            dropShadow.style.height = parseInt(parseInt(DomUtils.getElementHeight(elem))+(parseInt(this.yShrink)/2))+'px';
        }
    
        if (DomUtils.browser.isIE()) {
            var eStyle = DomUtils.getCurrentStyle(elem);
            pLeft   = parseInt(eStyle.paddingLeft);
            pRight  = parseInt(eStyle.paddingRight);
            pTop    = parseInt(eStyle.paddingTop);
            pBottom = parseInt(eStyle.paddingBottom);
            pWidth  = parseInt((!isNaN(pLeft) ? pLeft : 0)+(!isNaN(pRight)  ? pRight  : 0));
            pHeight = parseInt((!isNaN(pTop)  ? pTop  : 0)+(!isNaN(pBottom) ? pBottom : 0));
        } else {
            pHeight = 0;
            pWidth  = 0;
        }
        
        var img;
        var shadow                         = document.createElement('div');
        shadow.id                          = this.id+'_DropShadow_Main';
        shadow.style.position              = 'absolute';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting shadow width') );
        shadow.style.width                 = parseInt(parseInt(DomUtils.getElementWidth(elem))-parseInt(this.xShrink))+'px';
        shadow.style.height                = parseInt(parseInt(DomUtils.getElementHeight(elem))-parseInt(this.yShrink))+'px';
        shadow.style.left                  = parseInt(this.xOffset)+'px';
        shadow.style.top                   = parseInt(this.yOffset)+'px';
        shadow.style.border                = 'none';
        shadow.style.backgroundColor       = 'rgb('+this.rgbColor+')';
        shadow.style.zIndex                = zIndex;
        if (DomUtils.browser.isIE()) shadow.style.filter    += 'progid:DXImageTransform.Microsoft.Alpha(opacity='+(this.opacity*100)+')';
        else                         shadow.style.MozOpacity = this.opacity;
        dropShadow.appendChild(shadow);
    
        var bottomEdge                     = document.createElement('div');
        bottomEdge.id                      = this.id+'_DropShadow_Bottom';
        bottomEdge.className               = 'shadow';
        bottomEdge.style.position          = 'absolute';
        bottomEdge.style.top               = parseInt(parseInt(DomUtils.getElementHeight(shadow))+parseInt(this.yOffset))+'px';
        bottomEdge.style.left              = parseInt(this.xOffset)+'px';
        bottomEdge.style.height            = parseInt(this.blur.iRadius)+'px';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting bottom width') );
        bottomEdge.style.width             = parseInt(DomUtils.getElementWidth(shadow))+'px';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'bottom width: '+bottomEdge.style.width) );
        bottomEdge.style.zIndex            = zIndex;
        img                                = document.createElement('img');
        img.src                            = util.resourceManager.get(this.images[DropShadowInterface.imgIds.bottom]);
        img.height                         = parseInt(this.blur.iRadius);
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting image width') );
        img.width                          = parseInt(DomUtils.getElementWidth(shadow));
        img.style.position                 = 'absolute';
        img.style.left                     = '0px';
        img.style.top                      = '0px';

        DropShadowInterface_FixPNG(img);

        bottomEdge.appendChild(img);
        dropShadow.appendChild(bottomEdge);
    
        var rightEdge                      = document.createElement('div');
        rightEdge.id                       = this.id+'_DropShadow_Right';
        rightEdge.className                = 'shadow';
        rightEdge.style.position           = 'absolute';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting right width') );
        rightEdge.style.left               = parseInt(parseInt(DomUtils.getElementWidth(shadow))+parseInt(this.xOffset))+'px';
        rightEdge.style.top                = parseInt(this.yOffset)+'px';
        rightEdge.style.height             = parseInt(DomUtils.getElementHeight(shadow))+'px';
        rightEdge.style.width              = parseInt(this.blur.iRadius)+'px';
        rightEdge.style.zIndex             = zIndex;
        img                                = document.createElement('img');
        img.src                            = util.resourceManager.get(this.images[DropShadowInterface.imgIds.right]);
        img.height                         = parseInt(DomUtils.getElementHeight(shadow));
        img.width                          = parseInt(this.blur.iRadius);
        img.style.position                 = 'absolute';
        img.style.left                     = '0px';
        img.style.top                      = '0px';

        DropShadowInterface_FixPNG(img);

        rightEdge.appendChild(img);
        dropShadow.appendChild(rightEdge);
    
        var leftEdge                       = document.createElement('div');
        leftEdge.id                        = this.id+'_DropShadow_Left';
        leftEdge.className                 = 'shadow';
        leftEdge.style.position            = 'absolute';
        leftEdge.style.left                = parseInt(parseInt(this.xOffset)-parseInt(this.blur.iRadius))+'px';
        leftEdge.style.top                 = parseInt(this.yOffset)+'px';
        leftEdge.style.height              = parseInt(DomUtils.getElementHeight(shadow))+'px';
        leftEdge.style.width               = parseInt(this.blur.iRadius)+'px';
        leftEdge.style.zIndex              = zIndex;
        img                                = document.createElement('img');
        img.src                            = util.resourceManager.get(this.images[DropShadowInterface.imgIds.left]);
        img.height                         = parseInt(DomUtils.getElementHeight(shadow));
        img.width                          = parseInt(this.blur.iRadius);
        img.style.position                  = 'absolute';
        img.style.left                      = '0px';
        img.style.top                       = '0px';

        DropShadowInterface_FixPNG(img);

        leftEdge.appendChild(img);
        dropShadow.appendChild(leftEdge);
    
        var topEdge                         = document.createElement('div');
        topEdge.id                          = this.id+'_DropShadow_Top';
        topEdge.className                   = 'shadow';
        topEdge.style.position              = 'absolute';
        topEdge.style.left                  = parseInt(this.xOffset)+'px';
        topEdge.style.top                   = parseInt(parseInt(this.yOffset)-parseInt(this.blur.iRadius))+'px';
        topEdge.style.height                = parseInt(this.blur.iRadius)+'px';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting top width') );
        topEdge.style.width                 = parseInt(DomUtils.getElementWidth(shadow))+'px';
        topEdge.style.zIndex                = zIndex;
        img                                 = document.createElement('img');
        img.src                             = util.resourceManager.get(this.images[DropShadowInterface.imgIds.top]);
        img.height                          = parseInt(this.blur.iRadius);
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting image width') );
        img.width                           = parseInt(DomUtils.getElementWidth(shadow));
        img.style.position                  = 'absolute';
        img.style.left                      = '0px';
        img.style.top                       = '0px';

        DropShadowInterface_FixPNG(img);

        topEdge.appendChild(img);
        dropShadow.appendChild(topEdge);
    
        var brCorner                        = document.createElement('div');
        brCorner.id                         = this.id+'_DropShadow_BottomRightCorner';
        brCorner.className                  = 'shadow';
        brCorner.style.position             = 'absolute';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting br width') );
        brCorner.style.top                  = parseInt(parseInt(DomUtils.getElementHeight(shadow))+parseInt(this.yOffset))+'px';
        brCorner.style.left                 = parseInt(parseInt(DomUtils.getElementWidth(shadow))+parseInt(this.xOffset))+'px';
        brCorner.style.height               = parseInt(this.blur.iRadius)+'px';
        brCorner.style.width                = parseInt(this.blur.iRadius)+'px';
        brCorner.style.zIndex               = zIndex;
        img                                 = document.createElement('img');
        img.src                             = util.resourceManager.get(this.images[DropShadowInterface.imgIds.bottomRight]);
        img.height                          = parseInt(this.blur.iRadius);
        img.width                           = parseInt(this.blur.iRadius);
        img.style.position                  = 'absolute';
        img.style.left                      = '0px';
        img.style.top                       = '0px';
        
        DropShadowInterface_FixPNG(img);

        brCorner.appendChild(img);
        dropShadow.appendChild(brCorner);
    
        var trCorner                        = document.createElement('div');
        trCorner.id                         = this.id+'_DropShadow_TopRightCorner';
        trCorner.className                  = 'shadow';
        trCorner.style.position             = 'absolute';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting tr width') );
        trCorner.style.left                 = parseInt(parseInt(DomUtils.getElementWidth(shadow))+parseInt(this.xOffset))+'px';
        trCorner.style.top                  = parseInt(parseInt(this.yOffset)-parseInt(this.blur.iRadius))+'px';
        trCorner.style.height               = parseInt(this.blur.iRadius)+'px';
        trCorner.style.width                = parseInt(this.blur.iRadius)+'px';
        trCorner.style.zIndex               = zIndex;
        img                                 = document.createElement('img');
        img.src                             = util.resourceManager.get(this.images[DropShadowInterface.imgIds.topRight]);
        img.height                          = parseInt(this.blur.iRadius);
        img.width                           = parseInt(this.blur.iRadius);
        img.style.position                  = 'absolute';
        img.style.left                      = '0px';
        img.style.top                       = '0px';

        DropShadowInterface_FixPNG(img);

        trCorner.appendChild(img);
        dropShadow.appendChild(trCorner);
    
        var blCorner                        = document.createElement('div');
        blCorner.id                         = this.id+'_DropShadow_BottomLeftCorner';
        blCorner.className                  = 'shadow';
        blCorner.style.position             = 'absolute';
        blCorner.style.left                 = parseInt(parseInt(this.xOffset)-parseInt(this.blur.iRadius))+'px';
        //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'getting bl width') );
        blCorner.style.top                  = parseInt(parseInt(DomUtils.getElementHeight(shadow))+parseInt(this.yOffset))+'px';
        blCorner.style.height               = parseInt(this.blur.iRadius)+'px';
        blCorner.style.width                = parseInt(this.blur.iRadius)+'px';
        blCorner.style.zIndex               = zIndex;
        img                                 = document.createElement('img');
        img.src                             = util.resourceManager.get(this.images[DropShadowInterface.imgIds.bottomLeft]);
        img.height                          = parseInt(this.blur.iRadius);
        img.width                           = parseInt(this.blur.iRadius);
        img.style.position                  = 'absolute';
        img.style.left                      = '0px';
        img.style.top                       = '0px';

        DropShadowInterface_FixPNG(img);

        blCorner.appendChild(img);
        dropShadow.appendChild(blCorner);
    
        var tlCorner                        = document.createElement('div');
        tlCorner.id                         = this.id+'_DropShadow_TopLeftCorner';
        tlCorner.className                  = 'shadow';
        tlCorner.style.position             = 'absolute';
        tlCorner.style.left                 = parseInt(parseInt(this.xOffset)-parseInt(this.blur.iRadius))+'px';
        tlCorner.style.top                  = parseInt(parseInt(this.yOffset)-parseInt(this.blur.iRadius))+'px';
        tlCorner.style.height               = parseInt(this.blur.iRadius)+'px';
        tlCorner.style.width                = parseInt(this.blur.iRadius)+'px';
        tlCorner.style.zIndex               = zIndex;
        img                                 = document.createElement('img');
        img.src                             = util.resourceManager.get(this.images[DropShadowInterface.imgIds.topLeft]);
        img.height                          = parseInt(this.blur.iRadius);
        img.width                           = parseInt(this.blur.iRadius);
        img.style.position                  = 'absolute';
        img.style.left                      = '0px';
        img.style.top                       = '0px';

        DropShadowInterface_FixPNG(img);

        tlCorner.appendChild(img);
        dropShadow.appendChild(tlCorner);
        dropShadow.style.visibility = DomUtils.getCurrentStyle(elem).visibility;

    } else {
        throw new Error('unable to find content element');
    }
    //window.messageQueue.add( new Message('DropShadowInterface_Draw', 'finished') );
} // End DropShadowInterface_Draw




/**
 * "Erases" the drop shadow by removing the dom elements created with DropShadowInterface.draw().
 *
 * @access public
 * @since  v0.0.1a
 * @return void
 */
function DropShadowInterface_Erase() {
    //window.messageQueue.add( new Message('DropShadowInterface_Erase', 'called') );
    var dropShadow = document.getElementById(this.dropShadowId);
    if (dropShadow) DomUtils.removeElement(dropShadow);
    // Clean up dom references for IE
    dropShadow = null;
    //window.messageQueue.add( new Message('DropShadowInterface_Erase', 'finished') );
} // End DropShadowInterface_Erase




/**
 * Aligns the object's element by adjusting its left & top by the proper calculations (which are done
 * in this function) on the left & top of the element.
 *
 * @access public
 * @since  v0.0.1a
 * @return void
 */
function DropShadowInterface_AlignElement(pos) {
    //window.messageQueue.add( new Message('DropShadowInterface_AlignElement', 'called') );
    var elem       = document.getElementById(this.elemId);
    if (!elem)       throw new Error('Unable to find element: '+this.elemId);
    var dropShadow = document.getElementById(this.dropShadowId);
    if (!dropShadow) throw new Error('Unable to find drop shadow element: '+this.dropShadowId);
    // Align the drop shadow with the main element
    dropShadow.style.position = 'absolute';
    dropShadow.style.left     = DomUtils.getElementLeft(elem)+'px';
    dropShadow.style.top      = DomUtils.getElementTop(elem)+'px';
    // fanatic memory cleanup
    dropShadow = null;
    elem       = null;
    //window.messageQueue.add( new Message('DropShadowInterface_AlignElement', 'finished') );
} // End DropShadowInterface_AlignElement




/**
 * Sets the blur values of the drop shadow.
 *
 * radius:   radius of area to blur
 * sigma:    amount of pixels to consider when
 *           averaging pixel values
 *
 * @access public
 * @since  v1.1
 * @param  integer  radius   radius of area to blur
 * @param  integer  sigma    amount of pixels to consider when averaging pixel values
 * @return void
 */
function DropShadowInterface_SetBlur(radius, sigma) {
    this.blur = { iRadius: radius, iSigma: sigma };
} // End DropShadowInterface_SetBlur


/**
 * Fixes alpha transparency issue with PNGs on Microsoft Internet Explorer.
 *
 * @access public
 * @since  v1.1
 * @return void
 */
function DropShadowInterface_FixPNG(img) {
    if (DomUtils.browser.isIE()) {
        var arVersion = navigator.appVersion.split("MSIE");
        var version = 0.0;
        if (arVersion && arVersion.length > 1) version = parseFloat(arVersion[1]);
        if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
            var imgID    = (img.id) ? "id='" + img.id + "' " : "";
            var imgClass = (img.className) ? "class='" + img.className + "' " : "";
            var imgTitle = (img.title)                    ?
                            "title='" + img.title  + "' " :
                            "title='" + img.alt    + "' " ;
            var imgStyle = "display:inline-block;";
            if (img && img.style) { 
              imgStyle += img.style.cssText || ''; 
              img.style.cssText = "display: none";
            }
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
                           + " style=\"" + "width:" + img.width 
                           + "px; height:" + img.height 
                           + "px;" + imgStyle + ";"
                           + "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader"
                           + "(src=\'"+img.src+"\', sizingMethod='scale');\"></span>";
            img.src = "";
            img.outerHTML = strNewHTML;
        }
    }
}
