var setBodyTimeout  = false;

function setBody( fileName )
{
    parent.document.getElementById( 'main_body_div' ).innerHTML = '<center><br /><br /><p style="font-size:14px;font-weight:bold;margin-bottom:6px;">Loading Page Content...</p><img src="/images/loading_bar.gif" border="0" /></center>';

	var ajax			= new sack();
	
	ajax.requestFile	= "pages/" + fileName + ".php";
	ajax.method			= "GET";
	ajax.element		= "new_body_hidden";
	ajax.onCompletion	= finishSetBody;
	
    setBodyTimeout      = setTimeout( 'bodyNotLoaded()', 20 * 1000 );
    
	ajax.runAJAX();
}

function finishSetBody()
{
    if( setBodyTimeout )
    {
        clearTimeout( setBodyTimeout );
    }

    if( document.getElementById( 'new_body_hidden' ).innerHTML.length > 0 )
    {
	    parent.document.getElementById( 'main_body_div' ).innerHTML	= document.getElementById( 'new_body_hidden' ).innerHTML;
        
        setTimeout( 'autoSaveForm()', 60 * 1000 );
        
    } else {
    
        bodyNotLoaded();
    }
}


function bodyNotLoaded()
{
    setBodyTimeout  = false;
    
    parent.document.getElementById( 'main_body_div' ).innerHTML = '<div class="contentheading">Problems Loading Content</div><p>There was an error loading the content for this page. You may be experiencing Internet connectivity issues, or there might be a server error. Please wait a moment and try again, or use the "Chat with us live!" feature in the right-hand column for assistance.</p>';
}

function autoSaveForm()
{
    if( parent.document.website_type )
    {
        var oldAction                   = parent.document.website_type.action;
        var oldTarget                   = parent.document.website_type.target;
        
        parent.document.website_type.action    = '/custom/get_started/save.php';
        parent.document.website_type.target    = 'get_started_form_frame';
        
        parent.document.website_type.submit();
        
        parent.document.website_type.action    = oldAction;
        parent.document.website_type.target    = oldTarget;
    }
    
    setTimeout( 'autoSaveForm()', 60 * 1000 );
}