ro.preloadAssetViewer = function() {
	if( !document.images ) return false;

	//
	this.addRollover( // top button rollovers
		["bandwidth_high","bandwidth_low","change_media_preferences","close_window"],
		["over","off"],"/jfkl/images/asset_viewer/",".gif","-",true);

	this.addRollover( // tab rollovers
		["details","text_transcript","document_image","image_view"],
		["over","on","off"],"/jfkl/images/asset_viewer/tabs/",".gif","-",false);

	this.addRollover( // page button rollovers
		["download_this_file","select_these_preferences","download_mp3"],
		["over"],"/jfkl/images/asset_viewer/buttons/",".gif","-",true);
	

	this.addGenericRollover( // photo enlarge link
		"photo_enlarge",
		["over"],"/jfkl/images/global/photo_enlarge",".gif","-",true);

	return this.preloaded = true;
}

var windowSize = null;

function initScroll() {
	windowSize = new com.bigbad.WindowSize();
	updateScrollArea();
	setTimeout( "updateScrollArea();", 1 );
}

function updateScrollArea() {
	if( navigator.appName.indexOf("Microsoft") == 0 && navigator.appName.indexOf("Mac") == 0 ) return false; // ie/mac won't 
	if( windowSize == null ) return false;

	var innerSize = windowSize.getInnerSize();
	if( innerSize == null ) return false;

	var scrollArea = document.getElementById("scrollArea");
	var bodyWrapper = document.getElementById("bodyWrapper");

	if( scrollArea==null || bodyWrapper==null ) return false;

	var saHeight = innerSize.height - scrollArea.offsetTop;

	if( !isNaN( saHeight ) && saHeight > 100 ) {

		bodyWrapper.style.height = "auto";
		bodyWrapper.style.width = "auto";
		bodyWrapper.style.overflow = "visible";

		scrollArea.style.overflow = "auto";
		scrollArea.style.height = saHeight + "px";
		scrollArea.style.width = innerSize.width + "px";

	} else {

		scrollArea.style.height = "auto";
		scrollArea.style.width = "auto";
		scrollArea.style.overflow = "visible";

		bodyWrapper.style.overflow = "auto";
		bodyWrapper.style.height = innerSize.height + "px";
		bodyWrapper.style.width = innerSize.width + "px";
	}

	return true;
}

var currentSectionId = null;

function swapSections( sectionLink ) {
	var newSectionId = sectionLink.id.substr( 0, sectionLink.id.indexOf( "_link" ) );
	if( newSectionId == currentSectionId ) return false;

	sectionLink.onmouseout = sectionLink.onmouseover = function() { return ro.swapImage( this.firstChild.id, 'on' ) };

	// turn on the new section link
	ro.swapImage(newSectionId, 'on');

	if( currentSectionId != null ) {
		ro.swapImage( currentSectionId, 'off');
		var currentSectionLink = document.getElementById( currentSectionId + "_link" );
		currentSectionLink.onmouseover = function() { return ro.swapImage( this.firstChild.id, 'over' ) };
		currentSectionLink.onmouseout = function() { return ro.swapImage( this.firstChild.id, 'off' ) };

		var currentSectionBody = document.getElementById( currentSectionId + "_body" );
		currentSectionBody.style.display = "none";

		var currentSectionPagination = document.getElementById( currentSectionId + "_pagination" );
		if( currentSectionPagination )
			currentSectionPagination.style.display = "none";
	}


	var newSectionBody = document.getElementById( newSectionId + "_body" );
	newSectionBody.style.display = "block";

	var newSectionPagination = document.getElementById( newSectionId + "_pagination" );
	if( newSectionPagination )
		newSectionPagination.style.display = "block";

	currentSectionId = newSectionId;

	return false;
}
