YAHOO.namespace("bugsy");

/**
* Standard utility functions
*/
YAHOO.bugsy.util = function() {
    return {
        /**
		 * Used to strip html tags from a given string
		 * Note: This method is borrowed from http://www.prototypejs.org
		 * Prototype is freely distributable under the terms of an MIT-style license.
		 * 
		 * @param {Object} str
		 */
		stripTags : function (strToClean) {
			if (YAHOO.lang.isString(strToClean)) {
				return strToClean.replace(/<\/?[^>]+>/gi, '');	
			}
		},
		/**
		 * Used to create a new DOM element
		 * @param {Object} elem - Type if element to create (ex) div
		 */
		create : function (elem) {
			return document.createElementNS ?
					document.createElementNS('http://www.w3.org/1999/xhtml', elem) :
					document.createElement(elem);
		},
		/**
		 * Used to remove an element from the DOM
		 * @param {Object} elem
		 */
		remove : function (elem) {
			try {
				elem.parentNode.removeChild(elem);	
			} catch (e) {}
		}
    }
}();

YAHOO.bugsy.Effects = function() {
    return{
        
        EffectFirstChild : function(papaNodeID, effectName, removeAfterEffect) {
            var papaNode = YAHOO.util.Dom.get(papaNodeID);

            if (YAHOO.lang.isObject(papaNode) && papaNode.hasChildNodes()) {
                var firstChild = YAHOO.util.Dom.getFirstChild(papaNode);
                var eff = eval('new YAHOO.widget.Effects.' + effectName + '(firstChild)');

                eff.onEffectComplete.subscribe(function() {
                    if (removeAfterEffect === true) {
                        YAHOO.bugsy.util.remove(firstChild);
                    }
                });

                eff.animate();
            }
        }
        
    }
}();