$(function(){

  // Widths to 1
                 $("#modules").width(1).css({opacity: 0.01});
  $("#main_content_container").width(1).css({opacity: 0.01});
                  $("#header").width(1).css({opacity: 0.01});
                  $("#logo").hide();
                  
  // Add white overlay panels
  $("<div style='background: white; height: "+(6+$("#main_content_container").height())+"px; width: 100%; position: absolute; left: 0px; top: 398px;' id='slider_bottom'></div>").appendTo($("body"));
  $("<div style='background: white; height: 400px; width: 900px; position: absolute; left: 350px; top: 20px;' id='slider_header'></div>").appendTo($("#top"));
  $("#main_holder").removeClass("nearhide");
});

// Function to be called to build the page -- called by Flash
$.buildPage = function(){

  var speed = 750;

  function step1(){
    $("#intro").remove();
    $("#modules")
      .css({opacity: 1})
      .animate({width:'320px'}, speed);
    $("#main_content_container")
      .css({opacity: 1})
      .animate({width:'900px'}, speed, step2)
  }

  function step2(){
    $("#slider_bottom")
      .css({opacity: 1})
      .animate({
        'height': '0px',
        'top': $("#slider_bottom").height() + $("#slider_bottom").position().top
      }, speed, step3);
  };

  function step3(){
   $("#header")
    .css({opacity: 1})
    .animate({width:'900px'}, speed, step4);
  };

  function step4(){
    $("#slider_header")
      .css({opacity: 1})
      .animate({
        'height': '0px',
        'top': $("#slider_header").height() + $("#slider_header").position().top
      }, speed, step5);
  };

  function step5(){
    $("#logo").fadeIn(speed, step6);
  };

  function step6(){
    $("#slider_header,#slider_bottom").remove();
  };

  step1();
}

