// navigate to a new location
var popupWindow;

function Navigate(url)
{
	window.location.href=url;
}

function SwitchBackground(obj, imgSrc)
{
	obj.style.background = 'url(' + imgSrc +')';
}

function Popup(url,name)
{
	popupWindow = window.open(url, name, 'toolbar=no,scrollbars=no,location=no,status=no,menubar=no,resizable=no,width=605,height=376');
	
	if(window.focus)
	{
		popupWindow.focus();
	}
}

var mediaType = null;
function SupportedMediaType() {
	if (mediaType != null)
		return mediaType;
		
	if (Prototype.Browser.MobileSafari)
		return mediaType = '3gp';
	
	if(Prototype.Browser.IE) {
		var players = {
			wmv: 'Windows Media Player',
			mov: 'QuickTime'
		};
	}
	else {
		var players = {
			mov: 'QuickTime',
			wmv: 'Windows Media Player'
		};
	}

	if (Prototype.Browser.IE && navigator.userAgent.indexOf('Win')!=-1) {
		// Because IE has to be special
		var script = new Array();
		script.push('detectableWithVB = False');
		script.push('If ScriptEngineMajorVersion >= 2 then');
		script.push('  detectableWithVB = True');
		script.push('End If');
		script.push('Function detectActiveXControl(activeXControlName)');
		script.push('  on error resume next');
		script.push('  detectActiveXControl = False');
		script.push('  If detectableWithVB Then');
		script.push('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
		script.push('  End If');
		script.push('End Function');
		script.push('Function detectQuickTimeActiveXControl()');
		script.push('  on error resume next');
		script.push('  detectQuickTimeActiveXControl = False');
		script.push('  If detectableWithVB Then');
		script.push('    detectQuickTimeActiveXControl = False');
		script.push('    hasQuickTimeChecker = false');
		script.push('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
		script.push('    If IsObject(hasQuickTimeChecker) Then');
		script.push('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
		script.push('        detectQuickTimeActiveXControl = True');
		script.push('      End If');
		script.push('    End If');
		script.push('  End If');
		script.push('End Function');

		var vbscript = document.createElement('script');
		vbscript.setAttribute('language', 'VBScript');
		vbscript.text = script.join('\n');

		document.getElementsByTagName('head')[0].appendChild(vbscript);

		if (typeof(detectableWithVB) != 'undefined') {
			for (var ext in players) {
				if (ext=='mov' && detectQuickTimeActiveXControl()) {
					return mediaType = ext;
				} else if (ext=='wmv' && detectActiveXControl('MediaPlayer.MediaPlayer.1')) {
					return mediaType = ext;
				}
			}
		}
	} else if (navigator.plugins) {
		for (var ext in players) {
			for (var i=0; i < navigator.plugins.length; i++ ) {
				var name = navigator.plugins[i].name;

				if (name.indexOf(players[ext]) >= 0) {
					return mediaType = ext;
				}
			}
		}
	}
	
	return mediaType = 'none';
}
