// Set a few variables

var radioWin = null;
var radioFile = "../radio/radio.html";
var otherWin = null;
var tvWin = null;
var popupWidth=425;
var popupHeight=400;
var popupScroll='yes';
var popupResize='yes';
var popupLeft='1';

// Open the Senior Year Radio pop-up

function openRadio(where) {
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	
	if (where)	{	// Go to a specific song?
		theWhere = where;
	}
	else {
		theWhere = '';
	}
	if (isIE && !isWin)	{	// If Mac IE, pop up regular Real Player
		theURL = "rtsp://video.pbs.org:8080/media4/senioryear/playlist_nodj.smil#" + theWhere;
		document.location.href=theURL;
		return(false);
	}	
	else	{
		theURL = radioFile + "?" + theWhere;
	
		if (radioWin) {
			if(radioWin.closed==false) {
				radioWin.goToSong(where);
				radioWin.focus();
			}
			else	{
				radioWin = opendetails(theURL,'325','194','no','no','300','1','theRadio');
			}
		}
		else	{
			radioWin = opendetails(theURL,'325','194','no','no','300','1','theRadio');
		}
		//openedRadio = true;
		return (false);
	}
}

// ----------------------------------------------------------------------------
// Open the lyrics popup
function openLyrics(theURL) {
	theURL = theURL + "_pop.html";
	openPopUp(theURL);
}

// ----------------------------------------------------------------------------
// Open other popups

function openPopUp() {
	var theParameters = new Array(
		'theURL',
		'popupWidth',
		'popupHeight',
		'popupScroll',
		'popupResize',
		'popupLeft');
		
	for (i=0; i < (openPopUp.arguments.length); i++) {
		theVar = theParameters[i];
		theValue = openPopUp.arguments[i];
		eval(theVar + "= theValue");
	}

	if (otherWin) {
		if(otherWin.closed==false) {
			otherWin.close();
		}
	otherWin=opendetails(theURL,popupWidth,popupHeight,popupScroll,popupResize,popupLeft,'1','popInfo');
	}
	else	{
	otherWin=opendetails(theURL,popupWidth,popupHeight,popupScroll,popupResize,popupLeft,'1','popInfo')
	}
}

// ----------------------------------------------------------------------------
// Open TV Popup; takes arguments bw (bandwidth) and video filename

function openTV(bw,videoFN) {
	if (radioWin != null)	{
		if (radionWin.closed == false)	{
			radioWin.close();
		}
	}
	if (tvWin != null)	{
		if (tvWin.closed == false)	{
			tvWin.close();
		}
	}

	if(bw=='low')	{
		theWidth=280;
		theHeight=301;
	}
	else	{
		theWidth=540;
		theHeight=505;
	}
	theURL = "../radio/tv_" + bw + ".html?" + videoFN;
	
	if (tvWin) {
		if(tvWin.closed==false) {
			tvWin.focus();
		}
		else	{
			tvWin = opendetails(theURL,theWidth,theHeight,'no','no','150','1','theTV');
		}
	}
	else	{
		tvWin = opendetails(theURL,theWidth,theHeight,'no','no','150','1','theTV');
	}
	//openedRadio = true;
}

// ----------------------------------------------------------------------------
// Open detail window

function opendetails(theURL,popupWidth,popupHeight,scrollBars,resizable,left,top,windowName)	{
	detailswin = null;
	detailsDetails = 'scrollbars=' + scrollBars + ',resizable=' + resizable + ',width=' + popupWidth + ',height=' + popupHeight +  ',left=' + left + ',top=' + top;
	detailswin=window.open(theURL,windowName,detailsDetails);
	detailswin.focus();
	return (detailswin);
}

function closePopUp(theWin)	{
	if (theWin) {
		if(theWin.closed==false) {
			theWin.close()
		}
	}
}