(function($){
    window.addEvent('domready', function(){
        var navilinks = $$('.nav');
        var mainContent = $('mainFrame');
		var sjuccplayer = $('player');
        function getPage(myUrl){
            new Request.HTML({
                method: 'get',
                url: myUrl,
                update: mainContent,
                useSpinner: true,
                spinnerOptions: {
                    message: 'Loading...'
                },
                onRequest: function(){
                    new Fx.Scroll(mainContent).toTop();
                },
                onFailure: function(){
                    mainContent.set('html', '<p class="error">You\'re not supposed to be looking at this yet. Sincerely, EDZ.</p>');
                },
                onException: function(){
                    mainContent.set('html', '<p class="error">You\'re not supposed to be looking at this yet. Sincerely, EDZ.</p>');
                }
            }).send();
        }
        getPage('home');
		function getPlayer(){
			new Request.HTML({
                method: 'get',
                url: 'player',
                update: sjuccplayer,
                onFailure: function(){
                    mainContent.set('html', '<p class="error">You\'re not supposed to be looking at this yet. Sincerely, EDZ.</p>');
                },
                onException: function(){
                    mainContent.set('html', '<p class="error">You\'re not supposed to be looking at this yet. Sincerely, EDZ.</p>');
                }
            }).send();
		}
        getPlayer();
        navilinks.each(function(el){
            el.addEvents({
                'mouseenter': function(){
                    this.fade('0.5');
                },
                'mouseleave': function(){
                    this.fade('in');
                },
                'click': function(event){
                    event.stop();
                    getPage(this.get('href'))
                }
            })
        })
    })
})(document.id)

