/*
* Name: Ad Delay v0.1
* License:  GNUv2 (www.gnu.org/licenses/gpl-2.0.txt)
* Auther: Brian Gardner <getsnappy@ymail.com>
* Usage:
*
* adDelay.swapOut(arg1, arg2)
*     arg1 - the id of the placeholder div (in our example, skypePlaceholder)
*     arg2 - the id of the dummy div (in our example, skypeDummy)
*
* @see http://bit.ly/1hC4N7
*/
jQuery.namespace('snappy');
snappy.adDelay = {
    
    swapOut: function(placeholderId,dummyId) {
        var dummy = document.getElementById(dummyId);
        var placeholder = document.getElementById(placeholderId);
        if (!dummy) {
            alert("element with id " + dummyId + " does not exist");
        }
        if (!placeholder) {
            alert("element with id " + placeholderId + " does not exist");
        }

        /* loop through dummy nodes removing any JS nodes, preventing double execution */
        for (index = dummy.childNodes.length - 1; index >= 0; index--)
        {
            var element = dummy.childNodes[index];
            if ((element.nodeName == 'SCRIPT') || (element.nodeName == 'NOSCRIPT'))
                dummy.removeChild(element);
        }

        dummy.parentNode.removeChild(dummy);
        placeholder.parentNode.replaceChild(dummy, placeholder);
        dummy.style.display = 'block';
    }
};


