function Trim(s)
{
  if (s==null) return null;
  var r = s;
  while (r.length>0 && (r.charAt(0)==' '||r.charAt(0)=='\r'||r.charAt(0)=='\n'||r.charAt(0)=='\t')) {
    r = r.substring(1, r.length);
  }
  while (r.length>0 && (r.charAt(r.length-1)==' '||r.charAt(r.length-1)=='\r'||r.charAt(r.length-1)=='\n'||r.charAt(r.length-1)=='\t')) {
    r = r.substring(0, r.length-1);
  }
  return r;
}
function UrlParams()
{
  this.hash = new Array();
  this.length = 0;
  this.UrlParamsGetParam = UrlParamsGetParam;
  this.UrlParamsGetParamNames = UrlParamsGetParamNames;
  this.UrlParamsLength = UrlParamsLength;
  this.isHttps = isHttps;
  
  var url = window.location.href;
  var pos3, pos2, pos1 = url.indexOf("?");
  if (pos1==-1) return null;
  do {
    pos2 = url.indexOf("=", pos1 + 1);
    if (pos2!=-1) {
      pos3 = url.indexOf("&", pos2 + 1);
      if (pos3!=-1) {
        this.hash[Trim(url.substring(pos1 + 1, pos2))] = unescape(Trim(url.substring(pos2 + 1, pos3)));
        this.length++;
        pos1 = pos3;
      } else {
        this.hash[Trim(url.substring(pos1 + 1, pos2))] = unescape(Trim(url.substr(pos2 + 1)));
        this.length++;
        break;
      }
    } else {
      break;
    }
  } while(true);
  return this;
}
function UrlParamsGetParam(name)
{
  return this.hash[name];
}
function UrlParamsLength()
{
  return this.length;
}
function UrlParamsGetParamNames()
{
  var names = new Array();
  for (var i in this.hash) {
    names[names.length] = i;
  }
  return names;
}
function isHttps() 
{
  var url = new String(window.location.href);
  return url.indexOf("https:")!=-1;
}


