var staggerSides = 1;
var wideScreen = 0;

var videoWindow = null;

function fixTitle(theTitle)
{
	if( theTitle.charAt(0)=='-' ) return theTitle.slice(1);
	else return '"' + theTitle + '"';
}

function openVideoWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
	theParms = 'title='+fixTitle(theTitle)+'&movie='+theFile+'&width='+movWidth+'&height='+movHeight;

	w = screen.availWidth, h = screen.availHeight;
	if( w<800 ) w = 800;
	if( h<600 ) h = 600;

	windLeft = (w-windWidth)/2, windTop = (h-windHeight)/2;
	windTop = windTop - (windTop/4);

	// if the window already exists, the open will fail to resize so close it first
	if( videoWindow && videoWindow.open )
	{
		if( !videoWindow.closed ) videoWindow.close();
		delete videoWindow;
		videoWindow = null;
	}

	windName = 'wndMovie';
	videoWindow = window.open('videos_popup.html?'+theParms, windName,
		  'width=' + windWidth
		+ ',height=' + windHeight
		+ ',top=' + windTop
		+ ',left=' + windLeft
		+ ',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');

	return
}

function addVideoSection_GraphicSide(theFile,theTitle)
{
	comm = '<A CLASS="video" HREF=\'javascript:openVideoWindow("'+ theTitle + '","' + theFile;
	str = "<TD ALIGN='CENTER'><img src='"+theFile+".jpg' alt=''><br><span class='video_play'><img src='videos/video.gif' border='0' alt=''>&nbsp;";

	switch( wideScreen )
	{
	case 0:
		str += comm + '_56k",400,320,160,120)\'>Dialup</A>&nbsp;&nbsp;'
		+ comm + '_DSL",400,320,320,240)\'>Cable/DSL</A>&nbsp;&nbsp;'
		+ comm + '_HIGH",710,556,640,480)\'>Large</A>';
		break;
	case 1:
		str += comm + '_w56k",300,180,160,90)\'>Dialup</A>&nbsp;&nbsp;'
		+ comm + '_wDSL",508,320,428,240)\'>Cable/DSL</A>&nbsp;&nbsp;'
		+ comm + '_wHIGH",923,556,853,480)\'>Large</A>';
		break;
	case 2:
		str += comm + '_w160_44",560,370,320,180)\'>Dialup</A>&nbsp;&nbsp;'
		+ comm + '_w480_500",560,370,480,270)\'>Cable/DSL</A>&nbsp;&nbsp;'
		+ comm + '_w640_900",720,460,640,360)\'>Large</A>&nbsp;&nbsp;'
		+ comm + '_w960_2000",1040,640,960,540)\'>Super HD</A>';
		break;
	}

	str += '</span></TD>';

	document.write(str);
}

function addVideoSection_TextSide(theTitle,theDescription,theTime,theSide)
{
	str = '<td align="' + theSide + '" class="description_width">'
		+ '<span class="video_name">' + unescape(fixTitle(theTitle)) + '</span>'
		+ '<span class="video_description">' + unescape(theDescription) + '</span>'
		+ '<span class="video_time">(' + theTime + ' min)</span></td>';
	document.write(str);
}

function addVideoSection(theTitle,theDescription,theTime,theFile)
{
	document.write('<table align="CENTER" border="0" cellspacing="0" cellpadding="7"><tr valign="MIDDLE">');

	if( staggerSides )
	{
		addVideoSection_GraphicSide(theFile,theTitle);
		addVideoSection_TextSide(theTitle,theDescription,theTime,'LEFT');
	}
	else
	{
		addVideoSection_TextSide(theTitle,theDescription,theTime,'RIGHT');
		addVideoSection_GraphicSide(theFile,theTitle);
	}

	staggerSides = 1 - staggerSides;

	document.write('</tr></table>');
}

function addVideoSectionWide(theTitle,theDescription,theTime,theFile)
{
	wideScreen = 1;
	addVideoSection(theTitle,theDescription,theTime,theFile);
	wideScreen = 0;
}

function addVideoSectionHDWide(theTitle,theDescription,theTime,theFile)
{
	wideScreen = 2;
	addVideoSection(theTitle,theDescription,theTime,theFile);
	wideScreen = 0;
}
