// -----------------------------------------------------------------------------------
/*

	Table of Contents
	-----------------
	Configuration
	Global Variables

	Function list
	-----------------
	lightboxVid()
	makeBox()
	writePlayer()

*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "/GFX/lightbox/loading.gif";
var fileBottomNavCloseImage = "/GFX/lightbox/closelabel.gif";

var overlayOpacity = 0.8;	// controls transparency of shadow overlay

var animate = true;			// toggles resizing animations
var resizeSpeed = 7;		// controls the speed of the image resizing animations (1=slowest and 10=fastest)

var borderSize 	= 10;
var videoId   	= '';
var vidTitle  	= '';
var vThumb  	= '';
var vWidth   	= 600;
var vHeight   	= 550;
var sTags		= '';
var sCategories	= '';
var sMainCategories='';

function lightboxVid(tags,categories, mainCategories)	{
	sTags          = tags;
	sCategories    = categories;
	sMainCategories= mainCategories;

	//Modified
	//if(tags != "undefined" && tags != '') {
	if(tags != "undefined" ) {
		makeBox();
	}else	{
		myLightbox.end();
	}
}

function makeBox() {

	// stretch overlay to fill page and fade in
	var arrayPageSize = getPageSize();
	// calculate top and left offset for the lightbox
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 25);
	var lightboxLeft = arrayPageScroll[0] + (arrayPageSize[0] / 3.3);
	var totalWidth = vWidth + ( 2 * borderSize);
	var totalHeight = vHeight + ( 2 * borderSize);

	hideSelectBoxes();
	hideFlash();

	Element.setWidth('overlay', arrayPageSize[0]);
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

	Element.setTop('vidcont', lightboxTop);
	Element.setLeft('vidcont', lightboxLeft);
	Element.setWidth('vidcont', totalWidth);
	Element.setHeight('vidcont', totalHeight);

	new Effect.Appear('vidcont', { duration: overlayDuration, from: 0.0, to: 0.90 });

	Element.setWidth('flvPlayerStandalone', vWidth);
	Element.setHeight('flvPlayerStandalone', vHeight);
	Element.setLeft('flvPlayerStandalone', borderSize);
	Element.setTop('flvPlayerStandalone', borderSize);
	Element.show('flvPlayerStandalone');

	writePlayer();
}

function writePlayer(){
        var flashvars = {};
        flashvars.viewtype = "videogallery";
        flashvars.tags              = sTags;
        flashvars.categories        = sCategories;
        flashvars.mainCategories    = sMainCategories;

        var params = {};
        params.allowfullscreen   = "true";
        params.allowscriptacces  = "true";

        var attributes = {};
        attributes.id = "flvPlayerStandalone";
        attributes.name = "flvPlayerStandalone";

        swfobject.embedSWF("/SWF/mediaviewer.swf", "flvPlayerStandalone", vWidth, vHeight, "8.0.0","noflash.html", flashvars, params, attributes);

        /*
		var vfo = new FlashObject("../output/mediaviewer.swf", "mediaviewer", vWidth, vHeight, '8');

		vfo.addParam("allowfullscreen","true");
		vfo.addParam('allowscriptaccess','true');
		vfo.addVariable("viewtype", "videogallery");
		vfo.addVariable("categories", sCategories);
		vfo.addVariable("tags", sTags);
		vfo.write('flvPlayerStandalone');
		*/
		Element.show('flvPlayerStandalone');

}