

    //functions

    function ajaxLoad(url) {
      $j("#top12content").fadeOut("slow",function (){
        $j("#top12content").load(url,null,function(){
          $j("#top12content").fadeIn("slow",function() {
             if (jQuery.browser.msie) {
              this.style.removeAttribute('filter');  //ie hack for cleartype
             }
          });
        });
      });
    }


    //slideshow handling
    function slideSwitch() {

      $j("#top12nav li a").each(function (i) {
        if ($j(this).hasClass("active")) {
          $j(this).removeClass("active");
          if (i == ($j("#top12nav li").length-1)) {
            var $next = $j("#top12nav li a:first");
          } else {
            var $next = $j("#top12nav li a").eq(i+1);
          }
          $next.addClass("active");
          ajaxLoad($next.attr("href"));

          return false;
        }
      });

    }

    //start stop slideshow
    function slideOnOff(mode) {
      if (mode) { //on/off
        if (mode == "off") {
          clearInterval(window.slideTimer);
          window.slideTimer = null;
        }
        if (mode == "on") {
          window.slideTimer = setInterval("slideSwitch()", 3000);
        }
      } else { //toggle
        if (window.slideTimer && window.slideTimer != null) {
          clearInterval(window.slideTimer);
          window.slideTimer = null;
        } else {
          window.slideTimer = setInterval("slideSwitch()", 11000);
        }
      }
    }

    //handle slideshow button
    function toggleSlideshow(mode) {
      if ($j("#slideshow").html() == "Slideshow Enabled" || mode == "off") {
        $j("#slideshow").html("Slideshow Disabled");
        slideOnOff(mode);
      } else {
        slideOnOff();
        $j("#slideshow").html("Slideshow Enabled");
      }
      return false;
    }



    //document done loading - run scripts
    function runTopTwelve(appbase) {

      //load first one
      $j("#top12content").hide();
      $j("#top12nav li a:first").addClass("active");
      $j("#top12content").load(appbase+"top-twelve/1",null,function() {
        $j("#top12content").fadeIn("slow",function() {
           if (jQuery.browser.msie) {
            this.style.removeAttribute('filter'); //ie hack for cleartype
           }
        });
      });

      //nav handling when (1-12 are clicked)
      $j("#top12nav li a").click( function() {
        var ajaxurl = $j(this).attr("href");
        $j("#top12nav li a").removeClass("active");
        $j(this).addClass("active");
        toggleSlideshow("off");
        ajaxLoad(ajaxurl);
        return false;
      });

      //
      $j("#slideshow").click( function() {
        toggleSlideshow();
      });

      //start slideshow
      slideOnOff();


    };
