function launchVideo(videoURL) {
	var isMS = (navigator.appName.indexOf('Microsoft')!=-1 && navigator.userAgent.indexOf('Opera')==-1);
	var isNav = (navigator.appName.indexOf('Netscape')!=-1);
	var isWin = (navigator.userAgent.indexOf("Win") != -1);
	var spawnNew = true;
	// alert('MS: ' + isMS + '\n' + 'Nav: ' + isNav + '\nisWin: ' + isWin + '\nspawnNew: ' + spawnNew);

	if (!isWin || (isWin && !isNav && !isMS)) {
		var getConfirm = confirm('Warning: Streaming video may not be available for this browser or computer. If you have Microsoft Media Player Version 9 or above installed on your machine, click OK to try loading the streaming video anyway.');
		if (getConfirm)	{
			window.location.href = videoURL;
		}
		return false;
	} else if (isMS) {
		if (window.name == 'vlMedia') {
			spawnNew = false;
		} 
		var fullURL = '/london_tv/viewer/?videoURL=' + escape(videoURL);
		if (spawnNew) {
			var vlMedia = window.open(fullURL,'vlMedia','location=no,resizable=no,scrollbars=no,width=580,height=330');
			vlMedia.focus();
			return false;
		} else {
			window.location.href = fullURL;
			return false;
		}
	} else {
		this.location.href = videoURL;
		return false;
	}
}

var videoLinks = new Array();

/* Find all <a> tags with class="tvviewer" */
function getVideoLinks() {
	if (document.links) {
		for (i=0; i<document.links.length; i++) {
			var videoLink = document.links[i];
			if (videoLink.className=='tvviewer') {
				videoLink.onclick = function() {
					launchVideo(this.href);
					return false;
				}
			}
		}
	}
}

window.onload = getVideoLinks;
