function openInParent(URL){
	opener.location.href = URL;
}

function openWin(URL,width,height,scroll,resize, status, menubar, toolbar, location, directories) {
	noUrl = false	
	if (URL == "" || URL == null) { URL="about:blank"; noUrl=true }
	if (width == "" || width == null ) { width = 640 }
	if (height == "" || height == null ) { height = 480 }
	if (scroll == "" || scroll == null ) { scroll = 1 }
	if (resize == "" || resize == null ) { resize = 1 }
	if (status == "" || status == null ) { status = 1 }
	if (menubar == "" || menubar == null) {menubar=0}
	if (toolbar == "" || toolbar == null) {toolbar=0}
	if (location == "" || location == null) {location=0}
	if (directories == "" || directories == null) {directories=0}
	
	PARMS = 'toolbar='+toolbar +',location='+location +',directories='+directories +',status='+status +',menubar='+menubar +',scrollbars=' + scroll + ',resizable=' + resize + ',width=' + width + ',height=' + height
  var newWin = window.open(URL,"NEW",PARMS)  
  
	if (noUrl) {
		newWin.document.writeln("<BR><BR><FONT color='red'>It seems like you forgot to put in a value for URL when you called for <I>openWin()</I></FONT>")
		newWin.document.close()
	}
	return newWin;
}

function openFullScreenWin(u) {
	var w = screen.availWidth * (100/100);
	var h = screen.availHeight * (100/100);
	var parms = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+',top=1,left=1';
	var windowname = 'fullscreenpop';
	
	window.open(u,windowname,parms);
}


function getCleanUrl() {
	URL = document.URL
	myParamStartPos = URL.indexOf("?",0)
	if(myParamStartPos>0){
		URL = document.URL.substr(0,myParamStartPos)
		return URL
	}
	else return URL
}

function getParam(name) 
{
	var param;
	var idxStart = document.URL.indexOf('?');
	
	if (idxStart >= 0) {
		// get the query string, prepend and append & to make searching easier
		idxStart += 1;
		var url = "&"+document.URL.substring(idxStart, document.URL.length)+"&";
		
		// found the param?
		idxStart = url.indexOf("&"+name+"=");
		if (idxStart >= 0) {
			idxStart += name.length+2;
			var idxEnd = url.indexOf("&", idxStart);
			
			param = url.substring(idxStart, idxEnd);
		} 
	}

	return param;
} // getParam(name)


function changeUrlParams(params){
	currentCleanUrl = getCleanUrl()
	newUrl = currentCleanUrl + "?" +params
	document.location = newUrl
}

function getServerInfo() {
 return document.location.host
 //alert(document.location.port)
}

// My DHTML micro-API, see http://www.xs4all.nl/~ppk/js/index.html?dhtmloptions.html

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 = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var thereturn;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	thereturn = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) thereturn = tmp;
	}
	return thereturn;
}

// End mini-API


function changeLayerZ(layer, zindex){
	var x = new getObj(layer);
	x.style.zindex = ! zindex;

}
 
function toggleVisibility(layer){
	var x = new getObj(layer);
	visAttr = x.style.visibility;
	if (visAttr == 'visible' ) { 
		x.style.visibility = 'hidden'; 
	} else {
		x.style.visibility = 'visible';
	}

}

// push and shift for IE5

function Array_push() {
	var A_p = 0
	for (A_p = 0; A_p < arguments.length; A_p++) {
		this[this.length] = arguments[A_p]
	}
	return this.length
}

if (typeof Array.prototype.push == "undefined") {
	Array.prototype.push = Array_push
}

function Array_shift() {
	var A_s = 0
	var response = this[0]
	for (A_s = 0; A_s < this.length-1; A_s++) {
		this[A_s] = this[A_s + 1]
	}
	this.length--
	return response
}

if (typeof Array.prototype.shift == "undefined") {
	Array.prototype.shift = Array_shift
}

function createTOC()
{
	//var x = document.body.childNodes;
	var x = document.getElementById("content").childNodes;
	var y = document.createElement('div');
	y.id = 'toc';
	var a = y.appendChild(document.createElement('span'));
	a.onclick = showhideTOC;
	a.innerHTML = 'Contents';
	var z = y.appendChild(document.createElement('div'));
	z.onclick = showhideTOC;
	
	var toBeTOCced = new Array();
	for (var i=0;i<x.length;i++) 
	{
		if (x[i].nodeName.indexOf('H') != -1) 
		{
			toBeTOCced.push(x[i]);
		}
	}

	if (toBeTOCced.length < 2) return;

	for (var i=0;i<toBeTOCced.length;i++) 
	{
		var tmp = document.createElement('a');
		tmp.innerHTML = toBeTOCced[i].innerHTML;
		tmp.href = '#link' + i;
		tmp.className = 'page';
		
		z.appendChild(tmp);
		
		if (toBeTOCced[i].nodeName == 'H4')
			tmp.className += ' indent';
		var tmp2 = document.createElement('a');
		tmp2.id = 'link' + i;
		if (toBeTOCced[i].nodeName == 'H2')
		{
			tmp.innerHTML = 'Top';
			tmp.href = '#top';
			tmp2.id = 'top';
		}
		
		toBeTOCced[i].parentNode.insertBefore(tmp2,toBeTOCced[i]);
	}
	document.body.insertBefore(y,document.body.childNodes[2]);
}

var TOCstate = 'none';

function showhideTOC()
{
	TOCstate = (TOCstate == 'none') ? 'block' : 'none';
	document.getElementById('toc').lastChild.style.display = TOCstate;

}


	

