function QueryString(key){
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)	{
		if (QueryString.keys[i]==key)		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse(){
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i=0;i<pairs.length;i++)	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;		
		}
	}
}
QueryString_Parse();

/* Constructor: wmdUrlParts()
** Use:
**   var myUrlParts = new url( urlStr );
**   var hostname = myUrlParts.hostname;
** Properties:
**   is_valid   boolean (true = valid)
**   url        entire URL fed to constructor
**   scheme     http, ftp, mailto, etc.
**   login      web site login name
**   password   web site password for login
**   hostname   hostname/DNS name, e.g. "my.webmd.com"
**   port       TCP port, e.g. 443 for HTTPS
**   filepath   directory plus filename, e.g. 
"/content/page/12/1234_3422.htm"
**   query      query string, e.g. "?a=1&b=2&c=3"
**   fragment   page fragment, e.g. href="#section1"
*/
function wmdUrlParts ( urlStr )
{
  this.url       = "";
  this.scheme    = "";
  this.nonscheme = "";
  this.filepath  = "";
  this.query     = "";
  this.fragment  = "";
  this.authority = "";
  this.login     = "";
  this.password  = "";
  this.hostname  = "";
  this.port      = "";
  var valid1  = false;
  var valid2  = true;
  reUrl = /^\s*((([-+.\w\d]+):)?((\/\/([^?\/]*))?([^?#:]+)?(\?([^#\s]*))?(#([^\s]*))?)\s*)$/;
  var res = reUrl.exec( urlStr );
  if ( res )
  {
    valid1  = true;
    this.url       = ( res[1])?res[1]:"";
    this.scheme    = ( res[3] )?res[3]:"";
    this.nonscheme = ( res[4] )?res[4]:"";
    this.filepath  = ( res[7] )?res[7]:"";
    this.query     = ( res[9] )?res[9]:"";
    this.fragment  = ( res[11])?res[11]:"";
    this.authority = ( res[5] )?res[5]:"";
    if ( res[5] )
    {
      var reAuth = /^\/\/(([-_.!~*'();&%=+$,\d\w]+)(:([-_.!~*'();:&%=+$,\d\w]+))?@)?(([-\w\d]+\.)*([\w][-\w\d]*\.?)|\d+\.\d+\.\d+\.\d+)(:(\d+))?$/;
      resAuth = reAuth.exec( res[5] );
      if ( resAuth )
      {
        this.login    = ( resAuth[2] )?resAuth[2]:"";
        this.password = ( resAuth[4] )?resAuth[4]:"";
        this.hostname = ( resAuth[5] )?resAuth[5]:"";
        this.port     = ( resAuth[9] )?resAuth[9]:"";
      }
      else { valid2 = false; }
    }
  }
  this.is_valid = ( valid1 && valid2 );
}