//---------------------------------------------------------------------------------
//	class queryString
//---------------------------------------------------------------------------------
//	Description: 	This class function will parse out all querystring
//                vars and data making them available using the below methods.
// Parameter 1:	NONE
// Methods:       initialize() - Private, called on class instatiation
//                get(strKey) -  Public, Returns value for key matching strkey
//                               NOT case sensitive, returns(null) if not found
//                item(index) -  Public, Returns the value for key(index)
//                               returns(null) if not found
//                print()     -  Public, alerts all querystring data, debugging            
//---------------------------------------------------------------------------------
function clsQueryString()
{
   this.keys = new Array();
   this.values = new Array();
   this.url = ""; 
   this.file = "";
   
   this.initialize = function()
   {
      //Get QS vars
		query = window.location.search.substring(1);
		pairs = query.split("&");
		
		for(i=0;i<pairs.length;i++)
		{
			pos = pairs[i].indexOf('=');
			if(pos >= 0)
			{
				argname = pairs[i].substring(0,pos);
				value = pairs[i].substring(pos+1);
				this.keys[this.keys.length] = argname;
				this.values[this.values.length] = value;		
			}
		}
      
      //Get full URL
      strURL = new String(window.location);
	   pos = strURL.indexOf('?');
      if(pos == -1)
      {
         pos = strURL.length;
      }
      strURL = strURL.substring(0, pos);
      this.url = strURL;
      
      //Get file name xxxx.asp
      pos = strURL.lastIndexOf('/');
      if(strURL.lastIndexOf('.') > 0)
      {
         this.file = strURL.substring(pos+1);
      }
      return;
   };
   	
	this.get = function(strKey)
	{
		strKey = strKey.toLowerCase();
		for(c1=0;c1<this.keys.length;c1++)
		{
			if(this.keys[c1].toLowerCase() == strKey)
			{
				return this.values[c1];
			}
		}
		return(null);
	};
   
   this.item = function(index)
   {
      if(isNaN(parseInt(index))){return(null);}//make sure its a number
      if(index > this.values.length){return(null);}//check for rays index      
      return(this.values[index]);
   };
   
   this.print = function()
   {
      s = "QueryString Data\r\n";
      for(c2=0;c2<this.values.length;c2++)
      {
         s += this.keys[c2] + " = " + this.values[c2] + "\r\n";
      }
      alert(s);
      return;
   };
   
   this.initialize();
}//end class
