// QUICKTIME MOVIE CONTROLS USING JAVASCRIPT
// http://developer.apple.com/documentation/quicktime/REF/QT41_HTML/QT41WhatsNew-74.html
//
//    * QuickTime 4.1 is scriptable using Netscape 4 or 5 on Windows and Macintosh
//    * QuickTime 6 is scriptable using Internet Explorer on Windows, and most or all Netscape or Mozilla-based browsers on Windows or Macintosh. For more details, see "What's New in QuickTime 6."
//    * Plug-ins are not scriptable using Internet Explorer for Macintosh.

<!--
        function PlayIt(anObj) {
			anObj.Play();
        }
        function StopIt(anObj) {
			anObj.Stop();
			UpdateUI(anObj);
        }
		
		function PlayTOG(anObj) {
			if(anObj.GetRate()==0)
			{
				anObj.Play();
				document.getElementById('currentFR').innerHTML = '- - -';
				document.getElementById('play').innerHTML = 'pause';
				UpdateUI(anObj);				
			}else{
				anObj.Stop();
				UpdateUI(anObj);
			}
			
        }
		
		function playRate(anObj, rate) {
			//Mute if playing backwards.
/*
			if(rate >= 0) {
				volume(anObj, 1);
			}else {
				volume(anObj, 0);
			}
*/
			if(rate != 0) {
				document.getElementById('currentFR').innerHTML = '- - -';
				//document.getElementById('play').innerHTML = 'playing @ ' + parseInt((rate*100)) + '%';
			}
			anObj.SetRate(rate);
		}
		
		function StepBack(anObj) {
			anObj.Step(-1);
			UpdateUI(anObj);
		}
		
		function StepForw(anObj) {
			anObj.Step(1);
			UpdateUI(anObj);
		}
		function Controls(anObj) {
			if(anObj.GetControllerVisible()==1) {
				anObj.SetControllerVisible(0);
			}else {
				anObj.SetControllerVisible(1);
			}
		}
		
		function Kiosk(anObj) {
			if(anObj.GetKioskMode()==1) {
				anObj.SetKioskMode(0);
			}else {
				anObj.SetKioskMode(1);
			}
		}
		
		function FPS(anObj) {
			units = anObj.GetTimeScale();
			//alert ('RATE: ' + (units/25) +' fps')
			alert ('RATE: ' + units +' units');
			//return units;
		}
		
		function fSize(anObj) {
			bytes = anObj.GetMovieSize();
			kbytes = parseInt((bytes / 1024));
			alert ('FILESIZE: ' + kbytes + ' kb');
		}
		
		function current(anObj) {
			units = anObj.GetTime();
			alert ('CURRENT FRAME: ' + parseInt((units/25)));
		}
		
		function setcurrent(anObj, time) {
			anObj.SetTime(time*25);
		}
		
		function setcurrentPercent(anObj, percent) {
			position = (anObj.GetDuration()*percent);
			anObj.SetTime(position);
		}
		
		function length(anObj) {
			units = anObj.GetDuration();
			//frames = (units/25);
			//alert ('TOTAL LENGTH: ' + (units/25) +' frames');
			//return frames;
			return units;
		}
		
		function framelength(anObj) {
			units = anObj.GetDuration();
			frames = (units/25);
			return frames;
		}
		
		function start(anObj, time) {
			anObj.SetStartTime(time);
			//alert ('START TIME: ' + anObj.GetStartTime()+' units')
		}
		
		function startPercent(anObj, percent) {
			position = (anObj.GetDuration()*percent);
			anObj.SetStartTime(position);
			//alert ('START TIME: ' + anObj.GetStartTime()+' units')
		}
		
		function end(anObj, time) {
			anObj.SetEndTime(time);
			//alert ('END TIME: ' + anObj.GetEndTime()+' units')
		}
		
		function endPercent(anObj, percent) {
			position = (anObj.GetDuration()*percent);
			anObj.SetEndTime(position);
			//alert ('START TIME: ' + anObj.GetEndTime()+' units')
		}
		
		function volume(anObj, percent) {
			anObj.SetVolume((percent*100));
		}
//-->
<!--
	function setFrange(anObj,startFrame,endFrame) {
		StopIt(anObj);
		setcurrent(anObj,startFrame);
		start(anObj, (startFrame*25));
		end(anObj, (endFrame*25));
		start(anObj, (startFrame*25));
	}
	function setStartFrame(anObj,startFrame) {
		StopIt(anObj);
		setcurrent(anObj,startFrame);
		start(anObj, (startFrame*25));
		UpdateUI(anObj);
	}
	function setEndFrame(anObj,endFrame) {
		StopIt(anObj);
		setcurrent(anObj,endFrame);
		end(anObj, (endFrame*25));
		UpdateUI(anObj);
	}
//-->
<!--
function UpdateUI(anObj) {
	units = anObj.GetTime();
	rate = anObj.GetRate();
	lengthUnits = anObj.GetDuration();
	startTime = anObj.GetStartTime();
	endTime = anObj.GetEndTime();
	movieName=anObj.name;

	//MOVIE FRAME LENGTH
	//document.getElementById('length').innerHTML = parseInt((lengthUnits/25));
	//PLAY RANGE UPDATE

	fullWidth = document.getElementById('popup_contentDiv').offsetWidth
	barMaxWidth = fullWidth;
	
	if(anObj.GetStartTime()==0 && anObj.GetEndTime()==anObj.GetDuration()) {
		//Reset range text
		document.getElementById('playRange').innerHTML = '<a href=\"javascript:;\" onClick=\"javascript:setStartFrame(document.' + movieName + ',' + parseInt((units/25)) +');\">' + parseInt(startTime/25) + '</a>' + '<span style="margin:1px">-</span>' + '<a href=\"javascript:;\" onClick=\"javascript:setEndFrame(document.' + movieName + ',' + parseInt((units/25)) + ');\">'  + parseInt(endTime/25) + '</a>';

		//Reset "rangeBar"
		document.getElementById('rangeBar').style.width = "100%";
		document.getElementById('rangeBar').style.backgroundColor = "#ffffff";
		document.getElementById('rangeBar').style.left = "0px";
/* 	alert(fullWidth + ", " + barMaxWidth + ", " + barStartPos); */

	} else {
		//Set range text
		if(anObj.GetStartTime()>0){ startStyle = 'style=\'color:#00aa00\' ';}
		else { startStyle = '';}
		if(anObj.GetEndTime()<anObj.GetDuration()){ endStyle = 'style=\'color:#00aa00\' ';}
		else{ endStyle = '';}
		document.getElementById('playRange').innerHTML = '<a href=\"javascript:;\" ' + startStyle + 'onClick=\"javascript:setStartFrame(document.' + movieName + ',' + parseInt((units/25)) +');\">' + parseInt(startTime/25) + '</a>' + '<span style="margin:1px">-</span>' + '<a href=\"javascript:;\" ' + endStyle + 'onClick=\"javascript:setEndFrame(document.' + movieName + ',' + parseInt((units/25)) + ');\">'  + parseInt(endTime/25) + '</a>' + ' <a href=\"javascript:;\" style=\"font-size:8px;\"onClick=\"javascript:resetRange(document.' + movieName + ');\">reset</a>';

		//Set "rangeBar"
		movieFullFrange = anObj.GetDuration();
		moviePlayFrange = anObj.GetEndTime() - anObj.GetStartTime();
		barWidth = (moviePlayFrange / movieFullFrange) * (barMaxWidth - 64);
		barStartPos = ((anObj.GetStartTime() / movieFullFrange) * (barMaxWidth - 64));

		percentage = (moviePlayFrange / movieFullFrange) * 100;

		document.getElementById('rangeBar').style.width = percentage + "%";
		//document.getElementById('rangeBar').style.width = barWidth + "px";
		document.getElementById('rangeBar').style.backgroundColor = "#88ff88";
		document.getElementById('rangeBar').style.left = barStartPos + "px";

/* 	alert(fullWidth + ", " + movieFullFrange + ", " + moviePlayFrange + ", " + barMaxWidth + ", " + barWidth + ", " + barStartPos); */
						
	}

	
	//TOGGLE PLAY/PAUSE button
	if(rate == 0) {
		document.getElementById('currentFR').innerHTML = parseInt((units/25));
		//document.getElementById('play').innerHTML = 'play';
	}
	else {
		document.getElementById('currentFR').innerHTML = '- - -';
		//document.getElementById('play').innerHTML = 'pause';
	}
	
	
	// ADJUST TEMP PLAYHEAD "MATCHER"
	currentTimePos = ( parseInt((units)) / anObj.GetDuration() ) * 100;
	document.getElementById('playHeadMatcher').style.left = currentTimePos + "%";
	
}
/* TEXT TAGS FUNCTIONALITY */
	function resetRange(anObj) {
		anObj.SetStartTime(0);
		anObj.SetEndTime(anObj.GetDuration());
		UpdateUI(anObj);
	}
	
	function addFrameText(anObj,textarea) {
		units = anObj.GetTime();
		document.getElementById(textarea).value += '(FRAME:' + (parseInt((units/25))) + ')';
		document.getElementById(textarea).focus();
	}
	
	function addRangeText(anObj,textarea) {
		units = anObj.GetTime();
		document.getElementById(textarea).value += '(RANGE:' + (parseInt((anObj.GetStartTime()/25))) + '-' + (parseInt((anObj.GetEndTime()/25))) + ')';
		document.getElementById(textarea).focus();
	}
	
	function linkFrameText(anObj,frame){
		StopIt(anObj);
		setcurrent(anObj, frame);
		UpdateUI(anObj);
	}
	
	function linkRangeText(anObj,startFrame,endFrame){
		setFrange(anObj, startFrame, endFrame);
		PlayIt(anObj);
		UpdateUI(anObj);
	}
//-->
