/**
 * LinkityScript
 *
 * Uses a YUI singleton pattern to keep all the variables etc within name space and
 * provide a single object. The parentheses at the end make the object execute immediately
 * returning the object to the namespace. Functions above the return are private and are 
 * retained as they are referenced from the public functions, so they are a closure
 */
LinkityScript = function () {


    ////////////////////////////////////////////////////////////////////////////////
    // PRIVATE
    ////////////////////////////////////////////////////////////////////////////////

    var id = null;

    /**
     * responseSuccess
     *
     * Called to update status div
     * private
     */
    var responseSuccess = function(o){ 
        this.removeElement('urls', this.id);
    };


    /**
     * responseFailure
     *
     * Leave status div alone if we can't get a new status
     * private
     */
    var responseFailure = function(o){
        alert("Could not remove the link");
    };


    ////////////////////////////////////////////////////////////////////////////////
    // PUBLIC
    ////////////////////////////////////////////////////////////////////////////////

    return {


    removelink:
        function (id, surl) {
            this.id = id;
            var callback = { success:responseSuccess, failure:responseFailure, scope:LinkityScript };
            var transaction = YAHOO.util.Connect.asyncRequest('GET', surl, callback, true);
        },

    removeElement:
        function(parentId, elementId) {
            var parentElement = document.getElementById(parentId);
            var childElement = document.getElementById(elementId);
            parentElement.removeChild(childElement);
        }
    };
}();






