// 2007.08.17 KJD: Document created
// 2007.09.04 KJD: Update for ScreenShots to be default if both available

var theURL = "";

function switchTop(i)
{
	document.getElementById( "WidgetContents" ).src = i;
}

function switchURL(x){
	theURL = x;	
}

function getURL()
{
	// 2007.08.30 KJD: Updated width from 692 to 800
	//2008.11.11 AKD:Updated width from 800 to 900 and height from 600 to 660 
   window.open( theURL,'welcome','width=900,height=660,resizable');
}

function showDiv(thisitem) 
{
	document.getElementById(thisitem).style.visibility = 'visible';
}
	
function hideDiv(thisitem)
{
	document.getElementById(thisitem).style.visibility = 'hidden';
}

// 2007.08.17 KJD: Check for Videos/Screenshots
function Check_ss_gettype()
{
	var SS_ShowType = "";
	if( typeof VideoSS_Videos != 'undefined' )
	{
		if( VideoSS_Videos.length )
		{
			SS_ShowType = "Videos";
		}
	}

	if( typeof VideoSS_Screenshots != 'undefined' )
	{
		if( VideoSS_Screenshots.length )
		{
			SS_ShowType += "ScreenShots";
		}
	}
	
	Check_ss_settype( SS_ShowType );
}

// 2007.08.17 KJD: Set the type of page
function Check_ss_settype( thisType )
{
	if( thisType == 'Videos' )
	{
		Widget_VideoSetLinks( 'videos' );
		
		hideDiv( 'ScreenshotContent'	);
		showDiv( 'VideoContent'			);
	
		hideDiv( 'widget_buttonscreen' );
	}
	else if( thisType == 'VideosScreenShots' )
	{
		Widget_VideoSetLinks( 'videos' );
		Widget_VideoSetLinks( 'screenshots' );
	
		showDiv( 'ScreenshotContent'	);
		hideDiv( 'VideoContent'			);
	}
	else if( thisType == 'ScreenShots' )
	{
		Widget_VideoSetLinks( 'screenshots' );

		showDiv( 'ScreenshotContent'	);
		hideDiv( 'VideoContent'			);
		
		hideDiv( 'widget_buttonvideo' );
	}
	else
	{
		// 2007.08.17 KJD: Neither
		document.getElementById( 'VideoSS_box' ).style.visibility	= "hidden";
		document.getElementById( 'VideoSS_box' ).style.display		= "none";
	}
}

// 2007.08.17 KJD: Set the Text elements
function Widget_VideoSetTextTitles()
{
	// main title
	document.getElementById( 'widget_VideoTitleText' ).innerHTML	= VideoSS_Title;
	
	// video title
	document.getElementById( 'widget_VideoTitle' ).innerHTML		= VideoSS_videoTitle;
	
	// screenshot title
	document.getElementById( 'widget_ScreenTitle' ).innerHTML		= VideoSS_ScreenTitle;
}

// 2007.08.17 KJD: Set up the links
function Widget_VideoSetLinks( thisType, selectedItem )
{
	var setDefault = 0;

	if( !( selectedItem ) )
	{
		selectedItem = 0;
		setDefault = 1;
	}

	if( thisType == 'videos' )
	{
		var thisArray	= VideoSS_Videos;
		var thisDiv		= "widget_videolinks";
	}
	else if( thisType == 'screenshots' )
	{
		var thisArray	= VideoSS_Screenshots;
		var thisDiv		= "widget_screenlinks";
	}

	var TheseLinks = "";
	
	for( var i = 0; i < thisArray.length; i++ )
	{
	
		var thisData = thisArray[ i ].split( "####" );
		var selectedText = "";
					
		if( selectedItem >= 0 )
		{
			if( i == parseInt( selectedItem ) )
			{
				selectedText = "<font STYLE='color:#999'>";
			}
		}
		
		if( setDefault && ( i == 0 ) )
		{

			switchTop( thisData[2] ); 
			switchURL( thisData[1] );
			setDefault = 0;
		}
		
		
		TheseLinks += "<a "
			+ "onClick=\"Widget_VideoSetLinks( '" + thisType + "', " + i + "); switchTop( '" + thisData[2] + "'); switchURL( '" + thisData[1] + "' );"
			+ "\">" 
			+ selectedText + thisData[0] + "</font></a> ";
	
		if( i != thisArray.length )
		{
			TheseLinks += " | ";
		}
	}
	
	document.getElementById( thisDiv ).innerHTML = TheseLinks;
}


// 2007.08.18 KJD: Set the view state
function widget_SetView( thisType )
{

	if( thisType == 'videos' )
	{
		var thisArray	= VideoSS_Videos;
	}
	else if( thisType == 'screenshots' )
	{
		var thisArray	= VideoSS_Screenshots;
	}
	
	for( var i = 0; i < thisArray.length; i++ )
	{
		var thisData = thisArray[ i ].split( "####" );
		break;
	}

	switchTop( thisData[2] ); 
	switchURL( thisData[1] );

		
	// set links
	if( thisType == 'videos' )
	{
		hideDiv( 'ScreenshotContent'	);
		showDiv( 'VideoContent'			);
	}
	else if( thisType == 'screenshots' )
	{
		showDiv( 'ScreenshotContent'	);
		hideDiv( 'VideoContent'			);
	}
}

// 2007.08.18 KJD: Test
function widget_SetView_videos()
{
	widget_SetView( 'videos' );

}


// 2007.08.18 KJD: Test
function widget_SetView_screenshots()
{
	widget_SetView( 'screenshots' );
}


Widget_VideoSetTextTitles();
Check_ss_gettype();

