/**
* Ce fichier fait parti d'un package, toute modification doit entrainer la génération
* d'un nouveau package pour être pris en compte.
* voir l'objet ObjFichierPackage pour connaitre la marche à suivre pour regénérer un package
*/

/**
 * @package framework
 * @subpackage benchmark
 * @filesource
 */

/**
 * Objet js permettant de parser une url
 *
 * new benchmark.framework.ihm.ObjToolTip('div_saisie','ceci est un tooltip',
 *	{
 *		color		: '#000000',
 *		opacity	: 50,
 *		timeout	: 3000
 *	}
 *	);
 *
 * @author Arnaud De Bock <debock@benchmark.fr>
 * @package framework
 * @subpackage html_include
 * @version 1.00
 * @since 29/06/09 création du fichier
 */

if(typeof benchmark == "undefined") var benchmark = new Object();
if (typeof benchmark.framework == "undefined") 			{ benchmark.framework = new Object();}
if (typeof benchmark.framework.util == 'undefined') 		{ benchmark.framework.util = new Object();}


/**
* constructeur :
* @return void
*/
benchmark.framework.util.url = function() {

	/**
	* url utilise, soit une passé en param soit celle de la page
	*/
	this.url = window.location.href;

	/**
	 * on stocke les parametres de la query string
	 */
	this.parametre = null;

	/**
	* initialisation
	* @param string qs l'url du parsing
	* @param object les options que l'on veut passer
	* @author Arnaud De Bock <debock@benchmark.fr>
	* @return void
	*/
	this.initialise = function(qs,options) {
		var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
		jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
			p = p.split('=');
			p[1] = o.f(p[1]);
			params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
		});
		this.parametre = params;
	};

	/**
	* permet de récupérer un paramètre
	* @param string nom_parametre le parametre dont on veut la valeur
	* @author Arnaud De Bock <debock@benchmark.fr>
	* @return string la valeur
	*/
	this.recupereParametre = function(nom_parametre){
		return eval("this.parametre."+nom_parametre);
	};

	/**
	 * permet de savoir si une chaine voulue est présente dans l'url
	 * @param string chaine_test la chaine que l'on veut dans l'url
	 * @author Arnaud De Bock <debock@benchmark.fr>
	 * @return boolean vrai ou faux suivant la réponse
	 */
	this.urlContient = function(chaine_test)
	{
		if(this.url.search(chaine_test) > -1)
			return true;
		else
			return false;
	}

	// on init l'objet
	this.initialise();
};