var baseUrl ='/joy';

Ext.BLANK_IMAGE_URL = '/joy/img/extjs/default/s.gif';

Ext.UpdateManager.defaults.loadScripts = true;
Ext.QuickTips.init();
 
Ext.form.Field.prototype.msgTarget = 'under';

function debug(variable) {
	console.log(variable);
}


Ext.Ajax.on('requestexception', function(conn,response) {
	switch(response.status){
		case 401:
			window.document.location=baseUrl+'/admin/login';

/*			
			Ext.Msg.show({
			   title:'',
			   msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
			   buttons: Ext.Msg.YESNOCANCEL,
			   fn: processResult,
			   animEl: 'elId',
			   icon: Ext.MessageBox.QUESTION
			});			
	*/		
			
			//Ext.MessageBox.alert(_('system_message'), _('your_session_has_expired'));
			break;
		case 403:
			Ext.MessageBox.alert(_('system_message'), _('permission_denied'));
			break;
		default:
			alert('Server error');
			break;
	}
});
//Ext.Ajax.on('requestcomplete', function(response) {alert('ok'); } );

/*
window.onbeforeunload = function() { 
	return _('backbutton_message');
  }; 
*/



function _(str, section) {

	if (typeof(localisation)=="undefined"){ 
		
	} else {
		if (section){
			if (localisation[section][str]){ str = localisation[section][str]; return str;} 
		}
		if (localisation[str]){str = localisation[str]};
	}
	return str;
}




String.prototype.ucFirst = function() {
	return this.charAt(0).toUpperCase() + this.substring(1);
}


