document.observe('dom:loaded', function() {
    
    var title = $('title');
    title.absolutize();
    
    var coordinates = title.viewportOffset();
    var x0 = coordinates[0];
    var y0 = coordinates[1];
    
    Resets();

    var rand = 0.8;
    
    function addRandom() {
        
        randx = Math.floor(Math.random()*(rand*2 + 1));
        x = x0 + ((randx > rand) ? (rand - randx) : randx);
        
        randy = Math.floor(Math.random()*(rand*2 + 1));
        y = y0 + ((randy > rand) ? (rand - randy) : randy);
        
        title.setStyle({
            'top': x + 'px',
            'left':y + 'px'
        });
    }
    
    function Resets(){
        title.setStyle({
            'top': coordinates[0] + 'px',
            'left': coordinates[1] + 'px'
        });
    }
    
    title.observe('mouseover', function(event) {
        intervalID = setInterval(addRandom, 0.1);
    }).observe('mouseout', function(event){
        clearInterval(intervalID);
        Resets();
    });
    
    $$('a[rel="external"]').each(function(link){
		if(link.readAttribute('href') != '' && link.readAttribute('href') != '#'){
				link.writeAttribute('target','_blank');
        }
    });
     
});