// iPod Controls used on the iPod Demonstrator //
// Version V1.0.0, 17/09/2007 WBM. //
// Copyright 2007. Property of Design Atom - wwww.designatom.com//

// Set global variables
var tmrForward = 0;
var tmrRewind = 0;

// If this is an IE browsers then hide the alternative video player
function fctLoadVideo(){
	// Check if this is IE
	if (navigator.appName.indexOf("Microsoft")!=-1){
		document.getElementById('alternative').style.visibility = "hidden";
	}
}

// Play the video
function fctPlay() {
	// Test if we are using the Windows Media Player
	if (document.embeds['video']){
		// We are using the embedded function so use Quick Time controls
		// Check if the video is already playing
		if(document.embeds['video'].GetRate()==1){
			// Video is currently playing so stop (pause) it
			document.embeds['video'].Stop()
		}
		else {
			// Video is not currently playing
			// Reset the Fast Forward and Rewind timers if set
			window.clearTimeout(tmrForward);
			window.clearTimeout(tmrRewind);
			
			//document.embeds['podcast'].SetRate()=1
			document.embeds['video'].Play()
	   	}
	}
	else {
		// We are using the Windows Media Player
		// Check if the video is already playing
		if(document.video.PlayState==2){
			// Video is currently playing so pause it
   			document.video.Pause();
		}
		else {
			// Video is not currently playing
			// Reset the Fast Forward and Rewind timers if set
			window.clearTimeout(tmrForward);
			window.clearTimeout(tmrRewind);
			
			// Set the play rate to normal speed and play the video
			document.video.rate= 1.0;
			document.video.play();
	   	}
	}
}

// Fast Forward the video
function fctForward() {
	// Test if we are using the Windows Media Player
	if (document.embeds['video']){
		// We are using the embedded function so use Quick Time controls
		// Increase the Play Rate of the Video
		document.embeds['video'].SetRate(2.0)
	}
	else {
		// We are using the Windows Media Player
	   	// Pause the video
	  	// document.movie1.Pause();
	  	
		// Increment the position marker
   		video.CurrentPosition = video.CurrentPosition +2;
	}

   	// Recall this function after a short delay
	tmrForward = setTimeout('fctForward()', 250);
}

// Rewind the video
function fctRewind() {
	// Test if we are using the Windows Media Player
	if (document.embeds['video']){
		// We are using the embedded function so use Quick Time controls
		// Invert the Play Rate of the Video and speed up
		document.embeds['video'].SetRate(-2.0)
	}
	else {
		// We are using the Windows Media Player
	   	// Decrement the position marker
   		video.CurrentPosition = video.CurrentPosition -2;
	}
   	
   	// Recall this function after a short delay
	tmrRewind = setTimeout('fctRewind()', 250);
}

// This function clears the Fast Forward and Rewind Timers
// It is called for the MouseUp event
function fctClearTimers() {
	// Reset the Fast Forward and Rewind timers if set
	window.clearTimeout(tmrForward);
	window.clearTimeout(tmrRewind);

	// If using quicktime reset the play rate of the video
	if (document.embeds['video']) document.embeds['video'].SetRate(1.0)
}

// Insert Transparent images to bend the text. For iPod this is carried out
// in two parts in order to wrap around the video
function fctVideoCurve() {
	// Create a string of HTML code to bend the text
	strContent1 = '<img src="_images/transparent.gif" class="curve" width="7" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="12" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="17" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="21" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="24" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="27" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="30" height="10">';
	strContent1 += '<img src="_images/transparent.gif" class="curve" width="32" height="10">';
	
	
	strContent2 = '<img src="_images/transparent.gif" class="curve" width="33" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="34" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="35" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="36" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="36" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="37" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="37" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="38" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="38" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="37" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="37" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="36" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="36" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="35" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="35" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="34" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="33" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="31" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="29" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="26" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="23" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="20" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="17" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="14" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="10" height="10">';
	strContent2 += '<img src="_images/transparent.gif" class="curve" width="5" height="10">';
			
	// Insert the HMTL code for the images into the webpage
	document.all.curve1.innerHTML = strContent1;
	document.all.curve2.innerHTML = strContent2;
}
