$(document).ready(function(){
	$("table.form tr:nth-child(odd)").addClass("odd");
	$('#slideshow IMG').css({opacity: 0.0});
	$('#slideshow IMG:first').css({opacity: 1.0});
	 setInterval( "slideSwitch()", 5000 );
	 
	   //Fixes an animation glitch caused by the
  //div's dynamic height.  Need to set the
  //height style so the slide functions work
  //correctly.
  $("div.slideBody").each(function(){
    $(this).css("height", $(this).height() + "px");
	$(this).hide();
  });

  //hook the mouseup events to each header
  $("div.slidePanel").children("div.slideHeader").mouseup(function(){
  
    //find the body whose header was clicked
    var body = $(this).parent().children("div.slideBody");

    //slide the panel
    if(body.is(":hidden"))
      body.slideDown();
    else
      body.slideUp();
  });
  //==================================================================
  $("div.slidePanel").children("div.slideTitle").mouseup(function(){
  
    //find the body whose header was clicked
    var body = $(this).parent().children("div.slideBody");

    //slide the panel
    if(body.is(":hidden"))
      body.slideDown();
    else
      body.slideUp();
  });
  
	 
});

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');
	
	
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
			$active.animate({opacity: 0.0}, 1000);
        });
		
}


//===============================

