
var popup;
var videoPopup;

function getObjectByID(name) {				// Get an object's ID tag for easy referencing

	if (document.getElementById) {				// Firefox and Safari
		return document.getElementById(name);
	} else if (document.all) {				// IE
		return document.all[name]; 
	} else if (document.layers) {
		return document.layers[name];
	} else {
		return document.getElementById(name);		// Default for unknown browsers
	}
}


function embedFlash(thisFile, w, h) {	// Shows the activeX control without an annoying 'activate' prompt
	var embedCode = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' " 
		+ "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + w + "' height='" + h + "'> " 
		+ "<param name='movie' value='" + thisFile + "' /> " 
		+ "<param name='quality' value='high' /> " 
		+ "<param name='wmode' value='transparent' /> " 
		+ "<embed src='" + thisFile + "' width='" + w + "' height='" + h + "' quality='high' " 
		+ "pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='transparent'> " 
		+ "</embed></object>";

	document.write(embedCode);
}


function getScreenSpecs(defaultW, defaultH) {		// Accepts default width and height as input and returns 
							// either actual screen width and height or the defaults
	screenH = defaultH
	screenW = defaultW;

	if (parseInt(navigator.appVersion)>3) {
		 screenH = screen.height;
		 screenW = screen.width;
	}
	else if (navigator.appName == "Netscape" 
	    && parseInt(navigator.appVersion)==3
	    && navigator.javaEnabled()
	) 
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenH = jScreenSize.height;
	 screenW = jScreenSize.width;
	}

	return [screenW, screenH];
}



function openWin(whichURL,winW,winH) {				// Open document in a new window

	var screenWH = getScreenSpecs(800, 600);
	screenW = screenWH[0];
	screenH = screenWH[1];

	if (!winW) {
		winW = screenW;
		winH = screenH;
	}

	popWin=window.open(whichURL,"pWin","toolbar=no,scrollbars=yes,resizable=no,width="+winW+",height="+winH+ ",left=" + Math.round((screenW/2)-(winW/2))+ ",top=" + Math.round((screenH/3)-(winH/2)) );
}


function openFlash(file, w, h, title) {
	
	queryString = 'video/flashPlayer.html?w=' + w + '&h=' + h + '&file=' + file + '&title=' + title;

	if(videoPopup) {
		videoPopup.close();
	}
	
	w = w + 36;
	h = h + 82;

	videoPopup = window.open(queryString, 'videoWindow', 'height=' +h+ ', width=' +w+ ', scrollbars=no, resizeable=no');

}
	
function openBrowser(whichURL,winW,winH) {				// Open document in a new window

	var screenWH = getScreenSpecs(800, 600);
	screenW = screenWH[0];
	screenH = screenWH[1];

	if (!winW) {
		winW = screenW;
		winH = screenH;
	}

	popWin=window.open(whichURL,"pWin","toolbar=yes,scrollbars=no,menubar=yes,resizable=yes,width="+winW+",height="+winH+ ",left=" + Math.round((screenW/2)-(winW/2))+ ",top=" + Math.round((screenH/3)-(winH/2)) );
}

function openBrowserwScroll(whichURL,winW,winH) {				// Open document in a new window

	var screenWH = getScreenSpecs(800, 600);
	screenW = screenWH[0];
	screenH = screenWH[1];

	if (!winW) {
		winW = screenW;
		winH = screenH;
	}

	popWin=window.open(whichURL,"pWin","toolbar=yes,scrollbars=yes,menubar=yes,resizable=yes,width="+winW+",height="+winH+ ",left=" + Math.round((screenW/2)-(winW/2))+ ",top=" + Math.round((screenH/3)-(winH/2)) );
}


function openShow(page, name, h, w, scrollBool) {

	if(popup) {
		popup.close();
	}

	popup = window.open(page, name, 'height=' + parseInt(h) + ', width=' + parseInt(w) + ', scrollbars=' + scrollBool +', resizeable=0');
}

function getSchedURL() {

	var weekday = new Array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');

	var now = new Date();
	var today = weekday[now.getDay()];

	var url = "http://129.130.183.58:50001/websched.php?channel=1&mode=day&day=" + today + "&headers=1";
	getObjectByID('progGuide').src = url;
}

function embedQT(thisFile, w, h) {			// Shows the activeX control without an annoying 'activate' prompt

	var embedCode = "    <object classid='clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b' width='" + w + "' "
		+ "	height='" + h + "' codebase='http://www.apple.com/qtactivex/qtplugin.cab' align='middle'>"
              + "        <param name='QTSRCDONTUSEBROWSER' value='true'>"
              + "        <param name='SCALE' value='tofit'>"
              + "        <param name='SRC' value='" + thisFile + "'>"
              + "        <param name='AUTOPLAY' value='true'>"
              + "        <param name='CONTROLLER' value='true'>"
              + "        <param name='KIOSKMODE' value='true'>"
              + "        <param name='BGCOLOR' value='#000000'>"
              + "        <embed qtsrcdontusebrowser='true' src='" + thisFile + "'"
		+ " scale='tofit' width='" + w + "' height='" + h + "' autoplay='true' "
		+ " controller='true' kioskmode='true'"
		+ " bgcolor='#000000' pluginspage='http://www.apple.com/quicktime/download/' align='middle'>"
              + "        </embed>"
              + "      </object>";

	getObjectByID('videoDiv').innerHTML = embedCode;
}

function openDefault(page) {		// Opens a document in a default window that includes the location bar and is resizable

	pop2 = window.open(page, "fullWin", "scrollbars=yes,status=yes,menubar=yes,toolbar=yes,location=yes,width=999,height=680");
}
