// if quicktime plugin is not installed, show quicktime link

//haveqt = false;
// IE doesn't seem to support functions checking if quicktime plugin is installed
if (!is_ie) {
	if (!haveqt) {
		setTimeout("hide_video();", 100);
	}
}

function getStatus(which_video) {
	var movie;

	if (which_video == "avidere_video")
		movie = document.avidere_video;
	else if (which_video == "avidere_video2")
		movie = document.avidere_video2;

	try {
		return movie.GetPluginStatus();
	}
	catch (e) {
		return null;
	}
}

function getTime(which_video) {
	var movie;

	if (which_video == "avidere_video")
		movie = document.avidere_video;
	else if (which_video == "avidere_video2")
		movie = document.avidere_video2;

	try {
		return movie.GetTime() / movie.GetTimeScale();
	}
	catch (e) {
		return null;
	}
}

function getDuration(which_video) {
	var movie;

	if (which_video == "avidere_video")
		movie = document.avidere_video;
	else if (which_video == "avidere_video2")
		movie = document.avidere_video2;

	try {
		return movie.GetDuration() / movie.GetTimeScale();
	}
	catch (e) {
		return null;
	}
}

function show_video(video_container_id, quicktime_container_id) {
	if (video_container_id == "video_healthcare_image_training")
		show_healthcare_image_training_video("healthcare_image_video_div");
	else if (video_container_id == "video_personal_image_training")
		show_personal_image_training_video("personal_image_video_div");

	document.getElementById(video_container_id).style.display = "inline";
	document.getElementById(quicktime_container_id).style.display = "none";
}

function hide_video(video_container_id, quicktime_container_id) {
	document.getElementById(video_container_id).style.display = "none";
	document.getElementById(quicktime_container_id).style.display = "inline";
}

function check_video_end(video_id) {
	if (getStatus(video_id) == "Complete") {
		if (getDuration(video_id) - getTime(video_id) == 0) {
			//alert("video has ended");

			try {
				if (video_id == "avidere_video")
					movie = document.avidere_video;
				else if (video_id == "avidere_video2")
					movie = document.avidere_video2;

				movie.Rewind();
				//movie.Stop();
			}
			catch (e) {
			}

			current_video = null;
			show_content("main_content");
			//setTimeout("window.location.reload();", 1000);
		}
	}
}

var current_video;
setInterval("if (current_video) { check_video_end(current_video); }", 2000);
