$j = jQuery.noConflict();

$j(document).ready(function() {

  $j('#jPlayer').jPlayer({
    ready: function() {
      $j("#jPlayer").jPlayer('setFile', '/cnfintro.mp3').jPlayer('play');
    },
    swfPath: '/',
    nativeSupport: false
  });

  $j('ul li:first-child').addClass('first');
  $j('ul li:last-child').addClass('last');
  
  $j('#slides').cycle({
    fx: 'fade',
    timeout: 7000	// Duration of each slide in milliseconds
  });
  $j('#slideControls #prev').click(
    function() { $j('#slides').cycle('prev'); return false; }
  );
  $j('#slideControls #sleep').click(
    function() { $j('#slides').cycle('pause'); $j('#slideControls #go').show(); $j(this).hide(); return false; }
  );
  $j('#slideControls #go').click(
    function() { $j('#slides').cycle('resume'); $j('#slideControls #sleep').show(); $j(this).hide(); return false; }
  );
  $j('#slideControls #next').click(
    function() { $j('#slides').cycle('next'); return false; }
  );
  
  if($j.browser.msie) {
    v = parseInt($j.browser.version);
    if(v == 6) {
      $j('#navi > li').hover(
        function() { $j(this).addClass('over'); },
        function() { $j(this).removeClass('over'); }
      ).each(function() {
        $j('> a', this).addClass('ie6-png').css('background-image', $j(this).css('background-image')).parent().css('background-image', 'none');
      });
    }
    if(v < 8) {
      zIndexWorkaround();
    }
  }
});

function zIndexWorkaround()
{
        /*
        ** For each div with class menu (i.e.,
        ** the thing we want to be on top),
        */
        $j("#navi ul").parents().each(function() {
            var p = $j(this);
            var pos = p.css("position");
 
            // If it's positioned,
            if(pos == "relative" ||
               pos == "absolute" ||
               pos == "fixed")
            {
                /*
                ** Add the "on-top" class name when the
                ** mouse is hovering over it, and remove
                ** it when the mouse leaves.
                */
                p.hover(function() {
                        $j(this).addClass("on-top");
                    },
                    function() {
                        $j(this).removeClass("on-top");
                    });
            }
        });
}