function onAjaxError(XMLHttpRequest, textStatus, exception) 
{	
	var errortext = XMLHttpRequest.responseText;
	if (typeof exception != "undefined") {
		errortext += exception.message ? exception.message : exception;
		errortext += "\n" + _getStackTrace(exception);
	}
 	if (errortext.length > 0) alert("Ajax failure\n" + errortext);
}
function ajax( url, parameter, onSuccess, dataType, method)  {
	$.ajax({
		url: url,
		type: method || 'POST',
		dataType: dataType || "html",
		data: parameter ,
		success: onSuccess,
		error: onAjaxError,
		async: true
	});
}
function message ( type, message) {    
	$('#msg').html("<div class=\"notification  "+type+"  \">"+message+"</div>"); 
	
}

/* Clear all elements of a from */
function clear_form_elements(form) {

    $(form).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });

}
