/************************************************
* File: assets/javascript/essentials.js
* Widely used functions for the application
* Last modified on July 1, 2005, to add comments
************************************************/

// Wrapper function to ensure compatibility with older browsers
function getElement(name) {
	return document.getElementById?document.getElementById(name):document.all[name];
}

// Clears the fields contents and title, created in assets/titlecontent.inc
function clean() {
	getElement("contents").value = "";
	getElement("title").value = "";
	return false;
}
function highlight(element) {
	if (document.attachEvent) {
		element=element['srcElement']['which'];
	}
	element.style.color = "#104390";
}
function unhighlight(element) {
	if (document.attachEvent) {
		element=element['srcElement']['which'];
	}
	element.style.color = "black";
}
function buttonsetup() {
	var elements = document.getElementsByTagName("input");
	for (i = 0; i < elements.length; i++) {
		if (elements[i].type == 'button' || elements[i].type == 'submit') {
			if (document.addEventListener) {
				elements[i].addEventListener("mouseover", function() {highlight(this)}, false);
				elements[i].addEventListener("mouseout", function() {unhighlight(this)}, false);
			} else if (document.attachEvent) {
				elements[i].attachEvent("onmouseover", highlight);
				elements[i].attachEvent("onmouseout", unhighlight);
				elements[i].which = elements[i];
			}
		}
	}
}
