// JavaScript Document

function parseResponse(data){
	try{
		var response=$.parseJSON(data);
		if(response.status<0){
				
				var dialog = $('<div style="display:none"></div>').appendTo('body');
				
				dialog.load(
					'/html/errorDialog.html', 
					{},
					function (responseText, textStatus, XMLHttpRequest) {
						$('#errorMessage',dialog).html(response.message);
						$('#dialog-error',dialog).dialog({show: "fade",
														 modal: true,
														 resizable: false,
														 draggable: false,
														 close: function(){
															 /*if(response.status==SESSION_EXPIRED){
																window.location="loginForm.php";
															}*/
														 }
														 });
					}
				);
				return false;
				}
				else{
					return response;
				}

	}
	catch(exception){
				var dialog = $('<div style="display:none"></div>').appendTo('body');
				
				dialog.load(
					'/html/errorDialog.html', 
					{},
					function (responseText, textStatus, XMLHttpRequest) {
						$('#dialog-error',dialog).dialog({show: "fade",
														 modal: true,
														 resizable: false,
														 draggable: false
														 });
					}
				);
				return false;
	}
	
}
