var core = new Object();

/*
 * Notificações
 */
core.notify_success = function(message, timeout, element)
{
    core.__notify(message, timeout, element, "notif-success");
}
core.notify_error = function(message, timeout, element)
{
    core.__notify(message, timeout, element, "notif-error")
}
core.unnotify = function(element) {
    if (!element)
        var element = $('#notif-success, #notif-error');
    element.hide();
}

core.__notify = function(message, timeout, element, object_id) 
{
    if (!element)
        var element = $('#' + object_id);
    
    element.html(message).show();
    
    if (timeout) {
        setTimeout(function(){ element.hide() }, timeout * 1000);
    }    
}


/*
 * Parse dos parâmetros GET, retornando um objeto
 */
core.parse_GET = function() {
    var obj = {};
    var data = location.search.replace('?','').split('&')
    for (var i=0; i<data.length; i++) {
    	obj[ data[i].split('=')[0] ] = data[i].split('=')[1];
    }
    return obj;
}

/*
 * Retorna um objeto com todos os dados de um formulário, passado como parâmetro.
 */
core.form_data = function(form) {
    var data = form.find("input[checked], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], option[selected], textarea");
    var params = {};
    data.each(function() {
        params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
    });
    return params;
}