/**************************************************
 *
 *	NK_framework, contain some usefull functions for me.
 *
 *	@author    Neck - http://www.eikylon.net
 *	@version   1.0.0
 *	@licence   available under the Creative Commons Attribution 3.0 Unported - http://creativecommons.org/licenses/by/3.0/
 *	           WITHOUT ANY WARRANTY, use it "at your own risks"
 *	@created   december 2007
 *
 **************************************************/
NK_framework = {
	/**
	 * Framework version
	 *
	 * @var float
	 */
	version : 1.0,
	/**
	 * True if a class has been added if JS is active
	 *
	 * @var bool
	 */
	JSClass : false,

	/**
	 * Add the class .hasJS to <html>. Can be used BEFOR onload(),
	 * allows you to hide elements if javascript is active for example.
	 * Originally saw: http://forum.alsacreations.com/topic-5-31123-1-Feuille-CSS-seulement-si-javascript-desactive.html
	 *
	 */
	addJSClass : function() {
		if(this.JSClass) return;

		document.documentElement.className+=" hasJS";
		this.JSClass = true;
	},

	/**
	 * Emulate the GET variables.
	 *
	 * @param string the file you want get vars for
	 * @return array associative array with name=>value
	 */
	pseudoGet : function(fileName) {
		if (!document.getElementById) return;

		// loop through all script tag looking for our file
		var s;
		var scriptTags = document.getElementsByTagName('script');
		for (var i = 0; i < scriptTags.length; i ++) {
			s = scriptTags[i];

			// if we got a correct one extract vars
			if(s.src && s.src.toLowerCase().match(fileName.toLowerCase()+'\\.js\\?')) {
				var v = s.src.toLowerCase().match(fileName.toLowerCase()+'\\.js\\?(.*)$');
				v = v[1].split('&');

				// make array and return it
				var r = new Array();
				for(var j=0; j < v.length; j++) {
					v[j] = v[j].split('=');
					if(v[j].length == 2) {
						r[v[j][0].toLowerCase()] = v[j][1];
					}
				}
				return r;
			}
		}
	}
}