function disableEnterKey() {
	document.onkeypress = handleEnter;
}

function handleEnter(evt) {
	var evt = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if ((evt.keyCode == 13) && (node.type=="text")) {
		field = this;
		// Would be nice to do something like move focus to the next field, like 
		// handleEnter below.
		return false;
	}
}

function handleEnter2 (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} else return true;
}     

function replaceText(obj_id, newstring) {
	document.getElementById(obj_id).innerHTML = newstring;
}

function redirectURL(url) {
	window.location=url;
}

function redirect(url) {
	window.location=url;
}

function changeObjectVisibility(objectId, newVisibility) {
	// first get the object's stylesheet
	var styleObject = getStyleObject(objectId);

	// then if we find a stylesheet, set its visibility
	// as requested
	//
	if (styleObject) {
		styleObject.visibility = newVisibility;
		return true;
	} else {
		return false;
	}
}

function getStyleObject(objectId) {
	// checkW3C DOM, then MSIE 4, then NN 4.
	//
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {  
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) { 
		return document.layers[objectId];
	} else {
		return false;
	}
}

function showHelp(topic) {
	//openPopupWindow('<?php echo $base_url?>/help.php?topic=' . topic, 'Test', 100, 100, 100, 100);
	openPopupWindow('<?php echo $base_url?>/help/?topic=' + topic, 'Test', 300, 300, 100, 100);
}

function openPopupWindow(url, winName, w, h, x, y) {
	var sAttribs = "location=no,buttons=no,toolbar=no,scrollbars=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y ;
	if (navigator.appName == "Netscape" && navigator.appVersion.charAt (0) >= 4)
		sAttribs += ",resizable=no,left=" + x + ",top=" + y ;
	else if (navigator.appName == "Microsoft Internet Explorer")
		sAttribs += ",resizable=yes,left=" + x + ",top=" + y ;

	//newWindow = top.CCBodyi.open (url, winName, sAttribs);
	newWindow = open (url, winName, sAttribs);

	if (navigator.appName == "Microsoft Internet Explorer" &&
		navigator.appVersion.charAt (0) >= 4 && newWindow.opener == null)
	{
		newWindow.opener = window ;
	}

	// Bring window to front on Navigator 3.0+ and MSIE 4.0+
	if (navigator.appName == "Netscape" && navigator.appVersion.charAt (0) >= 3 ||
		navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.charAt (0) >= 4)
	{
		newWindow.focus();
	}
}

function toggleLayer(whichLayer, style) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		if (style) {
			style2.display = style;
		} else {
			style2.display = style2.display? "":"block";
		}
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function changeWidth(id, width) {
	if (document.getElementById) {
		// this is the way the standards work
		var style = document.getElementById(id).style;
		style.width = width;
	} else if (document.all) {
		// this is the way old msie versions work
		var style = document.all[id].style;
		style.width = width;
	} else if (document.layers) {
		// this is the way nn4 works
		var style = document.layers[id].style;
		style.width = width;
	}

}

function changeStyle(id, attr, value) {
	if (document.getElementById) {
		// this is the way the standards work
		//var style = document.getElementById(id).style;
		//style.attr = value;
		document.getElementById(id).style.attr = value;
	} else if (document.all) {
		// this is the way old msie versions work
		var style = document.all[id].style;
		style.attr = value;
	} else if (document.layers) {
		// this is the way nn4 works
		var style = document.layers[id].style;
		style.attr = value;
	}

}
