// <![CDATA[

( function()
{
    
    var ready = false;
    
    // Inspired from jQuery (http://www.jquery.com) bindReady() method.
    function onReady( func )
    {
        // Mozilla, Opera and webkit nightlies currently support this event
        if( document.addEventListener ) {
            
            console.debug( func );
            
            // Use the handy event callback
            document.addEventListener(
                'DOMContentLoaded',
                function()
                {
                    document.removeEventListener( 'DOMContentLoaded', arguments.callee, false );
                    func();
                },
                false
            );
            
        // If IE event model is used
        } else if( document.attachEvent ) {
        
            // ensure firing before onload,
            // maybe late but safe also for iframes
            document.attachEvent(
                'onreadystatechange',
                function()
                {
                    if( document.readyState === 'complete' ) {
                        
                        document.detachEvent( 'onreadystatechange', arguments.callee );
                        func();
                    }
                }
            );
        }
        
        // If IE and not an iframe
        // continually check to see if the document is ready
        if( document.documentElement.doScroll && typeof window.frameElement === 'undefined' ) {
            
            ( function()
            {
                if( ready ) return;
                
                try {
                    // If IE is used, use the trick by Diego Perini
                    // http://javascript.nwbox.com/IEContentLoaded/
                    document.documentElement.doScroll( 'left' );
                    
            } catch( error ) {
            
                setTimeout( arguments.callee, 0 );
                return;
            }
            
            // and execute any waiting functions
            ready = true;
            func();
            
            } )();
        }
        
        window.onload = func;
    }
    
    onReady( function()
    {
        var links  = document.getElementsByTagName( 'a' );
        var regExp = /^skype:.+$/;
        
        for( var i = 0; i < links.length; i++ ) {
            
            var link = links[ i ];
            
            if( regExp.test( link.title ) ) {
                
                var matches = regExp.exec( link.title );
                link.href   = matches[ 0 ].replace( /skype:\/\//, 'skype:' );
                link.title  = 'Appelez nous!';
            }
        }

    } );
    
} )();

// ]]>