$(document).ready(function(){

  var timer = setInterval( showDiv, 5000);
  var isClicked = false;
  var counter = 2;
  function showDiv() {

	if(isClicked) {
		clearInterval(timer);
		return; 
	}
	$('.section').removeClass('open');
    $('#div1, #div2, #div3')
      .stop()
      .hide()
      .filter( function() { return this.id.match('div' + counter); })   
      .show('fast')
	  .prev().addClass('open');
	  
	  if (counter === 1) {
		  clearInterval(timer);
		  return;
	  } else if (counter === 3) {
		  counter = 1;
	  } else {
		  counter++;
	  }	

  }

	$('.section').click(function() { 
		isClicked = true; 
		$('.section').removeClass('open');
		$(this).addClass('open')
		$('.display').hide();
		$(this).next().show();
	
	});

	  if ($.browser.msie) {
	//start IE
	 	$('#meet_the_cast').mouseenter(function() {
      		$('#meet_the_cast_spotlight').show();
		});
		$('#meet_the_cast_spotlight').mouseout(function() {
		  $('#meet_the_cast_spotlight').hide();
		});
	
		$('#behind_the_scenes').mouseenter(function() {
		  $('#behind_the_scenes_flashflare').show();
		});
		$('#behind_the_scenes_flashflare').mouseout(function() {
		  $('#behind_the_scenes_flashflare').hide();
		});
	//set the variable for the cloud links here
	var what = ".stars a";
	
	//the animation, call function, with pulse fade, end fade, and sparkle color + repition of effect
	headline_interval = setInterval('decorate_links_IE()', 300);

	headline_count = $(what).size();
	

	//end IE
	  } else {
	//start not IE	
		
		$('#meet_the_cast').mouseenter(function() {
		  $('#meet_the_cast_spotlight').fadeIn(500);
		});
		$('#meet_the_cast_spotlight').mouseout(function() {
		  $('#meet_the_cast_spotlight').fadeOut(500);
		});
	
		$('#behind_the_scenes').mouseenter(function() {
		  $('#behind_the_scenes_flashflare').fadeIn(500);
		});
		$('#behind_the_scenes_flashflare').mouseout(function() {
		  $('#behind_the_scenes_flashflare').fadeOut(500);
		});
		
		
			//set the variable for the cloud links here
		var what = ".stars a";
		
		//the animation, call function, with pulse fade, end fade, and sparkle color + repition of effect
		headline_interval = setInterval('decorate_links(0.8,0.2,"#fff")', 850);
		headline_interval = setInterval('decorate_links(0.6,0.1,"#ebebeb")', 450);
		
		//count number of links
		headline_count = $(what).size();
		
		//links start fade
		$(what).fadeTo('slow', 0.3);
		
		//the hover effect
		$(what).hover(function () {
			$(this).fadeTo('fast', 1.0)
		}, function () {
			$(this).fadeTo('slow', 0.3)
		})
  }//end not IE

});//end doc ready
	function decorate_links(start,end,color) {
    var a = Math.floor(Math.random() * headline_count);
    $(".stars a:eq(" + a + ")").fadeTo('slow', start, function () {
        $(this).css('color', color)
    });
    $(".stars a:eq(" + a + ")").fadeTo('slow', end);
	}
	
		function decorate_links_IE() {
    var a = Math.floor(Math.random() * headline_count);
    $(".stars a:eq(" + a + ")").toggle();
    //$(".stars a:eq(" + a + ")").toggle();
	}
