var videoIsEmbedded = false
var videoName = ""
var browser = navigator.appName;
function e(id) { return document.getElementById(id) }
function m(o) {
	var str = ''
	for (p in o)
		str += p + ': ' + o[p] + '\n'
	return str;
}
function defaultContent() {
	setContent('&Dagger;')
	videoIsEmbedded = false
}
function PLCContent() {
	videoIsEmbedded = false	
	setContent('&Dagger;')
}
function programCableContent() {
	videoIsEmbedded = false
	setContent('&Dagger;')
}
function PLCexeContent(exe) {
	htmlInclude('util/content/plc.html')
	beginDownload(exe)
}
function eztouchexeContent(exe) {
	htmlInclude('util/content/eztouch.html')
	beginDownload(exe)
}
function cmoreexeContent(exe) {
	htmlInclude('util/content/cmore.html')
	beginDownload(exe)
}
function AdobeContent() {
	setContent('&Dagger;')
}
function videoContent() {
	if (!videoIsEmbedded)
		return
	setContent(
		'<div align=center class=\"userMessage\">' +
		'Video Stopped' + '<br>' +
		'<a href=\"javascript:embedVideo(videoName)\">Click Here to Resume Playback</a>' +
		'</div>' +
	'')
	videoIsEmbedded = false
}
function setContent(html) {
	e('content').innerHTML = html
}
function htmlInclude(html) {
	var req = false;
	// For Safari, Firefox, and other non-MS browsers
	if (window.XMLHttpRequest) {
		try {
			req = new XMLHttpRequest();
		} catch (e) {
		req = false;
		}
	} else if (window.ActiveXObject) {
	// For Internet Explorer on Windows
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				req = false;
			}
		}
	}
/*	var element = document.getElementById(id);
	if (!element) {
		alert("Bad id " + id +
		"passed to htmlInclude." +
		"You need a div or span element " +
		"with this id in your page.");
		return;
	}
*/	if (req) {
		// Synchronous request, wait till we have it all
		req.open('GET', html, false);
		req.send(null);
		setContent(req.responseText);
		//e('content').innerHTML = req.responseText;
		//element.innerHTML = req.responseText;
	} else {
		element.innerHTML =
		"Sorry, your browser does not support " +
		"XMLHTTPRequest objects. This page requires " +
		"Internet Explorer 5 or better for Windows, " +
		"Firefox for any system, or Safari. Other " +
		"compatible browsers may also exist."; 
	}
}
function beginDownload(exe) 
{
  // Bizarre logic because JavaScript won't behave
  idl = 1;
  if (location.search) { // for NN2
    idl = -location.search.indexOf("idl=n");
  }
  if (idl > 0) {
    window.location = exe;
  }
  return 1;
}
function embedVideo(fileName) {
	var tag = "<embed id='video' src='av/" + fileName +
		"' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/download/default.asp' name=MMPlayer1 autostart='1' showstatusbar='1'></embed>"
	setContent(tag)
	videoIsEmbedded = true
	videoName = fileName
}
function showVideo() {
	if (!videoIsEmbedded)
		return
	var v = e('video')
	v.style.visibility = 'visible' 
	if (browser != "Netscape")
		v.Play()
}
function hideVideo() {
	if (!videoIsEmbedded)
		return
	var v = e('video')
	v.style.visibility = 'hidden' // so the menus can show over top
	if (browser != "Netscape")
		v.Stop()
}
document.writeln('<div id="content"></div>')
htmlInclude("util/content/default.html")
