_focus = null
function focusFirstField() {
	found = false
	var myForm = document.getElementById('myForm')
	for (i = 0; (i < myForm.elements.length) && (found == false); i++) {
		type = myForm.elements[i].type
		if ((type == "text") || (type == "password") || (type == "textarea")) {
			if ((_focus == null) || (myForm.elements[i].name == _focus)) {
				found = true
				try { myForm.elements[i].focus() } catch(err) { }
			}
		}
	}
	return
}

// Menu support
sfHover = function() {
	var sfEls = document.getElementById("menu1").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	var sfEls = document.getElementById("menu2").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className += " sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

// Popup functions
function ow(url) {
	window.open(url,'new_win','width=500,height=500,resizable=yes,scrollbars=yes')
}

function hb(url) {
	window.open(url,'hb','width=750,height=500,location=yes,menubar=yes,titlebar=yes,toolbar=yes,resizable=yes,scrollbars=yes')
}

function popup(url, name, width, height) {
	window.open(url, name, 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes')
}

function popUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}

// Light-weight popup
timeoutFlag = 0
timeoutLength = 500
currentPopup = ''

function getRealTop(el) {
    yPos = el.offsetTop
    tempEl = el.offsetParent
    while (tempEl != null) {
        yPos += tempEl.offsetTop
        tempEl = tempEl.offsetParent
    }
    return yPos
}

function getRealLeft(el) {
	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

function helpPopup(id, flag) {

	if (!flag) {
		if ((currentPopup != '') && (currentPopup != id)) {
			helpPopup(currentPopup, true)
		}
		currentPopup = id
		clearPopupTimeout()
		popup = document.getElementById('popup' + id)
		if (popup.style.display == 'none') {
			icon = document.getElementById(id)
			popup.style.top = getRealTop(icon) + 10 + 'px';
			popup.style.left = getRealLeft(icon) + 10 + 'px';
			popup.style.display = ''
		}
	}
	else {
		currentPopup = ''
		popup = document.getElementById('popup' + id)
		popup.style.display = 'none'
	}
}

function setPopupTimeout(id) {
	timeoutFlag = setTimeout('helpPopup("' + id + '", true)', timeoutLength);
}

function clearPopupTimeout() {
	clearTimeout(timeoutFlag)
}

id=0
pause=0

function nextArticle() {
 if (pause==1){
  setTimeout('nextArticle()', 1000)
  return
 }

 id++
 if (id >= articles.length) 
  id = 0

 f = document.getElementById('fader')
 f.innerHTML = articles[id]

 setTimeout('nextArticle()', 5000);
}
