/**
 * @author      Michael J. I. Jackson <mjijackson@gmail.com>
 * @copyright   2007 Michael J. I. Jackson
 * @license     http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL 3.0
 * @version     SVN: $Id: shadowbox-yui.js 48 2008-01-26 09:58:25Z mjijackson $
 */

if(typeof YAHOO == 'undefined'){
    throw 'Unable to load Shadowbox, core YUI utilities (yahoo, dom, event, anim) not found.';
}

// create the Shadowbox object first
var Shadowbox = {};

Shadowbox.lib = function(){

    var E = YAHOO.util.Event;
    var D = YAHOO.util.Dom;

    return {

       
        getStyle: function(el, style){
            return D.getStyle(el, style);
        },

       
        setStyle: function(el, style, value){
            if(typeof style != 'object'){
                var temp = {};
                temp[style] = value;
                style = temp;
            }
            for(var s in style){
                D.setStyle(el, s, style[s]);
            }
        },

        get: function(el){
            return D.get(el);
        },

        remove: function(el){
            el.parentNode.removeChild(el);
        },
        getTarget: function(e){
            return E.getTarget(e.browserEvent || e);
        },

        preventDefault: function(e){
            E.preventDefault(e.browserEvent || e);
        },

        addEvent: function(el, name, handler){
            E.addListener(el, name, handler);
        },

        removeEvent: function(el, name, handler){
            E.removeListener(el, name, handler);
        },

        animate: function(el, obj, duration, callback){
            var anim = new YAHOO.util.Anim(el, obj, duration, YAHOO.util.Easing.easeOut);
            if(typeof callback == 'function'){
                var f = function(){
                    anim.onComplete.unsubscribe(f);
                    callback.call(anim, anim);
                };
                anim.onComplete.subscribe(f, anim, true);
            }
            anim.animate();
        }

    };

}();

