var fphome = new function()
{
    this.duration = 700;

    this.init = function(e)
    {
        $('div.buttons').css('position', 'absolute');
        $(window).resize(this.onResize);
        $(window).trigger('resize');
    };

    this.onResize = function(e)
    {
        var newLeft = Math.floor(($(window).width() / 2) - $('#news-button img').width()) - 65;
        var newTop = Math.floor(($(window).height() / 2) - $('#news-button img').height()) - 140;
        if (newLeft < 0) newLeft = 0;
        if (newTop < 30) newTop = 30;
        $('#news-button').animate({left:newLeft,top:newTop}, {duration:self.duration,queue:false});

        var shopLeft = Math.floor(($(window).width() / 2) - $('#shop-button img').width()) - 130;
        var shopBottom = Math.floor(($(window).height() / 2) - $('#shop-button img').height()) - 112;
        if (shopLeft < 0) shopLeft = 0;
        if (shopBottom < 0) shopBottom = $('#shop-button img').height();
        $('#shop-button').animate({left:shopLeft,bottom:shopBottom},{duration:self.duration,queue:false});

        var fprLeft = Math.floor(($(window).width() / 2) - $('#FPR-button img').width()) - 215;
        var fprTop = Math.floor(($(window).height() / 2) - $('#FPR-button img').height()) - 49;
        if (fprLeft < 0) fprLeft = Math.floor($('#FPR-button img').width() / 3);
        if (fprTop < 30) fprTop = 30;
        $('#FPR-button').animate({left:fprLeft,top:fprTop}, {duration:self.duration,queue:false});

        var artLeft = Math.floor(($(window).width() / 2) - $('#artists-button img').width()) - 270;
        var artTop = Math.floor(($(window).height() / 2) - $('#artists-button img').height()) + 6;
        if (artLeft < 0) artLeft = 0;
        if (artTop < 30) artTop = 30;
        $('#artists-button').animate({left:artLeft,top:artTop}, {duration:self.duration,queue:false});

        var pubRight = Math.floor(($(window).width() / 2) - $('#management-button img').width()) - 100;
        var pubTop = Math.floor(($(window).height() / 2) - $('#management-button img').height()) - 75;
        if (pubRight > ($(window).width()) / 2) pubRight = $(window).width() / 2;
        if (pubTop < 30) pubTop = 30;
        $('#management-button').animate({right:pubRight,top:pubTop},  {duration:self.duration,queue:false});

        var conRight = Math.floor(($(window).width() / 2) - $('#contact-button img').width()) - 263;
        var conBottom = Math.floor(($(window).height() / 2) - $('#contact-button img').height()) - 55;
        if (conRight > ($(window).width()) / 2) conRight = $(window).width() / 2;
        if (conRight < 0) conRight = 0;
        if (conBottom < 0) conBottom = 0;
        $('#contact-button').animate({right:conRight,bottom:conBottom},{duration:self.duration,queue:false});

        var synRight = Math.floor(($(window).width() / 2) - $('#sync-button img').width()) - 185;
        var synBottom = Math.floor(($(window).height() / 2) - $('#sync-button img').height()) - 112;
        if (synRight > ($(window).width()) / 2) synRight = $(window).width() / 2;
        if (synRight < 0) synRight = Math.floor($('#sync-button img').width() / 2);
        if (synBottom < 0) synBottom = Math.floor($('#sync-button img').height() / 2);
        $('#sync-button').animate({right:synRight,bottom:synBottom},{duration:self.duration,queue:false});

        var manRight = Math.floor(($(window).width() / 2) - $('#publishing-button img').width()) - 70;
        var manBottom = Math.floor(($(window).height() / 2) - $('#publishing-button img').height()) - 37;
        if (manRight > ($(window).width()) / 2) manRight = $(window).width() / 2;
        if (manRight < 0) manRight = $('#publishing-button img').width();
        if (manBottom < 0) manBottom = $('#publishing-button img').height();
        $('#publishing-button').animate({right:manRight,bottom:manBottom},{duration:self.duration,queue:false});

        var jukRight = Math.floor(($(window).width() / 2) - $('#jukebox-button img').width()) + 160;
        var jukBottom = Math.floor(($(window).height() / 2) - $('#jukebox-button img').height()) - 170;
        if (jukBottom < 0) jukBottom = Math.floor($('#jukebox-button img').height() / 2);
        $('#jukebox-button').animate({right:jukRight,bottom:jukBottom},{duration:self.duration,queue:false});
    };
};
$(function() {fphome.init();});

