﻿
/* Voer een ajax request uit voor een menu link */
function linkAjaxShow(event) {
    event.preventDefault();

    $('#MainContent').html('');

    $.ajax({ url: this.href,
        type: 'get',
        dataType: 'html',
        success: setContentShow,
        error: ajaxError
    });
}


function setContentShow(newContent) {
    $('#MainContent').hide();
    $('#MainContent').html(newContent);

    // add ajaxfadeIn behaviour to ajaxLink class in new content
    $('a.ajaxlink').click(linkAjaxShow);

    $('#MainContent').fadeIn('slow');
}

function ajaxError(XMLHttpRequest, textStatus, errorThrown) {
    window.location.replace('/error/unhandled');
}



/* 
* On startup off page 
*/
$(document).ready(function() {

    /* add functinality to class menulink to do this in an ajax fashion */
    $('a.menulink').click(linkAjaxShow);

});


