
Utils.alertBox = function(title, message, icon, width, height, callBack) {
	
	Ext.MessageBox.show({
		title: title,
		msg: message,
		icon: (icon != null) ? icon : Ext.MessageBox.WARNING,
		buttons: Ext.MessageBox.OK,
		width: (width != null) ? width : 255,
		height: (height != null) ? height : 120,
		autoWidth: (width != null) ? false : true,
		autoHeight: (height != null) ? false : true,
		fn: (callBack != null && typeof(callBack) == "function") ? callBack : null
	});
	
}

Utils.warn = function(message) {
	
	Utils.alertBox("iData", message);	
}

Utils.info = function(message) {
	
	Utils.alertBox("iData", message, Ext.MessageBox.INFO);
	
}

Utils.handleError = function(errorMessage, callBack) {
	
	Utils.alertBox("Error", errorMessage, Ext.MessageBox.ERROR, null, null, callBack);
	
	
}



Utils.checkError = function(response) {
	
	// Check for HTTP-level error.
	if (response.status != 200) {
		return "HTTP error " + response.status + " - " + response.statusText;
	}
    
	// Check for application-level error.
	try {
		var errors = response.responseXML.getElementsByTagName("error");
	}
	catch(e) {
		return ""
	}
	
	var errId;
	try {
		errId = errors[0].getElementsByTagName("id")[0].childNodes[0].nodeValue;
	}
	catch(e) {
		errId = "";
	}
	
	var errLvl1Text;
	try {
		errLvl1Text = errors[0].getElementsByTagName("lvl1text")[0].childNodes[0].nodeValue;
	}
	catch(e) {
		errLvl1Text = "";
	}
	
	var errLvl2Text;
	try {
		errLvl2Text = errors[0].getElementsByTagName("lvl2text")[0].childNodes[0].nodeValue;
	}
	catch(e) {
		errLvl2Text = "";
	}

	return errLvl1Text;      
	
}
