$(document).ready(function(){

    });

function LoadMainPage(page,baseurl) {
    
    AnimateContentFadeout(function() {
        $('#actual-content').load(baseurl+'?/content/'+page,HandleAjaxReply);
    });
    if(page == 'index') {
        HideLowerMenu();
    } else {
        MoveLogoUp();
        LoadLowerMenu(baseurl);
    }
    return false;
}

function LoadSubPage(parent,page,baseurl) {
    $('#subcontent').hide('blind', function() {
        $('#subcontent').load(baseurl+'?/content/'+parent+'/'+page,function() {
            $('#subcontent').show('blind');
        });
    });
    return false;
}

function LoadLowerMenu(baseurl) {
    $('#lower-menu').load(baseurl+'?/content/lowermenu');
}

function HideLowerMenu() {
    $('#lower-menu').hide('blind');
}

function HandleAjaxReply(response,status,xhr) {
    if(status == 'error') {
        $('#actual-content').html('Error: '+xhr.status+" "+xhr.statusText);
    }
    AnimateContentFadeIn();
}

function AnimateContentFadeout(callback) {
    $('#footer-spacer').fadeOut(100);
    $('#footer-container').fadeOut(100);
    $('#content-container').animate({
        opacity: 0,
        width: 0
    },300,callback);
}

function AnimateContentFadeIn() {
    
    $('#content-container').animate({
        opacity: 1,
        width: 800
    },300, function () {
        $('#footer-spacer').fadeIn(100);
        $('#footer-container').fadeIn(100);
    });
}

function MoveLogoUp() {
    if($('#title-spacer').css('display') != 'none') {
        $('#title-spacer').hide('blind');
    }
}
function MoveLogoDown() {
    if($('#title-spacer').css('display') == 'none') {
        $('#title-spacer').show('blind');
    }
}

