function dims() {
  if (window.innerHeight)                                                         
  /* NN4 a kompatibilní prohlížeče */
    return new Array(window.innerWidth, window.innerHeight);
  else if (document.documentElement && document.documentElement.clientHeight)     
  /* MSIE6 v std. režimu - Opera a Mozilla již uspěly s window.innerHeight */
    return new Array(document.documentElement.clientWidth, document.documentElement.clientHeight);
  else if (document.body && document.body.clientHeight)                           
  /* starší MSIE + MSIE6 v quirk režimu */
    return new Array(document.body.clientWidth, document.body.clientHeight);
  else
    return null;
} 
  
function centerDiv(divid, divWidth)
{
  var d = dims();
  if (d != null)
  {
    var container = document.getElementById(divid);
    var rest = (d[0]-divWidth)/2; 
    container.style.marginLeft = rest+"px";
    container.style.marginRight = "auto";
  }
}

function rand(max)    { return Math.floor(Math.random() * (max + 1)); }

/*********************************************************************************************************/
/*******                      QUERY STRING PARSING                                                  ******/
/*******                      http://www.eggheadcafe.com/articles/20020107.asp                      ******/
/*********************************************************************************************************/

function PageQuery(q) {
  if(q.length > 1) 
    this.q = q.substring(1, q.length);
  else 
    this.q = null;
    
  this.keyValuePairs = new Array();
  if(q) {
    qsplit = this.q.split("&");
    for(i=0; i < qsplit.length; i++) {
			kv = qsplit[i].split("=");
      this.keyValuePairs[i] = { paramName : kv[0], paramValue: kv[1] };
    }
  }
  
  this.getKeyValuePairs = function() { return this.keyValuePairs; }
  
  this.getValue = function(s) {
    for(j=0; j < this.keyValuePairs.length; j++) {
      if(this.keyValuePairs[j].paramName == s)
        return this.keyValuePairs[j].paramValue;
    }
    return false;
  }
  this.contains = function(s) {
    for(j=0; j < this.keyValuePairs.length; j++) {
      if(this.keyValuePairs[j].paramName == s)
        return true;
    }
    return false;
  }
  
  this.getParameters = function() {
    var a = new Array(this.getLength());
    for(j=0; j < this.keyValuePairs.length; j++) {
      a[j] = this.keyValuePairs[j].paramName;
    }
    return a;
  }
  
  this.getLength = function() { return this.keyValuePairs.length; } 
  this.isEmpty   = function() { return this.q == null; }
}

function queryString(key){
  var page = new PageQuery(window.location.search); 
  return unescape(page.getValue(key)); 
}

function DEBUG_displayItem(key){
  if(queryString(key)=='false') {
    document.write("you didn't enter a ?name=value querystring item.");
  }else{
    document.write(queryString(key));
  }
}
