// JavaScript Document
// By Christof Daetwyler, M.D.
// Drexel University College of Medicine
// 2006
// contact: christof.daetwyler@drexelmed.edu

var myMovieCell;
var randomName;
var randomNumber;
var movieNumber;
var myWindowWidth;
var myWindowHeight;
var myMovieWidth;
var myMovieHeight;


function setMovieWidth()
{
  getWindowSize();
  myMovieWidth = eval(myWindowWidth) - 240;
  myMovieHeight = Math.round(eval(myMovieWidth*0.75));
  if ((myWindowHeight - myMovieHeight) < 50) {
  	myMovieHeight = eval(myWindowHeight) - 180;
  	myMovieWidth = Math.round(eval(myMovieHeight*1.33));
	}
//	alert(myMovieWidth+"*"+myMovieHeight);
  document.getElementById("MovieColumn").setAttribute("width",eval(myMovieWidth)+10);
}

function getWindowSize() 
{
// I found this script at http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  myWindowWidth = myWidth;
  myWindowHeight = myHeight;
}

  function pausecomp(millis)
{
date = new Date();
var curDate = null;
do { var curDate = new Date(); }
while(curDate-date < millis);
}


function initializeWatch()
{
resetAll();
document.getElementById("mover_watch").style.display = "inline";
document.getElementById("mover_watch").style.verticalAlign = "top";
setMovieWidth();
}


function loadMovie(movie) {
	
resetCellBackgroundColorExcept(movie);

myStr = "";
myStr = '<OBJECT CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" WIDTH="'+myMovieWidth+'" HEIGHT="'+myMovieHeight+'" id="main_movie"  CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B">';
myStr = myStr + '<PARAM NAME="SRC" VALUE="'+movie+'">';
myStr = myStr + '<PARAM name="SCALE" VALUE="tofit">';
myStr = myStr + '<PARAM name="CONTROLLER" VALUE="TRUE">';
myStr = myStr + '<PARAM name="BGCOLOR" value="#FFFFFF">';
myStr = myStr + '<EMBED SRC="'+movie+'" name="main_movie" WIDTH="'+myMovieWidth+'" SCALE="tofit" HEIGHT="'+myMovieHeight+'" align="center" CONTROLLER="TRUE" type="video/quicktime" BGCOLOR="#FFFFFF" BORDER="0" PLUGINSPAGE="http://www.apple.com/quicktime/download/indext.htm" enablejavascript="true"></EMBED><\/OBJECT>';

document.getElementById("movieCell").innerHTML = myStr;
document.getElementById("movieCell").style.display = "inline";
document.getElementById("introCell").style.display = "none";
}

function resetCellBackgroundColorExcept(movie){
  var x=document.getElementsByTagName("td");
  
  // first: reset the backgrounds to black
  for(i=0;i<x.length;i++){
	  x[i].style.backgroundColor="000000";
    }
	
	// then set the background of the click-link to grey:
  for(i=0;i<x.length;i++){
	  j=x.length-i-1;
	  if (x[j].innerHTML.indexOf(movie) > -1)
		{
	      x[j].style.backgroundColor="666666";
		  break
	    }
	}
}


function getAttributes(obj){
		for(var i=0;i<obj.attributes.length;i++){
			if(obj.attributes[i].specified){
				alert(obj.attributes[i].nodeName + "=" + obj.attributes[i].nodeValue);
			}
		}
	}

/*******************************************************
QUICKTIME DETECT
All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
*******************************************************/

var quicktime=new Object();

// Set some base values
quicktime.installed=false;
quicktime.version='0.0';


if (navigator.plugins && navigator.plugins.length)
{
	for (x=0; x<navigator.plugins.length; x++)
	{
		if (navigator.plugins[x].name.indexOf('QuickTime Plug-in') != -1)
		{
			quicktime.installed=true;
			quicktime.version=navigator.plugins[x].name.split('QuickTime Plug-in ')[1].split(' ')[0];
			break;
		}
	}
}
else if (window.ActiveXObject)
{
	try
	{
		oQTime=new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck.1');
		if (oQTime)
		{
			quicktime.installed=oQTime.IsQuickTimeAvailable(0);
			quicktime.version=parseInt(oQTime.QuickTimeVersion.toString(16).substring(0,3))/100;
		}
	}
	catch(e) {}
}



quicktime.ver2=(quicktime.installed && parseInt(quicktime.version) >= 2) ? true:false;
quicktime.ver3=(quicktime.installed && parseInt(quicktime.version) >= 3) ? true:false;
quicktime.ver4=(quicktime.installed && parseInt(quicktime.version) >= 4) ? true:false;
quicktime.ver5=(quicktime.installed && parseInt(quicktime.version) >= 5) ? true:false; 
quicktime.ver6=(quicktime.installed && parseInt(quicktime.version) >= 6) ? true:false;
quicktime.ver7=(quicktime.installed && parseInt(quicktime.version) >= 7) ? true:false; 
quicktime.ver8=(quicktime.installed && parseInt(quicktime.version) >= 8) ? true:false; 
quicktime.ver9=(quicktime.installed && parseInt(quicktime.version) >= 9) ? true:false;


function doquicktimestuff()
{
var myVar='';
if (quicktime.ver7)
	{
	// if QuickTime 7.0 or newer is installed, do QuickTime 7.0 stuff.
	
	myVar=''
	myVar='<font face="Verdana" size="-1">Your system meets the requirements</font><br>'
	myVar=myVar+'<font face="Verdana" size="-1">The videos should run smoothly.</font><br>'
	document.write(myVar);
	}
	else if (quicktime.installed)
	{
	// do older QuickTime stuff
	myVar=''
	myVar='<font face="Verdana" color="red" size="-1"><b>SYSTEM REQUIREMENTS ARE NOT MET!</b></font><br>'
	myVar=myVar+'<font face="Verdana" size="-1"><b><blink>You have an older version of Quicktime!</blink></font></b><br>';
	myVar=myVar+'<font face="Verdana" size="-1">Your version is: </font>' + quicktime.version;
	myVar=myVar+'<br><font face="Verdana" size="-1">Please go <a href="http://www.apple.com/quicktime/win.html" target="_blank"> here</a> and get Quicktime version 7.0</font><br>';
	document.write(myVar);
	document.getElementById("systemrequirements").style.backgroundColor='FFCC33';
	}
	else
	{
	// QuickTime is NOT installed. Do something else.
	
	myVar=''
	myVar='<font face="Verdana" color="red" size="-1"><b>SYSTEM REQUIREMENTS ARE NOT MET!</b></font><br>'
	myVar=myVar+'<font face="Verdana" size="-1"><b><blink>You do NOT have Quicktime installed!</blink></b></font><br>';
	myVar=myVar+'<font face="Verdana" size="-1">Please go <a href="http://www.apple.com/quicktime/win.html" target="_blank"> here</a> and get Quicktime version 7.0</font><br>'; 
	document.write(myVar);
	document.getElementById(systemrequirements).style.backgroundColor='FFCC33';
	}



}