$(document).ready(function(){
	  rotatePics(1);
	  
	  //Navigation Control
/*  
 	  initMenu();
	  function initMenu() {
		  $('#nav ul li ul').hide();

		  $('#nav ul li a').mouseover(
		    function() {
		      var checkElement = $(this).next();
		      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		        $('#nav ul:visible').slideUp('normal');
		        checkElement.slideDown('normal');
		        return false;
		        }
		      }
		    );
		}	  
*/
	  //Dropdown menu

	  $('#nav li ul').css({
		    display: "none",
		    left: "auto"
		  });
		  $('#nav li').hoverIntent(function() {
		    $(this)
		      .find('ul')
		      .stop(true, true)
		      .slideDown('slow');
		  }, function() {
		    $(this)
		      .find('ul')
		      .stop(true,true)
		      .fadeOut('slow');
		  });

	  	  	  	      	
	  //Accordion Menu
/*
	  $('#nav ul > li ul')
	    .click(function(e){
	      e.stopPropagation();
	    })
	    .filter(':not(:first)')
	    .hide();
	    
	  $('#nav ul > li, #celebs ul > li > ul > li').click(function(){
	    var selfClick = $(this).find('ul:first').is(':visible');
	    if(!selfClick) {
	      $(this)
	        .parent()
	        .find('> li ul:visible')
	        .slideToggle();
	    }
	    
	    $(this)
	      .find('ul:first')
	      .stop(true, true)
	      .slideToggle();
	  });	  
*/	  
	});

	function rotatePics(currentPhoto) {
	  var numberOfPhotos = $('#mainstage img').length;
	  currentPhoto = currentPhoto % numberOfPhotos;
		
	  $('#mainstage img').eq(currentPhoto).fadeOut(2000, function() {
			// re-order the z-index
	    $('#mainstage img').each(function(i) {
	      $(this).css(
	        'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
	      );
	    });
	    $(this).show();
	    setTimeout(function() {rotatePics(++currentPhoto);}, 8000);
	  });
	}

