/**
 * Contains all the javascript for visual aspects of the chloe site
 */


function menuItemSelected(item, newItemIcon, subMenuPanel)
{
	$(item).find("p").stop().animate({color: "#670BD8"}, 200);
	$(item).find(".menuImage").attr("src", newItemIcon);
	//$(subMenuPanel).stop().fadeIn(500);
}

function menuItemDeselected(item, newItemIcon, subMenuPanel)
{
	$(item).find("p").stop().animate({color: "#3F3F3F"}, 200);
	$(item).find(".menuImage").attr("src", newItemIcon);
	//$(subMenuPanel).stop().fadeOut(500);
}

function showWhatModal()
{
	$('#whatModal').css('z-index','1000');	
	$('#whatModal').animate({
	    opacity: 0.80
	  }, 1000, function() {
		  $('#whatModalContent').css('z-index','1000');
		  $('#whatModalContent').css('display','block');
		  $('#whatModalContent').animate({
			    height: '480px',
			    width: '640px',		
			    marginLeft: '-320px',
			    marginTop: '-240px',
			  }, 800, function() {
				  $('.modalContent').css('display','block');				  
			  });
	  });
}

function closeWhatModal()
{	
	$('.modalContent').css('display','none');
	$('#whatModalContent').animate({
	    height: '240px',
	    width: '320px',		
	    marginLeft: '-160px',
	    marginTop: '-120px',
	  }, 800, function() {
		  $('#whatModalContent').css('z-index','-1');
		  $('#whatModalContent').css('display','none');
		  
		  $('#whatModal').animate({
			    opacity: 0.0
			  }, 1000, function() {
				  $('#whatModal').css('z-index','-1');	
			  });
	  });
}

function showModal(elem,content)
{		
	$('#trailerModal').css('z-index','1000');	
	$('#trailerModal').animate({
	    opacity: 0.80
	  }, 1000, function() {
		  $('#trailerModalContent').css('z-index','1000');
		  $('#trailerModalContent').css('display','block');
		  $('#trailerModalContent').animate({
			    height: '480px',
			    width: '640px',		
			    marginLeft: '-320px',
			    marginTop: '-240px',
			  }, 800, function() {
				  $('.modalContent').css('display','block');
				  var player = $f("player");
					if (player.isLoaded()) {
						player.play();
					}
			  });
	  });	 
}

function closeModal()
{	
	var player = $f("player");
	if (player.isLoaded()) {
		player.stop();
	}
	$('.modalContent').css('display','none');
	$('#trailerModalContent').animate({
	    height: '240px',
	    width: '320px',		
	    marginLeft: '-160px',
	    marginTop: '-120px',
	  }, 800, function() {
		  $('#trailerModalContent').css('z-index','-1');
		  $('#trailerModalContent').css('display','none');
		  
		  $('#trailerModal').animate({
			    opacity: 0.0
			  }, 1000, function() {
				  $('#trailerModal').css('z-index','-1');	
			  });
	  });
}


(function($) {  
	     
    $.fn.newsScroll = function(options) {  
	      
      return this.each(function() {     
	      
           var  $this = $(this),   
	      
             	defaults = {  
	               speed: 400,  
	               delay: 3000	               
	            },  
	     
	             settings = $.extend({}, defaults, options);   
	     
	         setInterval(function() {  
	               $this.children('li:first')  
	                       .animate({  
	                           marginTop : '-' + $this.children('li:first').outerHeight(),  
	                          opacity: 'hide' },  
	     
	                          settings.speed,  
	     
	                          function() {  
	                               $this  
	                                 .children('li:first')  
	                                 .appendTo($this)  
	                                .css('marginTop', 0)  
	                                 .fadeIn(300);  
	                         }  
	                     ); // end animate  
	         }, settings.delay); // end setInterval  
	       });  
	   } 
	     
	   })(jQuery);    

