document.addEvent('domready', function() {
    if (document.id('mymovieshref') != null) {
        document.id('mymovieshref').addEvent('click', function(event) {
            event.stop();
            var req = new Request({
                method: 'get',
                url: document.id('mymovieshref').get('href'),
                onRequest: function() { 
                    /*alert('The request has been made, please wait until it has finished.'); */ 
                    document.getElementById('mymovieshref').set('text', 'Adding myMovies')                    
                },
                onComplete: function(response) {
                    /*alert('The response is the following : ' + response);  */
                    if (response == "1")
                    {
                        var copy = document.getElementById('mymovieshref').clone();
                        copy.set('href', '/mymovies');
                        copy.set('text', 'In myMovies');
                        copy.replaces(document.getElementById('mymovieshref'));
                    } 
                }
            }).send();
        });
    }
});    

