var ezjs = 
{
    /**
     * Récupère un settings .ini
     * @param blockName String Nom du bloc de settings (ne peut pas contenir le caractère '/')
     * @param varName String Nom de la variable de settings (ne peut pas contenir le caractère '/')
     * @param fileName String Nom du fichier de settings, si non précisé, il s'agit de site.ini (ne peut pas contenir le caractère '/')
     * @param baseURL String Base de l'url eZPublish, utilisé pour construire la requête
     * @return Object Renvoie un objet un une chaine correspondant au settings
     */
    ini: function( blockName, varName, fileName, baseURL )
    {
	var url = '';
	if( ( baseURL !== undefined ) && ( baseURL != '/' ) )
	{
	     url = url.concat( baseURL );
	}
	
	url = url.concat( '/xhr/ini' );
	
	if( blockName !== undefined )
	{
	    url = url.concat( '/' ).concat( encodeURIComponent( blockName ) );
	    if( varName !== undefined )
	    {
		url = url.concat( '/' ).concat( encodeURIComponent( varName ) );
		if( fileName !== undefined )
		{
		    url = url.concat( '/' ).concat( encodeURIComponent( fileName ) );
		}
	    }
	}

	var xhrArgs = {	url: url ,
			handleAs: 'json',
			preventCache: true,
			sync: true,
			headers: {  'Content-Type': 'application/json',
				    'Content-Encoding': 'utf-8'
				    }
			};
			
	return dojo.xhrGet( xhrArgs ).results[0];
    },

    /**
     * Accède à une traduction eZ Publish
     * @param context String Précise le contexte de la source (ne peut pas contenir le caractère '-' )
     * @param source String Le texte à traduire (ne peut pas contenir le caractère '/')
     * @param comments String Un commentaire à l'intention du traducteur (ne peut pas contenir '/')
     * @param parameters Object Un objet spécifiant les paramètres de traduction (ne peut pas contenir le caractère '/')
     * @param baseURL String Base de l'url eZPublish, utilisé pour construire la requête
     * @return String Le texte traduit
     */
    i18n: function( context, source, comments, parameters, baseURL )
    {
	var url = '';
	if( ( baseURL !== undefined ) && ( baseURL != '/' ) )
	{
	     url = url.concat( baseURL );
	}
	
	url = url.concat( '/xhr/i18n' );
	
	if( context !== undefined )
	{
	    url = url.concat( '/' ).concat( encodeURIComponent( context.replace(/\//g, '-') ) );
	    if( source !== undefined )
	    {
		url = url.concat( '/' ).concat( encodeURIComponent( source ) );
		if( comments !== undefined )
		{
		    url = url.concat( '/' ).concat( encodeURIComponent( comments ) );
		    if( parameters !== undefined )
		    {
			url = url.concat( '/' ).concat( encodeURIComponent( dojo.toJson( parameters ) ) );
		    }
		}
	    }
	}

	var xhrArgs = {	url: url,
			handleAs: 'text',
			preventCache: true,
			sync: true,
			headers: {  'Content-Type': 'text/plain',
				    'Content-Encoding': 'utf-8'
				    }
			};

	return dojo.xhrGet( xhrArgs ).results[0];
    }
};

// EXAMPLES

//console.log( ezjs.ini( 'GMapControls', 'Controls', 'gmap.ini' ) );
//console.log( ezjs.i18n( 'opievoy/gmap', 'This is %a test, and it is %b', 'mycomments', { '%a': 'efficace', '%b': 'fonctionnel' }, 'index.php?' ) );
