function openWindow(url,w,h,windowname) {
	if (!w) {
		w = '600';
	}
	if (!h) {
		h = '400';
	}
	if (!windowname) {
		windowname = 'window';
	}
	popupWin=window.open(url,windowname,'scrollbars,resizeable,'+'width='+w+',height='+h);
	popupWin.focus();
}

function jprompt(message,url) {
	input_box=confirm(message);
	if (input_box==true) {
		window.location=url;
	}
}

function submitform(formname,valuename,thevalue) {
	document.forms[formname].elements[valuename].value = thevalue;
	document.forms[formname].submit();
}


if (window.addLoadEvent)
{
	//return true;
}
else
{
	// Simon Willison's addLoadEvent handler
	function addLoadEvent(func)
	{
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  oldonload();
		  func();
		}
	  }
	}
}

addLoadEvent(function () {
	if (!document.getElementsByTagName) return false;

	var tmp;
	// do form fields focus for IE
	var fieldsInput = document.getElementsByTagName('input');
	for (i=0; i < fieldsInput.length; i++)
	{
		if (fieldsInput[i].type == 'text' || fieldsInput[i].type == 'password')
		{
			fieldsInput[i].onfocus = function () {
				this.className += " focus";
			}
			fieldsInput[i].onblur = function () {
				//this.className = this.className.replace(new RegExp(" focus\\b"), "");
				tmp = this.className.split(' ');
				this.className = tmp[0];
			}
		}
	}
	var fieldsTextarea = document.getElementsByTagName('textarea');
	for (var j=0; j < fieldsTextarea.length; j++)
	{
		fieldsTextarea[j].onfocus = function () {
			this.className += " focus";
		}
		fieldsTextarea[j].onblur = function () {
			//this.className = this.className.replace(new RegExp(" focus\\b"), "");
			tmp = this.className.split(' ');
			this.className = "";
		}
	}

	// do front-nav hover for IE
	if (!document.getElementById) return false;
	if (!document.getElementById("frontnav")) return false;
	var frontnav = document.getElementById("frontnav");
	var lis = frontnav.getElementsByTagName("li");
	for (var i=0; i < lis.length; i++)
	{
		lis[i].onmouseover = function()
		{
			this.className = "hover";
		}
		lis[i].onmouseout = function()
		{
			this.className = "";
		}
	}
	return true;
});

function oc(id) {
	var e=document.getElementById(id).style;
	if (e.display=='') {
		e.display='none';
	} else {
		e.display='';
	}
}

function visno(id) {
	e=document.getElementById(id).style;
	e.display='none';
}

function visyes(id) {
	e=document.getElementById(id).style;
	e.display='';
}

//addLoadEvent(function() {
var addLoadEvent_function = function() {
	var cookie = getCookie("style");
	var font = getCookie("fontsize");
	var resetcookie = getCookie("reset");
	reset = resetcookie ? resetcookie : 100;
	var fontsize = font ? font : 100;
	fromcookie = true;
};
addLoadEvent_function();

function splitup(value, separator, part) {
	value = value.split(separator);
	
	return value[part];
}

function sizetext(action) {	
	var newsize;
	var body = document.getElementById('top');
	var size = (body.style.fontSize != null) ? body.style.fontSize : '';
	var value = size == '' ? "100" : splitup(size, "%", 0);

	switch(action) {
		case "up":
			newsize = parseInt(value) + 10;
			break;
		case "down":
			newsize = parseInt(value) - 10;
			break;
		case "reset":
			newsize = reset;
			break;
	} //increase or decrease according to given action

	var increase = newsize + "%";
	currentsize = newsize;
	body.style.fontSize = increase;
}

function getCookie(type) {
	var info = type + "=";
	var cookies = document.cookie.split(';');

	for(var i = 0; i < cookies.length; i++) {
		var title = cookies[i].replace(/^\s+/, '');

		if (title.indexOf(info) == 0) {
			if (title.substring(info.length, title.length) == "null") {
				return '';
			}
			return title.substring(info.length, title.length);
		}
	}
	return '';
}