function navigateScrollerToPage(scrollerClass, index)
{
	var tabsRef = $("#tabs-container." + scrollerClass + " > div > ul");
	var currIndex = tabsRef.data('selected.tabs');
	var length = tabsRef.tabs("length");
	tabsRef.tabs('select', index);
}

function navigateScroller(scrollerClass, dir)
{
	var tabsRef = $("#tabs-container." + scrollerClass + " > div > ul");
	var currIndex = tabsRef.data('selected.tabs');
	var newIndex = currIndex + dir;
	var length = tabsRef.tabs("length");

	if (newIndex < 0 || newIndex > length)
	{
		return;
	}
	tabsRef.tabs('select', newIndex);


	switch (scrollerClass)
	{
		case "photo":
			updatePhotUrlHash(newIndex);
			break;
		case "premierev2":
			updatePhotUrlHash(newIndex);
			break;
	}
}

function setupScroller(scrollerClass)
{

//	debugger
	var imageLocation = _assetPath + "images/";
	var thumbsPerPage;
	switch (scrollerClass)
	{
		case "museum":
			thumbsPerPage = 6;
			imageLocation += "museum/"
			break;

		case "list":
		case "listAdmin":
			thumbsPerPage = 6;
			imageLocation += "thumbsList/"
			break;

		case "thumbstrip":
			thumbsPerPage = 5;
			imageLocation += "thumbs/"
			break;

		case "press":
			thumbsPerPage = 8;
			imageLocation += "press/"
			break;

		case "video":
			thumbsPerPage = 6;
			imageLocation += "thumbsVideo/"
			break;
			
		case "photo":
			thumbsPerPage = 1;
			imageLocation += "photos/"
			break;
		
		case "premierev2":
			thumbsPerPage = 1;
			imageLocation += "premiere_resized/"
			break;
	}

	var fragment, fragmentCount = 1;
	var list = eval("_" + scrollerClass + "List");
	var listThumbs = $("#tabs-container." + scrollerClass + " > #list-thumbs");
	
	for (var i = 0; i < list.length; i++)
	{
		if (i % thumbsPerPage == 0)
		{
			fragment = $("<div>").attr("id", "fragment-" + fragmentCount);
			listThumbs.append(fragment);
			
			var shortcut = $("<li>")
				.append(
					$("<a></a>")
						.attr("href", "#fragment-" + fragmentCount)
						.append($("<span>&#8226;</span>"))
				)
			$("#tabs-shorcuts." + scrollerClass).append(shortcut);

			fragmentCount++;
		}
		
		var listItem = list[i];
		var entry;
		switch (scrollerClass)
		{
			case "museum":
				entry = $("<a></a>")	//* <a></a>, <span></span> are required for IE. FF can handle $("<a>")
					.attr("href", "#")
					.attr("style", "background-image:url(" + imageLocation + listItem + "-thumb.jpg);")
					.attr("imgname", listItem)
					.click(function() {showMuseumImage($(this).attr("imgname"));});
				break;

			case "list":
			case "thumbstrip":
				entry = $("<a></a>")
					.attr("href", _rootPath + "List/" + listItem.fileName + ".htm")
					.attr("style", "background-image:url(" + imageLocation + listItem.image + ");")
					.append("<span>").append(listItem.name);
				break;

			case "listAdmin":
				entry = $("<a></a>")
					.attr("href", _rootPath + listItem.fileName)
					.attr("style", "background-image:url(" + imageLocation + listItem.image + ");")
					.append("<span>").append(listItem.name);
				break;

			case "press":
				entry = $("<div></div>")
					.attr("class", "press-entry")
					.append($("<span class='credits'>" + listItem.date + 
						("" == listItem.author ? "" : " - " + listItem.author) + 
						"</span>"))
					//*.append($("<span class='source'>" + listItem.source + "</span>"))
					.append($("<h2><a href=\"" + listItem.fileName + ".htm\">"  + listItem.source + "</a></h2>" +
					"	<a href=\"" + listItem.fileName + ".htm\" class='teaser'>" + listItem.teaser + "</a>"));
				break;

			case "video":
				entry = $("<div></div>")
					.attr("class", "video-div")
					.append(
						$("<a></a>")
						.attr("class", "thumb")
						.attr("href", _rootPath + "Video/" + listItem.fileName + ".htm")
						.css("background-image", "url(" + _assetPath + "images/thumbsVideo/" + listItem.thumb + ")")
						)
					.append(
						$("<span></span>")
						.append(
							$("<h3></h3>")
							.attr("class", "video")
							.text(listItem.title)
						)
						.append(
							$("<a></a>")
							.attr("href", _rootPath + "Video/" + listItem.fileName + ".htm")
							.append("<img src=\"" + _assetPath + "images/button-play.gif\" />")
						)
					)
				break;
			case "photo":
				entry = $("<div></div>")
					.append(
						$("<a></a>")
						.css("background-image", "url(" + imageLocation + listItem + ")")
						)
				break;
			case "premierev2":
				entry = $("<div></div>")
					.append(
						$("<a></a>")
						.css("background-image", "url(" + imageLocation + listItem + ".jpg)")
						)
				break;
		}
		fragment.append(entry);
	}

	//* this initiates tabs
	$("#tabs-container." + scrollerClass + " > div > ul").tabs({ fx: { opacity: 'toggle' } });

	//* this centers the navigation elements
	$("#tabs-container." + scrollerClass + " > div.navig")
		.css("margin-left", (listThumbs.width() 
								- $("#tabs-container." + scrollerClass + " > div.navig").width()) / 2
								- parseInt(listThumbs.css("padding-left")))
		.css("visibility", "visible");

}
function showMuseumImage(imageName)
{
	$("#museum-main-image").attr("src", _assetPath + "images/museum/" + imageName + "-big.jpg");
}

function updatePhotUrlHash(index)
{
	location.hash = _photoList[index];
	//location.href = "#" + _photoList[index];
}

function updatePremierev2UrlHash(index) {
	location.hash = _premierev2List[index];
	//location.href = "#" + _photoList[index];
}