// JavaScript Document

window.addEvent("domready", function() { 
	
	//Flash IE Update
	FlashIEUpdate();
	
	//Smooth Scroll
	new SmoothScroll({duration: 1000, fps:60, transition: Fx.Transitions.cubicOut}); 
	
	//menu javascript
	//try { startList(); } catch(err) { null; } //flyout
	//try { sfHover(); } catch(err) {	null; } //dropdown
	
	//load local javascripts
	try { localInit(); } catch(err) { null; }
	
});

/* Flash IE Update */

function FlashIEUpdate () {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);
				
				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
			
				}
			}
		}
	}


/*function WriteFlashTags(url,image) {
 document.write('<div style="z-index:0;margin:0px;padding:0px;width:100%;overflow:hidden"><OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 height="320" width="336" classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="_cx" VALUE="19659"><PARAM NAME="_cy" VALUE="8467"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="/website/ui/global/swf/flashvideo.swf?flv='+url+'&image='+image+'"><PARAM NAME="Src" VALUE="/website/ui/global/swf/flashvideo.swf?flv='+url+'&image='+image+'"><PARAM NAME="WMode" VALUE="transparent"><!--PARAM NAME="Play" VALUE="-1"><PARAM NAME="Loop" VALUE="-1"--><PARAM NAME="Quality" VALUE="High">');
 document.write('<EMBED src="/website/ui/global/swf/flashvideo.swf?flv='+url+'&image='+image+'" wmode="transparent" menu="false" quality="high" WIDTH="336" HEIGHT="320" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
 document.write('</OBJECT></div>');
}*/

function WriteFlashTags(url, width, height) {
 document.write('<div style="z-index:0;margin:0px;padding:0px;width:100%;overflow:hidden"><OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 height='+height+' width='+width+' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="_cx" VALUE="19659"><PARAM NAME="_cy" VALUE="8467"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="'+url+'"><PARAM NAME="Src" VALUE="'+url+'"><PARAM NAME="WMode" VALUE="transparent"><!--PARAM NAME="Play" VALUE="-1"><PARAM NAME="Loop" VALUE="-1"--><PARAM NAME="Quality" VALUE="High">');
 document.write('<EMBED src="'+url+'" wmode=transparent menu=false quality=high WIDTH='+width+' HEIGHT='+height+'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
 document.write('</OBJECT></div>');
}

function StreamMedia(url, width, height, autostart) {
document.write('<OBJECT ID=MediaPlayer1 width="'+width+'" height="'+height+'" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft® Windows® Media Player components..." type="application/x-oleobject"><PARAM NAME="FileName" VALUE="'+url+'"><PARAM NAME="AutoStart" VALUE="'+autostart+'"><EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="'+url+'" name="MediaPlayer1" width='+width+' height='+height+'	AutoStart='+autostart+'></EMBED>');
document.write('</OBJECT>');
}

/* The following functions are used by tinyMCE, the HTML editor, for inserting media objects */
function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? ' id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? ' name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? ' width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? ' height="' + p.height + '"' : '';
	h += '>';
	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';
	
	h += '<object  type="' + mt + '"';
	h += typeof(p.src) != "undefined" ? ' data="' + p.src + '"' : '';
	h += typeof(p.id) != "undefined" ? ' id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? ' name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? ' width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? ' height="' + p.height + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '</object></object>';

	document.write(h);
}
/* end of tinyMCE media functions */