var frameWidth = 824;
var thisID	=	0;
var offset = 0;
var newsPos = 0;
var vidID = '';

$(document).ready(function() {
	//header
	$("#navigation li").hover(	
		function() { $(this).removeClass("inactive").addClass("active"); },
		function() { $(this).removeClass("active").addClass("inactive"); }
	);
	
	$("#home_navigation li").hover(	
		function() { $(this).removeClass("inactive").addClass("active"); },
		function() { $(this).removeClass("active").addClass("inactive"); }
	);
	
	$(".castItem").click(function(){
		$(".innerContainer .active").removeClass("active");
		$(this).addClass("active");
		thisID = parseInt($(this).attr("id"));
		thisID -= 1;
		offset = thisID * frameWidth * -1;
		
		$("#castContent .inner").stop().animate({
	        left: offset+"px"
	      }, 700 );
      
		
	});

	$("#submitButton").click(function(){
		
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = $("#emailAddress").val();

		if(reg.test(address) == false) {
			alert('Please enter a valid email address');
	    	return false;
		}
		else{
			$.ajax({
				type: "POST",
				url: "/index.php/home/addNewsletter",
				data: {
					email: address
				},
				success: function(response) {
					$("#newsletterSection").html("You have been added to the mailing list");
				},
				error: function(r, t, e) {
					alert(e);
				}
			});			
		}
	});
	
	$(".prev").click(function(){
		newsPos = parseInt( $(".innerNews").css("left") ) + 830;
		$(".innerNews").stop().animate({
	        left: newsPos+"px"
	      }, 200 );
		return false;
	});
	
	$(".next").click(function(){
		newsPos = parseInt( $(".innerNews").css("left") ) - 830;
		$(".innerNews").stop().animate({
	        left: newsPos+"px"
	      }, 200 );
		return false;
	});
	
	$("#rushTickets img").hover(
		function(){
			$("#rushBox").show().css("left","225px").stop().animate({
		        left: 210,
				opacity:1
		      }, 400 );
		},
		function(){
			$("#rushBox").stop().animate({
		        left: 185,
				opacity:0
		      }, 400,'linear', function(){ $("#rushBox").hide(); } );
		}
	);
	
	$(".videoItem").click(function(){
		vidID = $(this).attr("rel");
		$("#videoDisplay").html('<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/'+ vidID +'&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/'+ vidID +'&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"></embed></object>');
	});
	
	$("#triggerShow").click(function(){
		$(".white").removeClass("white");
		$(this).addClass("white");
		$("#aboutPosition").stop().animate({
			top: 0
		}, 500 );

		$("#outterAbout").stop().animate({
	        height: 1260
	      }, 500 );
	});
	$("#triggerMiller").click(function(){
		$(".white").removeClass("white");
		$(this).addClass("white");
		$("#aboutPosition").stop().animate({
	        top: -1260
	      }, 500 );

		$("#outterAbout").stop().animate({
	        height: 1260
	      }, 500 );
	});
	$("#triggerPartners").click(function(){
		$(".white").removeClass("white");
		$(this).addClass("white");
		$("#aboutPosition").stop().animate({
	        top: -2520
	      }, 500 );
	
		$("#outterAbout").stop().animate({
	        height: 860
	      }, 500 );
	});
	
	$(".photo a img").hover(
		function(){
			$(this).stop().animate({
		        opacity: .1
		      }, 500 );
		},
		function(){
			$(this).stop().animate({
		        opacity: 1
		      }, 500 );
		}
	);
	
	$('.photo a').lightBox();
	
	$(".mediaList .newsHeader").click(function(){
		$(".mediaList .white").removeClass("white");
		$(this).addClass("white");
		offset = parseInt ($(this).attr("rel"));
		
		if (offset == 0){
			$("#videoDisplay").show();
		}
		else {
			$("#videoDisplay").hide();
		}
		
		$(".innerNews").stop().animate({
	        left: ( -1 * offset * frameWidth )
	      }, 500 );
	});
	
		$(".newsListMenu .newsHeader").click(function(){
		$(".newsListMenu .white").removeClass("white");
		$(this).addClass("white");
		offset = parseInt ($(this).attr("rel"));
				
		$(".innerNewsContainer").stop().animate({
	        top: ( -460 * offset )
	      }, 500 );
	});
	
	$(".ReviewPrev").click(function(){
		newsPos = parseInt( $(".innerReviews").css("left") ) + 830;
		$(".innerReviews").stop().animate({
	        left: newsPos+"px"
	      }, 200 );
		return false;
	});
	
	$(".ReviewNext").click(function(){
		newsPos = parseInt( $(".innerReviews").css("left") ) - 830;
		$(".innerReviews").stop().animate({
	        left: newsPos+"px"
	      }, 200 );
		return false;
	});
	
	
});