flashCnt = 0;

// called when a sub menu button has finished repossitioning
function startMainBody()
{
    mainBodyDiv.style.width = "0px";
    mainBodyDiv.style.height = "0px";
    mainBodyDiv.innerHTML = "";
    continueMainBodyRight();
}

// called periodically till the main body background is fully filled to right
function continueMainBodyRight()
{
    var hOffset = 5, bodyHeightHere=5, bodyRightSpeed=75;

    // get the possition of the sub menu and logo pos, these are used to determine the size of the main body
    var subMenuPos = findPos(subMenuDiv);
    var logoPos = findPos(mainLogo);
    var mainBodyPos = findPos(mainBodyDiv);

    // place main body and expand to the right
    mainBodyDiv.style.top = (subMenuPos.top)+"px";
    mainBodyDiv.style.left = (subMenuPos.right+hOffset)+"px";
    mainBodyDiv.style.width = (mainBodyPos.width+bodyRightSpeed)+"px";
    mainBodyDiv.style.height = bodyHeightHere+"px";

    // the amount of pixels left to expand
    var leftToExpand = logoPos.right - (subMenuPos.right+hOffset+mainBodyPos.width+bodyRightSpeed);

    if (leftToExpand <= 0)
    {
        mainBodyDiv.style.width = (mainBodyPos.width+bodyRightSpeed+leftToExpand)+"px";
        screenMoving = setTimeout("continueMainBodyDown();", 40);
    }
    else
        screenMoving = setTimeout("continueMainBodyRight();", 40);
}

// called periodically till the main body background is fully filled down
function continueMainBodyDown()
{
    var hOffset = 5, bodyDownSpeed=75;
    
    var subMenuPos = findPos(subMenuDiv);
    var mainBodyPos = findPos(mainBodyDiv);

    // place main body and expand down
    mainBodyDiv.style.top = (subMenuPos.top)+"px";
    mainBodyDiv.style.left = (subMenuPos.right+hOffset)+"px";
    mainBodyDiv.style.width = (mainBodyPos.width)+"px";
    mainBodyDiv.style.height = (mainBodyPos.height+bodyDownSpeed)+"px";

    // the amount of pixels left to expand
    var leftToExpand = subMenuPos.bot - (subMenuPos.top+mainBodyPos.height+bodyDownSpeed);

    if (leftToExpand <= 0)
    {
        mainBodyDiv.style.height = (mainBodyPos.height+bodyDownSpeed+leftToExpand)+"px";
        flashCnt = 0;
        mainBodyDiv.innerHTML = "<table class=\"loading\"><tr><td><p><h1>Loading...</h1></p><p><img src=\"./res/loading.gif\"</p></tr></td></table>";
        runAjax("getBody.php?main="+buttonOrder[0]+"&sub="+subButtonOrder[0], ajaxMainBodyLoad);
        screenMoving = false;
    }
    else
        screenMoving = setTimeout("continueMainBodyDown();", 40);
}

// called once the main body has finished loading
function ajaxMainBodyLoad(_urlText)
{
    mainBodyDiv.innerHTML = _urlText; // set the main body to show the page loaded

    // handel any special conditions for this page, ie starting a slide show
    switch(buttonOrder[0])
    {
        case "game":
            switch(subButtonOrder[0])
            {
                case "gameScreenShots":
                    startSlideShow();
                    break;
            }
            break;
       default:
            break;
    }
}