// JavaScript Document - John Kirkwood - jkirkwood@kclinfo.com
// Many thanks to Peter-Paul Koch http://www.quirksmode.org
// and Thomas A Powell - The Complete Reference Web Design 2nd edition

// DHTML micro-API from http://www.quirksmode.org
function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
  return this;
}

// Check if the frameset is displayed and, if not, display the frameset with correct content page
// Needs 'fixFrame()' in the frameset page
// Called as <body onload="checkFrame()"> or by 'window.onload=checkFrame;'
// Adapted from http://www.quirksmode.org to handle subdirectories
function checkFrame()
{
	if ((top != self.parent) || (top == self)) {
		top.location.replace(self.location.href.substring(0, self.location.href.indexOf(self.location.pathname)) + '/index.htm?' + escape(self.location.pathname));
	}
}

// Function to assign the right source page in the content frame of the frameset
// Look for a pagename in the URL after the '?', passed from the inner page by checkframe()
// Called as <frameset onload="fixFrame()" ... >
// John Kirkwood (adapted from http://www.quirksmode.org)
function fixFrame(framename)
{
	var innerpage = (location.href.indexOf("?") + 1);
	// if a pagename is being passed in with '?pagename.htm' then use it
	if (innerpage) {
		getObj(framename).obj.src = unescape(location.href.substring(innerpage));
	}
}

window.onload = checkFrame;