﻿function hidegeenstreep()
{
    $("#geenstreep").css({'display': 'none'});    
}

function geenstreep(pa)
{
    var offset = $(pa).offset();       
    $("#geenstreep").css({
        'display' : 'block',
        'left' : (offset.left - 10),
        'top' : (offset.top - 5)
    });
}

/* ** algemene ajax calls ** */
function ajaxCallUrl(sUrl, sDestionation) {
    var oDiv = $(sDestionation);
    if (oDiv.length != 1)
        return true;

    // 2 stukjes html aan table toevoegen
    oDiv.append("<div class=\"shader\"><!-- --></div><div class=\"loading\"><!-- --></div>");

    // AJAX call doen
    $.ajax({
        url: sUrl,
        cache: false,
        dataType: "html",
        success: afterLoadSuccess,
        error: afterLoadError,
        destination: sDestionation
    }); // $.ajax()
    return false;
}

/* ** algemene ajax calls ** */
function ajaxPostForm(oForm, sDestionation, sFunc) {
    var oDiv = $(sDestionation);
    if (oDiv.length != 1)
        return true;

    // 2 stukjes html aan table toevoegen
    oDiv.append("<div class=\"shader\"><!-- --></div><div class=\"loading\"><!-- --></div>");

    // AJAX call doen
    $.ajax({
        type: "POST",
        url: oForm.attr('action'),
        data: oForm.serialize(),
        cache: false,
        dataType: "html",
        success: afterLoadSuccess,
        error: afterLoadError,
        destination: sDestionation,
        afterFunc : sFunc
    }); // $.ajax()
    return false;
}

function afterLoadSuccess(htmlData) {
    if (this.destination) {
        $(this.destination).html(htmlData);
        if (this.afterFunc)
            this.afterFunc();
    } else {
        afterLoadError(false, false, false);
    }
}

function afterLoadError(xhr, err, e) {
    document.location.href = this.url;
}

/* ** home - vrienden weggooien ** */
function ajaxDeleteFriend(sUrl) {
    return ajaxCallUrl(sUrl, "#FriendList");
}

/* ** list search - paging & sorting ** */
function ajaxSearchResult(sUrl) {
    return ajaxCallUrl(sUrl, "#PartialResult");
}

/* ** voor joep ** */
if ((typeof jQuery) == 'function') {
    var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
    $(document).keydown(function(e) {
        kkeys.push(e.keyCode);
        if (kkeys.toString().indexOf(konami) >= 0) {
            $(document).unbind('keydown', arguments.callee);
            $("body").addClass("konami");
        }
    });
}