/* ##### firefox/opera vs. ie differences ##### */

function getElementClassAttribute(element) {
	return (element.getAttribute("class") ?
		element.getAttribute("class") /*firefox*/ : 
		element.getAttribute("className") /*ie*/)
}
function setElementClassAttribute(element, className) {
	if (document.defaultView) /*firefox and opera*/
		element.setAttribute("class", className)
	else
		element.setAttribute("className", className)
}
function setElementFontSize(element, fontSize) {
	if (document.defaultView) { /*firefox and opera*/
		element.style.fontSize = fontSize
		//element.style.font = fontSize + " " + document.defaultView.getComputedStyle(element, null).getPropertyValue("font-family")
	}
	else if (element.currentStyle) { /*ie*/
		element.style.font = fontSize + " " + element.currentStyle["fontFamily"]
	}
}
function setElementZIndex(element, zIndex) {
	if (document.defaultView) { /*firefox and opera*/
		element.style.zIndex = zIndex
	}
	else if (element.currentStyle) { /*ie*/
		element.style.zIndex = zIndex
	}
}
function getElementProperty(element, property) { //returns computed style
	//if property is "margin-left/marginLeft" then property parameter should be "margin-Left"

	if (document.defaultView) { /*firefox and opera*/
		return document.defaultView.getComputedStyle(element, null).getPropertyValue(property)
	}
	else if (element.currentStyle) { /*ie*/
		return element.currentStyle[property.replace(/-/, '')]
	}	
}

/* other functions */

function enableStylesheet(id, flag) {
	var linkelement = document.getElementById(id)
	linkelement.disabled = ! flag
}
/*function setActiveStylesheet(title) {
	var i, a, main
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if ((a.getAttribute("rel").indexOf("style") != -1) && (a.getAttribute("title"))) {
			a.disabled = true
			if(a.getAttribute("title") == title) a.disabled = false
		}
	}
}*/

function winopen(node) { //node is either an <a> element, or an href
	var w = window.open((node.href ? node.href : node), '_blank', 'width=400,height=200,scrollbars=yes,resizable=yes')
	w.focus()
}

function links() {
	var sidebar = document.getElementById('left')
	for(var i = 0; (a = document.getElementsByTagName('div')[i]); i++) {
		a = document.getElementsByTagName('div')[i]
		if ((a.getAttribute('class') == 'links') || (a.getAttribute('className') == "links")) { 
			setElementClassAttribute(a, null) //prevents it from links div from being picked up again
			sidebar.appendChild(a)
		}
	}
}
function selectAll(ancestor, checked)
{
	inputelements = ancestor.getElementsByTagName('input');
	for (i = 0; i < inputelements.length; i++) if (inputelements[i].type == "checkbox") inputelements[i].checked = checked
}
function toggle(parentElement) {
	var checkbox = parentElement.getElementsByTagName('input')[0]
	if (! checkbox.disabled) {
		checkbox.checked = ! checkbox.checked
	}
}

