
Utils = {}

Utils.email = function(name, email, message, options) {
    if (!options) options = {};
    
    jQuery.ajax(
        {
            type: "GET",
            url:  "scripts/ajax.php",
            data: { 
                q:          "email",
                name:       name,
                email:      email,
                message:    message,
                subject:    (options.subject ? options.subject : 'N-BRAIN Contact Form')
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                if (options.failure) {
                    options.failure(textStatus);
                }
                else {
                    alert(textStatus);
                }
            },
            success: function(data){
                if (data != 'true') {
                    if (options.failure) {
                        options.failure(data);
                    }
                    else {
                        alert(data);
                    }
                }
                else {
                    if (options.success) {
                        options.success(data);
                    }
                }
            }
        }
    );
}