var flashcomponents = Object();
var footerlinks = Object();
var mediaplayer = Object();

function launch_window(winurl,winname,winfeatures) {
	//This launches a new window and then
	//focuses it if window.focus() is supported

	newwin = window.open(winurl,winname,winfeatures);
 	setTimeout('newwin.focus();',250);

}

flashcomponents.init = function() {

	flashcomponents.pathtoswf = '/Portals/_default/Skins/GMG/Swf/';

	footerlinks.init();
	mediaplayer.init();
}

footerlinks.init = function() {

	document.getElementById('footerpanel').innerHTML =
		'<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="45">' +
			'<param name="movie" value="' + flashcomponents.pathtoswf + 'footer.swf" />' +
			'<param name="quality" value="high" />' +
			'<param name="bgcolor" value="#000000" />' +
			'<embed src="' + flashcomponents.pathtoswf + 'footer.swf" quality="high" bgcolor="#000000" width="100%" height="45" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
		'</object>';
}

mediaplayer.init = function() {

	if (document.getElementById('mediaplayerbutton') != null) {
		document.getElementById('mediaplayerbutton').onclick = mediaplayer.mediabuttonclick;
		document.getElementById('mediaplayerlink').href = '#';

		mediaplayer.visible = false;

	} else {
		// we are on the home page - show home page flash version
		document.getElementById('mediaplayerpanel').innerHTML =
			'<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="348" height="310">' +
				'<param name="movie" value="' + flashcomponents.pathtoswf + 'mediaplayer.swf?section=index" />' +
				'<param name="allowScriptAccess" value="always" />' +
				'<param name="quality" value="high" />' +
				'<param name="bgcolor" value="#FFFFFF" />' +
				'<embed src="' + flashcomponents.pathtoswf + 'mediaplayer.swf?section=index" allowScriptAccess="always" quality="high" bgcolor="#FFFFFF" width="348" height="310" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
			'</object>';
	}
}

mediaplayer.mediabuttonclick = function() {

	// toggle visible flag
	mediaplayer.visible = !mediaplayer.visible;

	// determine if we are on the green templated pages
	var mediapanelid = 'mediaplayerpanelred';
	var flashparam = '';

	if (document.getElementById('mediaplayerpanelred') == null) {
		mediapanelid = 'mediaplayerpanelgreen';
		flashparam = '?section=scott_trust';
	}

	if (mediaplayer.visible) {
		// write out flash embed code
		document.getElementById(mediapanelid).innerHTML =
			'<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="348" height="310">' +
				'<param name="movie" value="' + flashcomponents.pathtoswf + 'mediaplayer.swf' + flashparam + '" />' +
				'<param name="allowscriptaccess" value="samedomain" />' +
				'<param name="quality" value="high" />' +
				'<param name="wmode" value="transparent" />' +
				'<param name="bgcolor" value="#FFFFFF" />' +
				'<embed src="' + flashcomponents.pathtoswf + 'mediaplayer.swf' + flashparam + '" allowscriptaccess="samedomain" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="348" height="310" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
			'</object>';

	} else {
		document.getElementById(mediapanelid).innerHTML = '&nbsp;';
	}

	// adjust mediaplayer panel class to suit
	document.getElementById(mediapanelid).className = (mediaplayer.visible)
		? 'mediaplayershow'
		: 'mediaplayerhide';

	// return false to suppress button anchor tag from working
	return false;
}

// closeGMGMediaPlayer() is called by the flash media player when requested to be closed
function closeGMGMediaPlayer() {

	mediaplayer.mediabuttonclick();
}


window.onload = flashcomponents.init;