



function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

	
function thisMovie(movieName) {
	 if (navigator.appName.indexOf("Microsoft") != -1) {
		 return window[movieName];
	 } else {
		 return document[movieName];
	 }
 }
 	
function SeekToCuePoint(value) {
	 thisMovie("RSNAVideoPlayer").SeekToCuePoint(value);
 }
 
 function sendToActionScript(value) {
	 thisMovie("RSNAVideoPlayer").sendToActionScript(value);
 }	
	
function SendSeek(seek) {
	//alert("sent highlight");
	//alert('seek' + seek);
	var flashMovie=getFlashMovieObject("dpsVideo");
	flashMovie.SetVariable("currentseek", seek);
	

	//alert(thisHQarray);
}


function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    try {return theMovie.PercentLoaded() == 100; } catch(e) { return false;}
  } else {
    return false;
  }
}


function isPlaying(movie){
	var flashMovie=getFlashMovieObject(movie);
	  	if (flashMovie.IsPlaying()) { alert("movie is playing"); } else {alert("movie is not playing")}
}

function flashLoaded(movie){
	var flashMovie=getFlashMovieObject(movie);
	return flashMovie.PercentLoaded();
}





//drawFlash
// this function will draw your flash file to specfic div at a specified width and height.
// target = the div tag to hold your flash
// url = the url to your flash file
// width, height - obvious


function drawFlash(target,url, width, height, name,autoplay,type,displaytype){
	//alert('did it ' + target + ' width: ' + width + ' height: ' + height );
	//alert(displaytype);
	var doplay = false;
	if(autoplay == 'Y'){doplay=true;}
	
	var doloop = false;
	if(displaytype == 'HIGHLIGHT' && type=='PPT SLIDE'){doloop = true;doplay=true;}
	

	
	//var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	//if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	    + 'width="' + width + '" height="' + height + '"' + 'id="' + name + '"'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	    + '<param name="movie" value="' + url  + '" /><param name="' + doloop +'" value="false" /><param name="play" value="' + doplay +'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" /><param name="SCALE" value="exactfit" />'
	    + '<embed src="' + url + '" loop="' + doloop +'" menu="false" quality="high" bgcolor="#ffffff" swliveconnect="true" '
	    + 'width="' + width + '" height="' + height + '" name="' + name +'" align="top"'
	    + 'play="' + doplay +'"'
	    + 'loop="' + doloop +'"'
	    + 'quality="high"'
		+ 'wmode="transparent"'
		+ 'scale="exactfit"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'type="application/x-shockwave-flash"'
	    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/embed>'
	    + '<\/object>';
	    document.getElementById(target).innerHTML =oeTags;

		//document.getElementById(target).innerHTML = url;
		//PlayFlash(name);

	 // } else {  // flash is too old or we can't detect the plugin
	  //  var alternateContent = ''
	  //	+ 'This content requires the Macromedia Flash Player.'
	   //	+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
	   // document.write(alternateContent);  // insert non-flash content
	  // document.getElementById(target).innerHTML =alternateContent;
	 // }

	  /*if(type=='PPT SLIDE' && autoplay == 'Y'){
	  	flashplayingInterval = setInterval(function(){checkPlayStatus(name);}, 100);
	  }*/
	  

} // end drawUpload



function drawFlashBG(target,url,frametoplay, bg_id){
		
	//var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	var width=document.getElementById(target).style.width.split("px")[0];
	var height=document.getElementById(target).style.height.split("px")[0];
	var name = target + '_' + bg_id;
	var doloop = false;
	var doplay = false;
	
	//Check to see if this background is already loaded.
	var flashMovie=getFlashMovieObject(name);
	
	//alert(name);
	
	if(movieIsLoaded(flashMovie)){
		//alert('bgloaded: ' + frametoplay);
		flashMovie.GotoFrame(frametoplay);
		
	} else {
	
	//if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	    + 'width="' + width + '" height="' + height + '"' + 'id="' + name + '"'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	    + '<param name="movie" value="' + url  + '" /><param name="loop" value="' + doloop +' /><param name="play" value="' + doplay +'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" /><param name="SCALE" value="exactfit" />'
	    + '<embed src="' + url + '" loop="' + doloop +'" menu="false" quality="high" bgcolor="#ffffff" swliveconnect="true" '
	    + 'width="' + width + '" height="' + height + '" name="' + name +'" align="top"'
	    + 'play="' + doplay +'"'
	    + 'loop="' + doloop +'"'
	    + 'quality="high"'
		+ 'wmode="transparent"'
		+ 'scale="exactfit"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'type="application/x-shockwave-flash"'
	    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/embed>'
	    + '<\/object>';
	    document.getElementById(target).innerHTML =oeTags;

		//document.getElementById(target).innerHTML = url;
		//PlayFlash(name);

	//  } else {  // flash is too old or we can't detect the plugin
	    //var alternateContent = ''
	  //+ 'This content requires the Macromedia Flash Player.'
	   //	+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
	   // document.write(alternateContent);  // insert non-flash content
	  // document.getElementById(target).innerHTML =alternateContent;
	 // }
	}// is movie loaded
}



function drawFlashPPT(target,url, ppt_id, autoplay,type,displaytype){
	//alert('did it ' + target + ' width: ' + width + ' height: ' + height );
	//alert(displaytype);
	var doplay = false;
	if(autoplay == 'Y'){doplay=true;}
	
	var doloop = false;
	if(displaytype == 'HIGHLIGHT' && type=='PPT SLIDE'){doloop = false;doplay=true;}

	if(displaytype == 'SLIDE' && type=='PPT SLIDE'){doloop = false;doplay=false;}
	
	
	var width=document.getElementById(target).style.width.split("px")[0];
	var height=document.getElementById(target).style.height.split("px")[0];
	var name = target + '_' + ppt_id;
	
	//var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	//if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	    + 'width="' + width + '" height="' + height + '"' + 'id="' + name + '"'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	    + '<param name="movie" value="' + url  + '" /><param name="loop" value="' + doloop +'" /><param name="play" value="' + doplay +'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" /><param name="SCALE" value="exactfit" />'
	    + '<embed src="' + url + '" loop="' + doloop +'" menu="false" quality="high" bgcolor="#ffffff" swliveconnect="true" '
	    + 'width="' + width + '" height="' + height + '" name="' + name +'" align="top"'
	    + 'play="' + doplay +'"'
	    + 'loop="' + doloop +'"'
	    + 'quality="high"'
		+ 'wmode="transparent"'
		+ 'scale="exactfit"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'type="application/x-shockwave-flash"'
	    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/embed>'
	    + '<\/object>';
	    document.getElementById(target).innerHTML =oeTags;

		//document.getElementById(target).innerHTML = url;
		//PlayFlash(name);

	//  } else {  // flash is too old or we can't detect the plugin
	 //   var alternateContent = ''
	 // 	+ 'This content requires the Macromedia Flash Player.'
	  // 	+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
	   // document.write(alternateContent);  // insert non-flash content
	  // document.getElementById(target).innerHTML =alternateContent;
	 // }

	  if(type=='PPT SLIDE' && autoplay == 'Y' && displaytype == 'SLIDE'){
		// animationcurrentstate ='playing';
	  	//flashplayingInterval = setInterval(function(){checkPlayStatus(name);},50);
		//alert(flashplayingInterval);
		//clearInterval(flashplayingInterval);
	  }
	  

} // end drawUpload




function PlayFlash(name){
		var flashMovie=getFlashMovieObject(name);
		alert(flashMovie.IsPlaying());
		flashMovie.Play();
		alert(flashMovie.IsPlaying());

}




			


function drawRSNAVideo(target,url, width, height,loop,autoplay,cuepoint,preloader){
	//alert('loop: ' + loop);
	//alert('autoplay: ' + autoplay);
	//var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	//if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<div style="display:block"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="dpsVideo"' 
	    + 'width="' + width + '" height="' + height + '"'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	    + '<param name="movie" value="/swf/RSNAFlvPlayer.swf?preloader=' + preloader + '&stream=' + url + '&loop=' + loop + '&maintainAspectRatio=N&autoPlay=' + autoplay + '&cuepoint=' + cuepoint + '" /><param name="SCALE" value="exactfit" /><param name="loop" value="true" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />'
	    + '<embed src="/swf/RSNAFlvPlayer.swf?preloader=' + preloader + '&stream=' + url + '&loop=' + loop + '&maintainAspectRatio=N&autoPlay=' + autoplay + '&cuepoint=' + cuepoint + '" loop="false" menu="false" quality="high" bgcolor="#ffffff" '
	    + 'width="' + width + '" height="' + height + '" name="dpsVideo" align="top"'
		+ 'scale="exactfit"'
	    + 'play="false"'
	    + 'loop="true"'
	    + 'quality="high"'
		+ 'wmode="transparent"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'type="application/x-shockwave-flash"'
	    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/embed>'
	    + '<\/object></div>';
	    document.getElementById(target).innerHTML =oeTags;
		//document.write(oeTags);   // embed the flash movie
	//  } else {  // flash is too old or we can't detect the plugin
	 //   var alternateContent = ''
	 // 	+ 'This content requires the Macromedia Flash Player.'
	  // 	+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
	   // document.write(alternateContent);  // insert non-flash content
	//   document.getElementById(target).innerHTML =alternateContent;
	 // }
//

} // end drawFlashVideo

function drawRSNAAudio(target,server,app,stream, width, height,loop,autoplay){
	//alert('audio: ' + stream);
//	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	//if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="RSNAAudio' + target + '"' 
	    + 'width="' + width + '" height="' + height + '"'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	    + '<param name="movie" value="/swf/mp3.swf?stream=' + stream + '&loop=' + loop + '&autoplay=' + autoplay + '&app=' + app +'&server=' + server +'" /><param name="SCALE" value="exactfit" /><param name="loop" value="true" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />'
	    + '<embed src="/swf/mp3.swf?stream=' + stream + '&loop=' + loop + '&autoplay=' + autoplay + '&app=' + app +'&server=' + server + '" loop="false" menu="false" quality="high" bgcolor="#ffffff" '
	    + 'width="' + width + '" height="' + height + '" name="RSNAAudio' + target + '" align="top"'
		+ 'scale="exactfit"'
	    + 'play="false"'
	    + 'loop="true"'
	    + 'quality="high"'
		+ 'wmode="transparent"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'type="application/x-shockwave-flash"'
	    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/embed>'
	    + '<\/object>';
	    document.getElementById(target).innerHTML =oeTags;
		//document.write(oeTags);   // embed the flash movie
	//  } else {  // flash is too old or we can't detect the plugin
	///    var alternateContent = ''
	  //	+ 'This content requires the Macromedia Flash Player.'
	   //	+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
	   // document.write(alternateContent);  // insert non-flash content
	   //document.getElementById(target).innerHTML =alternateContent;
	  //}


} // end drawFlashVideo


function drawRSNAChat(target, width, height,room,name,profileId){
	//alert('loop: ' + loop);
	//alert('autoplay: ' + autoplay);
	//var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	//if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<div style="display:block"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="dpsChat"' 
	    + 'width="' + width + '" height="' + height + '"'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
	    + '<param name="movie" value="/swf/RSNARoomChat.swf?profileID=' + profileId + '&name=' + name + '&room=' + room +'"  /><param name="SCALE" value="exactfit" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />'
	    + '<embed src="/swf/RSNARoomChat.swf?profileID=' + profileId + '&name=' + name + '&room=' + room +'" loop="false" menu="false" quality="high" bgcolor="#ffffff" '
	    + 'width="' + width + '" height="' + height + '" name="dpsChat" align="top"'
		+ 'scale="exactfit"'
	    + 'play="false"'
	    + 'loop="false"'
	    + 'quality="high"'
		+ 'wmode="transparent"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'type="application/x-shockwave-flash"'
	    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/embed>'
	    + '<\/object></div>';
	    document.getElementById(target).innerHTML =oeTags;
		//document.write(oeTags);   // embed the flash movie
	 // } else {  // flash is too old or we can't detect the plugin
	  //  var alternateContent = ''
	  //	+ 'This content requires the Macromedia Flash Player.'
	   //	+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
	   // document.write(alternateContent);  // insert non-flash content
	  // document.getElementById(target).innerHTML =alternateContent;
	 // }


} // end drawFlashVideo






