var slideInUse = new Array();

function Slide(objId, options) {
	this.obj = document.getElementById(objId);
	this.duration = 1;
	this.height = parseInt(this.obj.style.height);

	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.duration) { this.duration = this.options.duration; }
		
	this.up = function() {
		this.curHeight = this.height;
		this.newHeight = '1';
		if(slideInUse[objId] != true) {
			var finishTime = this.slide();
			window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);
		}
	}
	
	this.down = function() {
		this.newHeight = this.height;
		this.curHeight = '1';
		if(slideInUse[objId] != true) {
			this.obj.style.height = '1px';
			this.obj.style.display = 'block';
			this.slide();
		}
	}
	
	this.slide = function() {
		slideInUse[objId] = true;
		var frames = 30 * duration; // Running at 30 fps

		var tIncrement = (duration*1000) / frames;
		tIncrement = Math.round(tIncrement);
		var sIncrement = (this.curHeight-this.newHeight) / frames;

		var frameSizes = new Array();
		for(var i=0; i < frames; i++) {
			if(i < frames/2) {
				frameSizes[i] = (sIncrement * (i/frames))*4;
			} else {
				frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
			}
		}
		
		for(var i=0; i < frames; i++) {
			this.curHeight = this.curHeight - frameSizes[i];
			window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
		}
		
		window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
		
		if(this.options.onComplete) {
			window.setTimeout(this.options.onComplete, tIncrement * (i-2));
		}
		
		return tIncrement * i;
	}
	
	this.finishup = function(height) {
		this.obj.style.display = 'none';
		this.obj.style.height = height + 'px';
	}
	
	return this;
}

function toggle(nr,time)
{
	if(typeof time == 'undefined') { time = 1; }

	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'down' : 'up';
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'down' : 'up';
	}
	else if (document.getElementById)
	{
		current = (document.getElementById(nr).style.display == 'none') ? 'down' : 'up';
	}
	
	if (current == 'down')
	{
		Slide(nr,{duration:time}).down();
	}
	else
	{
		Slide(nr,{duration:time}).up();
	}
}

function hideTimes(startMonth, endMonth, abrev)
{
	var teamName = document.getElementById('teamName').value;
	document.FORM3.reset();
	document.getElementById('teamName').value = teamName;
	
	for ( var j = startMonth; j <= endMonth; j++ )
	{
		var children = document.getElementById(abrev+'monthtimes_'+j).getElementsByTagName('div');
		
		for ( var i = 0; i < children.length; i++ )
		{
			// Hide all the elements
//			children[i].display = 'none';
			if (document.layers)
			{
				document.layers[children[i].id].display = 'none';
			}
			else if (document.all)
			{
				document.all[children[i].id].style.display = 'none';
			}
			else if (document.getElementById)
			{
				document.getElementById(children[i].id).style.display = 'none';
			}
		}
	}
}

function toggleId(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}