var _restoreSize = true; // Variable to control whether window restores it's size/position when altered, set to "false" in Custom Edit or the individual theme to disable auto window resizing
var _firstTimeSize = true; // Used to store whether an auto-resizing skins has resized itself for the first time.
var _resizeOnOpen = true; // Resize the player only the first time the window is opened
var _fullScreen = 'true'; // Turn off flash fullscreen button
var foundFlash = false;

function tellerror(msg, url, linenumber){
	errorCount += 1;
	writeDebug('<font color=red><BR>Error message= '+msg+'\nURL= '+url+'<BR>Line Number= '+linenumber + '</font>');
	return true;
}
window.onerror=tellerror;

/*--------------------------------------------------------*/
/*---------Utility Functions------------------------------*/

// Different playerStates...
// 1 - Playing
// 2 - Stopped
// 3 - Buffering
// 4 - Paused
// 5 - Closed
// 6 - Error

// Different playerAbility's
// false -- we can't speak with it
// true -- can use javascript

// Different buttonStates:
// play, stop, pause, ffw, rew


// Added by DOF 2011.04.01
// Flag to indicate that new code to support Flash and Firefox which was
var runNewCode = true;

// If we are passed the "test" flag, or if the Player=3 (flash), or if we are in Firefox
if((getParameterByName("test") == "true") || (getParameterByName("Player") == "1") || (getParameterByName("Player") == "3") || (jQuery.browser.mozilla)) {
	// run the new code
	runNewCode = true;
}


// Browser detection, image swapper, preload images
function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && (agent.indexOf("safari") == -1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4) && (this.major < 5));
	this.ns5 = (this.ns && (this.major >= 5));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
    this.safari = (agent.indexOf("safari") != -1);
    this.ffox = (agent.indexOf("firefox/") != -1);
	this.chrome = (agent.indexOf("chrome/") != -1);
	//alert("" + this.major + " " + this.ns4 + " " + this.ns5);
	this.win   = ( (agent.indexOf("win")!=-1) || (agent.indexOf("16bit")!=-1) ); 
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all 
    //        Win32, so you can't distinguish between Win95 and WinNT. 
    this.win95 = ((agent.indexOf("win95")!=-1) || (agent.indexOf("windows 95")!=-1)); 

    // is this a 16 bit compiled version? 
    this.win16 = ((agent.indexOf("win16")!=-1) || 
                  (agent.indexOf("16bit")!=-1) || (agent.indexOf("windows 3.1")!=-1) || 
                  (agent.indexOf("windows 16-bit")!=-1) ); 

    this.win31 = ((agent.indexOf("windows 3.1")!=-1) || (agent.indexOf("win16")!=-1) || 
                  (agent.indexOf("windows 16-bit")!=-1)); 

    // NOTE: Reliable detection of Win98 may not be possible. It appears that: 
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent. 
    //       - On Mercury client, the 32-bit version will return "Win98", but 
    //         the 16-bit version running on Win98 will still return "Win95". 
	this.winxp = ((agent.indexOf("winnt5.1")!=-1) || (agent.indexOf("windows nt 5.1")!=-1)); 
    this.win98 = ((agent.indexOf("win98")!=-1) || (agent.indexOf("windows 98")!=-1)); 
    this.winnt = ((agent.indexOf("winnt")!=-1) || (agent.indexOf("windows nt")!=-1)); 
    this.win32 = ( this.win95 || this.winnt || this.win98 || 
                   ((this.major >= 4) && (navigator.platform == "Win32")) || 
                   (agent.indexOf("win32")!=-1) || (agent.indexOf("32bit")!=-1) ); 

    this.os2   = ((agent.indexOf("os/2")!=-1) || 
                  (navigator.appVersion.indexOf("OS/2")!=-1) || 
                  (agent.indexOf("ibm-webexplorer")!=-1)); 

    this.mac    = (agent.indexOf("mac")!=-1); 
    this.mac68k = (this.mac && ((agent.indexOf("68k")!=-1) || 
                               (agent.indexOf("68000")!=-1))); 
    this.macppc = (this.mac && ((agent.indexOf("ppc")!=-1) || 
                               (agent.indexOf("powerpc")!=-1))); 
    this.linux    = (agent.indexOf("linux")!=-1); 
	this.ubuntu   = (agent.indexOf("ubuntu")!=-1); 

    this.vms   = ((agent.indexOf("vax")!=-1) || (agent.indexOf("openvms")!=-1)); 


}

var is = new Is();

if(is.ns4) {
    doc = "document";
    sty = "";
    htm = ".document"
    xpos = "e.contentX";
    ypos = "e.contentY";
} else if(is.ie4) {
    doc = "document.all";
    sty = ".style";
    htm = ""
    xpos = "event.x";
    ypos = "event.y";
}


/* BEGIN Flash Defaults and Supporting Function(s) */

/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
 
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
 

var flashHeight = 0;
var flashWidth = 0;
var flashVars = {
	autostart: 'true',
	themeColor: '0066dd',
	mode: 'sidebyside',
	scaleMode: 'stretch',
	frameColor: '333333',
	fontColor: 'cccccc',
	link: '',
	embed: '',
	enableFullscreen: _fullScreen
};
var flashParams = {allowFullScreen: 'true', scaleMode: 'fit'};
var flashAttributes = {id: 'lyMedia',name: 'lyMedia'};

/* END Flash Defaults and Supporting Function(s) */

function getObjectRef(objectName,subcontainer,container){

	if(document.all)
		return eval("document.all." + objectName);
		
	if (document.implementation &&document.implementation.hasFeature && document.implementation.hasFeature("html", "1.0")) 
		return document.getElementById(objectName);

	if(objectName.substring(0,2) == "ly")
		return eval("document['" + objectName + "']");

	
	if(objectName == "mmMedia")
		return eval("getObjectRef('lyMedia').document.embeds['mmMedia']");

	if(objectName == "imLoading")
		return eval("document['lySplash'].document.imLoading");
		
	if(objectName == "imLoadingBar")
		return eval("document['lySplash'].document.imLoadingBar");	
		
	if(objectName == "imRew")
		return eval("document['lyRew'].document.imRew");
		
	if(objectName == "imFfw")
		return eval("document['lyFfw'].document.imFfw");
	
	if(objectName == "imStop")
		return eval("document['lyStop'].document.imStop");
	
	if(objectName == "imPause")
		return eval("document['lyPause'].document.imPause");
	
	if(objectName == "imPlay")
		return eval("document['lyPlay'].document.imPlay");
		
	if(objectName == "imPrevSlide")
		return eval("document['lyPrevSlide'].document.imPrevSlide");
		
	if(objectName == "imNextSlide")
		return eval("document['lyNextSlide'].document.imNextSlide");
		
	if(objectName == "imFlag")
		return eval("getObjectRef('lyFlag').document.imFlag");
	
	if(objectName == "inSlideList")
		return eval("getObjectRef('lySlideList').document.forms[0]");	
	
	if(objectName == "inCurrentSlide")
		return eval("getObjectRef('inSlideList').elements[0]");
		
	if(objectName == "imSlide")
		return eval("document['lySlide'].document.images[0]");
		
	if(objectName == "imTracker")
		return eval("document['lyTracker'].document.images[0]");
		
	if(objectName == "imPlayerIcon")
		return eval("document['lySwitchMedia'].document.images[0]");
		
	if(container != null && subcontainer != null)
		return eval("document['"+subcontainer+"'].document."+container+".document."+objectName);
		
	if(subcontainer != null)
		return eval("document['"+subcontainer+"'].document."+objectName);
	
	writeDebug("Cant Find " + objectName);
	
		
}

function getObjectStyleRef(objectName){

	var theObj = null;
	if (typeof objectName == "string"){
		if(is.ns4)
			theObj = getObjectRef(objectName);
		else
			theObj = getObjectRef(objectName).style;
	}else{
		if(is.ns4)
			theObj = objectName;
		else
			theObj = objectName.style;
	}
		
	return theObj;
}


function allLoaded(){

	var passed = true;

	if(playerAbility && currentPlayer != "flash") //TODO: FIX THIS
		passed = (passed && getObjectRef("lyMedia") !=null && getObjectRef("mmMedia") !=null);
	
	errorCount = 0;
	allsystemsgo = passed;

	if(!allsystemsgo && errorCount<5) 
		setTimeout("allLoaded();",1000);
	else if(errorCount > 4){
		if(currentPlayer == "wmp"){
			writeMedia('real');
			currentPlayer='real';
			errorCount=0;
			setTimeout("allLoaded();",1000);
		}else{
			writeMedia('wmp');
			currentPlayer='wmp';
			errorCount=0;
			setTimeout("allLoaded();",1000);
		}
	} 
	
}

function swapImage(imageName, imageFile){
	
	if((tmpImage = imageLookup[imageFile]) != null){
		
		getObjectRef(imageName).src = imageData[tmpImage].src;
		
	}else{
	
		writeDebug('swapImage: Did not find in cache ' + imageFile);
		getObjectRef(imageName).src = imageFile;
		
	};
	
}

function masterLoop(){
	
	masterLoopTimerLength = 900;
	
	if(isFfw || isRew)
		masterLoopTimerLength = 300;
		
	loopTimerID = setTimeout("masterLoop();",masterLoopTimerLength);
	loopCount = loopCount + 1;
	
	
	if(allsystemsgo) { 
		
		//We always want to poll the player and update the clock
		checkPlayer();
	    position = getPlayerPosition();
	    
		if(!isFfw && !isRew){
	    	if (currentPlayer == "real" || currentPlayer == "qt") { nextposition = position / 1000; } else { nextposition = position; }
	  	}

		// Display the status or the clock
		if (!(!document.getElementById('mmMediaPlayer'))) {
			if((mmMediaPlayer.playState >= 3 && mmMediaPlayer.playState <= 5))
				displayTime(mmMediaPlayer.controls.currentPositionString);
			else {
	        	displayText(reportState());
			}
		} else {
			if((isPlaying() && !isBuffering()) || isFfw || isRew)
				//if(isPlaying() || isFfw || isRew))
				displayTime(nextposition);
			else{
				text = reportState();
	        	displayText(text);
			}
		}
		
		if (isFfw || isRew){
			if (!(!document.getElementById('mmMediaPlayer'))) {
				var currPosStr = new Array();
				currPosStr = mmMediaPlayer.controls.currentPositionString.split(':');
				nextposition = mmMediaPlayer.controls.currentPosition; //changed TWS - 04/17/09
				
				if (isFfw && mmMediaPlayer.playState != 4) {
					// player.controls.fastForward appears to be NOT working, faking it...
	            	if(scanSpeed < maxScanSpeed)
						scanSpeed = scanSpeed + scanSpeedInc;
		            	//audioSet(nextposition+scanSpeed);
						nextposition+=scanSpeed;
						audioSet(nextposition);
				}
				
				if (isRew && mmMediaPlayer.playState != 5) {
					// player.controls.fastReverse appears to be NOT working, faking it...
					if(scanSpeed < maxScanSpeed)
						scanSpeed = scanSpeed + scanSpeedInc;
	           		    // Fast Rewind 30 seconds.
						audioSet(nextposition);
	            	if (nextposition > scanSpeed) {
	               		//audioSet(nextposition-scanSpeed);
						nextposition-=scanSpeed;
						audioSet(nextposition);
	            	} else {
	                	audioSet(.1);
						stopPressed();
						// stop.
	            	}
				}
				
			} else {
	        	if (isFfw) {
	            	if(scanSpeed < maxScanSpeed)
						scanSpeed = scanSpeed + scanSpeedInc;
		            	//audioSet(nextposition+scanSpeed);
						nextposition+=scanSpeed;
	       		} else {
					if(scanSpeed < maxScanSpeed)
						scanSpeed = scanSpeed + scanSpeedInc;
	           		 // Fast Rewind 30 seconds.
	            	if (nextposition > scanSpeed) {
	               		//audioSet(nextposition-scanSpeed);
						nextposition-=scanSpeed;
						
	            	} else {
	                	audioSet(.1);
						stopPressed();
						// stop.
	            	}
	        	}
			}
    	} else {
			scanSpeed = 0;		
		}
		
		
		if(archiveStatus==0)
			pushCheckSlide();
			
		if(slideControl=="sync")
			syncCheckSlide();
			
		if(captionTimes.length)
			checkCaption()
		
		customInterfaceOnTick();
		customOnTick();
		
	}
	var dtimer = new Date();
	
	if(!(loopCount%(60*waitTime)) && trackFlag){
		
		if(seenStreamPush)
			getObjectRef('imTracker').src = trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+loopCount + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=1" + "&q=" + dtimer.getTime() + "&pm=1";
		else
			getObjectRef('imTracker').src = trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+loopCount + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=1" + "&q=" + dtimer.getTime() + "&pm=0";
		
		writeDebug(trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+loopCount + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=1" + "&q=" + dtimer.getTime());
		writeDebug("Tracking User");
	}

	// archive-event, can-talk to player
	if(!(loopCount%10) && postTrackFlag && isPlaying() && !isBuffering() && !isFfw && !isRew){
		if(nextposition / (postWaitTime * 60)>=1){
		
	    	if(parseInt(nextposition / (postWaitTime * 60)) != currentZone){
				currentZone = parseInt(nextposition / (postWaitTime * 60));
				getObjectRef('imTracker').src = trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=0" + "&q=" + dtimer.getTime();
				writeDebug(trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=0" + "&q=" + dtimer.getTime());
				writeDebug("Post Tracking User... in zone: " + currentZone);
			}
		
		} else {
		
			//What to do?  Do we want to track users at time 0???? -- Setting now to track users at 10 seconds!
			if(nextposition > 10){
		
				if(0 != currentZone){
					currentZone = 0;
					getObjectRef('imTracker').src = trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID+ "&l=0" + "&q=" + dtimer.getTime();
					writeDebug(trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID+ "&l=0" + "&q=" + dtimer.getTime());
					writeDebug("Post Tracking User... in zone*: " + currentZone);
				}
			}
		}
	}
	
	// archive-event, can't talk to player, just report back every postWaitTime minutes
	if(!(loopCount%10) && postTrackFlag && !playerAbility && !trackStarted) {
		trackStarted = true;
		currentZone = 0;
		getObjectRef('imTracker').src = trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=0" + "&q=" + dtimer.getTime();
		writeDebug(trackURL + "?m=" + trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=0" + "&q=" + dtimer.getTime());
		writeDebug("Post Tracking User... cannot determine zone, using duration instead: " + currentZone);
	}
	
	if(!(loopCount%(postWaitTime*60)) && postTrackFlag && !playerAbility) {
		currentZone = Math.ceil(loopCount / (postWaitTime*60));
		getObjectRef('imTracker').src = trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=0" + "&q=" + dtimer.getTime();
		writeDebug(trackURL + "?m=" + trackURL + "?m=" + mediaID + "&u=" + mediaUserID + "&c="+currentZone + "&p=" + currentPlayer + "&i=" + uniqueID + "&r=" + randSessionID + "&l=0" + "&q=" + dtimer.getTime());
		writeDebug("Post Tracking User... cannot determine zone, using duration instead: " + currentZone);
	}
	
	if(!(loopCount%5))
		writeStatus();
		
	if(!(loopCount%6)){
		if((isPlaying() || isBuffering()) && buttonState != "play" && buttonState != "ffw" && buttonState !="rew"){
			buttonState = "play"
			setPlayerButtons();
		} else if(isStopped()  && buttonState != "stop"){
			buttonState = "stop";
			setPlayerButtons();		
		}
	}
}

function checkModKeys(evt) {
	
	var alt = (is.ns) ? evt.modifiers & Event.ALT_MASK : window.event.altKey;
	var ctrl = (is.ns) ? evt.modifiers & Event.CONTROL_MASK : window.event.ctrlKey;
	var shift = (is.ns) ? evt.modifiers & Event.SHIFT_MASK : window.event.shiftKey;

	
	if(ctrl){
		makeCenterPopup("debug.cfm","debug",300,200);
		debug=1;
	}
		
	if(shift){
		makeCenterPopup("remotedebug.cfm","remoteDebug",100,100);
		remoteDebug=1;
	}

	//writeDebug("Tried Key Checking");
	
	return false;

}


// <debug>

function writeStatus(){
	if(debug && !debugWindow.closed){
		statusString = ":" + loopCount + " Loaded: "+allsystemsgo+" Slide: "+slide + " State: " +playerState + "<BR><HR noshade size=1>";
		
		if(remoteDebug)
			writeDebug(statusString);
			
		if(is.ns4){
			if(debugWindow.document != null && debugWindow.document['statusLayer'] !=null){
				debugWindow.document['statusLayer'].document.write(statusString);
				debugWindow.document['statusLayer'].document.close();
			}
		} else if(is.ie) {
		
			debugWindow.document.all.statusLayer.innerHTML = statusString;
		
		} else if(document.implementation &&document.implementation.hasFeature && document.implementation.hasFeature("html", "1.0")){
			// asuming ns6....
			
			debugWindow.document.getElementById('statusLayer').innerHTML = statusString;
		} else {
			alert("can't debug w/this browser...");
		}
	}

}

function writeDebug(text){

	if((debug && debugWindow && !debugWindow.closed) || remoteDebug)
		debugString = ":" + loopCount + " " + text + "\n<BR>" + debugString;

	if(debug && debugWindow && !debugWindow.closed){
		if(is.ns4){
			if(debugWindow.document != null && debugWindow.document['debugLayer'] !=null){
				debugWindow.document['debugLayer'].document.write(debugString);
				debugWindow.document['debugLayer'].document.close();
			}
		} else if(is.ie) {
		
			debugWindow.document.all.debugLayer.innerHTML = debugString;
		
		} else if(document.implementation &&document.implementation.hasFeature && document.implementation.hasFeature("html", "1.0")){
			// asuming ns6....
			
			debugWindow.document.getElementById('debugLayer').innerHTML = debugString;
		} else {
			alert("can't debug w/this browser...");
		}
	}

}

function makeCenterPopup(file, name, w, h){
	var xPos, yPos;
	var winProp;	
	
	xPos = (screen.width/2)-(w/2);
	yPos = (screen.height/2)-(h/2);
	
	winProp = "width=" + w + ",height=" + h + ",left=" + xPos + ",top=" + yPos +",scrollbars=1,resizable=1,status=0";

	if(name == 'debug')
		debugWindow = window.open(file, name, winProp);	
	else
		remoteDebugWindow = window.open(file, name, winProp);	
		
	if(name == 'debug' && debugWindow && debugWindow.moveTo)
		debugWindow.moveTo(0,0);
	
	if(debugWindow)
		debugWindow.focus();
	window.focus();
}

// </debug>

// <layercontrols>

function writeToLayer(layerName, text){

	if(is.ns4){
		getObjectRef(layerName).document.write(text);
		getObjectRef(layerName).document.close();
	} else {
		getObjectRef(layerName).innerHTML = text;
	}
	
}


function changeFrame(newUrl) {
	writeDebug("Writing to Inline Frame: " + newUrl);

	if(document.elCont == null){
		getObjectRef("lyIFrame").innerHTML="<iframe src='" + newUrl + "' name='lyFloatingFrame' height="+initLyIFrame[3]+" width="+initLyIFrame[2]+" marginwidth='10' marginheight='10' frameborder='0'></iframe>"; 
	}else if(document.elCont == null && is.mac){
		getObjectRef("lyFloatingFrame").src=newUrl;
	} else {
		elMain.load(newUrl,initLyIFrame[2]-40);
	}

}

function writeMedia(whichMedia){

	allsystemsgo=false;
	writeDebug("Writing Media: " + whichMedia); 

	if(is.ie && !is.mac){
		// IE (non-mac) uses different HTML code to embed players
		if(whichMedia=="real"){
			buffer="";
			buffer = buffer + "\n<OBJ" + "ECT name=\"mmMedia\" class" + "id=\"cls" + "id:" + "CFCDAA03" + "-8BE4" + "-11cf" + "-B84B" + "-0020AFBBCCFA\" ";
			if(compatibilityCheck('real') != 3){
				buffer = buffer + "\n	height=\"" + initLyNoMedia[3] + "\"";
				buffer = buffer + "\n	width=\"" + initLyNoMedia[2] + "\">";
			}else{
				buffer = buffer + "\n	height=\"" + initLyMedia[3] + "\"";
				buffer = buffer + "\n	width=\"" + initLyMedia[2] + "\">";
			}
			buffer = buffer + "\n<PARAM NAME=\"AUTOSTART\" VALUE=\"1\">";
			buffer = buffer + "\n<PARAM NAME=\"NOLABELS\" VALUE=\"1\">";
			buffer = buffer + "\n<PARAM NAME=\"SRC\" VALUE=\""+ realPathString +"\">";
			
			if(compatibilityCheck('real') != 3)
				buffer = buffer + "\n<PARAM NAME=\"CONTROLS\" VALUE=\"All\">";
			else
				buffer = buffer + "\n<PARAM NAME=\"CONTROLS\" VALUE=\"ImageWindow\">";
				
			buffer = buffer + "\n<PARAM NAME=\"CONSOLE\" VALUE=\"one\">";
			buffer = buffer + "\n<PARAM NAME=\"CENTER\" VALUE=\"0\">";
			buffer = buffer + "\n<PARAM Name =\"NOJAVA\" Value=\"1\"> ";
	      		buffer = buffer + "\n</OB" + "JECT>";
			writeToLayer("lyMedia",buffer);
			
		}else if(whichMedia=="wmp"){
		
			// Commenting out the old "wmp" writeMedia() section (DOF 2011.04.28)
			
			/*
			buffer = ""
			buffer += "\n<obj" + "ect name=\"mmMedia\" id=\"mmMediaPlayer\" class" + "id=\"cls" + "id:" + "6BF52A52" + "-394A" + "-11D3" + "-B153" + "-00C04F79FAA6\" ";
			buffer = buffer + "\n	standby=\"Loading Microsoft Windows Media Player components...\" ";
			buffer = buffer + "\n	type=\"application/x-oleobject\"  ";
			
			if(compatibilityCheck('wmp') != 3)
				buffer = buffer + "\n	Width=" +initLyNoMedia[2] + " Height=" + initLyNoMedia[3] + ">";
			else
				buffer = buffer + "\n	Width=" + initLyMedia[2] + " Height=" + initLyMedia[3] + ">";
				
			buffer = buffer + "\n<PARAM NAME=\"url\" VALUE=\""+ wmpPathString +"\" />";
			buffer = buffer + "\n<PARAM NAME=\"AutoStart\" VALUE=\"TRUE\" />";
			buffer = buffer + "\n<PARAM NAME=\"AutoSize\" VALUE=\"FALSE\" />";
			buffer = buffer + "\n<PARAM NAME=\"StretchToFit\" VALUE=\"TRUE\" />";
			
			if(compatibilityCheck('wmp') != 3)
				buffer = buffer + "\n<PARAM NAME=\"uiMode\" VALUE=\"full\" />";
			else
				buffer = buffer + "\n<PARAM NAME=\"uiMode\" VALUE=\"none\" />";

			buffer = buffer + "\n<PARAM NAME=\"ShowStatusBar\" Value=\"false\" />";
			buffer = buffer + "\n</ob" + "ject>";
			writeDebug(wmpPathString);
			writeDebug("Width=" +initLyNoMedia[2] + " Height=" + initLyNoMedia[3]);
			writeToLayer("lyMedia",buffer);
			mmMediaPlayer.URL = wmpPathString;
			mmMediaPlayer.controls.play();
			*/
	 
 			/*
			// Use the code from the FF "wmp" writeMedia() section (DOF 2011.04.28)
			buffer = "";
			buffer = buffer + "\n<embed type=\"video/x-ms-asf-plugin\" ";
			buffer = buffer + "\n	pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\" ";
			buffer = buffer + "\n	src=\""+wmpPathString+"\" ";
			buffer = buffer + "\n	AnimationatStart=\"0\" ";
			buffer = buffer + "\n	Name=\"mmMedia\" ";
			buffer = buffer + "\n	id=\"mmMedia\"";
			buffer = buffer + "\n	autostart=\"TRUE\" ";
			buffer = buffer + "\n	AutoSize=\"FALSE\" ";
			buffer = buffer + "\n	StretchToFit=\"1\" ";
			
			buffer = buffer + "\n	ShowControls=\"1\" ";
			
			buffer = buffer + "\n	ShowDisplay=\"0\" ";
			buffer = buffer + "\n	ShowStatusBar=\"1\" ";
			var iHeight = initLyNoMedia[3] + 5;
			buffer = buffer + "\n	Width=\"" + initLyNoMedia[2] + "\" Height=\"" + iHeight + "\">";
			
			writeToLayer("lyMedia",buffer);	
 		*/
	
			buffer = ""
			buffer += "\n<obj" + "ect name=\"mmMedia\" id=\"mmMediaPlayer\" class" + "id=\"cls" + "id:" + "6BF52A52" + "-394A" + "-11D3" + "-B153" + "-00C04F79FAA6\" ";
			buffer = buffer + "\n	standby=\"Loading Microsoft Windows Media Player components...\" ";
			buffer = buffer + "\n	type=\"application/x-oleobject\"  ";
			var iHeight = initLyNoMedia[3];
			if(eventType.toLowerCase().indexOf("audio") != -1) {
		 	   buffer = buffer + "\n	style=\"position: absolute; top: -17px;\"  ";
  			   iHeight += 17;
		 	}
				buffer = buffer + "\n	Width=" +initLyNoMedia[2] + " Height=" + iHeight + ">";
		 	
			buffer = buffer + "\n<PARAM NAME=\"url\" VALUE=\""+ wmpPathString +"\" />";
			buffer = buffer + "\n<PARAM NAME=\"AutoStart\" VALUE=\"TRUE\" />";
			buffer = buffer + "\n<PARAM NAME=\"AutoSize\" VALUE=\"FALSE\" />";
			buffer = buffer + "\n<PARAM NAME=\"StretchToFit\" VALUE=\"false\" />";
			
		 
				buffer = buffer + "\n<PARAM NAME=\"uiMode\" VALUE=\"full\" />";
		 
			buffer = buffer + "\n<PARAM NAME=\"ShowStatusBar\" Value=\"true\" />";
			buffer = buffer + "\n</ob" + "ject>";
 

			writeToLayer("lyMedia",buffer);
			mmMediaPlayer.URL = wmpPathString;
			mmMediaPlayer.controls.play();		
			 
		} else if(whichMedia=="qt"){
		
			buffer="";
			buffer+="<OBJ" + "ECT class" + "id=\"cls" + "id:" + "02BF25D5" + "-8C17" + "-4B23" + "-BC80" + "-D3488ABDDC6B\" ";
            buffer+="codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\"  ";
			if(compatibilityCheck('qt') != 3)
				buffer = buffer + "\n	Width=" +initLyNoMedia[2] + " Height=" + initLyNoMedia[3] + ">";
			else
				buffer = buffer + "\n	Width=" + initLyMedia[2] + " Height=" + initLyMedia[3] + ">";
            buffer+="id=\"mmMedia\" name=\"mmMedia\">  ";
            buffer+="\n<PARAM name=\"src\" value=\"" + qtPathString + "\">  ";
			buffer+="\n<PARAM NAME=\"AUTOPLAY\" VALUE=\"TRUE\"> ";
			buffer+="\n<PARAM NAME=\"ENABLEJAVASCRIPT\" VALUE=\"TRUE\"> ";
			if(compatibilityCheck('qt') != 3)
				buffer+="\n<PARAM NAME=\"CONTROLLER\" VALUE=\"TRUE\"> ";
			else
				buffer+="\n<PARAM NAME=\"CONTROLLER\" VALUE=\"FALSE\"> ";
			buffer+="\n</OBJ" + "ECT>  ";
			//alert(buffer);
			writeToLayer("lyMedia",buffer);
	
		
		} else if(whichMedia=="flash") {
			
			embedFlash();
			
		} else {
			buffer= " ";
			writeToLayer("lyMedia",buffer);
			allsystemsgo=true;
			playerAbility=false;
			return
		}
	} else {
		// is not IE or is Mac
		if(whichMedia=="real"){
			buffer = "";
		    buffer = buffer + "\n<em" + "bed name=\"mmMedia\" id=\"mmMedia\"";
			buffer = buffer + "\n	SRC=\""+realPathString+"\" ";
			buffer = buffer + "\n	type=\"audio/x-pn-realaudio-plugin\" ";
			
			if(compatibilityCheck('real') != 3){
				if(initLyNoMedia[3] < 50)
					buffer = buffer + "\n	ALIGN=\"center\" WIDTH=\"" + initLyNoMedia[2] + "\" HEIGHT=\"" + initLyNoMedia[3] + "\" CONSOLE=\"one\" CONTROLS=\"ControlPanel\" ";
				else
					buffer = buffer + "\n	ALIGN=\"center\" WIDTH=\"" + initLyNoMedia[2] + "\" HEIGHT=\"" + initLyNoMedia[3] + "\" CONSOLE=\"one\" CONTROLS=\"ImageWindow,ControlPanel\" ";
			
			} else
				buffer = buffer + "\n	ALIGN=\"center\" WIDTH=\"" + initLyMedia[2] + "\" HEIGHT=\"" + initLyMedia[3] + "\" CONSOLE=\"one\" CONTROLS=\"ImageWindow\" ";
				
			buffer = buffer + "\n	AUTOSTART=\"TRUE\"";
			buffer = buffer + "\n	AUTOSIZE=\"FALSE\"";
			buffer = buffer + "\n	STRETCHTOFIT=\"TRUE\"";
			buffer = buffer + "\n	pluginsurl=\"http://www.real.com/products/player/index.html\"";
			buffer = buffer + "\n	pluginspage=\"http://www.real.com/products/player/index.html\">";
			writeToLayer("lyMedia",buffer);
	
		}else if(whichMedia=="wmp"){
		
			
			if(0){
				writeToLayer("lyMedia","sorry don't support");
			} else {
				//alert('wrote1');
				buffer = "";
				buffer = buffer + "\n<embed type=\"video/x-ms-asf-plugin\" ";
				buffer = buffer + "\n	pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\" ";
				buffer = buffer + "\n	src=\""+wmpPathString+"\" ";
				
				var iHeight = initLyNoMedia[3]
				if(eventType.toLowerCase().indexOf("audio") != -1) {
					buffer = buffer + "\n	style=\"position: absolute; top: -17px;\" ";
				}
				
				buffer = buffer + "\n	AnimationatStart=\"0\" ";
				buffer = buffer + "\n	Name=\"mmMedia\" ";
				buffer = buffer + "\n	id=\"mmMedia\"";
				buffer = buffer + "\n	autostart=\"TRUE\" ";
				buffer = buffer + "\n	AutoSize=\"FALSE\" ";
				buffer = buffer + "\n	StretchToFit=\"1\" ";
				if(compatibilityCheck('wmp') != 3)
					buffer = buffer + "\n	ShowControls=\"1\" ";
				else
					buffer = buffer + "\n	ShowControls=\"0\" ";
				
				buffer = buffer + "\n	ShowDisplay=\"0\" ";
				buffer = buffer + "\n	ShowStatusBar=\"0\" ";
				if(compatibilityCheck('wmp') != 3) {
				
					if(eventType.toLowerCase().indexOf("audio") != -1) {
						iHeight += 17;
					}
					buffer = buffer + "\n	Width=\"" + initLyNoMedia[2] + "\" Height=\"" + iHeight + "\">";
				 
				} else {					
					if((is.safari) || (browser == "firefox")) {
						// If it is safari or ff, extend the video area over where the custom IE controls would be
						//initLyMedia[3] += 45;
					}
					buffer = buffer + "\n	Width=\"" + initLyMedia[2] + "\" Height=\"" + initLyMedia[3] + "\">";
				
				}
				
			 	
				writeToLayer("lyMedia",buffer);		
				if(is.mac && is.ns4){
					//setLayerHide("lyMedia");
					//setLayerZIndex("lyMedia",0);
					getObjectRef("lyMedia").moveTo(800,800);
					writeDebug("Mac-NS4 fix");
				}
				//alert('wrote');
			}
		} else if(whichMedia=="qt"){
		
		
			buffer = "";
		 	buffer += "<EMB" + "ED ";
            buffer += "src=\"" + qtPathString + "\" ";
            buffer += "\nname=\"mmMedia\" ";
			buffer += "\nid=\"mmMedia\" ";
			if(compatibilityCheck('qt') != 3)
				buffer = buffer + "\n	Width=\"" + initLyNoMedia[2] + "\" Height=\"" + initLyNoMedia[3] + "\" ";
			else
				buffer = buffer + "\n	Width=\"" + initLyMedia[2] + "\" Height=\"" + initLyMedia[3] + "\" ";
			if(compatibilityCheck('qt') != 3)
				buffer+="\n CONTROLLER\=TRUE ";
			else
				buffer+="\n CONTROLLER\=FALSE ";
            buffer += "\nenablejavascript=\"true\"> ";
            buffer += "\n</EMBED> ";
			writeToLayer("lyMedia",buffer);

		} else if(whichMedia=="flash") {
			
			embedFlash();
			
		} else {
			buffer= " ";
			writeToLayer("lyMedia",buffer);
			allsystemsgo=true;
			playerAbility=false;
			return
		
		}
		
		
	}
	
	swapImage('imPlayerIcon',buttonDir+currentPlayer+'icon.gif')
	allLoaded();
}

function embedFlash() {
	 		
	//flashHeight = eval(parseInt(initLyMedia[3]) + parseInt(initLyCustom6[3]));
	jQuery("#lyMedia").css("visibility", "hidden");
	flashWidth = eval(parseInt(initLyMedia[2]));
	if(eventType.toLowerCase().indexOf("audio") == -1) {
		// Make the height the correct size for the video
		flashHeight = eval(parseInt(initLyMedia[3]) + 45);	
	} else {
		// Make the height the correctly sized for the player control bar only
		flashHeight = 45;	
		 
		// Move the flash player to the correct position
		var controlMediaTop = parseInt( jQuery("#lyCustom6").css("top") );		
		jQuery("#lyMedia").css("top", controlMediaTop) 
	 
	
	}
	 
	jQuery("#lyMedia").width(flashWidth);
	jQuery("#lyMedia").height(flashHeight);
	 
	flashVars.src = escape(flashPathString);
	
	if(flashPathString.length > 0 ) {
		
		swfobject.embedSWF('flash/AkamaiFlashPlayer.swf', 'lyMedia', flashWidth, flashHeight, '9.0.0', 'expressInstall.swf', flashVars, flashParams, flashAttributes);
	} else {
		alert("Flash media stream src is invalid.\n\n--> " + flashPathString);
	}
	if(is.ie) {
		 
		setTimeout(fixFlashForIE, 1000)
	}
		
	if(jQuery.browser.safari) {
		
		setTimeout(fixFlashForSafari, 1000)
		
	} 
}

// IE needs this function run AFTER everythying else
function fixFlashForIE() {
	// Fix player position in FF when audio only
	if((eventType.toLowerCase().indexOf("audio") != -1)) { 
		var controlMediaTop = parseInt( jQuery("#lyCustom6").css("top") );	
		var controlMediaLeft = parseInt( jQuery("#lyCustom6").css("left") );				
		jQuery("#lyMedia").css("top", controlMediaTop);
		jQuery("#lyMedia").css("left", controlMediaLeft);
	}
	
	// Fix for "Google 16x9" skin
	if(buttonDir.indexOf("161") != -1) {
		jQuery("#lyMedia").css("left", 14);
		jQuery("#lyMedia").css("top", 301);
	}
	
}

// Safari needs this function run AFTER everythying else
function fixFlashForSafari() {
	// Fix player position in FF when audio only
	if((eventType.toLowerCase().indexOf("audio") != -1)) { 
		var controlMediaTop = parseInt( jQuery("#lyCustom6").css("top") );	
		var controlMediaLeft = parseInt( jQuery("#lyCustom6").css("left") );				
		jQuery("#lyMedia").css("top", controlMediaTop);
		jQuery("#lyMedia").css("left", controlMediaLeft);
	} 
		 
} 


function getLayerLeft(theLayer){
	var myLayer = getObjectStyleRef(theLayer)
	if (is.ns4) {
		return myLayer.left;
	} else if (is.ie)  {
		return myLayer.pixelLeft;
	} else  {
		return parseInt(myLayer.left);
	}
}

function getLayerTop(theLayer){
	var myLayer = getObjectStyleRef(theLayer);
	
	if (is.ns4) {
		return myLayer.top;
	} else if (is.ie)  {
		return parseInt(myLayer.pixelTop);
	} else  {
		return parseInt(myLayer.top);
	}

}


function setLayerLeft(theLayer,l){
	var myLayer = getObjectStyleRef(theLayer);
	if (is.ns4)	{
		//writeDebug("theLayer:  " + 	theLayer);
		myLayer.left = l
	} else if (is.ie)	{
		myLayer.pixelLeft = l
	} else  {
    	myLayer.left = l + "px"
  	}

}

function setLayerTop(theLayer,t){
	myLayer = null;
	
	if(document.elCont != null && theLayer=='lyIFrame')	
		myLayer = document.elCont;
	else
		myLayer = getObjectStyleRef(theLayer);
		
	if (is.ns4)	{
		myLayer.top = t
	} else if (is.ie)	{
		myLayer.pixelTop = t
	} else  {
    	myLayer.top = t + "px"
  	}

}

function setLayerClip(theLayer,top,right,bottom,left){
	
	if(is.ns4){
		getObjectStyleRef(theLayer).clip.right = right;
   		getObjectStyleRef(theLayer).clip.bottom = bottom;
		getObjectStyleRef(theLayer).clip.top = top;
		getObjectStyleRef(theLayer).clip.left = left;
	} else {
		getObjectStyleRef(theLayer).clip = "rect(" + top + " " + right + " " + bottom + " " + left + ")";

	}
}


function setLayerVisible(theLayer) {
	//writeDebug("Showing "+theLayer);
	
	theObj = null;
	
	if(document.elCont != null && theLayer=='lyIFrame'){	
		//theObj = document.elCont;
		theObj = document.elCont;
		writeDebug("elCont visibility: " + theObj.visibility);
		theObj.visibility = "visible";
		document.elCont.document.elMain.visibility = "visible";
		document.elCont.document.elScroll.visibility = "visible";
		document.elCont.document.elScroll.document.elBGcol.visibility = "visible";
		document.elCont.document.elScroll.document.elBG.visibility = "visible";
		document.elCont.document.elScroll.document.elThumb.visibility = "visible";
		document.elCont.document.elScroll.document.elThumb.document.elThumbBot.visibility = "visible";
		document.elCont.document.elScroll.document.elButtonBot.visibility = "visible";
		//scrollerObject.refresh();
	} else {
		theObj = getObjectStyleRef(theLayer);
		theObj.visibility = "visible";
	}
	
	
}

function setLayerHide(theLayer) {
	//writeDebug("Hiding "+theLayer);
	
	
	if(document.elCont != null && theLayer=='lyIFrame'){	
		//theObj = document.elCont;
		//scrollerObject.refresh();
		theObj = document.elCont;
		document.elCont.document.elMain.visibility = "hidden";
		document.elCont.document.elScroll.visibility = "hidden";
		document.elCont.document.elScroll.document.elBGcol.visibility = "hidden";
		document.elCont.document.elScroll.document.elBG.visibility = "hidden";
		document.elCont.document.elScroll.document.elThumb.visibility = "hidden";
		document.elCont.document.elScroll.document.elThumb.document.elThumbBot.visibility = "hidden";
		document.elCont.document.elScroll.document.elButtonBot.visibility = "hidden";
	} else {
		theObj = getObjectStyleRef(theLayer);
	}
	theObj.visibility = "hidden";
}

function setLayerZIndex(theLayer, z) {
	theObj = null;
	if(document.elCont != null && theLayer=='lyIFrame'){	
		//theObj = document.elCont;
		theObj = document.elCont;
		writeDebug("elCont zIndex: " + theObj.zIndex);
		
		//scrollerObject.refresh();
	} else {
		theObj = getObjectStyleRef(theLayer)
	}
	theObj.zIndex = z;
}

function getLayerZIndex(theLayer)	{
	var theObj = getObjectStyleRef(theLayer);
	return theObj.zIndex;
}

function setLayerHeight(theLayer,newHeight)	{
	var theObj = getObjectStyleRef(theLayer);
	writeDebug('height: ' + theObj.height);
	theObj.height=newHeight;
}

function setLayerTo(theLayer,left,top,height,width,zindex,visible){
		
	setLayerLeft(theLayer,left);
	setLayerTop(theLayer,top);
	//if(height > 0 && width > 0)
	//	setLayerClip(theLayer,top,width,height,left);
	
	setLayerZIndex(theLayer,zindex);
	
	
	if(visible)
		setLayerVisible(theLayer);
	else
		setLayerHide(theLayer);
		
	
}

function resetLayers(){

	//alert("" + initLyFlag[0] + " "  + initLyFlag[1]);
	
	setLayerTo("lyFlag",initLyFlag[0],initLyFlag[1],initLyFlag[2],initLyFlag[3],initLyFlag[4],initLyFlag[5]);
	setLayerTo("lyTracker",initLyTracker[0],initLyTracker[1],initLyTracker[2],initLyTracker[3],initLyTracker[4],initLyTracker[5]);
	setLayerTo("lySlide",initLySlide[0],initLySlide[1],initLySlide[2],initLySlide[3],initLySlide[4],initLySlide[5]);
 
	
	if((compatibilityCheck(currentPlayer) == 3) && (browser != "firefox")) {
		/*
		setLayerTo("lyMedia",initLyMedia[0],initLyMedia[1],initLyMedia[2],initLyMedia[3],initLyMedia[4],initLyMedia[5]);
		setLayerTo("lyRew",initLyRew[0],initLyRew[1],initLyRew[2],initLyRew[3],initLyRew[4],initLyRew[5]);
		setLayerTo("lyFfw",initLyFfw[0],initLyFfw[1],initLyFfw[2],initLyFfw[3],initLyFfw[4],initLyFfw[5]);
		setLayerTo("lyStop",initLyStop[0],initLyStop[1],initLyStop[2],initLyStop[3],initLyStop[4],initLyStop[5]);
		setLayerTo("lyPause",initLyPause[0],initLyPause[1],initLyPause[2],initLyPause[3],initLyPause[4],initLyPause[5]);
		setLayerTo("lyPlay",initLyPlay[0],initLyPlay[1],initLyPlay[2],initLyPlay[3],initLyPlay[4],initLyPlay[5]);
		setLayerTo("lyStatus",initLyStatus[0],initLyStatus[1],initLyStatus[2],initLyStatus[3],initLyStatus[4],initLyStatus[5]);
		*/
		
		// Hide all custom media controls DIVs disappear... (DOF 2011.04.27)
		setLayerTo("lyMedia",initLyNoMedia[0],initLyNoMedia[1],initLyNoMedia[2],initLyNoMedia[3],initLyNoMedia[4],initLyNoMedia[5]);
		setLayerTo("lyRew",initLyRew[0],initLyRew[1],initLyRew[2],initLyRew[3],initLyRew[4],0);
		setLayerTo("lyFfw",initLyFfw[0],initLyFfw[1],initLyFfw[2],initLyFfw[3],initLyFfw[4],0);
		setLayerTo("lyStop",initLyStop[0],initLyStop[1],initLyStop[2],initLyStop[3],initLyStop[4],0);
		setLayerTo("lyPause",initLyPause[0],initLyPause[1],initLyPause[2],initLyPause[3],initLyPause[4],0);
		setLayerTo("lyPlay",initLyPlay[0],initLyPlay[1],initLyPlay[2],initLyPlay[3],initLyPlay[4],0);
		setLayerTo("lyStatus",initLyStatus[0],initLyStatus[1],initLyStatus[2],initLyStatus[3],initLyStatus[4],0);
		
	} else {
		setLayerTo("lyMedia",initLyNoMedia[0],initLyNoMedia[1],initLyNoMedia[2],initLyNoMedia[3],initLyNoMedia[4],initLyNoMedia[5]);
		setLayerTo("lyRew",initLyRew[0],initLyRew[1],initLyRew[2],initLyRew[3],initLyRew[4],0);
		setLayerTo("lyFfw",initLyFfw[0],initLyFfw[1],initLyFfw[2],initLyFfw[3],initLyFfw[4],0);
		setLayerTo("lyStop",initLyStop[0],initLyStop[1],initLyStop[2],initLyStop[3],initLyStop[4],0);
		setLayerTo("lyPause",initLyPause[0],initLyPause[1],initLyPause[2],initLyPause[3],initLyPause[4],0);
		setLayerTo("lyPlay",initLyPlay[0],initLyPlay[1],initLyPlay[2],initLyPlay[3],initLyPlay[4],0);
		setLayerTo("lyStatus",initLyStatus[0],initLyStatus[1],initLyStatus[2],initLyStatus[3],initLyStatus[4],0);
	}
	
	setLayerTo("lyNextSlide",initLyNextSlide[0],initLyNextSlide[1],initLyNextSlide[2],initLyNextSlide[3],initLyNextSlide[4],initLyNextSlide[5]);
	setLayerTo("lyPrevSlide",initLyPrevSlide[0],initLyPrevSlide[1],initLyPrevSlide[2],initLyPrevSlide[3],initLyPrevSlide[4],initLyPrevSlide[5]);
	setLayerTo("lySlideList",initLySlideList[0],initLySlideList[1],initLySlideList[2],initLySlideList[3],initLySlideList[4],initLySlideList[5]);
	setLayerTo("lyIFrame",initLyIFrame[0],initLyIFrame[1],initLyIFrame[2],initLyIFrame[3],initLyIFrame[4],initLyIFrame[5]);
	setLayerTo("lySplash",initLySplash[0],initLySplash[1],initLySplash[2],initLySplash[3],initLySplash[4],initLySplash[5]);
	setLayerTo("lyClosedCaption",initLyClosedCaption[0],initLyClosedCaption[1],initLyClosedCaption[2],initLyClosedCaption[3],initLyClosedCaption[4],initLyClosedCaption[5]);
	
	streamCount = 0;
	
	if(realPathString.length)
		streamCount++;
	if(wmpPathString.length)
		streamCount++;
	if(qtPathString.length)
		streamCount++;
	if(allowNoAudio)
		streamCount++;
	
	
	if(!is.ns4 && streamCount > 1)
		setLayerTo("lySwitchMedia",initLySwitchMedia[0],initLySwitchMedia[1],initLySwitchMedia[2],initLySwitchMedia[3],initLySwitchMedia[4],initLySwitchMedia[5]);
	else
		setLayerTo("lySwitchMedia",initLySwitchMedia[0],initLySwitchMedia[1],initLySwitchMedia[2],initLySwitchMedia[3],initLySwitchMedia[4],0);
		
	setLayerTo("lyCustom0",initLyCustom0[0],initLyCustom0[1],initLyCustom0[2],initLyCustom0[3],initLyCustom0[4],initLyCustom0[5]);
	setLayerTo("lyCustom1",initLyCustom1[0],initLyCustom1[1],initLyCustom1[2],initLyCustom1[3],initLyCustom1[4],initLyCustom1[5]);
	setLayerTo("lyCustom2",initLyCustom2[0],initLyCustom2[1],initLyCustom2[2],initLyCustom2[3],initLyCustom2[4],initLyCustom2[5]);
	setLayerTo("lyCustom3",initLyCustom3[0],initLyCustom3[1],initLyCustom3[2],initLyCustom3[3],initLyCustom3[4],initLyCustom3[5]);
	setLayerTo("lyCustom4",initLyCustom4[0],initLyCustom4[1],initLyCustom4[2],initLyCustom4[3],initLyCustom4[4],initLyCustom4[5]);
	setLayerTo("lyCustom5",initLyCustom5[0],initLyCustom5[1],initLyCustom5[2],initLyCustom5[3],initLyCustom5[4],initLyCustom5[5]);
	setLayerTo("lyCustom6",initLyCustom6[0],initLyCustom6[1],initLyCustom6[2],initLyCustom6[3],initLyCustom6[4],initLyCustom6[5]);
	setLayerTo("lyCustom7",initLyCustom7[0],initLyCustom7[1],initLyCustom7[2],initLyCustom7[3],initLyCustom7[4],initLyCustom7[5]);
	setLayerTo("lyCustom8",initLyCustom8[0],initLyCustom8[1],initLyCustom8[2],initLyCustom8[3],initLyCustom8[4],initLyCustom8[5]);
	setLayerTo("lyCustom9",initLyCustom9[0],initLyCustom9[1],initLyCustom9[2],initLyCustom9[3],initLyCustom9[4],initLyCustom9[5]);
	setLayerTo("lyCustom10",initLyCustom10[0],initLyCustom10[1],initLyCustom10[2],initLyCustom10[3],initLyCustom10[4],initLyCustom10[5]);
	setLayerTo("lyCustom11",initLyCustom11[0],initLyCustom11[1],initLyCustom11[2],initLyCustom11[3],initLyCustom11[4],initLyCustom11[5]);
	setLayerTo("lyCustom12",initLyCustom12[0],initLyCustom12[1],initLyCustom12[2],initLyCustom12[3],initLyCustom12[4],initLyCustom12[5]);
	setLayerTo("lyCustom13",initLyCustom13[0],initLyCustom13[1],initLyCustom13[2],initLyCustom13[3],initLyCustom13[4],initLyCustom13[5]);
	setLayerTo("lyCustom14",initLyCustom14[0],initLyCustom14[1],initLyCustom14[2],initLyCustom14[3],initLyCustom14[4],initLyCustom14[5]);
	setLayerTo("lyCustom15",initLyCustom15[0],initLyCustom15[1],initLyCustom15[2],initLyCustom15[3],initLyCustom15[4],initLyCustom15[5]);
	setLayerTo("lyCustom16",initLyCustom16[0],initLyCustom16[1],initLyCustom16[2],initLyCustom16[3],initLyCustom16[4],initLyCustom16[5]);
	setLayerTo("lyCustom17",initLyCustom17[0],initLyCustom17[1],initLyCustom17[2],initLyCustom17[3],initLyCustom17[4],initLyCustom17[5]);
	setLayerTo("lyCustom18",initLyCustom18[0],initLyCustom18[1],initLyCustom18[2],initLyCustom18[3],initLyCustom18[4],initLyCustom18[5]);
	setLayerTo("lyCustom19",initLyCustom19[0],initLyCustom19[1],initLyCustom19[2],initLyCustom19[3],initLyCustom19[4],initLyCustom19[5]);
	
	setTimeout("centerSlide()",500);
	
	
	// Fix player position in FF when audio only
 
	if((browser != "ie") && (eventType.toLowerCase().indexOf("audio") != -1) && (runNewCode == true)) { 
		var controlMediaTop = parseInt( jQuery("#lyCustom6").css("top") );	
		var controlMediaLeft = parseInt( jQuery("#lyCustom6").css("left") );				
		jQuery("#lyMedia").css("top", controlMediaTop);
		jQuery("#lyMedia").css("left", controlMediaLeft);
	}
	
	jQuery("#lyMedia").css("visibility", "visible");
	 
}



function slideRight(layerName,endPosition){

	setLayerLeft(layerName,getLayerLeft(layerName)+3);

	if(endPosition > getLayerLeft(layerName))
		timeoutID = setTimeout("slideRight('" + layerName + "'," + endPosition + ")", 100);

}

// </layercontrols>

// <playercontrols>

/*------------------------------------------------------------*/
/*---------Player Controls------------------------------------*/


// System Functions
function syncAudio() {

	var starttime = slideTimes[slide-1];
	audioSet(starttime);
}



// Set Audio/Video Position
function audioSet(position) {
 
	if(position < 0)
		position = 0;
		
	writeDebug("Setting Audio to position: " + position);
 
	if((currentPlayer != "flash") && (!playerAbility))
		return false;
		
	if (currentPlayer == "real") {
        if ((playerState == 2) && (getObjectRef("mmMedia").CanPlay() != -1)) {
   			getObjectRef("mmMedia").DoPlay();
       	    getObjectRef("mmMedia").SetPosition(position*1000);
            //if (slideControl == "sync") { videocontrols.playPressed(1); }
        } else {
    	    getObjectRef("mmMedia").SetPosition(position*1000);
        }
	}
	if (currentPlayer == "wmp") {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			writeDebug("fn audioSet: " + position)
			mmMediaPlayer.controls.currentPosition = position;
		} else {
		 
			if (getObjectRef("mmMedia").SetCurrentPosition) {
			    getObjectRef("mmMedia").SetCurrentPosition(position);
			}
			else if (getObjectRef("mmMedia").CurrentPosition){
	
			   	getObjectRef("mmMedia").CurrentPosition = position;
	
			} else if (getObjectRef("mmMedia").controls) {
			
				getObjectRef("mmMedia").controls.currentPosition = position;
			
			} else {
				playerState=6;
				errorString = "SetCurrentPosition failed";
				writeDebug(errorString);
			}
		}
	}
	if (currentPlayer == "qt") {
		//Set Audio to position: 'position'
		getObjectRef("mmMedia").SetTime(position*1000);
		getObjectRef("mmMedia").Play();

	}
 
	if (currentPlayer == "flash") {
		// Set position
		setFlashCurrentTime(position);
	
	}

}

// Stop.
function Stop() {

	if(!playerAbility)
		return false;
	
	isFfw = 0;
	isRew = 0;
	writeDebug("Stopping");
	if (currentPlayer == "real") {
		if (getObjectRef("mmMedia").CanStop() != -1){
			getObjectRef("mmMedia").DoStop();
		}
	}
	if (currentPlayer == "wmp") {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			mmMediaPlayer.controls.stop();
			mmMediaPlayer.controls.currentPosition = 0;
		}
		else if (getObjectRef("mmMedia").SetCurrentPosition) {
			getObjectRef("mmMedia").Stop();
		    getObjectRef("mmMedia").SetCurrentPosition(0);
		}
		else if(getObjectRef("mmMedia").CurrentPosition){
			getObjectRef("mmMedia").Stop();
		   	getObjectRef("mmMedia").CurrentPosition = 0;
		} else {
			playerState=6;
			errorString = "SetCurrentPosition (in stop) failed";
			writeDebug(errorString);
			getObjectRef("mmMedia").Stop();
			
		}
	}
	
	if (currentPlayer == "qt") {
		// Stop Player and set to time 0
		getObjectRef("mmMedia").Rewind();
		getObjectRef("mmMedia").SetRate(0);

	}
	
	
}


// Play
function Play() {

	writeDebug("Playing");
	
	if(!playerAbility)
		return false;
	
	if(isStopped()){
	    if ((slideControl == "sync") && (isStopped())){ 
			setSlide(1);
		}
	}
	
	if(!isPlaying() && !isBuffering()){
		if (currentPlayer == "real") {
			if (getObjectRef("mmMedia").CanPlay() != -1) {
				getObjectRef("mmMedia").DoPlay();
				}
		}
		if (currentPlayer == "wmp") {
			writeDebug("currentPlayer:" + currentPlayer);
			if (!(!document.getElementById('mmMediaPlayer'))) {
				//writeDebug("Playing via New WMP Method");
				mmMediaPlayer.controls.play();
			}
			else {
				//writeDebug("Playing via Old WMP Method");
				getObjectRef("mmMedia").Play();
			}
		}
		if (currentPlayer == "qt") {
			getObjectRef("mmMedia").Play();
		}
	}
	
	if(isFfw || isRew){
		audioSet(nextposition);
		isFfw = 0;
		isRew = 0;
	}
}
	
// Pause - if possible
function Pause() {
	writeDebug("Pausing");

	//writeDebug("!playerAbility:" + !playerAbility);
		
	if(!playerAbility)
		return false;
		
	if(isFfw || isRew){
		audioSet(nextposition);
		isFfw = 0;
		isRew = 0;
	}
	
	//writeDebug("currentPlayer:" + currentPlayer);
		
	if (currentPlayer == "real") {
		if (getObjectRef("mmMedia").CanPause() != -1){
			getObjectRef("mmMedia").DoPause();
		}
	}
	if (currentPlayer == "wmp") {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			//writeDebug("NEW Pause");
			mmMediaPlayer.controls.pause();
		} else {
			//writeDebug("OLD Pause");
			getObjectRef("mmMedia").Pause();
		}
	}
	
	if (currentPlayer == "qt") {
		getObjectRef("mmMedia").SetRate(0);
	}
	
}
	
// Sleep - if possible
function Sleep() {
	writeDebug("Sleeping for Ffw or Rew");
	
	
	if(!playerAbility)
		return false;
		
	if(isStopped()){
	    if ((slideControl == "sync") && (isStopped())){ 
			setSlide(1);
		}
	}
	if(!isPlaying() && !isBuffering()){
		if (currentPlayer == "real") {
			if (getObjectRef("mmMedia").CanPlay() != -1) {
				getObjectRef("mmMedia").DoPlay();
				}
		}
		if (currentPlayer == "wmp") {
			getObjectRef("mmMedia").Play();
		}
		if (currentPlayer == "qt") {
			getObjectRef("mmMedia").Play();
		}
	}
	
		
	if (currentPlayer == "real") {
		if (getObjectRef("mmMedia").CanPause() != -1){
			getObjectRef("mmMedia").DoPause();
		}
	}
	if (currentPlayer == "wmp") {
		getObjectRef("mmMedia").Pause();
	}
	
	if (currentPlayer == "qt") {
		getObjectRef("mmMedia").SetRate(0);
	}
	
}

function getPlayerPosition() {

	if((currentPlayer != "flash") && (!playerAbility))
		return 0;
		
	var playerpos = 0;
	if (currentPlayer == "real") {
		playerpos = getObjectRef("mmMedia").GetPosition();
		//alert(playerpos);
	}
	if (currentPlayer == "wmp") {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			playerpos = mmMediaPlayer.controls.currentPosition; //changed TWS - 04/17/09
		}
		else if (getObjectRef("mmMedia").GetCurrentPosition) {
			playerpos = getObjectRef("mmMedia").GetCurrentPosition();
		}
		else if(getObjectRef("mmMedia").CurrentPosition){
			playerpos = getObjectRef("mmMedia").CurrentPosition;
		} 
		else if(getObjectRef("mmMedia").controls){
			playerpos = getObjectRef("mmMedia").controls.currentPosition;
		} else {
			//playerState=6;
			//errorString = "getPlayerPosition failed";
		}
	}
	
	if (currentPlayer == "qt") {
		// Get position, set in playerpos
		playerpos = getObjectRef("mmMedia").GetTime() 
	
	}
	
	if (currentPlayer == "flash") {
		// Get position, set in playerpos
		playerpos = getFlashCurrentTime(); 
	
	}
	
	//writeDebug("Position?: " + playerpos);
	return playerpos;		

}

function getPlayerState() {

	if(!playerAbility)
		return false;
		
	var state = -1;
	if (currentPlayer == "real") {
		state = getObjectRef("mmMedia").GetPlayState();
	}
	if (currentPlayer == "wmp") {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			state = mmMediaPlayer.playState;
		}
		else if (getObjectRef("mmMedia").GetReadyState) {
			if (getObjectRef("mmMedia").GetReadyState() >= 3) {
				state = getObjectRef("mmMedia").GetPlayState();
			}
			else { state = -1; }
		}
		else if (getObjectRef("mmMedia").ReadyState){
			if (getObjectRef("mmMedia").ReadyState >= 3) {
				state = getObjectRef("mmMedia").PlayState;
			}
			else { state = -1; }
		} else {
			playerState=6;
			errorString = "getPlayerState failed " + getObjectRef("mmMedia").PlayState;
			writeDebug(errorString);
		}
	}
	if (currentPlayer == "qt") {
		// Get player state (1 through 6)
		//alert(getObjectRef("mmMedia"));
		state = getObjectRef("mmMedia").GetPluginStatus();
		//writeDebug("Getting Player State " + state);
		//state = "Playable";
		 
	
	}
	if (currentPlayer == "flash") {
		
		 if(getFlashState() == "playing") {
			state = 1;
		 }
		 if(getFlashState() == "paused") {
			state = 4;
		 }
		 if(getFlashState() == "stopped") {
			state = 2;
		 }
		 if(getFlashState() == "buffering")  {
			state = 3;
		 }
		 if(getFlashState() == "") {
			state = 6;
		 }
	
	}
	
	return state;		
}

function isPlaying() {
	
	if(!playerAbility)
		return false;
		
	checkPlayer();
	 
	if(runNewCode == false) {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			return mmMediaPlayer.playState == 2;
		} else {
			return (playerState == 1  || playerState==3);
		}
	} else {
		if (document.getElementById('mmMediaPlayer') != null) {
			return document.getElementById('mmMediaPlayer').playState == 3;
		} else {
			if (!(!document.getElementById('mmMedia'))) {
				if(is.ie) {
					return document.getElementById('mmMedia').playState == 2;
				} else {
					return document.getElementById('mmMedia').playState == 3;
				}
					
			} else {
				return (playerState == 1  ||  playerState==3);
			}
		}
		 
	
	}
}

function isStopped() {
	if(!playerAbility)
		return false;
		
	if (!(!document.getElementById('mmMediaPlayer'))) {
		return mmMediaPlayer.playState == 1;
	} else {
		if (playerState == 2) { return true; } else { return false; }
	}
}

function isBuffering() {
	
	if(!playerAbility)
		return false;

	if (!(!document.getElementById('mmMediaPlayer'))) {
		//writeDebug("fn isBuffering(), play state: " + mmMediaPlayer.playState);
		return mmMediaPlayer.playState == 6;
	} else {
		return playerState == 3;
	}

}

function isPaused() {

	if(!playerAbility)
		return false;
		
	if (!(!document.getElementById('mmMediaPlayer'))) {
		return mmMediaPlayer.playState == 2;
	} else {
		return playerState == 4;
	}
}

function playerStateOk() {

	if(!playerAbility)
		return false;
		
    // Only allow player mods if its not error'd or closed.
    if ((playerState == 5) || (playerState == 6)) {
        errorString = "playerStateOk failed";
		writeDebug(errorString);
        return false;
    }
    else { return true; }
}

// Checks Player State, converts to the global state - 'playerState'
function checkPlayer() {
	

	if(!playerAbility){
		state=-1;
		playerState = 6;
		return false;
	}
	
	var state = getPlayerState();
	if (currentPlayer == "real") {
		if (state == 0) { //Stopped.
		    playerState = 2;
		}
		if (state == 1) { //Contacting.. 
			playerState = 3;
		}
		if (state == 2) { //Buffering.. 
			playerState = 3;
		}
		if (state == 3) { //Playing.. 
			playerState = 1;
		}
		if (state == 4) { //Paused.. 
			playerState = 4;
		}
		if (state == 5) { //Seeking.. 
			playerState = 5;
		}
		if (state == -1) { //Error.. 
			playerState = 6;
		}
	}
	if (currentPlayer == "wmp") {
		if (!(!document.getElementById('mmMediaPlayer'))) {
			if (state == 1) { //Stopped. 
				playerState = 2;
			}
			if (state == 2) { //Paused.. 
				playerState = 4;
			}
			if (state == 6) { //Buffering.. 
				if (getObjectRef("mmMedia").GetBufferingProgress) {
					if (getObjectRef("mmMedia").GetBufferingProgress() > 90) {
						playerState = 1; 
					}
					else { playerState = 3; }
				}
				else if(getObjectRef("mmMedia").BufferingProgress){
					if (getObjectRef("mmMedia").BufferingProgress > 90) {
						playerState = 1; 
					}
					else { playerState = 3; }
				} else {
					//not fatal
				}
			}
			if (state == 7) { //Waiting.. 
				playerState = 3;
			}
			if ((state == 4) || (state == 5)) { //Scanning.. 
				playerState = 3;
			}
			if (state == 8) { //Closed.. 
				playerState = 5;
			}
			if (state == -1) { //Error.. 
				playerState = 6;
			}
		} else {
			if (state == 0) { //Stopped. 
				playerState = 2;
			}
			if (state == 1) { //Paused.. 
				playerState = 4;
			}
			if (state == 2) { //Buffering.. 
				if (getObjectRef("mmMedia").GetBufferingProgress) {
					if (getObjectRef("mmMedia").GetBufferingProgress() > 90) {
						playerState = 1; 
					}
					else { playerState = 3; }
				}
				else if(getObjectRef("mmMedia").BufferingProgress){
					if (getObjectRef("mmMedia").BufferingProgress > 90) {
						playerState = 1; 
					}
					else { playerState = 3; }
				} else {
					//not fatal
					
					
				}
			}
			if (state == 3) { //Waiting.. 
				playerState = 3;
			}
			if ((state == 4) || (state == 5)) { //Scanning.. 
				playerState = 3;
			}
			if (state == 8) { //Closed.. 
				playerState = 5;
			}
			if (state == -1) { //Error.. 
				playerState = 6;
			}
		}
	}
	
	//writeDebug(state);
	if (currentPlayer == "qt") {
		
		if(state != 'Playable' && state !='Complete' && state !="Waiting" && state !="Loading"){
			playerState = 6;	// Error
			writeDebug(state);
		} else if(state == "Waiting" || state =="Loading"){
			playerState = 3;	// Buffering
		} else if(getObjectRef("mmMedia").GetRate() > 0) {
			playerState = 1;	// Playing
		} else if(getObjectRef("mmMedia").GetRate() == 0 && getObjectRef("mmMedia").GetTime() == 0) {
			playerState = 2;	// Stopped
		} else if(getObjectRef("mmMedia").GetRate() == 0) {
			playerState = 4;	// Paused
		} else {
			writeDebug(state);
			playerState = -1; 	// Error
		
		}
	
	}
	
	if (currentPlayer == "flash") {
		
		playerState = state;
	
	}
	//setPlayerButtons();
}


function reportState() {
	if (!(!document.getElementById('mmMediaPlayer'))) {
		// via http://msdn.microsoft.com/en-us/library/bb249361(VS.85).aspx
	    switch(mmMediaPlayer.playState) {
		    case 0 : 
		        return "Buffering&#x2026;";
		    case 1 : 
		        return "Stopped";
		    case 2 : 
		        return "Paused";
		    case 3 : 
		        return "Playing";
		    case 4 : 
		        return "Fast Forward";
			case 5: 
				return "Rewind";
			case 6: 
				return "Buffering&#x2026;";
			case 7: 
				return "Buffering&#x2026;";
		    case 8 : 
		        return "Stopped";
		    case 9 : 
		        return "Loading&#x2026;";
		    case 10 : 
		        return "Paused";
			case 11: 
				return "Connecting&#x2026;";
		    default : 
		        return errorString;
	    }
	} else {
	    switch(playerState) {
	    case 1 : 
	        return "Playing...";
	    case 2 : 
	        return "Stopped";
	    case 3 : 
	        return "Buffering...";
	    case 4 : 
	        return "Paused";
		case 5: 
			return "Connecting...";
		case 6: 
			return "Connecting...";
		case -1: 
			return "Connecting...";
	    default : 
	        return errorString;
	    }
	}
}

function displayTime(timeInSeconds) {
	if(!playerAbility)
		return false;
		
	if (!(!document.getElementById('mmMediaPlayer'))) {
		var text = timeInSeconds;
	} else {
		var hours = 0;
		var displayhours = "";
		var minutes = 0;
		var displayminutes = "";
		var seconds = 0;
		var displayseconds = "";
		//alert(timeInSeconds);
		if (timeInSeconds/3600 > 1) {
			// Has Hours.
			hours = parseInt(timeInSeconds/3600);
			timeInSeconds = timeInSeconds - (hours*3600)
		}
		if (timeInSeconds/60 >= 1) {
			// Has Minutes.
			minutes = parseInt(timeInSeconds/60);
			timeInSeconds = timeInSeconds - (minutes*60)
		}
		//seconds = "0" + seconds;
		//writeDebug(timeInSeconds);
		seconds = parseInt(timeInSeconds);
		if (hours < 10) { displayhours = "0" + hours; } else { displayhours = hours;  }
		if (minutes < 10) { displayminutes = "0" + minutes; } else { displayminutes = minutes;  }
		if (seconds < 10) { displayseconds = "0" + seconds; } else { displayseconds = seconds;  }
		if (isNaN(displayseconds)) {displayseconds = "" + "00"}
		
		
		var text = '' + displayhours + ':' + displayminutes + ':' + displayseconds + '';
		//alert(text);
	}

	writeToLayer("lyStatus",'<span class="textStatus">'+text+'</span>');
}

function displayText(display) {
	if(!playerAbility)
		return false;
		
    if(is.ns4){
		writeToLayer("lyStatus",'<span class="textStatus">'+display+'</span>');
		//getObjectStyleRef("lyStatus").

	} else
		writeToLayer("lyStatus",'<span class="textStatus">'+display+'</span>');
	
   // writeToLayer("lyStatus",nicetext);
    return -1;
}

function setPlayerButtons() {
	writeDebug("Resetting buttons now to: " + buttonState);
	//buttonState can be set to:
	// 'play'
	// 'pause'
	// 'stop'
	// if none of those, then it will check the player and reset all buttons

	if(buttonState == "play"){
		swapImage('imPause',buttonDir + 'pause_up.gif');
		swapImage('imStop',buttonDir + 'stop_up.gif');
		swapImage('imPlay',buttonDir + 'play_down.gif');
		swapImage('imFfw',buttonDir + 'ffw_up.gif');
		swapImage('imRew',buttonDir + 'rew_up.gif');
		setLayerZIndex('lyPlay',2);
	
	}else if(buttonState == "pause"){
		swapImage('imPause',buttonDir + 'pause_down.gif');
		swapImage('imStop',buttonDir + 'stop_up.gif');
		swapImage('imPlay',buttonDir + 'play_up.gif');
		swapImage('imFfw',buttonDir + 'ffw_up.gif');
		swapImage('imRew',buttonDir + 'rew_up.gif');
		setLayerZIndex('lyPlay',4);
	
	}else if(buttonState == "stop"){
		swapImage('imPause',buttonDir + 'pause_up.gif');
		swapImage('imStop',buttonDir + 'stop_down.gif');
		swapImage('imPlay',buttonDir + 'play_up.gif');
		swapImage('imFfw',buttonDir + 'ffw_up.gif');
		swapImage('imRew',buttonDir + 'rew_up.gif');
		setLayerZIndex('lyPlay',4);
	
	}else if(buttonState == "ffw"){
		swapImage('imPause',buttonDir + 'pause_up.gif');
		swapImage('imStop',buttonDir + 'stop_up.gif');
		swapImage('imPlay',buttonDir + 'play_up.gif');
		swapImage('imFfw',buttonDir + 'ffw_down.gif');
		swapImage('imRew',buttonDir + 'rew_up.gif');
		setLayerZIndex('lyPlay',4);
	
	}else if(buttonState == "rew"){
		swapImage('imPause',buttonDir + 'pause_up.gif');
		swapImage('imStop',buttonDir + 'stop_up.gif');
		swapImage('imPlay',buttonDir + 'play_up.gif');
		swapImage('imFfw',buttonDir + 'ffw_up.gif');
		swapImage('imRew',buttonDir + 'rew_down.gif');
		setLayerZIndex('lyPlay',4);
	
	}
	
}


function launchMediaChanger() {

		// First Launch
		
		h=415;
		w=420;
		
		xPos = (screen.width/2)-(w/2);
		yPos = (screen.height/2)-(h/2);
	
		winProp = "width=" + w + ",height=" + h + ",left=" + xPos + ",top=" + yPos +",scrollbars=0,resizable=0,status=1";

		mediaChanger = window.open("mediachange.cfm", "MediaChangerWindow", winProp);	
	
		realCheckedString = "";
		wmpCheckedString = "";
		qtCheckedString = "";
		noneCheckedString = "";
		
		if(currentPlayer == "real"){
			realCheckedString = "checked";
		} else if (currentPlayer == "wmp"){
			wmpCheckedString = "checked";
		} else if (currentPlayer == "qt"){
			qtCheckedString = "checked";
		} else {
			noneCheckedString = "checked";
		}
		
		// Now pass along the string to write

		globalBuffer = "";		
		globalBuffer += "<TABLE WIDTH=400><TR><TD ALIGN=CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD COLSPAN=3><IMG SRC=\"images/SELECT_PLAYER_TOP.gif\"></TD></TR>";
		globalBuffer += "<TR><TD BACKGROUND=\"images/SELECT_PLAYER_LEFT.gif\" ROWSPAN=6><IMG SRC=images/spacer.gif width=34 height=1></TD>";
		globalBuffer += "<TD><IMG SRC=images/spacer.gif width=325 height=1></TD>";
		globalBuffer += "<TD BACKGROUND=\"images/SELECT_PLAYER_RIGHT.gif\" ROWSPAN=6><IMG SRC=images/spacer.gif width=36 height=1></TD></TR>";
		globalBuffer += "<TR><TD style=\"font-family: tahoma,helvetica; font-size: 12pt; color: 000000;\"><form name='theform'>";
		
		if(foundReal && realPathString.length){
			foundAnyPlayer = true;
			globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='real' onClick=\"opener.changeMediaTo = 'real';\" "+realCheckedString+">Real Player";
			
			if(compatibilityCheck('real') != 3){
				globalBuffer += "( <font color=red>*</font> )";
				potIncomp = true;
			}
			globalBuffer += "<BR>";
		}
		if(foundWMP && wmpPathString.length){
			foundAnyPlayer = true;
			globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='wmp' onClick=\"opener.changeMediaTo = 'wmp';\" "+wmpCheckedString+">Windows Media Player";
			
			if(compatibilityCheck('wmp') != 3){
				globalBuffer += "<font color=red>*</font>";
				potIncomp = true;
			}
			globalBuffer += "<BR>";
		}
		if(foundQuick && qtPathString.length){
			foundAnyPlayer = true;
			globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='qt' onClick=\"opener.changeMediaTo = 'qt';\" "+qtCheckedString+">QuickTime";
			
			if(compatibilityCheck('qt') != 3){
				globalBuffer += "<font color=red>*</font>";
				potIncomp = true;
			}
			globalBuffer += "<BR>";
		}
		if(allowNoAudio){
			foundAnyPlayer = true;
			globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='none' onClick=\"opener.changeMediaTo = 'none';\" "+noneCheckedString+">No Audio";
			
			globalBuffer += "<BR>";
		}
		globalBuffer += "</form></TD></TR>";
		
		if(foundAnyPlayer)
			globalBuffer += "<TR><TD ALIGN=CENTER><BR><a href=\"#\" onClick=\"opener.playerAbility =  (opener.compatibilityCheck(opener.changeMediaTo) == 3);opener.writeDebug('Talk to player?'+opener.playerAbility);opener.currentPlayer = opener.changeMediaTo;opener.writeMedia(opener.currentPlayer);opener.resetLayers();opener.playPressed();window.close();return false;\"><IMG SRC=\"images/viewevent.gif\" BORDER=0></A></TD></TR>";
		else
			globalBuffer += "<tr><td>No players detected. <BR><BR> Please download <a target='_blank' href='http://www.shareholder.com/common/rp.cfm'><font color=red>Real Player</font></A> or <a target='_blank' href='http://www.shareholder.com/common/wmp.cfm'><font color=red>Windows Media Player</font></A></TD></TR>"
			
		if(potIncomp)
			globalBuffer += "<TR><TD style=\"font-family: tahoma,helvetica; font-size: 8pt; color: 000000;\"><BR><font color=red>*</font> May cause reduced functionality due to browser incompatibility</TD></TR>";
		else
			globalBuffer += "<TR><TD><IMG SRC=images/spacer.gif width=1 height=1></TD></TR>";		
			
		globalBuffer += "<TR><TD COLSPAN=3><IMG SRC=\"images/SELECT_PLAYER_BOTTOM.gif\"></TD></TR>";
		globalBuffer += "<TR><TD COLSPAN=3><TABLE CELLPADDING=5 CELLSPACING=5><TR><TD style=\"font-family: tahoma,helvetica; font-size: 10pt; color: 000000; text-align: justify\">";
		globalBuffer += "This page  makes use of the RealAudio plugin, Windows Media Player and/or Quicktime. To experience the audio features, you need sound capabilities on your personal computer and installation of RealPlayer or Windows Media Player. These features are available at no cost. ";
		globalBuffer += "</TR></TD></TABLE></TD></TR></TABLE>";
		globalBuffer += "</TD></TR></TABLE>";
		//alert(globalBuffer);
		if(is.mac && is.ie){
			foundAnyPlayer = false;
			globalBuffer="<form name='theform'>";
			if(foundReal && realPathString.length){
				foundAnyPlayer = true;
				globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='real' onClick=\"opener.changeMediaTo = 'real';\" "+realCheckedString+">Real Player";
				
				if(compatibilityCheck('real') != 3){
					globalBuffer += "( <font color=red>*</font> )";
					potIncomp = true;
				}
				globalBuffer += "<BR>";
			}
			if(foundWMP && wmpPathString.length){
				foundAnyPlayer = true;
				globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='wmp' onClick=\"opener.changeMediaTo = 'wmp';\" "+wmpCheckedString+">Windows Media Player";
				
				if(compatibilityCheck('wmp') != 3){
					globalBuffer += "( <font color=red>*</font> )";
					potIncomp = true;
				}
				globalBuffer += "<BR>";
			}
			if(foundQuick && qtPathString.length){
				foundAnyPlayer = true;
				globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='qt' onClick=\"opener.changeMediaTo = 'qt';\" "+qtCheckedString+">QuickTime";
				
				if(compatibilityCheck('qt') != 3){
					globalBuffer += "<font color=red>*</font>";
					potIncomp = true;
				}
				globalBuffer += "<BR>";
			}
			if(allowNoAudio){
				foundAnyPlayer = true;
				globalBuffer += "\n<BR><input type='radio' name='chooseplayer' value='none' onClick=\"opener.changeMediaTo = 'none';\" "+noneCheckedString+">No Audio";
			
				globalBuffer += "<BR>";
			}
			if(foundAnyPlayer)
				globalBuffer += "</form><a href=\"#\" onClick=\"opener.playerAbility =  (opener.compatibilityCheck(opener.changeMediaTo) == 3);opener.writeDebug('Talk to player?'+opener.playerAbility);opener.currentPlayer = opener.changeMediaTo;opener.writeMedia(opener.currentPlayer);opener.resetLayers();opener.playPressed();window.close();return false;\"><IMG SRC=\"images/viewevent.gif\" BORDER=0></A>";
			else
				globalBuffer += "No players detected.  Please download <a href='http://www.shareholder.com/common/rp.cfm'>Real</A> or <a href='http://www.shareholder.com/common/wmp.cfm'>Windows Media Player</A>";
		}
		
		mediaChanger.focus();
		
}

function setVolumeToMax() {
  if(currentPlayer == "wmp"){
    maxVolume = 0;
  }else{
    maxVolume = 100;
  }
  writeDebug("Setting Volume to:"+maxVolume);
  if((is.ie) && (currentPlayer == "wmp")) {    
  
	if(!(!getObjectRef("mmMedia").settings)) {
		// If the "settings" object exists
		getObjectRef("mmMedia").settings.volume = 100;
	} else {
		getObjectRef("mmMedia").Volume = maxVolume;
	}
	
  }else{
    try{
      getObjectRef("mmMedia").SetVolume(maxVolume);
    }
	catch(err) {
      writeDebug("Problem setting maxVolume");
	}
  }
}

// </playercontrols>

// <userevents>

function nextSlidePressed() {
	if(!allsystemsgo) {
		return false;	
	}
	//playPressed();
	if (slide < maxSlide) {
		tmp = parseInt(slide) + 1;
		jumpToSlide(tmp);
		//alert(slide+1);
	swapImage('imNextSlide',buttonDir + 'nextslide_down.gif');
	setTimeout("swapImage('imNextSlide',buttonDir + 'nextslide_up.gif');",300);
	}


}

function nextSlideOver(){
	swapImage('imNextSlide',buttonDir + 'nextslide_over.gif');
}


function nextSlideOut(){
	swapImage('imNextSlide',buttonDir + 'nextslide_up.gif');
}

function prevSlidePressed() {
	if(!allsystemsgo) {
		return false;	
	}
	//playPressed();
	if (slide > minSlide) {
		jumpToSlide(slide-1);
	swapImage('imPrevSlide',buttonDir + 'prevslide_down.gif');
	setTimeout("swapImage('imPrevSlide',buttonDir + 'prevslide_up.gif');",300);
	}
}

function prevSlideOver(){
	swapImage('imPrevSlide',buttonDir + 'prevslide_over.gif');
}

function prevSlideOut(){
	swapImage('imPrevSlide',buttonDir + 'prevslide_up.gif');
}

function pullDownChanged(pullDownIndex){
	if(!allsystemsgo) {
		return false;	
	}
	jumpToSlide(pullDownIndex+1);

}


function linkedToSlide(newSlide) {
	if(!allsystemsgo) {
		return false;	
	}
    jumpToSlide(newSlide);

}

function linkedToTime(position) {
	
	if(!allsystemsgo) 
		return false;	
	
	if(!playerAbility)
		return false;
		
	audioSet(position);
	
	if (slideControl == "sync") {
		var newSlide = 1;
		for(var x=1; x<slideTimes.length+1; x++) {
			if (slideTimes[x] <= position) {
				newSlide = x;
			}
			if (newSlide > maxSlide) { newSlide = maxSlide; }
		}
		//setSlide(newSlide);
	}

}


function pausePressed(){
	if(!allsystemsgo) {
		return false;	
	}

	
	if (!(!document.getElementById('mmMediaPlayer'))) {
		writeDebug("new WMP Control State: " + mmMediaPlayer.playState)
		if (mmMediaPlayer.playState == 2) {
			// already paused
			Play();
			buttonState="play";
			setPlayerButtons();
		} else {
			Pause();
			buttonState="pause";
			setPlayerButtons();
		}
	}else if(isPlaying() || isBuffering() || isFfw || isRew){
    	Pause();
		
		buttonState="pause";
		setPlayerButtons();
		
	}else if(isPaused()){
    	Play();
		buttonState="play";
		setPlayerButtons();
	} else {
   //alert("The event must be playing for you to make this selection.");
	}
	
	
}

function stopPressed(){

	if(!allsystemsgo) {
		return false;	
	}
	
	Stop();
	
	buttonState="stop";
	setPlayerButtons();
	
	
}

function playPressed(){

	if(!allsystemsgo) {
		return false;	
	}
	

    Play();

	
	buttonState="play";
	setPlayerButtons();
	
	
}

function ffwPressed(){

	if(!allsystemsgo) {
		return false;	
	}
	
	if (!(!document.getElementById('mmMediaPlayer'))) {
		writeDebug("new WMP Control State: " + mmMediaPlayer.playState)
		if (mmMediaPlayer.playState == 4) {
			// already ffwding
			Play();
			buttonState="play";
			setPlayerButtons();
		} else {
			mmMediaPlayer.controls.fastForward();
			isFfw = 1;
			isRew = 0;
			buttonState="ffw";
			setPlayerButtons();
		}
	}else if(!isFfw){
		Sleep();
		isFfw = 1;
		isRew = 0;
		buttonState="ffw";
		setPlayerButtons();
	} else {
		Play();
		buttonState="play";
		setPlayerButtons();
	}
	
	
	
}
function rewPressed(){

	if(!allsystemsgo) {
		return false;	
	}
	
	if (!(!document.getElementById('mmMediaPlayer'))) {
		writeDebug("new WMP Control State: " + mmMediaPlayer.playState)
		if (mmMediaPlayer.playState == 5) {
			// already rewing
			Play();
			buttonState="play";
			setPlayerButtons();
		} else {
			mmMediaPlayer.controls.fastReverse();
			isFfw = 0;
			isRew = 1;
			buttonState="rew";
			setPlayerButtons();
		}
	}else if(!isRew){
		Sleep();
		isFfw = 0;
		isRew = 1;
		buttonState="rew";
		setPlayerButtons();
	} else {
		Play();
		buttonState="play";
		setPlayerButtons();
	}
	
	
}

function pauseOver(){
	if(!allsystemsgo) {
		return false;	
	}
	if(buttonState=="play" || buttonState=="ffw" || buttonState=="rew"){
		swapImage('imPause',buttonDir + 'pause_over.gif');
	}
}

function stopOver(){

	if(!allsystemsgo) {
		return false;	
	}
	
	if(buttonState!="stop"){
		swapImage('imStop',buttonDir + 'stop_over.gif');
	}
}

function playOver(){

	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="play"){
		swapImage('imPlay',buttonDir + 'play_over.gif');
	}
}


function ffwOver(){

	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="ffw"){
		swapImage('imFfw',buttonDir + 'ffw_over.gif');
	}
}

function rewOver(){

	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="rew"){
		swapImage('imRew',buttonDir + 'rew_over.gif');
	}
}

function pauseOut(){

	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="pause"){
		swapImage('imPause',buttonDir + 'pause_up.gif');
	}
}

function stopOut(){
	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="stop"){
		swapImage('imStop',buttonDir + 'stop_up.gif');
	}
}

function playOut(){
	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="play"){
		swapImage('imPlay',buttonDir + 'play_up.gif');
	}
}

function ffwOut(){
	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="ffw"){
		swapImage('imFfw',buttonDir + 'ffw_up.gif');
	}
}

function rewOut(){
	if(!allsystemsgo) {
		return false;	
	}
	
	
	if(buttonState!="rew"){
		swapImage('imRew',buttonDir + 'rew_up.gif');
	}
}

// </userevents>

// <detect>

// initialize global variables
var javascriptVersion1_1 = true;
var detectableWithVB = false;
var pluginFound = false;


function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if(javascriptVersion1_1) {
	window.location.replace(daURL);
    } else {
	window.location = daURL;
    }
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) || 
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }	
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) { 
    pluginFound = detectPlugin('Shockwave','Director'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    // DOn'T WANT TO DO THIS ANY MORE 
    return false;

    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }	
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	//pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
	pluginFound = detectActiveXControl('wmplayer.ocx');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}   
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
} // detectPlugin

// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}


function autoDetect(){

	//writeDebug("Qucktime: " + detectQuickTime());
	//writeDebug("Real: " + detectReal());
	//writeDebug("Windows Media: " + detectWindowsMedia());
	foundWMP = detectWindowsMedia();
	foundReal = detectReal();
	foundQuick = detectQuickTime();
	foundFlash = swfobject.getFlashPlayerVersion().major;	

	if(foundFlash) {
		currentPlayer = "flash";
	} else if(foundWMP) {
		currentPlayer = "wmp";
	} else if(foundReal) {
		currentPlayer = "real";
	} else {
		alert('alert no available player');
	}
	//alert(QueryString("homedir"));
	//window.location.href='media.cfm?homedir=macro&player=real&accesslevel=full';
}

// </detect>

// <slidecontrols>

/*-----------------------------------------------------------*/
/*---------Slide Controls------------------------------------*/

function pushCheckSlide(){
	
	if(!is.ns4){
		var d = new Date();
		
		if(!(loopCount%pushCheckTicksSkipped))		
			getObjectRef("imFlag").src = flagImageURL + "&unique=" + d.getTime();
			
		//writeDebug(flagImageURL + "?unique=" + d.getTime());
		
		if(checkImage(getObjectRef("imFlag"))){
			if(getObjectRef("imFlag").width == 1 && loopCount > 3){
				//if still on slide 1 after a few loops, then set delay
				doneFirstPush = true;
			}
			
			if(slideControl=="push" && realtimeSlide != getObjectRef("imFlag").width && (pushMethod == 0 || !seenStreamPush)){
				realtimeSlide = getObjectRef("imFlag").width;
				
				if(pushDelay&&currentPlayer != 'none'){
					if(doneFirstPush){
						writeDebug("Going to push slide #" + realtimeSlide + " in " + pushDelayTime + " seconds");
						setTimeout("setSlide("+realtimeSlide+");",1000*pushDelayTime);
					}else{
						writeDebug("First slide seen, so changing slide now to: " + realtimeSlide);
						doneFirstPush = true;
						setSlide(realtimeSlide);
					}
	
				} else {
					writeDebug("No Delay, pushing slide to: " + realtimeSlide);
					setSlide(realtimeSlide);
				
				}
				
			}
			
			// Must set to first slide correctly for advance push method
			
			if(slideControl=="push" && realtimeSlide != getObjectRef("imFlag").width && pushMethod == 1){
				realtimeSlide = getObjectRef("imFlag").width;
	
				if(!doneFirstPush){
					writeDebug("First slide seen, so changing slide now to: " + realtimeSlide);
					doneFirstPush = true;
					setSlide(realtimeSlide);
				} else {
				   writeDebug("Using advanced push method so ignoring this push command for slide: " + realtimeSlide);
				
				}
				
			}
			
			if(getObjectRef("imFlag").height != curHeight){
				writeDebug('found new height ' + getObjectRef("imFlag").height);
				curHeight = getObjectRef("imFlag").height;

				if(Math.floor(curHeight / 10) > eventPhase){
                                        writeDebug('Phase Change detected');
					getObjectRef('lyGetCustom').src = "phasechange.cfm?mediaid=" + mediaID + "&mediauserid=" + mediaUserID + "&oldphase=" + eventPhase + "&newPhase=" + Math.floor(curHeight / 10);
					
				} else {
					getObjectRef('lyGetCustom').src = execPageURL + "?unique=" + d.getTime();
					writeDebug(execPageURL);
				}
			}		
		}

	} else {
		var d = new Date();
		
		if(!(loopCount%pushCheckTicksSkipped))
			getObjectRef("lyFlag").load(flagPageURL+"?unique=" + d.getTime(),100);

		if(getObjectRef("lyFlag") != null && getObjectRef("lyFlag").document.forms != null && getObjectRef("lyFlag").document.forms[0] != null && getObjectRef("lyFlag").document.forms[0].elements != null && getObjectRef("lyFlag").document.forms[0].elements[1] != null){
			//if(getObjectRef("imSlide").src !=  "http://development1" + slideDir + "s" + getObjectRef("lyFlag").document.forms[0].elements[0].value + ".jpg"){
			//writeDebug(getObjectRef("lyFlag").document.forms[0].elements[1].value + " " + slide);
			
			if(getObjectRef("lyFlag").document.forms[0].elements[1].value == 1)
				doneFirstPush = true;
			
			if(slideControl=="push" && realtimeSlide != getObjectRef("lyFlag").document.forms[0].elements[1].value){
				//writeDebug("Out of synch, pushing new slide: " + getObjectRef('lyFlag').document.forms[0].elements[1].value);
				realtimeSlide = getObjectRef("lyFlag").document.forms[0].elements[1].value;
				if(pushDelay&&currentPlayer != 'none'){
					if(doneFirstPush){
						writeDebug("Going to push slide #" + realtimeSlide + " in " + pushDelayTime + " seconds");
						setTimeout("setSlide("+realtimeSlide+");",1000*pushDelayTime);
					}else{
						writeDebug("First slide seen, so changing slide now to: " + realtimeSlide);
						doneFirstPush = true;
						setSlide(realtimeSlide);
					}

				} else {
					writeDebug("No Delay, pushing slide to: " + realtimeSlide);
					setSlide(realtimeSlide);
				
				}
			}
			
			if(curHeight != getObjectRef("lyFlag").document.forms[0].elements[0].value){
				curHeight = getObjectRef("lyFlag").document.forms[0].elements[0].value;
                eval(getObjectRef("lyFlag").document.forms[0].elements[2].value);
				writeDebug("new height " + curHeight + " running: " + getObjectRef("lyFlag").document.forms[0].elements[2].value);
			}
		}
		
		
		
		
	}
}
	
function syncCheckSlide(){
   
	var newSlideFound = false;
	var newCaptionFound = false;
	
	if(!playerAbility)
		return false;
	 
	
	//checkPlayer();
    //position = getPlayerPosition();
    //var nextposition = 0;
   // if (currentPlayer == "real" || currentPlayer == "qt") { nextposition = position / 1000; } else { nextposition = position; }
	
 

	if(!isPlaying() && !isBuffering() && !isFfw && !isRew)
		return;

	writeDebug("syncCheckSlide: checking position: " + nextposition);
	 
 

	while(nextposition >= slideTimes[slide] && slide < maxSlide){
		newSlideFound = true;
     	slide = slide + 1;
	}
	
	

	while(nextposition < slideTimes[slide-1] && slide > 1){
		newSlideFound = true;
		slide = slide - 1;
	}
 
	if(newSlideFound){
		sLog("syncCheckSlide newSlideFound = " + slide);
		writeDebug("Must Change Slide");
		setSlide(slide);
	}
	
	
	if(currentCustomEvent < customTimes.length){
		if(customTimes[currentCustomEvent + 1] < nextposition){
			currentCustomEvent +=1;
			writeDebug("Firing Custom Event: " + customEvents[currentCustomEvent]);
			eval(customEvents[currentCustomEvent]);
			
		}
	}
	if(currentCustomEvent >0){
		if(customTimes[currentCustomEvent] > nextposition){
			
			writeDebug("Firing Custom Event: " + customEventsReverse[currentCustomEvent]);
			eval(customEventsReverse[currentCustomEvent]);
			currentCustomEvent -=1;
		}
	}
}


function checkCaption(){
	newCaptionFound = false;

	while(captionTimes[currentCaption + 1] < nextposition && currentCaption < captionTimes.length){
		newCaptionFound = true;
     	currentCaption +=1;
   	}

	while(nextposition < captionTimes[currentCaption] && currentCaption > 1){
		newCaptionFound = true;
		currentCaption = currentCaption - 1;
	}
	
	if(newCaptionFound){
		changeCaption(currentCaption);
		writeDebug("Firing Caption at time: " + nextposition);
	}
	
}

function changeCaption(thisCaption){

	writeToLayer("lyClosedCaption","<TABLE WIDTH=" + initLyClosedCaption[2] + "><TR><TD class=textCaption>" + captionValues[thisCaption] + "</TD></TR></TABLE>");

}

function getSlideURLResized(slideNum,width,height){

	writeDebug("Getting Slide Path for slide " + slideNum + " at " + width + "x" + height);
	return slideDir.replace("%S%",slideNum).replace("%W%",width).replace("%H%",height);
}

function getSlideURL(slideNum){
	return getSlideURLResized(slideNum,initLySlide[2],initLySlide[3]);


}

function setSlide(slideNum){
	sLog("set slide to " + slideNum);

	// Sets the slide, caches next slide
	writeDebug("Setting Slide: " + slideNum);
    

	getObjectRef("imSlide").src = getSlideURL(slideNum);
	
	
	slide = slideNum;
	//alert(getObjectRef('inSlideList'));
	
	setSlideList(slide);

	customInterfaceOnSlideChange();
	customOnSlideChange();
}

function slideListSetSlide(newSlide){

	getObjectRef("imSlide").src = slideDir + "/s" + newSlide + slideExt;
	slide = newSlide;
    if (slideControl == "sync") { syncAudio(); }


}

function jumpToSlide(newSlide) {

	sLog("jumpToSlide(" + newSlide + ")");
	
	// syncs everything to given slide (slide, dropdown, media).

	setSlide(newSlide);
	 
    if (slideControl == "sync") { syncAudio(); }
	
}

function refreshSlideList(){

	writeDebug("Writing Slide List"); 

	if(listType=="plaintext"){
		writeToLayer('lySlideList','Slide Name: ' + slideTitles[0]);
		
	} else if (listType == "dropdown") {
		
		buffer = ""
		
		if(!(is.mac && is.ie) && initLySlideList[2]>0)
			buffer+="<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD width="+initLySlideList[2]+" align=center>";
		else
			buffer+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
			
		buffer = buffer + "<form name='inSlideList' id='inSlideList' method='post'>";
		buffer = buffer + "\n<select name='inCurrentSlide'  id='inCurrentSlide'  onChange='pullDownChanged(this.selectedIndex);'>";
		
		for(i=0; i<slideTitles.length; i++)
			buffer = buffer + "\n<option value='" + i+1 + "'>" + slideTitles[i] + "</option>";
		
		buffer = buffer + "\n</select></form>";
		
		if(!(is.mac && is.ie) && initLySlideList[2]>0)
			buffer+="</TD></TR></TABLE>";
		
		writeToLayer("lySlideList",buffer);
		
	} else {
	
		writeDebug("Can't refresh the slide list!"); 
	}
	
	//writeDebug(getObjectRef("inSlideList").width);
}

function setSlideList(listNum){

	if(listType=="plaintext"){
		writeToLayer('lySlideList','Slide Name: ' + slideTitles[listNum-1]);
		writeDebug("Writing SlideList "+listNum-1); 
	} else if (listType == "dropdown") {
		getObjectRef("inSlideList").elements[0].selectedIndex = (slide-1);
		writeDebug("Setting SlideList "+getObjectRef('inSlideList').elements[0].selectedIndex); 
	} else if(listType.length){
		writeDebug("Running custom setSlideList function:  "+listType+"("+listNum+")"); 
		eval(listType+"("+listNum+")");
	} else {
		writeDebug("Can't set slide to "+listNum); 
	}

}

function centerSlide(){
	
	if(eventType.toLowerCase().indexOf("slide") != -1) {
		//initLySlide = new Array(275,15,420,-1,2,1);
		if(getObjectRef('imSlide').width > 100 && getObjectRef('imSlide').height > 100){
			var newSlideLeft = (initLySlide[2] - getObjectRef('imSlide').width)/2 + initLySlide[0];
			var newSlideTop = (initLySlide[3] - getObjectRef('imSlide').height)/2 + initLySlide[1];
			writeDebug(initLySlide[3]+ " " + getObjectRef('imSlide').height+ " " + initLySlide[1]);
			writeDebug("Centering slide to : " + newSlideLeft + "," + newSlideTop);
			
			
			setLayerLeft('lySlide',newSlideLeft);
			setLayerTop('lySlide',newSlideTop);
			
			setLayerVisible('lySlide');
		} else {
		
			setTimeout("centerSlide()",1000);
		
		
		}
		//LayerTop = (Config Height - Slide Height / 2) + Config To;
		//LayerLeft =  (Condfig Width - Slide Width / 2) + Config Left
	}
}

function embedSlideEvent(mySlide){
	if(pushMethod==1 && slideControl == "push" || !playerAbility) {
		writeDebug("Embedding slide: " + mySlide);
		setSlide(mySlide);
	} else
		writeDebug("Pushmethod set to 0 or not push event, ignoring embed command for slide: " + mySlide + ' at time: ' + nextposition);
}


function checkImage(img) {
    

	/* Firefox */
	
	if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
		writeDebug("Pushcheck failed 1");
		return false;
    	}
	
    	/* IE */
	if(img.width == 28 && img.height == 30){
		writeDebug("Pushcheck failed 2");
        	return false;
    	}

     	/* SAFARI */
        if(img.width == 20 && img.height == 20 ){
		writeDebug("Pushcheck failed 3");
        	return false;
    	}

  	/* MOZILLA ON MAC */
        if(img.width == 0 && img.height == 0 ){
		writeDebug("Pushcheck failed 4");
        	return false;
    	}
	
    	/* WORKED ON OLDER BROWSERS */

     	if (typeof img.complete != "undefined" && !img.complete) {
		writeDebug("Pushcheck failed 5: " + img.complete);
        	return false;
     	}

    	return true;
}

function changePhase(newPhase){

	writeDebug("Found new phase.  Old Phase: " + eventPhase + " New Phase: " + newPhase);
}



// </slidecontrols>

// <mediapresentation>

function detectPlayers(){

	document.title = webcastTitle;

	if ((is.ie && is.mac)){
		//alert('hi3 ' + document.body.clientWidth);
		if((document.body.clientHeight < myWindowHeight-35 || document.body.clientHeight>myWindowHeight+35) || (document.body.clientWidth<myWindowWidth-35|| document.body.clientWidth>myWindowWidth+35)){
			// alert(self.innerHeight + " " + myWindowHeight + ";" + self.innerWidth + " " + myWindowWidth);
			window.resizeTo(myWindowWidth,myWindowHeight+30);
			window.moveTo((screen.width/2)-(myWindowWidth/2),(screen.height/2)-(myWindowHeight/2));
			location.reload();
			return false;
		}
	
	}
	
	cacheImages();
	foundWMP = detectWindowsMedia();
	getObjectRef("imLoadingBar").src = imageLoading[1].src;
	foundReal = detectReal();
	getObjectRef("imLoadingBar").src = imageLoading[2].src;
	foundQuick = detectQuickTime();
	getObjectRef("imLoadingBar").src = imageLoading[3].src;
	

	foundFlash = swfobject.getFlashPlayerVersion().major;

	writeDebug("FoundWMP: " + foundWMP);
	writeDebug("FoundReal: " + foundReal);
	writeDebug("FoundQuick: " + foundQuick);
	
	doneLoadingYet();
}

function doneLoadingYet(){

	potIncomp = false;
	writeDebug(cacheProgress);

	if(cacheProgress >= precacheImages.length-2){

		maxSlide = slideTitles.length;
		
		// Add a unique date stamp to the extensions so that every time you are in the event, you reload the images (to prevent caching problems)
		var d = new Date();
		joinTime = d.getTime();

		if(slideExt.indexOf("?") == -1)
			slideExt += "?";
		else
			slideExt += "&";

		slideExt += "unique=" + d.getTime()

		if(is.chrome) {
			myWindowWidth += 10;
			myWindowHeight += 5;
		} else {
			myWindowWidth -=10;
			myWindowHeight -=30;
		}
	
		foundAnyPlayer = false;
		
		clearTimeout(imageLoadingTimeout);
		
		writeDebug("Done Loading Images");
		getObjectRef("imLoadingBar").src = imageLoading[imageLoading.length-1].src;
				
		buffer = "";		
		buffer += "<TABLE WIDTH=400><TR><TD ALIGN=CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD COLSPAN=3><a href=\"#\" onClick=\"checkModKeys(event); return false;\"><IMG Border=0 SRC=\"images/SELECT_PLAYER_TOP.gif\"></A></TD></TR>";
		buffer += "<TR><TD BACKGROUND=\"images/SELECT_PLAYER_LEFT.gif\" ROWSPAN=5><IMG SRC=images/spacer.gif width=34 height=1></TD>";
		buffer += "<TD><IMG SRC=images/spacer.gif width=325 height=1></TD>";
		buffer += "<TD BACKGROUND=\"images/SELECT_PLAYER_RIGHT.gif\" ROWSPAN=5><IMG SRC=images/spacer.gif width=36 height=1></TD></TR>";
		buffer += "<TR><TD style=\"font-family: tahoma,helvetica; font-size: 12pt; color: 000000;\"><form name='theform'>";
		
		if(foundReal && realPathString.length){
			foundAnyPlayer = true;
			buffer += "\n<BR><input type='radio' name='chooseplayer' value='real' onClick=\"currentPlayer = 'real';\" ";
			if(currentPlayer == 'real')
				buffer += 'checked';
			buffer += ">Real Player";
			
			if(compatibilityCheck('real') != 3){
				buffer += "( <font color=red>*</font> )";
				potIncomp = true;
			}
			buffer += "<BR>";
		}
		if(foundWMP && wmpPathString.length){
			foundAnyPlayer = true;
			buffer += "\n<BR><input type='radio' name='chooseplayer' value='wmp' onClick=\"currentPlayer = 'wmp';\" "
			if(currentPlayer == 'wmp')
				buffer += 'checked';
			buffer += ">Windows Media Player";
			
			if(compatibilityCheck('wmp') != 3){
				buffer += "<font color=red>*</font>";
				potIncomp = true;
			}
			buffer += "<BR>";
		}
		if(foundFlash && flashPathString.length){
			foundAnyPlayer = true;
			buffer += "\n<BR><input type='radio' name='chooseplayer' value='flash' onClick=\"currentPlayer = 'flash';\" "
			if(currentPlayer == 'flash')
				buffer += 'checked';
			buffer += ">Flash Media Player";
			
			if(compatibilityCheck('flash') != 3){
				buffer += "<font color=red>*</font>";
				potIncomp = true;
			}
			buffer += "<BR>";
		}
		if(foundQuick && qtPathString.length){
			foundAnyPlayer = true;
			buffer += "\n<BR><input type='radio' name='chooseplayer' value='qt' onClick=\"currentPlayer = 'qt';\" "
			if(currentPlayer == 'qt')
				buffer += 'checked';
			buffer += ">QuickTime";
			
			if(compatibilityCheck('qt') != 3){
				buffer += "<font color=red>*</font>";
				potIncomp = true;
			}
			buffer += "<BR>";
		}
		if(allowNoAudio){
			foundAnyPlayer = true;
            if(realPathString.length == 0 && wmpPathString.length == 0 && qtPathString.length == 0) {
                currentPlayer = "none";
    			buffer += "\n<BR><input type='radio' name='chooseplayer' value='none' checked>No Audio - Slides Only";
            } else {
	    		buffer += "\n<BR><input type='radio' name='chooseplayer' value='none' onClick=\"currentPlayer = 'none';\">No Audio - Slides Only";
            }
			
			buffer += "<BR>";
		}
		buffer += "</form></TD></TR>";
		
		if(foundAnyPlayer)
			buffer += "<TR><TD ALIGN=CENTER><BR><a href=\"#\" onClick=\"init(); return false;\"><IMG SRC=\"images/viewevent.gif\" BORDER=0></A></TD></TR>";
		else
			buffer += "<tr><td>No players detected. <BR><BR> Please download <a target='_blank' href='http://www.shareholder.com/common/rp.cfm'><font color=red>Real Player</font></A> or <a target='_blank' href='http://www.shareholder.com/common/wmp.cfm'><font color=red>Windows Media Player</font></A></TD></TR>"
		
		// ///////////////////////////////////////////////////
		buffer += "<tr><td COLSPAN=3><div style=\"font-family: tahoma,helvetica;  font-size: 8pt; color: 000000;\" id='customLaunchMessage'></div></TD></TR>";
	  	
		if(potIncomp)
		 	buffer += "<TR><TD COLSPAN=3 style=\"font-family: tahoma,helvetica;  font-size: 8pt; color: 000000;\"><BR><font color=red>*</font> May cause reduced functionality due to browser incompatibility</TD></TR>";
		else
			buffer += "<TR><TD COLSPAN=3><IMG SRC=images/spacer.gif width=1 height=1></TD></TR>";		
		
		
		buffer += "<TR><TD COLSPAN=3><IMG SRC=\"images/SELECT_PLAYER_BOTTOM.gif\"></TD></TR>";
		buffer += "<TR><TD COLSPAN=3><TABLE CELLPADDING=5 CELLSPACING=5><TR><TD style=\"font-family: tahoma,helvetica; font-size: 10pt; color: 000000; text-align: justify\">";
		buffer += "This page makes use of Windows Media Player, Flash Player, the RealAudio plugin and/or Quicktime. To experience the audio features, you need sound capabilities on your personal computer and installation of a player.  Please download one of the players from the links below. ";
		buffer += "</TR></TD></TABLE></TD></TR></TABLE>";
		buffer += "<TABLE WIDTH=100% CELLPADDING=5 CELLSPACING=5><TR style=\"font-family: tahoma,helvetica; font-size: 10pt; color: 000000; text-align: justify\">";
		
		if(wmpPathString.length)
			buffer += "<TD><a target='_blank' href='http://www.shareholder.com/common/wmp.cfm'><font color=red>Windows Media Player</font</A></TD>";
		if(flashPathString.length)
			buffer += "<TD><a target='_blank' href='http://www.adobe.com/flashplayer'><font color=red>Flash Player</font</A></TD>";
		if(realPathString.length)
			buffer += "<TD align=right><a target='_blank' href='http://www.shareholder.com/common/rp.cfm'><font color=red>RealAudio Player</font</A></TD>";
		if(qtPathString.length)
			buffer += "<TD align=right><a target='_blank' href='http://www.shareholder.com/common/qt.cfm'><font color=red>Qucktime Player</font</A></TD>";
		
		buffer += "</TR></TABLE>";
		buffer += "</TD></TR></TABLE>";

		if(is.mac && is.ie){
			foundAnyPlayer = false;
			buffer="<form name='theform'>";
			
			if(foundReal && realPathString.length){
				foundAnyPlayer = true;
				buffer += "\n<BR><input type='radio' name='chooseplayer' value='real' onClick=\"currentPlayer = 'real';\" ";
				if(currentPlayer == 'real')
					buffer += 'checked';
				buffer += ">Real Player";
				
				if(compatibilityCheck('real') != 3){
					buffer += "( <font color=red>*</font> )";
					potIncomp = true;
				}
				buffer += "<BR>";
			}
			if(foundWMP && wmpPathString.length){
				foundAnyPlayer = true;
				buffer += "\n<BR><input type='radio' name='chooseplayer' value='wmp' onClick=\"currentPlayer = 'wmp';\" "
				if(currentPlayer == 'wmp')
					buffer += 'checked';
				buffer += ">Windows Media Player";
				
				if(compatibilityCheck('wmp') != 3){
					buffer += "<font color=red>*</font>";
					potIncomp = true;
				}
				buffer += "<BR>";
			}
			if(foundQuick && qtPathString.length){
				foundAnyPlayer = true;
				buffer += "\n<BR><input type='radio' name='chooseplayer' value='qt' onClick=\"currentPlayer = 'qt';\" "
				if(currentPlayer == 'qt')
					buffer += 'checked';
				buffer += ">QuickTime";
				
				if(compatibilityCheck('qt') != 3){
					buffer += "<font color=red>*</font>";
					potIncomp = true;
				}
				buffer += "<BR>";
			}
			if(allowNoAudio){
				foundAnyPlayer = true;
				buffer += "\n<BR><input type='radio' name='chooseplayer' value='none' onClick=\"currentPlayer = 'none';\">No Audio - Slides Only";
				
				buffer += "<BR>";
			}
			if(foundAnyPlayer)
				buffer += "</form><a href=\"#\" onClick=\"init(); return false;\"><IMG SRC=\"images/viewevent.gif\" BORDER=0></A>";
			else
				buffer += "No players detected.  Please download <a href='http://www.shareholder.com/common/rp.cfm'>Real</A> or <a href='http://www.shareholder.com/common/wmp.cfm'>Windows Media Player</A>";
				
				
			buffer += "<br/><div id='customLaunchMessage'></div>";
		}
		if(!playerPassed){
			writeDebug("Attempting to write buffer");
			
			writeToLayer("lySplash",buffer);
			writeDebug("Done writing buffer");
		}
		writeDebug("Writing buttons");
		writeToLayer("lySlide","<IMG SRC=\"" + getSlideURL(1) +" \" name=\"imSlide\" id=\"imSlide\" onContextMenu=\"return false;\">");
		writeToLayer("lyRew","<a href=\"#\" onMouseOver=\"rewOver();\" onClick=\"rewPressed();return false;\" onMouseOut=\"rewOut();\" onFocus=\"this.blur();\"><IMG name=\"imRew\" id=\"imRew\" SRC=\"" + buttonDir + "rew_up.gif\" border=\"0\" alt=\"Fast Rewind\"></a>");
		writeToLayer("lyStop","<a href=\"#\" onMouseOver=\"stopOver();\" onClick=\"stopPressed();return false;\" onMouseOut=\"stopOut();\" onFocus=\"this.blur();\"><IMG name=\"imStop\" id=\"imStop\" id=\"imStop\" SRC=\"" + buttonDir + "stop_up.gif\" border=\"0\" alt=\"Stop\"></a>");
		writeToLayer("lyPause","<a href=\"#\" onMouseOver=\"pauseOver();\" onClick=\"pausePressed();return false;\" onMouseOut=\"pauseOut();\" onFocus=\"this.blur();\"><IMG name=\"imPause\" id=\"imPause\" id=\"imPause\" SRC=\"" + buttonDir + "pause_up.gif\" border=\"0\" alt=\"Pause\"></a>");
		writeToLayer("lyPlay","<a href=\"#\" onMouseOver=\"playOver();\" onClick=\"playPressed();return false;\" onMouseOut=\"playOut();\" onFocus=\"this.blur();\"><IMG name=\"imPlay\" id=\"imPlay\" SRC=\"" + buttonDir + "play_down.gif\" border=\"0\" alt=\"Play\"></a>");
		writeToLayer("lyFfw","<a href=\"#\" onMouseOver=\"ffwOver();\" onClick=\"ffwPressed();return false;\" onMouseOut=\"ffwOut();\" onFocus=\"this.blur();\"><IMG name=\"imFfw\" id=\"imFfw\" SRC=\"" + buttonDir + "ffw_up.gif\" border=\"0\" alt=\"Fast Forward\"></a>");
		writeToLayer("lyPrevSlide","<a href=\"#\"  onMouseOver=\"prevSlideOver();\"  onMouseOut=\"prevSlideOut();\" onMouseDown=\"prevSlidePressed();return false;\"><img name=\"imPrevSlide\" id=\"imPrevSlide\" SRC=\"" + buttonDir + "\\prevslide_up.gif\" border=\"0\"></A>");
		writeToLayer("lyNextSlide","<a href=\"#\"  onMouseOver=\"nextSlideOver();\"  onMouseOut=\"nextSlideOut();\" onMouseDown=\"nextSlidePressed();return false;\"><img name=\"imNextSlide\" id=\"imNextSlide\" SRC=\"" + buttonDir + "\\nextslide_up.gif\" border=\"0\"></A>");
		
		writeToLayer("lyStatus","Connecting");
		
		writeToLayer("lySwitchMedia","<a href=\"#\" onClick=\"launchMediaChanger();return false;\"><IMG name=\"imPlayerIcon\" id=\"imPlayerIcon\" SRC=\"" + buttonDir + currentPlayer+"icon.gif\" border=\"0\" alt=\"Player\"></A>");
		writeDebug("Writing custom layers");
		if(lyCustom0HTML.length)
			writeToLayer("lyCustom0",lyCustom0HTML);
		if(lyCustom1HTML.length)
			writeToLayer("lyCustom1",lyCustom1HTML);
		if(lyCustom2HTML.length)
			writeToLayer("lyCustom2",lyCustom2HTML);
		if(lyCustom3HTML.length)
			writeToLayer("lyCustom3",lyCustom3HTML);
		if(lyCustom4HTML.length)
			writeToLayer("lyCustom4",lyCustom4HTML);
		if(lyCustom5HTML.length)
			writeToLayer("lyCustom5",lyCustom5HTML);
		if(lyCustom6HTML.length)
			writeToLayer("lyCustom6",lyCustom6HTML);
		if(lyCustom7HTML.length)
			writeToLayer("lyCustom7",lyCustom7HTML);
		if(lyCustom8HTML.length)
			writeToLayer("lyCustom8",lyCustom8HTML);
		if(lyCustom9HTML.length)
			writeToLayer("lyCustom9",lyCustom9HTML);
		if(lyCustom10HTML.length)
			writeToLayer("lyCustom10",lyCustom10HTML);
		if(lyCustom11HTML.length)
			writeToLayer("lyCustom11",lyCustom11HTML);
		if(lyCustom12HTML.length)
			writeToLayer("lyCustom12",lyCustom12HTML);
		if(lyCustom13HTML.length)
			writeToLayer("lyCustom13",lyCustom13HTML);
		if(lyCustom14HTML.length)
			writeToLayer("lyCustom14",lyCustom14HTML);
		if(lyCustom15HTML.length)
			writeToLayer("lyCustom15",lyCustom15HTML);
		if(lyCustom16HTML.length)
			writeToLayer("lyCustom16",lyCustom16HTML);
		if(lyCustom17HTML.length)
			writeToLayer("lyCustom17",lyCustom17HTML);
		if(lyCustom18HTML.length)
			writeToLayer("lyCustom18",lyCustom18HTML);
		if(lyCustom19HTML.length)
			writeToLayer("lyCustom19",lyCustom19HTML);
			
		writeDebug("Done Writing layers");

		if(useIFrame)
			getObjectRef("lyIFrame").innerHTML="<iframe src='" + iFrameInitSRC + "' name='lyFloatingFrame' height="+initLyIFrame[3]+" width="+initLyIFrame[2]+" frameborder='0'></iframe>"; 
		
		if(playerPassed)
			setTimeout('init()', 2000);
		
	}else {
		writeDebug("not done loading yet");
		setTimeout('doneLoadingYet()', 500);
	}
	
	try {
		customLaunchCode();
	} catch (ex) {
		// do nothing if this object doesn't exist
	}

}



function playAnimation(num){
	percentDone = 0;
	
	if(numCachedImages){
	
		tmpVar = parseInt(((cacheProgress/numCachedImages)*6))+4;
		//writeDebug('Done so far: ' + tmpVar + '..' + cacheProgress + '..' + numCachedImages + '..' + imageLoading.length);
		if(tmpVar<imageLoading.length)
			getObjectRef("imLoadingBar").src = imageLoading[tmpVar].src;
	
	}

	if(debug)
		makeCenterPopup("debug.cfm","debug",300,200);

	if(remoteDebug)
		makeCenterPopup("remotedebug.cfm","remoteDebug",100,100);
	
	
	imageLoadingTimeout = setTimeout('playAnimation(('+num+'+1) % 8)', 100);
}

function cacheImages(){

	numCachedImages = precacheImages.length;
	for(i = 0; i<precacheImages.length; i++){
		imageData[i] = new Image();
		imageData[i].onload = cacheDone;
		imageData[i].src = precacheImages[i];
		imageLookup[precacheImages[i]] = i;
	
	}

}

function cacheDone(){
	cacheProgress+=1;
	writeDebug('Cached Image Done ' + cacheProgress + '/' + numCachedImages + " - " + imageData[cacheProgress-1].src);
	
}

function addImageToCache(src){
	numCachedImages += 1;
	
	imageData[numCachedImages - 1] = new Image();
	imageData[numCachedImages - 1].onload = cacheDone;
	imageData[numCachedImages - 1].src = src;
	imageLookup[src] = numCachedImages - 1;
	
	//writeDebug('Starting Precache ' + cacheProgress + '/' + numCachedImages + ' :' + imageData[numCachedImages - 1].src + ' in slot ' + imageLookup[src]);

}

function compatibilityCheck(player){

	//INPUT:
	//	PLAYER:real,wmp,qt,flash
	
	//OUTPUT
	//	0: No Support
	//	1: Limited support
	//	2: Unknown Support
	// 	3: Full Support
	
	returnValue=0;
	os="";
	browser="";
	
	if(player == 'none')
		return 0;
	
	if(is.ns4)
		browser="nn4";
	else if(is.ie)
		browser="ie";
	else if(is.chrome)
		browser="chrome";
	else if(is.ffox)
		browser="firefox";
	else if(is.op3)
		browser="opera";
	else if(is.ns5)
		browser="nn6";
	
	if(browser == "nn6" && navigator.userAgent.toLowerCase().indexOf("netscape/7") != -1)
		browser = "nn7";
	
	if(is.win)
		os="win";
	else if(is.mac)
		os="mac";
	else if(is.linux)
		os="linux";
		
	if(!os.length){
		writeDebug("Error in checking for os, setting to win");
		os='win';
	}
	
	if(!browser.length){
		writeDebug("Error in checking for browser, setting to ie");
		browser='ie';
	}
	
	if(os=='mac'){
		if(browser=='nn4'){
			if(player=='qt')
				returnValue=3;
			else
				returnValue=3;
		} else if(browser=='nn6'){
			if(player=='real')
				returnValue=1;
			else if(player=='qt')
				returnValue=1;
			else
				returnValue=1;
		} else if(browser=='nn7'){
			if(player=='qt' || player=='real' || player=='wmp')
				returnValue=1;
		} else if(browser=='ie'){
			if(player=='qt')
				returnValue=1;
			else
				returnValue=1;
		} else if(browser=="chrome"||browser=="firefox") {
			if(player=='flash')
				returnValue=3;
			else 
				returnValue=1;
		} else if(browser=="opera") {
			returnValue=1;
		}
	
	
	} else if(os=='win'){
	
		/*
		if(runNewCode == false) {
		
			if(browser=='nn4'){
				if(player=='qt')
					returnValue=3;
				else
					returnValue=3;
			} else if(browser=='nn6'){
				if(player=='qt')
					returnValue=1;
				else if(player=='wmp')
					returnValue=1;
				else if(player=='real')
					returnValue=3;
			} else if(browser=='nn7'){
					returnValue=1;
			} else if(browser=='ie'){
				if(player=='qt')
					returnValue=1;
				else
					returnValue=3;
	 	 
			} else if(browser=="chrome"||browser=="firefox"||browser=="opera") {
		
				returnValue=1;
			}
		 
		} 
		*/
		
		/*if(runNewCode == true) { */
		 
			if(browser=='nn4'){
				if(player=='qt')
					returnValue=3;
				else
					returnValue=3;
			} else if(browser=='nn6'){
				if(player=='qt')
					returnValue=1;
				else if(player=='wmp')
					returnValue=1;
				else if(player=='real')
					returnValue=3;
			} else if(browser=='nn7'){
					returnValue=1;
			} else if(browser=='ie'){
				if(player=='qt')
					returnValue=1;
				else
					returnValue=3;
		 	} else if (browser=="firefox") {
				// Added by DOF 
				if((player=='wmp') || (player=='flash'))
					returnValue=2;
				else
					returnValue=1;		
			} else if(browser=="chrome") {
				if((player=='wmp') || (player=='flash'))
					returnValue=2;
				else
					returnValue=1;
		
			} else if (browser=="opera") {
				returnValue=1;
			}
		/* } */
		
		
	} else if(os=="linux")  {
		// no activeX on linux :(
		returnValue=1;
	}
	
	writeDebug("Compatibility: " + os + " , " + browser + " , " + player + " : " + returnValue);
	
	return returnValue;


}

function resizeBack(){
	//window.resizeTo(myWindowWidth,myWindowHeight);
	
	_docHeight =  (window.innerHeight != undefined)?window.innerHeight:document.body.offsetHeight;
	_docWidth = (window.innerWidth != undefined)?window.innerWidth:document.body.offsetWidth;
	
	// Added this to prevent resize on open in certain themes -- DOF 5.13.2011
	if(_restoreSize || _resizeOnOpen) {
		try{
			if(myWindowWidth - _docWidth != 0  || myWindowHeight - _docHeight != 0)
				window.resizeBy(myWindowWidth - _docWidth , myWindowHeight - _docHeight );
		} catch(err){
			setTimeout("resizeBack()",100);
		}
		
		if(_restoreSize == false ) {
			_resizeOnOpen == false;
		}
	}
}

resizer = 0;
function resizeBackWait(){
	
	clearTimeout(resizer);
	resizer = setTimeout("resizeBack()",100);

}

function init(){

	writeDebug("Starting init function");

	if(!is.ns4 && !(is.mac && is.ie)){
		
		if(is.safari){
			resizeBack()
			setTimeout("resizeBack()",2000);
		}else
			resizeBack()
		
		try {
		  	if(_resizeOnOpen) {
				window.moveTo((screen.width/2)-(myWindowWidth/2),(screen.height/2)-(myWindowHeight/2)-80);
		  	}
		} catch (e) {
		
		}
		
		if(_restoreSize) {
			window.onresize=resizeBackWait;
		}
		writeDebug("Tried to resize");
	}
	
	writeDebug("Agent: " + navigator.userAgent.toLowerCase());
	writeDebug("Is Mac: " + is.mac);
	writeDebug("Is Safari: " + is.safari);
	writeDebug("Is Netscape: " + is.ns);
	writeDebug("Is IE: " + is.ie);
	writeDebug("Is Linux: " + is.linux);
	writeToLayer("lySplash","<img src='"+buttonDir + "background.jpg'>");
	
	refreshSlideList();
	
	compatibilityCheckValue = compatibilityCheck(currentPlayer);
	
	playerAbility =  (compatibilityCheckValue == 3);
	
	if(runNewCode == true) {
	
		if(os == "win") {
			if((browser == "firefox") || (browser == "safari") || (browser == "chrome")) {
				if((currentPlayer == "flash") || (currentPlayer == "wmp")) {
					playerAbility = true;
				}
			}
		}
			
	}
	
	writeDebug("Talk to player? " +playerAbility);
	writeMedia(currentPlayer);	
	resetLayers();

	allLoaded();

	customInterfaceOnLoad();
	customOnLoad();
	window.onunload=customOnUnload;
	
	// Check the server for Event state data 
	var myserverCheckIntercal = setInterval("checkServerData();",10000);
 
	setTimeout("setVolumeToMax();",500);
	masterLoop();	
	
}
function forceFullRefresh(){
	setTimeout('location.href= fullURL + "&rand=" + (new Date()).getTime()',5000);	
}

// Browser safe logging
function sLog(value) {
	try {
		console.log(value);
	} catch (err) {
	
	}
}


// Fire off embedded commands in Windows Media Stream in Firefox (DOF 2011-03-08 )
function OnDSScriptCommandEvt(bstrType, bstrParam)
{	
	if(navigator.userAgent.indexOf("Firefox") != -1) {
		try {	
			jQuery("#durlwindow").attr("src",bstrParam);
		} catch (err) {
	
		}
	}
}

// Flash SWF ExternalInterface functions -- DOF 2011.03.17 

function getID( swfID ){
	 var me;
	 if(navigator.appName.indexOf("Microsoft") != -1){
		  me = window[swfID];
	 }else{
		  me = document[swfID];
	 }
	 return me;
}

function getFlashDuration(){
	var flashControl = getID("lyMedia");
	var myDuration = flashControl.Duration();
	return myDuration;
}

function getFlashCurrentTime(){
	var flashControl = getID("lyMedia");
	var myCurrentTime = flashControl.CurrentTime();
	return myCurrentTime;
}

function setFlashCurrentTime(value){
	var flashControl = getID("lyMedia");
	flashControl.SetCurrentTime(value);
}

function getFlashState() {
	var flashControl = getID("lyMedia");
	return flashControl.State();
}

function playFlash() {
	var flashControl = getID("lyMedia");
	flashControl.PlayMedia();
}

function pauseFlash() {
	var flashControl = getID("lyMedia");
	flashControl.Pause();
}

function resumeFlash() {
	var flashControl = getID("lyMedia");
	flashControl.Resume();
}

function stopFlash() {
	var flashControl = getID("lyMedia");
	flashControl.StopMedia();
}

// Get QueryString Parameters
function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

// Handle Flash Media Stream Commands (OnStream)
// --> source: corresponds to url from the flash object
// --> frame: is loc
function handleFlashStreamCommand(value1, value2) {
	if (source == 'done') {
		//handle that the stream has been stopped
	}
	else {
		//handle script command
		sLog("loadHTML() - source = " + value1);
		sLog("loadHTML() - frame = " + value2);
	}
}

// Handle errors from the Flash Player
function handleFlashError(value1) {
	alert("An error has occurred with the Media Stream: \n\n" + value1);
}

// Check server data asynchronously and refresh the page if event is in new state
function checkServerData() { 
	//var sAjaxUrl = "https://management-dev.shareholder.com/event/build2/player_ajax.cfm";
	var sAjaxUrl = "http://www.shareholder.com/visitors/event/build2/player_ajax.cfm";
	jQuery.getJSON( sAjaxUrl + "?callback=?",
				    {  mediaid: mediaID},
				    function(data) {	 							
						jQuery.each(data, function(key, val) {																							
							// Handle returned data
							//console.log('checkServerData() JSON -> ' + key + ' =' + val);
							
							// If "data.scheduleid" has a value
							if(!isNaN(data.scheduleid)) {
								// If "data.scheduleState" has a new value
								if(_oldEncoderState != data.scheduleState) {
									// Refresh the page
									_oldEncoderState = data.scheduleState;									
									
									window.location.href = window.location.href;
								}
							}
							
						  });
	
					}
			);
	 
}
 
 
// </mediapresentation>
