 var ok = (top.frames.length > 0);
 if (!ok)
 {
	 var p = location.pathname.indexOf("/content/");
	 if (p >= 0)
	 {
 		var page = location.pathname.substring(p + 9);
 		var i = 1;
 		var s = page;
 		p = s.indexOf("/");
 		while (p > 0)
 		{
 			i++;
 			s = s.substring(p+1);
 			p = s.indexOf("/");
 		}
 		s = "";
 		while (i > 0)
 		{
 			s += "../";
			i--;
 		}
 		window.location.replace(s + 'index.php?page=' + page);
	}
	else
	{
		var page = location.pathname.substring(1);
 		var i = 1;
 		p = page.indexOf("/");
 		while (p > 0)
 		{
 			i++;
 			page = page.substring(p+1);
 			p = page.indexOf("/");
 		}
		window.location.replace('index.php?page=../' + page);
	}
 }
 
window.onscroll = function()
{
  if (typeof top.window.pageYOffset != 'undefined')
  {
    if (top.window.pageYOffset > 0) top.window.scrollTo(0,0);
  }
  else if (typeof top.window.document.documentElement.scrollTop != 'undefined' && top.window.document.documentElement.scrollTop > 0)
  {
		if (top.window.document.documentElement.scrollTop > 0) top.window.scrollTo(0,0);
  }
  else if (typeof top.window.document.body.scrollTop != 'undefined')
  {
    if (top.window.document.body.scrollTop > 0) top.window.scrollTo(0,0);
  }
}
 
function trim(value) {
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}

function goto(h)
{
  top.goto(h);
}

function gotoTab(nr)
{
  document.getElementById('div1').style.display = (nr == 1 ? "" : "none")
  document.getElementById('div2').style.display = (nr == 2 ? "" : "none")
  
  document.getElementById('tab1').setAttribute("class", (nr == 1 ? "sel" : "unsel"));
  document.getElementById('tab2').setAttribute("class", (nr == 2 ? "sel" : "unsel"));
  
  document.getElementById('tab1').setAttribute("className", (nr == 1 ? "sel" : "unsel"));
  document.getElementById('tab2').setAttribute("className", (nr == 2 ? "sel" : "unsel"));
}

function gotoCal(nr)
{
  document.getElementById('div1').style.display = (nr == 1 ? "" : "none")
  document.getElementById('div2').style.display = (nr == 2 ? "" : "none")
  document.getElementById('div3').style.display = (nr == 3 ? "" : "none")
  
  document.getElementById('tab1').setAttribute("class", (nr == 1 ? "sel" : "unsel"));
  document.getElementById('tab2').setAttribute("class", (nr == 2 ? "sel" : "unsel"));
  document.getElementById('tab3').setAttribute("class", (nr == 3 ? "sel" : "unsel"));
  
  document.getElementById('tab1').setAttribute("className", (nr == 1 ? "sel" : "unsel"));
  document.getElementById('tab2').setAttribute("className", (nr == 2 ? "sel" : "unsel"));
  document.getElementById('tab3').setAttribute("className", (nr == 3 ? "sel" : "unsel"));
}

function PageQuery(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.getValue = function(s)
  {
		for(var j=0; j < this.keyValuePairs.length; j++)
		{
			if(this.keyValuePairs[j].split("=")[0] == s) return this.keyValuePairs[j].split("=")[1];
		}
		return '';
	}
	
  this.getParameters = function()
  {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++)
		{
  	  a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}

  this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key)
{
  var page = new PageQuery(window.location.search); 
  return unescape(page.getValue(key)); 
}

function displayItem(key)
{
	if(queryString(key)=='') 
	{
		document.write("you didn't enter a ?name=value querystring item.");
	}
	else
	{
		document.write(queryString(key));
	}
}

function check4Enter(e)
{
 var cc;
 if(e && e.which)
 {
  cc = e.which;
 }
 else
 {
  e = event;
  cc = e.keyCode;
 }

 if(cc == 13)
 {
  document.forms[0].submit();
  return false;
 }
 else return true;
}
