function prepareLightbox()
{
	hideSelectBoxes();
	hideFlash();

	// stretch overlay to fill page and fade in
	var arrayPageSize = getPageSize();
	Element.setWidth('overlay', arrayPageSize[0]);
	Element.setHeight('overlay', arrayPageSize[1]);

	new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

	imageArray = [];
	imageNum = 0;		
}

function launchLightbox()
{
	// calculate top and left offset for the lightbox 
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
	var lightboxLeft = arrayPageScroll[0];
	Element.setTop('lightbox', lightboxTop);
	Element.setLeft('lightbox', lightboxLeft);
		
	Element.show('lightbox');
		
	myLightbox.changeImage(imageNum);
}

function showLightBox(url, caption)
{
	caption = caption.replace("[SQM]", "'");
	prepareLightbox();
	imageArray.push(new Array(url, caption));
	launchLightbox();
}

function showLightBoxAlbum(path, stringArray)
{
	showBulkLightBox(0, path, stringArray);
}

function showBulkLightBox(nowid, path, stringArray)
{
	prepareLightbox();

	imageNum = nowid;
	var photos = stringArray.split("[T]");
	for (var i=0; i<photos.length ; i++ )
	{
		var data = photos[i].split("[U]");
		data[0] = data[0].replace("[SQM]", "'");
		if (data[1] != undefined)
		{
			imageArray.push(new Array(path + data[1], data[0]));
		}
	}
	launchLightbox();
}

function showAlbumLightBox(xmlpath, albumId, nowid, nowplaying)
{
	var albumIndex;
	albumIndex = albumId + "," + nowid;

	imageNum = nowplaying;
	BizModules.UltraPhotoGallery.AjaxDotNetForLightBox.GetAlbumLightboxScripts(xmlpath, albumIndex, showAlbumLightBox_CallBack);
}

function showAlbumLightBox_CallBack(response)
{
	if (response.error != null)
	{ 
		alert("Error occured");
		return;
	}
	
	showBulkLightBox(imageNum, "", response.value);
}



