var showingprogram = '';
var wait, goIn;
var inUse = '';

function showprogram(it) {
 if (showingprogram == it) return; // It's already visible
 if (showingprogram != '') {hideprogram(showingprogram)};
 if (document.all) { 
 	document.all(it).style.display='block'; 
 	document.all(it).style.visibility='visible'; 
 	}
 else 
 	if (document.getElementById) { 
 		document.getElementById(it).style.display='block'; 
 		document.getElementById(it).style.visibility='visible'; 
 		fader(it,'in'); 
 		}
 showingprogram = it;
}

function hideprogram(it) {
 if (showingprogram != it) return; // Don't hide it if it isn't showing
 if (document.all) { 
 	document.all(it).style.visibility='hidden'; 
 	document.all(it).style.display='none';}
 else 
 	if (document.getElementById) {
 		fader(it,'out'); 
 		document.getElementById(it).style.visibility='hidden'; 
 		document.getElementById(it).style.display='none';}
}

function fader( objID, dir ) {
	var fade_index, index_limit;

//	if ( inUse != '' && inUse != dir ) { return; }
//	if ( inUse == dir ) { return; }

	inUse = dir;

	if (document.all) {	
		if (document.all(objID).filters) {
			fade_index = document.all(objID).filters.alpha.opacity;
			}
		}
	else 
		if (document.getElementById) { 
			fade_index = document.getElementById(objID).style.MozOpacity * 100; 
			}

	fade_index  = dir == 'in' ? fade_index + 5 : fade_index - 5;
	index_limit = dir == 'in' ? 100 : 0;

	if (document.all) { 
		if (document.all(objID).filters) {
			document.all(objID).filters.alpha.opacity = fade_index; 
			}
		}
	else 
		if (document.getElementById) { 
			document.getElementById(objID).style.MozOpacity = fade_index / 100.0; 
			}

	goIn = setTimeout('fader(\''+objID+'\',\''+dir+'\')',10);

	if ( ( dir == 'in' && fade_index >= index_limit ) || ( dir == 'out' && fade_index <= index_limit ) ) 
	{
		clearTimeout( goIn );
		inUse = '';
	}

}

function changeselector(it) {

	var i = 0;
	if (document.all) { 
		var numofoptions = document.all('selectprogram').length;
		var inspectingselect = document.all('selectprogram');
		while ((i <= numofoptions) && (inspectingselect[i].value != it)) {
			i++;
		}
		if (i < numofoptions) { 
			inspectingselect[i].selected = true;
			inspectingselect.focus();
		}
	}
	else
		if (document.getElementById) {
			var numofoptions = document.getElementById('selectprogram').length;
			var inspectingselect = document.getElementById('selectprogram');
			while ((i <= numofoptions) && (inspectingselect[i].value != it)) {
				i++;
			}
			if (i < numofoptions) { 
				inspectingselect[i].selected = true;
				inspectingselect.focus();
			}
		}
}

