// JavaScript Document
<!--


// #######################################################################################
var currentImageUrl = "null";

var iterImageCount = 0;
var iterImageCountHeader = 0;
var iterImageCountFooter = 0;
var iterImageCountLeftPane = 0;
var iterImageCountArchive = 0;

var NUM_OF_TOTAL_IMAGES = 17;
var NUM_OF_HEADER_IMAGES = 4;
var NUM_OF_FOOTER_IMAGES = 1;
var NUM_OF_ARCHIVE_IMAGES = 10;
var NUM_OF_LEFT_PANE_IMAGES = 2;




// Used to set/initialize the current Cover Archive Image.
function setBGImage(id,newUrl)
{
  document.getElementById(id).style.backgroundImage = "url("+newUrl+")";
  currentImageUrl = newUrl;
}

// Used to temporarily change the background image of a TABLE or TD for hovering only.
function hoverChangeBGImage(id,newUrl)
{
  document.getElementById(id).style.backgroundImage = "url("+newUrl+")";
}

// Used to permanently change the background image of a TABLE or TD on a mouse click.
function clickChangeBGImage(id,newUrl)
{
  document.getElementById(id).style.backgroundImage = "url("+newUrl+")";
  currentImageUrl = newUrl;
}

// Used to change the background back to the current image of a TABLE or TD from un-hovering.
function revertBGImage(id)
{
  if (currentImageUrl != "null")
  {
    document.getElementById(id).style.backgroundImage = "url("+currentImageUrl+")";
  }
}


// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// Used to keep track of all loaded images
function anotherImageLoaded()
{
    iterImageCount++;
    
    var percentage = 0;
    percentage = (iterImageCount/NUM_OF_TOTAL_IMAGES)*100
    document.getElementById("loadingID").innerHTML = "Loading... " + Math.ceil(percentage) + "%";
    // alert("Loading Count [head][foot][lp][arch][tot]: " +iterImageCountHeader+" // "+iterImageCountFooter+" // "+iterImageCountLeftPane+" // "+iterImageCountArchive+" // "+iterImageCount);

    if (iterImageCount >= NUM_OF_TOTAL_IMAGES)
    {
        setTimeout("turnOnMiddleSection();",600);
    }
}

// Used to keep track of all loaded header images
function anotherHeaderImageLoaded()
{
    iterImageCountHeader++;
    if (iterImageCountHeader >= NUM_OF_HEADER_IMAGES)
    {
        // turnOnHeader();
    }
}

// Used to keep track of all loaded footer images
function anotherFooterImageLoaded()
{
    iterImageCountFooter++;
    if (iterImageCountFooter >= NUM_OF_FOOTER_IMAGES)
    {
        turnOnFooter();
    }
}

// Used to keep track of all loaded left pane images
function anotherLeftPaneImageLoaded()
{
    iterImageCountLeftPane++;
    if (iterImageCountLeftPane >= NUM_OF_LEFT_PANE_IMAGES)
    {
        // turnOnLeftPane();
    }
}

// Used to keep track of all loaded archive images
function anotherArchiveImageLoaded()
{
    iterImageCountArchive++;
    if (iterImageCountArchive >= NUM_OF_ARCHIVE_IMAGES)
    {
        // turnOnArchive();
    }
}


// Used to display the header images
function turnOnHeader()
{
    document.getElementById("headerMiddleID").style.visibility = "visible";
}

// Used to display the footer images
function turnOnFooter()
{
    document.getElementById("footerID").style.visibility = "visible";
}

// Used to display the left pane images
function turnOnLeftPane()
{
    document.getElementById("leftPaneID").style.visibility = "visible";
}

// Used to display the archive images
function turnOnArchive()
{
    document.getElementById("thmStripID").style.visibility = "visible";
    document.getElementById("archiveCoverID").style.visibility = "visible";
}

// Used to display the left pane and archive images 
function turnOnMiddleSection()
{
    document.getElementById("loadingID").style.visibility = "hidden";

    turnOnHeader();
    turnOnLeftPane();
    turnOnArchive();
}


// #######################################################################################


function trimString(str)
{
    var resultStr = '';
    if (str == null || str.length == 0) return resultStr;
			    
    var i = 0; 
    var ii = 0; 
    var j = str.length - 1; 

    while (str.substr(i,1) == ' ' && i < str.length) 
    {
        i++;
    }

    // This catches the case where the entire string is only blank spaces
    if (i == str.length) return resultStr;

    while (str.substr(j,1) == ' ' && j >= 0) 
    {
        j--;
        ii++;
    }

    resultStr = str.substr(i,(str.length - (i + ii)));
		        
    return resultStr;
}


// #######################################################################################




//-->
