//setup base tag
var isPfv = queryString('pfv');
if (isPfv == '1')
{
  var pfvUrl = queryString('url');
  document.write('<base href="' + window.location.protocol + '//' + window.location.host.toLowerCase() + pfvUrl + '" />');
//document.write( window.location.protocol + '//' + window.location.host.toLowerCase() + pfvUrl);
}

function openPfvWindow(relativePath)
{

  var pfvPath = relativePath + 'printerfriendly.aspx?pfv=1&url=' + escape(window.location.pathname.toLowerCase());
//alert(pfvPath);
  popupWindow = window.open(pfvPath,'remote','resizable,scrollbars,left=50,top=50,width=700,height=350,');
}

function PageQueryString(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
  for(var i=0; i < this.q.split("&").length; i++) {
  this.keyValuePairs[i] = this.q.split("&")[i];
  }
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getQueryStringValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
  if(this.keyValuePairs[j].split("=")[0].toLowerCase() == s.toLowerCase())
  return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getQueryStringParameters = function() {
var a = new Array(this.getQueryStringLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
  a[j] = this.keyValuePairs[j].split("=")[0];
  }
return a;
}
this.getQueryStringLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
var page = new PageQueryString(window.location.search); 
return unescape(page.getQueryStringValue(key)); 
}

function displayItem(key){
if(queryString(key)=='false') 
{
  document.write("you didn't enter a ?name=value querystring item.");
}else{
  document.write(queryString(key));
  }
}
