/* This version of JavaScript Query_String can be used by anyone who is not intented
to do profit directly with this code, it means you can not sale the code as is, 
you can use it ont your web or php project, or put in a CD Magazine, if you really
do profit with your project and my code consider sharing them :P.
If you want to include the Query_String in some web editor, do not remove this legend.
The lastest version can be found at
http://www.compunauta.com/forums/linux/programacion/java/gus_query_string.html

This is Open and Free Software, madgus@gmail.com, gustavo@compunauta.com
*/

var QUERY=new Object();

function getQueryString(){
var RE = new RegExp('\\+','gi');
var QUERY_STRING=document.location+"";
QUERY_STRING=QUERY_STRING.replace(RE," ");
var QUERY_KEY="VERSION";
var QUERY_DES="2006_madgus@gmail.com";
QUERY[QUERY_KEY]=QUERY_DES;
var vpos;
pos=QUERY_STRING.indexOf("#");
	//if marker enable, remove from string
	if(pos != -1){
	QUERY_STRING=QUERY_STRING.substring(0,pos);
	}
pos=QUERY_STRING.indexOf("?");
	if (pos != -1){
	QUERY_STRING=QUERY_STRING.substring(pos+1,QUERY_STRING.length);
	while ((pos = QUERY_STRING.indexOf("&"))!=-1){
		QUERY_KEY=QUERY_STRING.substring(0,pos);
		QUERY_STRING=QUERY_STRING.substring(pos+1,QUERY_STRING.length);
		addQuery(QUERY_KEY);
	}
	if (QUERY_STRING.length!=0){
	addQuery(QUERY_STRING);
	}
	}else{return;}
}

function addQuery(QUERY_KEY){
//this query key is a substring having whole key=escape(val);
		vpos=QUERY_KEY.indexOf("=");
		if(vpos!=-1){
		QUERY_DES=unescape(QUERY_KEY.substring(vpos+1,QUERY_KEY.length));
		QUERY_KEY=QUERY_KEY.substring(0,vpos);
		QUERY[QUERY_KEY]=QUERY_DES;
		}else{
		QUERY_DES="";
		QUERY[QUERY_KEY]=QUERY_DES;
		}
}

function getQuery(QUERY_KEY){
if (QUERY_KEY==""){return "";}
if(QUERY[QUERY_KEY]!=undefined){
return QUERY[QUERY_KEY];
}else {return "";}
}
