// --------------- banner functions
var mq, pause		// global variables for banners
var msecs = 25	 	// constant

function banners(){
// pause for 2 seconds when the longest banner is fully displayed, then start all of them again
	pause++
	for (i = 0; i < mq.length; i++){
		var m = mq[i]
		len = m.innerHTML.length
		if (len < m.title.length){
			m.innerHTML = m.title.substr(0, len+1)
			pause = 0
			}
		}
	if (pause >= 2000/msecs){
		for (i = 0; i < mq.length; i++)
			mq[i].innerHTML = "&nbsp;"
		}
	}	
function init_banner(){
	pause = 0
	mq = document.getElementsByName("banner")
	for (i = 0; i < mq.length; i++)
		mq[i].title = mq[i].innerHTML
	setInterval(banners, msecs)
	}
// --------------------- competition functions
function hilite(opt){
	var player = opt.options[opt.selectedIndex].text
	var ko = document.getElementById("ko").rows
	for (var r = 1; r < ko.length; r++){
		var rw = ko[r]
		for (var c = 0; c < rw.cells.length; c++){
			var cell = rw.cells[c]
			if (cell.innerHTML.search(player)>= 0){
				cell.style.color = "#FF0000"
				cell.style.fontWeight = "bold"
				}
			else {
				cell.style.color = ""
				cell.style.fontWeight = ""
				}
			}
		}	
	}

//---------------- calendar functions
function coaching_email(e){
	e.href = "mailto:"+e.id.replace(/#/,"@")+"?subject=Coaching"
	}

function toggle(m){	 // all rows are displayed if script is disabled
	rowset = document.getElementById(m.name)
	if (!rowset)
		rowset = document.getElementById("calendar").tBodies[2*parseInt(m.name.substr(1))-5]
	if (m.alt == "show"){
		m.src = "../images/minus.gif"
		m.alt = "hide"
		rowset.style.display = ""
		}
	else {
		m.src = "../images/plus.gif"
		m.alt = "show"
		rowset.style.display = "none"
		}
	}	

function hidepast(){
	d = new Date()
	// collapse by default only for past months in the current year
	if (d.getFullYear() == parseInt(document.title)){
		mth = d.getMonth()
		if (mth > 9)
			mth = 9
		for (i = 0; i < mth; i++){
			m = document.getElementsByName("m"+String(i));
			if (m.length > 0)
				toggle(m[0])
			}
		}
	}
function showall(){
	for (i = 0; i <= 12; i++){
		m = document.getElementsByName("m"+String(i))
		if (m.length > 0){
			m = m[0]
			m.alt = "show"
			toggle(m)
			}
		}
	}
function hideall(){
	for (i = 0; i <= 12; i++){
		m = document.getElementsByName("m"+String(i))
		if (m.length > 0){
			m = m[0]
			m.alt = "hide"
			toggle(m)
			}
		}
	}
function popup(href,w, h){
	if (!w)
		w = 480;
	if (!h)
		h = w;
	window.open(href, "","width="+w+",height="+h+",menubar=1,toolbar=0,status=0,scrollbars=1")
	return false	// keeps calling page
	}

