// JavaScript Document

//////////////////////////////////////////////
/// Code Added 2-2007
/// JrL
/// slide show affect for  featured videos
///
/// Note absolute image paths are used in this file.

	var videoCount = 0 ; /// how many videos to show updated by c# Code
	var curVideoCount = 0 ;  /// Zero based count of video to show
	var videoDelay = 8000;  /// delay in millisec between videos
	var videoPauseDelay = 5000;  /// delay in millisec between before restarting slide show when video img#button is clickeed
	var the_timeOutVideo = null;  /// place holder for video setTimeout event

function pauseVideoFeatures()
{
	stopVideo();
	showHideVideoObj('featuresPauseVideo');
	showHideVideoObj('featuresPlayVideo');

}

function playVideoFeatures()
{
//	curVideoCount = (curVideoCount +  1 ) % videoCount ;  
	showHideVideoObj('featuresPauseVideo');
	showHideVideoObj('featuresPlayVideo')
	nextVideo();

}

function showThisVideoItem(intItem) // used by onClick for "button#" image
{	// remember curVideoCount Zero based list
	curVideoCount = intItem % videoCount ;  
	stopVideo();
	nextVideo();
}

/// video functions	
function nextVideo(){ 
	ShowVideo(curVideoCount +  1) ; 
	HighlightVideoImage(curVideoCount +  1) ; 
	curVideoCount = (curVideoCount +  1 ) % videoCount ;  
	the_timeOutVideo = setTimeout("nextVideo();", videoDelay);  
} 
function stopVideo() { clearTimeout(the_timeOutVideo); } 

function showVideoItem(pID){
	stopVideo() ;
	HighlightVideoImage(pID) ; 
	ShowVideo(pID);
	curVideoCount = pID - 1;
	the_timeOutVideo = setTimeout("nextVideo();", videoPauseDelay); 
	 
}

function ShowVideo(videoID)
{
	for (intCounter = 1; intCounter <= videoCount; intCounter++)
	{ 
		if(intCounter == videoID)
		{
			showObj('featureVidID_' + intCounter);
		}else
		{
			hideObj('featureVidID_' + intCounter);
		}
	}

}

function HighlightVideoImage(intIndex){
	var objItem;
	var strImage;
	var intCounter;
	for (intCounter = 1; intCounter <= videoCount; intCounter++)
	{ 
		if (document.getElementById)
		{
			objItem = document.getElementById('btnVidFeature' + intCounter);
		}  else if (document.layers){
			objItem = document.layers['btnVidFeature' + intCounter];
		}
		if(intCounter == intIndex)
		{
			//	Set Highlighted Image
			if (imgPreLoad)
			{
				eval("btn" + intCounter + ".src = '/images/btn" + intCounter + "x.gif';");
				eval("btn" + intCounter + "x.src = '/images/btn" + intCounter + "x.gif';");
			}
			
			objItem.src = "/images/btn" + intCounter + "x.gif";
		}
		else
		{
		//alert('-' + objItem + '- 97')
			//Reset other Images
			if (imgPreLoad)
			{
				eval("btn" + intCounter + ".src = '/images/btn" + intCounter + ".gif';");
				eval("btn" + intCounter + "x.src = '/images/btn" + intCounter + "x.gif';");
			}
			objItem.src = "/images/btn" + intCounter + ".gif";
		}
	}
}
///
//////////////////////////////////////////////
//---------------------------- Show / Hide ---------------------------- //
//----------------------------------------------------
// Show or hide an element , and swap image
// used in Right Hand Content area
	
function showHideVideoObj(name){
	var obj;
		if (document.getElementById)
		{
			obj = document.getElementById(name);
		}  else if (document.layers){
			obj = document.layers[name];
		}
		
		if (obj.style.display == "none"){
			obj.style.display = "block";
			}
		else{
			obj.style.display = "none";
			}
			
}
// Show Element
function showObj(name){
	var obj;
		if (document.getElementById)
		{
			obj = document.getElementById(name);
		}  else if (document.layers){
			obj = document.layers[name];
		}
		
		obj.style.display = "block";
}

// Hide Element
function hideObj(name ){
	var obj;
		if (document.getElementById)
		{
			obj = document.getElementById(name);
		}  else if (document.layers){
			obj = document.layers[name];
		}
		if(obj != null)
			obj.style.display = "none";	
					}

function changeVideoImageByID(objID, imgSwap)
{
	if (imgPreLoad && document.getElementById )
	{
		oImg = document.getElementById(objID);
		oImg.src = eval(imgSwap + ".src");
	}
}
var imgPreLoad = false;

if (document.images)
{
	btn1 = new Image();
	btn1.src =  "/images/btn1.gif";

	btn1x = new Image();
	btn1x.src =  "/images/btn1x.gif";

	btn2 = new Image();
	btn2.src =  "/images/btn2.gif";

	btn2x = new Image();
	btn2x.src =  "/images/btn2x.gif";

	btn3 = new Image();
	btn3.src =  "/images/btn3.gif";

	btn3x = new Image();
	btn3x.src =  "/images/btn3x.gif";

	btn4 = new Image();
	btn4.src =  "/images/btn4.gif";

	btn4x = new Image();
	btn4x.src =  "/images/btn4x.gif";

	btnPause = new Image();
	btnPause.src =  "/images/btnPause.gif";

	btnPlay = new Image();
	btnPlay.src =  "/images/btnPlay.gif";

	imgPreLoad = true;
}

//////////////////////////////////////////////
//------------------------ SHADOWBOX FUNCTIONS -------------------------- //
//----------------------------------------------------
function showVideo(videoPath) {
	pageTracker._trackPageview('/video/'+videoPath);
	Shadowbox.open({
        player: 'swf',
	   modal:false,
	   autoplayMovies:true,
	   content: 'swf/video.swf?flashvars='+videoPath,
        height:470,
        width:645,
	   title: '',
	   options:{enableKeys:false, displayNav:false} });
}
function showVideoFromLitMed(videoPath) {
	pageTracker._trackPageview('/video/'+videoPath);
	Shadowbox.open({
        player: 'swf',
	   modal:false,
	   autoplayMovies:true,
	   content: '/swf/video.swf?flashvars='+videoPath,
        height:470,
        width:645,
	   title: '',
	   options:{enableKeys:false, displayNav:false} });
}