var insideLayer = false;
var useNS = (navigator.appName == "Netscape");

function navOver(obj, id, parent_id, sub, children) {

	//alert('id = '+id+' parent_id = '+parent_id+' obj = '+obj);
	if (sub) {
		if (!insideLayer)
			showSubMenu(id, parent_id, obj, 1, 0, 1, 0, -361, -115);
	} else {
		if (!insideLayer)
			showSubMenu(id, parent_id, obj, 0, 1, 0, 1, 0, 0);
	}
	insideLayer = true;
	obj.className = (children ? 'children ' : '') + 'over';
}

function navOut(obj, children) {
	insideLayer = false;
	obj.className = (children ? 'children' : '');
}

function cancelEvent(event) {

	if (useNS) event.preventDefault();
	event.cancelBubble = true;

}

function showSplash(id,nr,state)
{
	_showSplash(id,state);
	_resetSplash(id,nr);
}

function _showSplash(id,state)
{
	var splashimg = document.getElementById('splash'+id+'img');
	var splashtext = document.getElementById('splash'+id+'text');
	var splashtitle = document.getElementById('splash'+id+'title');
	if (state) {
		if (splashtitle != null) splashtitle.className = 'splashtitleover';
		if (splashimg != null) splashimg.style.display = 'none';
		if (splashtext != null) splashtext.style.display = 'block';
	} else {
		if (splashtitle != null) splashtitle.className = 'splashtitle';
		if (splashimg != null) splashimg.style.display = 'block';
		if (splashtext != null) splashtext.style.display = 'none';
	}
}
function _resetSplash(id,nr)
{
	for (var i=1; i<=nr; i++) {
		if (i != id)
			_showSplash(i,0);
	}

}
function submitSearch(fieldname, event)
{
	if (event) {
		if (navigator.appName == "Netscape") {
			var code = event.which;
		} else {
			var code = event.keyCode;
		}
	}


	if (!event || code == 13) { /* <enter> */

		str = document.getElementById(fieldname).value;
		str = str.replace(/\+/ig, "PLUS_SIGN");
		document.location.href='/search/'+str;

	}

	return true;
}
function submitOnEnter(event, formname) {

	if (navigator.appName == "Netscape") {
		var code = event.which;
	} else {
		var code = event.keyCode;
	}
	if (code == 13) {
		document.forms[formname].submit();
		return false;
	}
	return true;
}
function clearForm(formid) {
	var TheForm = document.getElementById(formid);
	var Field;
	for(var i=0; i<TheForm.elements.length; i++) {

		Field = TheForm.elements[i];
		switch (Field.type) {
			case 'select-one':
			case 'select-mutiple':
				Field.selectedIndex = -1;
				break;
			case 'text':
				Field.value = '';
				break;
		}

	}
}


function openPopup(url) {

	window.open(url, '_blank', 'width=800,height=600,resizable=yes');

}