function CreateRequest(url){
		return new Request(url);
	}
	
	//Based on http://blog.strictly-software.com/2008/10/using-javascript-to-parse-querystring.html
	function Request(qry){

		this.ParamValues = {};
		
		this.CurrentQuery='';
		this.AnchorValue = "";
		this.BaseUrl='';

		//if no querystring passed to constructor default to current location
		if(qry && qry.length>0){
			this.CurrentQuery = qry;
		}else{
			if(location.search.length>0){
				this.CurrentQuery = location.href;
			}else{
				this.CurrentQuery = "";
			}
		}

		this.RemoveIfLastChar = function(str, lastchar){
			if(str==null) return '';
			if(str.length<2) return '';
			var c = str.substring(str.length-1,str.length);
			if( c==lastchar){
				return str.substring(0, str.length-1);
			}else{
				return str;
			}
		}
		
		//returns url without parameters
		this.getBase = function(){
			if(this.CurrentQuery==null) return '';
			var i = this.CurrentQuery.indexOf('?');						
			var ret='';
			if(i<0){
				ret=this.CurrentQuery; //no parameters, return url as is
			}else{
				ret = this.CurrentQuery.substring(0,i)
			}
			//remove any garbage at the end			
			ret = this.RemoveIfLastChar(ret, '&');			
			ret = this.RemoveIfLastChar(ret, '/');
			
			return ret;			
		}
		
		//may want to parse a query that is not the current window.location
		this.ParseQuery = function(qry){ 
			var rex = /[?&]([^=]+)(?:=([^&#]*))?/g;
			var rexa = /(\#.*$)/;
			var qmatch, key, amatch;

			//parse querystring storing key/values in the ParamValues associative array
			while(qmatch = rex.exec(qry)){
				key = decodeURIComponent(qmatch[1]);//get decoded key
				val = decodeURIComponent(qmatch[2]);//get decoded value

				if(this.ParamValues[key]){ //if we already have this key then update it if it has a value
					if(key&&key!="") this.ParamValues[key] = this.ParamValues[key] + ","+val;
				}else{
					this.ParamValues[key] = val;					
				}
			}
			
			//store anchor value if there is one
			amatch = rexa.exec( qry );
			if(amatch) this.AnchorValue = amatch[0].replace("#","");
			
			this.BaseUrl = this.getBase();
		}

		//run function to parse querystring and store array of key/values and any anchor tag
		if(this.CurrentQuery.length){
			this.ParseQuery( this.CurrentQuery );
		} 

		this.GetValue = function(key){ if(!this.ParamValues[key]) return ""; return this.ParamValues[key]; }
		this.GetAnchor = this.AnchorValue;	

		this.SetValue = function(key,val){
			this.ParamValues[key]=val;
		}
		
		this.SetBase = function(s){
			this.BaseUrl = s;
		}
		
		this.GetBase = function(){
			return this.BaseUrl;
		}
				
		//returns full url, including parameters
		this.ToString = function(){
			var s=this.GetBase();
			var i=0;
			for(var key in this.ParamValues){
				if(i==0){
					s+='?';
				}else{
					s+='&';
				}
				i++;
				s+=key+'='+this.ParamValues[key];
			}			
			return s;
		}
		
		this.GetParameters = function(){
			return this.ParamValues;
		}
		
	}

