jQuery(document).ready(function(){
  var flashvars3 = {};
  var params3 = {
    wmode: "transparent"
  };
  var attributes3 = {};
  /* Facilities Image Scroller */
  jQuery(".facilities ul.tourImage li:gt(0)").hide();
  var curTour = 1;
  var curImage = "#image1";
  var buttonClicks = 0;
  jQuery("#next").click(function() {
    buttonClicks++;
    if ($(".tourImage li").is(":animated")) {
      return;
    }
    curImage = "#image" + curTour;
    jQuery(curImage).fadeOut(400, function() {
      curTour++;
      if(curTour > 4) {
        curTour = 1;
      }
      curImage = "#image" + curTour;
      jQuery(curImage).fadeIn(400);
    });
    loadSwf();
    return false;
  });
  jQuery("#prev").click(function() {
    buttonClicks++;
    if ($(".tourImage li").is(":animated")) {
      return;
    }
    curImage = "#image" + curTour;
    jQuery(curImage).fadeOut(400, function() {
      curTour--;
      if(curTour < 1) {
        curTour = 4;
      }
      curImage = "#image" + curTour;
      jQuery(curImage).fadeIn(400);
    });
    loadSwf();
    return false;
  });
  
  /* Process Functions */
  jQuery("#step2div, #step3div, #step4div, #step5div, #step6div").hide();
  var curStep = "#step1div";
  var curLink = "#step1";
  var nextStep;
  jQuery(".processNav a").click(function() {
    nextStep = "#" + jQuery(this).attr("id") + "div";
    if (curStep == nextStep) {
      return false;
    }
    jQuery(curLink).removeClass("active");
    curLink = "#" + jQuery(this).attr("id");
    jQuery(this).addClass("active");
    jQuery(curStep).fadeOut(400, function() {
      jQuery(nextStep).fadeIn(400);
      curStep = nextStep;
    });
    return false;
  });
  
  /* Kids Functions */
  jQuery("#kids2div, #kids3div, #kids4div, #kids5div, #kids6div").hide();
  var curKid = "#kids1div";
  var nextKid;
  jQuery(".kids .sidebar a").click(function() {
    nextKid = "#" + jQuery(this).attr("id") + "div";
    if (nextKid == curKid) {
      return false;
    }
    jQuery(curKid).fadeOut(400, function() {
      jQuery(nextKid).fadeIn(400);
      curKid = nextKid;
    });
    return false;
  });
  
  function removeElement() {
    jQuery("#walkon").hide();
    jQuery("object").hide();
    jQuery("#walkon").css('display', 'none');
  }
  
  function loadSwf() {
    if (buttonClicks > 1) {
      return false;
    } else {
      jQuery("walkon2").show();
      swfobject.embedSWF("/flash/line2.swf", "walkon2", "720", "480", "9.0.0", "/flash/expressInstall.swf", flashvars3, params3, attributes3);
      return false; 
    }
  }
});