/**
 * 
 * Custom js (jQuery) functions of the application
 *
 */

// simple accordeon menu
jQuery.fn.accordeonMenu = function () {
    var menu = $(this);
    $('> li > a:not(.active) ~ .sub', menu).hide();
    var items = $('> li > a', menu).click(function () {
        items.removeClass('active');
        $(this).addClass('active').siblings('.sub').slideDown('normal');
        items.not('.active').siblings('.sub').slideUp('normal');
    });
    return menu;
};//eof accordeonMenu

jQuery.fn.digitsOnly = function () {
    var $this = $(this);
    $this.keypress(function (e) {
        // allow digits only
        if (e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) {
            return false;
        }
    });
    return $this;
};

$(document).ready(function () {
    $('#accordion').accordeonMenu();        

    $('a.menu_item').click(function () {
        $.cookie('selected_path', $(this).attr('__path'), {path: '/'});
    });

});
