//------------------------------------------------------------------------------
// This code is called by index.htm.  It is used to create the frame structure.
//------------------------------------------------------------------------------

if (self.name == 'menu') {
	// Sometimes, Netscape will try to load this index inside the menu frame.  I haven't
	// worked out why but this will detect that situation and reset the location property.
	self.location.href = "welcome.htm";
} else {
	var thePage = pageFromSearch('welcome.htm');
	var width = '277';

	self.document.writeln('<frameset cols="100%" rows="57,30,*,62" border="1" frameborder="0" framespacing="4">');
	self.document.writeln('');
 	self.document.writeln('<frameset cols="450,*" rows="100%" border="1" frameborder="0" framespacing="4">');
 	self.document.writeln(' <frame name="title"  src="title.htm"     scrolling="no" frameborder="0" marginwidth="0" marginheight="0" APPLICATION="yes">');
 	self.document.writeln(' <frame name="search" src="reSearchSuite-SearchForm/searchin.htm" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" APPLICATION="yes">');
 	self.document.writeln('</frameset>');
	self.document.writeln('');
	self.document.writeln(' <frame name="toolbar" src="toolbar.htm" scrolling="no">');
	self.document.writeln('');
	self.document.writeln(' <frameset cols="' + width + ',*" rows="100%">');
	self.document.writeln('  <frame name="menu" src="menu.htm" scrolling="auto" frameborder="0" marginwidth="1" marginheight="1" APPLICATION="yes">');
	self.document.writeln('  <frame name="text" src="' + thePage + '" scrolling="auto" frameborder="0" APPLICATION="yes">');
	self.document.writeln(' </frameset>');
	self.document.writeln('');
	self.document.writeln(' <frameset cols="' + width + ',*" rows="100%">');
 	self.document.writeln(' <frame name="menuCntrl" src="menucntrl.htm" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" APPLICATION="yes">');
 	self.document.writeln(' <frame name="copyright" src="copyright.htm" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" APPLICATION="yes">');
	self.document.writeln(' </frameset>');
	self.document.writeln('');
	self.document.writeln('</frameset>');
}

// From Joust
function pageFromSearch(def) {
	var s = self.location.search;
	if ((s == null) || (s.length <= 1)) {return def;}
	var p = getParm(s, 'page', '&');
	p = (p != '') ? fixPath(p) : def;

	//alert(p);
	return p;
}

function getParm(theStr, parm, delim) {
	// returns value of parm from string
	if (theStr.length == 0) {return '';}
	var sPos = theStr.indexOf(parm + "=");
	if (sPos == -1) {return '';}
	sPos = sPos + parm.length + 1;
	var ePos = theStr.indexOf(delim, sPos);
	if (ePos == -1) {ePos = theStr.length;}
	return unescape(theStr.substring(sPos, ePos));
}

function fixPath(p) {
	var i = p.indexOf('?', 0);
	if (i >= 0) {p = p.substring(0,i);}
	if (p.substring(0,2) == '/:') {p = p.substring(p.indexOf('/', 2), p.length);}
	i = p.indexOf('\\', 0);
	while (i >= 0) {
		p = p.substring(0,i) + '/' + p.substring(i+1,p.length);
		i = p.indexOf('\\', i);
	}
	return p;
}
