//preload the images so the application look good on slow networks.
function preLoadImages() 
{
    var image1 = new Image();
    image1.src = "button.png";

    var image2 = new Image();
    image2.src = "SawDustSoupHeader.png";
}

//hide a div or other element using it's id
function hide(id) 
{
    document.getElementById(id).style.display = 'none';
}

//show a div or other element using it's id
function show(id) 
{
    document.getElementById(id).style.display = 'block';
}

//show the home page
function home()
{
    hideAll();
    show('mainpage');
    prevPage = 'mainpage';
    curPage = 'mainpage';
}

//hide all pages
function hideAll()
{
    hide('mainpage');
    hide('networking');
}

//show a page based on it's id
function gotoPage(id)
{
    prevPage = getPrevPage(id);
    hideAll();
    show(id);
    curPage = id;
    if (id == 'mainpage')
    {
            home();
    }
}

//get the previous page id based on the page shown (used for 'back' operations
function getPrevPage(id)
{
    if (id == 'networking')
    {
            return 'mainpage';
    }
    return 'mainpage';	
}
