function bgSwap(project ,id) {
    $('body').css('background-image', "url(images/"+project+"/"+id+".jpg)");
}

$(document).ready(function() {

    function addMega(){
        $(this).addClass("hovering");
    }

    function removeMega(){
        $(this).removeClass("hovering");
    }

    var megaConfig = {
        interval: 1,
        sensitivity: 4,
        over: addMega,
        timeout: 200,
        out: removeMega
    };

    $('li.mega').hoverIntent(megaConfig)
});

function box_type ( type, id ) {
    $('#' + type + '-' + id).click(function() {
        $('#dialog-' + type + '-' + id).dialog('open');
        return false;
    });
    $('#dialog-' + type + '-' + id).dialog({
        autoOpen: false,
        show: 'drop',
        hide:  {
            effect: 'explode',
            duration: 500
        }
    });
}

function box_bio ( id ) {
    $('#' + id).click(function() {
        $('#dialog-' + id).dialog('open');
        return false;
    });
    $('#dialog-' + id).dialog({
        autoOpen: false,
        show: 'drop',
        hide:  {
            effect: 'explode',
            duration: 500
        }
    });
}

function box ( id , detail ) {
    box_type('project', id);
    if (detail == true) {
        box_type('detail', id);
    }
}

$(function() {
    //Boxes !
    box('cra', true);
    box('hak', true);
    box('ret', true);
    box('sep', true);
    
    box('kli', false);
    box('mar', true);
    box('ped', false);
    box('the', false);
    
    box_bio('pno');
    box_bio('pbi');
    box_bio('pfa');
    box_bio('pki');
    box_bio('pma');
    box_bio('psh');
    box_bio('pwa');
    box_bio('credits');
});

function swap (id) {
    $('#'+id+'').toggle();
}

function swapEN (id) {
    $('#en-'+id+'').show();
    $('#fr-'+id+'').hide();
    $('#de-'+id+'').hide();
}

function swapFR (id) {
    $('#en-'+id+'').hide();
    $('#fr-'+id+'').show();
    $('#de-'+id+'').hide();
}

function swapDE (id) {
    $('#en-'+id+'').hide();
    $('#fr-'+id+'').hide();
    $('#de-'+id+'').show();
}

(function($) {
    var cache = [];
    $.preLoadImages = function() {
        var args_len = arguments.length;
        for (var i = args_len; i--;) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
})(jQuery)
