$(document).ready(function() {
    activateFonts();
    accessibility();
    animatePlayer();
    backLinks();
});

function activateFonts() {
    Cufon.replace('#ugf #header #nav', { hover: true });
    Cufon.replace('#footer p a[rel=Copyright], #footer a.disclaimer span.content', { hover: true });
    Cufon.replace('#error h1, #error h2, #error p');
    Cufon.replace('#content h1, #content h2');
    Cufon.replace('#content.stickerbook.page .stickers a span');
    Cufon.replace('#content a.historyBack span');
    Cufon.replace('#sidebar.blog h2');
    Cufon.replace('a.ugly span');
    Cufon.replace('ol.commentlist .commentcontent cite, h3#respond, h3#comments');
    Cufon.replace('#content.mirror .pagination span');
    Cufon.replace('#content.profile .image span, #content.profile .details .number, #content.profile .details p.bio, #content.profile dl');
    Cufon.replace('#content div.downloads div h3');
    Cufon.replace('#content .winugly .form li label');
    
}

function animateCrest() {
    $("#header span.crest").css("margin-top","-234px");
    $("#header span.crest").animate({
        marginTop: "-124px"
    }, 1100);
}

function animatePlayer() {
    $("#ugf.register .player-side span").hover(
      function() {
          $(this).animate({ width: "131px" }, 600);
      },
      function() {
          $(this).animate({ width: "30px" }, 500);
      }
    )
}  

function accessibility() {
    $('a').click(function() { this.blur() });
}

function backLinks() {
    $("a.historyBack").click(function() {
        $(this).attr('href', 'javascript:history.go(-1)');
    });
}

// Register
function Success() {
    var nRandom = Math.floor(Math.random() * 4) + 1;
    $("#ugf #content").html("<img src='/assets/images/register/success" + nRandom + ".jpg' />");
    $("#ugf #content").append("<p class='thankyou-text'>We'll let you know when the site is ugly enough for you to see it!</p>");
    Cufon.replace('#ugf.register p.thankyou-text');
}

function AlreadyRegistered() {
    alert("You've already signed up! Don't worry, we'll let you know when the site is ready!");
}

function Error(sError) {
    alert(sError);
}