function embedControlVideo(movie, width, height, id) 
{
	document.write("<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='" + width + "' height='" + height + "' codebase='http://www.apple.com/qtactivex/qtplugin.cab' id='" + id + "'>");		
		document.write("<param name='src' value='" + movie + "' />");
		document.write("<param name='controller' value='true' />");
		document.write("<param name='autoplay' value='true' />");
		document.write("<param name='enablejavascript' value='true' />");
		document.write("<param name='scale' value='tofit' />");
		document.write("<param name='kioskmode' value='false' />");
		document.write("<param name='bgcolor' value='#000000' />");
			
		document.write("<embed ");
			document.write("src='" + movie + "'");
			document.write("width='" + width + "'");
			document.write("name='" + id + "'");
			document.write("height='" + height + "'");
			document.write("autoplay='true'");
			document.write("scale='tofit'");
			document.write("kioskmode='false'");
			document.write("bgcolor='#000000'");
			document.write("type='video/quicktime'");
			document.write("pluginspage='http://www.apple.com/quicktime/download/'");
			document.write("enablejavascript='true'");
			document.write("controller='true'");
		document.write("></embed>");
	document.write("</object>");
}

function embedControlVideo2(movie, width, height, id) 
{
	document.write("<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='" + width + "' height='" + height + "' codebase='http://www.apple.com/qtactivex/qtplugin.cab' id='" + id + "'>");		
		document.write("<param name='src' value='" + movie + "' />");
		document.write("<param name='controller' value='true' />");
		document.write("<param name='autoplay' value='true' />");
		document.write("<param name='enablejavascript' value='true' />");
		document.write("<param name='scale' value='tofit' />");
		document.write("<param name='kioskmode' value='false' />");
		document.write("<param name='bgcolor' value='#000000' />");
			
		document.write("<embed ");
			document.write("src='" + movie + "'");
			document.write("width='" + width + "'");
			document.write("name='" + id + "'");
			document.write("height='" + height + "'");
			document.write("autoplay='true'");
			document.write("scale='tofit'");
			document.write("kioskmode='false'");
			document.write("bgcolor='#000000'");
			document.write("type='video/quicktime'");
			document.write("pluginspage='http://www.apple.com/quicktime/download/'");
			document.write("enablejavascript='true'");
			document.write("controller='true'");
		document.write("></embed>");
	document.write("</object>");
}

/* define function that shows percentage of movie loaded
function showProgress() 
{ 
var percentLoaded = 0 ; 
percentLoaded = parseInt((document.movie1.GetMaxTimeLoaded() / document.movie1.GetDuration()) * 100); 
document.getElementById("loadStatus").innerHTML = 'Movie loading: ' + percentLoaded + '% complete...'; 
} 
// define function that executes when movie loading is complete
function movieLoaded() 
{ 
document.getElementById("loadStatus").innerHTML = "Movie Loaded" ; 
} */

function checkVideo()
{
    var video = document.controlMovie;
    var time = parseInt(video.GetTime()/video.GetTimeScale());
    
    if (time > 1)
    {
        try
        {
            if (video.GetRate() == 0) pauseVideo();
            if (video.GetRate() == 1) playVideo();
        }
        catch(e)
        {
        }
    }
}

function playVideo()
{
    var video = document.controlMovie;
    var pause = document.getElementById("pause");
    
    video.Play();
    if (pause.innerHTML.indexOf("play") > -1) pause.innerHTML = '<a href="javascript:pauseVideo();"><img src="images/pause.jpg" alt="Pause" title="Pause"></a>&nbsp;';
}

function pauseVideo()
{
    var video = document.controlMovie;
    var pause = document.getElementById("pause");
    
    video.Stop();
    if (pause.innerHTML.indexOf("pause") > -1) pause.innerHTML = '<a href="javascript:playVideo();"><img src="images/play.jpg" alt="Play" title="Play"></a>&nbsp;';
}

function rewindVideo()
{
    var video = document.controlMovie;
    var pause = document.getElementById("pause");
    var rate = video.GetRate();
    
    video.Step(-300);
    if (rate) video.Play();
}

function fastForwardVideo()
{
    var video = document.controlMovie;
    var pause = document.getElementById("pause");
    var rate = video.GetRate();
    
    video.Step(300);
    
    if (rate) video.Play();
}

function checkForCaptions()
{
    var video = document.controlMovie;
    //Do something here.
}

function closeCaptioning(state)
{
    var video = document.controlMovie;
    var closeCaption = document.getElementById("closeCaptioning");
    
    if (state == "on")
    {
        video.SetTrackEnabled(4, true);
        closeCaption.innerHTML = '<a href="javascript:closeCaptioning(\'off\');"><img src="images/closeCaptioning.jpg" alt="Close Captioning" title="Close Captioning" /></a>';
    }
    else
    {
        video.SetTrackEnabled(4, false);
        closeCaption.innerHTML = '<a href="javascript:closeCaptioning(\'on\');"><img src="images/closeCaptioning.jpg" alt="Close Captioning" title="Close Captioning" /></a>';
    }
}

function embedVideo(asset, autoPlay)
{
	document.write("<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='400' height='317' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>");
		document.write("<param name='id' value='controlMovie' />");
		document.write("<param name='name' value='controlMovie' />");
		document.write("<param name='src' value='" + asset +"' />");
		document.write("<param name='controller' value='true' />");
		document.write("<param name='autoplay' value='true' />");
		document.write("<param name='enablejavascript' value='true' />");
		document.write("<param name='scale' value='tofit' />");
		document.write("<param name='kioskmode' value='true' />");
		document.write("<param name='bgcolor' value='#C7CED8' />");
			
		document.write("<embed ");
		    document.write("id='controlMovie'");
		    document.write("name='controlMovie'");
			document.write("src='" + asset + "'");
			document.write("width='400'");
			document.write("height='317'");
			document.write("autoplay='true'");
			document.write("scale='tofit'");
			document.write("kioskmode='true'");
			document.write("bgcolor='#C7CED8'");
			document.write("type='video/quicktime'");
			document.write("pluginspage='http://www.apple.com/quicktime/download/'");
			document.write("enablejavascript='true'");
			document.write("controller='true'");
		document.write("></embed>");
	document.write("</object>");
}

function embedAltVideo(asset, width, height)
{
	document.write("<object id='movie1' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='"+width+"' height='"+height+"' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>");
		document.write("<param name='src' value='" + asset +"' />");
		document.write("<param name='controller' value='true' />");
		document.write("<param name='autoplay' value='true' />");
		document.write("<param name='enablejavascript' value='true' />");
		document.write("<param name='scale' value='tofit' />");
		document.write("<param name='kioskmode' value='true' />");
		document.write("<param name='bgcolor' value='#666666' />");
			
		document.write("<embed ");
			document.write("src='" + asset + "'");
			document.write("name='movie1'");
			document.write("width='"+width+"'");
			document.write("height='"+height+"'");
			document.write("autoplay='true'");
			document.write("scale='tofit'");
			document.write("kioskmode='true'");
			document.write("bgcolor='#666666'");
			document.write("type='video/quicktime'");
			document.write("pluginspage='http://www.apple.com/quicktime/download/'");
			document.write("enablejavascript='true'");
			document.write("controller='true'");
		document.write("></embed>");
	document.write("</object>");
}

// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var DH = 0;
var an = 0;
var al = 0;
var ai = 0;

if (document.getElementById) 
{
	ai = 1; 
	DH = 1;
}
else 
{
	if (document.all) 
	{
		al = 1; 
		DH = 1;
	} 
	else
	{ 
		browserVersion = parseInt(navigator.appVersion); 
		
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) 
		{
			an = 1; DH = 1;
		}
	}
}

function fd(oi, wS) 
{
	if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); 
	if (al) return wS ? document.all[oi].style: document.all[oi]; 
	if (an) return document.layers[oi];
}

function pw() 
{
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}

function mouseX(evt) 
{
	if (evt.pageX) return evt.pageX; 
	else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
	else return null;
}

function mouseY(evt) 
{
	if (evt.pageY) return evt.pageY; 
	else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
	else return null;
}

function popUp(evt,oi) 
{
	if (DH) 
	{
		var wp = pw(); 
		ds = fd(oi,1); 
		dm = fd(oi,0); 
		st = ds.visibility; 
		
		if (dm.offsetWidth) ew = dm.offsetWidth; 
		else if (dm.clip.width) ew = dm.clip.width; 
		
		if (st == "visible" || st == "show") 
		{ 
			ds.visibility = "hidden"; 
		} 
		else 
		{
			tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); 
			
			if (lv < 2) lv = 2; 
			else if (lv + ew > wp) lv -= ew/2; 
			
			if (!an) 
			{
				lv += 'px';
				tv += 'px';
			} 
			
			ds.left = lv; 
			ds.top = tv; 
			ds.visibility = "visible";
		}
	}
}

/* XHTML compliant function to setting targets on links */
function setTargets() {
	var getHref=document.getElementsByTagName("A");
	for (i=0; i< getHref.length; i++) {
		if (getHref[i].rel=="_blank") {
			getHref[i].target="_blank"; 
		}
	}
}

function bright(img) {
	img.className="dim";
}	

function dim(img) {
	img.className="bright";
}

function fullScreen(page)
{
    var popup = document.getElementById("popupDIV");
    var video = document.controlMovie;
    var fullVideo = window.frames["fullVideo"].document.controlMovie;
    var fullVideoPause = window.frames["fullVideo"].document.getElementById("pause");
    var time = video.GetTime();
    var rate = video.GetRate();
    
    //Stop the small video and set it's height and width to zero.
    video.Stop();
    video.style.height = 0 + "px";
    video.style.width = 0 + "px";
    
    //Set the popup visibility to visible.
    popup.style.visibility = "visible";

    //Stop the full video and jump it ahead.
    fullVideo.Stop();
    fullVideo.SetTime(time);
    
    
    //If the rate of the small video was playing, set the full video to playing.
    if (rate)
    {
        fullVideo.Play();
        fullVideoPause.innerHTML = '<a href="javascript:pauseVideo();"><img src="images/pause.jpg" alt="Pause" title="Pause" /></a>&nbsp;';
    }
    else
    {
        fullVideo.Stop();
        fullVideoPause.innerHTML = '<a href="javascript:playVideo();"><img src="images/play.jpg" alt="Play" title="Play" /></a>&nbsp;';
    }
}

function smallScreen(page)
{
    var popup = parent.document.getElementById("popupDIV");
    var parentVideo = parent.document.controlMovie;
    var parentVideoPause = parent.document.getElementById("pause");
    var fullVideo = document.controlMovie;
    var time = parseInt(fullVideo.GetTime()/fullVideo.GetTimeScale());
    var rate = fullVideo.GetRate();
    
    fullVideo.Stop();
    popup.style.visibility = "hidden";
    
    time = time * parentVideo.GetTimeScale();
    parentVideo.Stop();
    parentVideo.SetTime(time);
    parentVideo.style.height = 302 + "px";
    parentVideo.style.width = 400 + "px";
    
    if (rate)
    {
        parentVideo.Play();
        parentVideoPause.innerHTML = '<a href="javascript:pauseVideo();"><img src="images/pause.jpg" alt="Pause" title="Pause" /></a>&nbsp;';
    }
    else
    {
        parentVideo.Stop();
        parentVideoPause.innerHTML = '<a href="javascript:playVideo();"><img src="images/play.jpg" alt="Play" title="Play" /></a>&nbsp;';
    }
}


//Variable used to store the set interval ID.
var interval;

function setUp(startTime, endTime)
{
    //Check to ensure that the start time has a value.
    if (startTime != "" || startTime != "undefined")
    {
        //Get a reference to the movie and stop it until the movie loads.
        var movie = document.controlMovie;
        movie.Stop();
        
        //Create an interval to check the start time.
        interval = window.setInterval("jumpAhead(" + startTime + "," + endTime + ")", 1000);    
    }
}

function jumpAhead(startTime, endTime)
{
    //Get a reference to the movie and check how much has loaded.
    var movie = document.controlMovie;
    var movieTime = parseInt(movie.GetMaxTimeLoaded() / movie.GetTimeScale());
    
    //If the movie's current load time is greater than or equal to the start time, then jump the video ahead.
    if (movieTime >= startTime)
    {
        //Stop the movie, jump ahead, and start it again.
        movie.Stop();
        movie.SetTime(startTime * movie.GetTimeScale());
        movie.Play();
        
        //Clear the start time interval.
        window.clearInterval(interval);
        
        //Set up an interval that will check to see if the video has reached the end point.
        interval = window.setInterval("endAt(" + endTime + ")",1000);
    }
}

function endAt(endTime)
{
    //Get a reference to the movie and check it's current time.
	var movie = document.controlMovie;
	var movieTime = parseInt(movie.GetTime()/movie.GetTimeScale());
    
    //If the movie's current time is greater than or equal to the end time, then stop the movie.
	if (movieTime >= endTime)
	{
		//Stop the movie.
		movie.Stop();
		
		//Remove the end time interval.
		window.clearInterval(interval);
	}
}
