// JavaScript Document
// FF Bugfix
window.onunload = function(){};
//Media SubMenu
$(document).ready(function() {
	$('.plusNav li').hover(function() {
		$(this).children("ul").stop(true, true).animate({
			opacity: 'toggle'
		}, 250, function() {
			//Animation Completes
		});	
	});
});

//Home Tweet Scroll
$(document).ready(function() {
		$('#tweetLeft').click(function() {
			if($("#homeTweet").position().left < 0 && !$("#homeTweet").is(":animated")) {
				$('#homeTweet').animate({
					left: '+=546'
				}, 500, function() {
				});
				return false;
			}
			if($("#homeTweet").position().left === 0 ) {
				$('#homeTweet').animate({
					left: '+=6'
				}, 50, function() {
				});
				$('#homeTweet').animate({
					left: '-=6'
				}, 300, function() {
				});
				return false;
			}
			else {
				return false;
			}
		});
});
$(document).ready(function() {
		$('#tweetRight').click(function() {
			if($("#homeTweet").position().left > -1172 && !$("#homeTweet").is(":animated")) {
				$('#homeTweet').animate({
					left: '-=546'
				}, 500, function() {
				});
				return false;
			}
			if($("#homeTweet").position().left = -1172 && !$("#homeTweet").is(":animated")) {
				$('#homeTweet').animate({
					left: '-=6'
				}, 50, function() {
				});
				$('#homeTweet').animate({
					left: '+=6'
				}, 300, function() {
				});
				return false;
			}
			else {
				return false;
			}
		});
});


//Hide/Show legal
$(document).ready(function() {
	//hide search div
	$("#footerLegalText").hide();
	//displays legal text on click
	$("#viewLegal").click(function() {
		$("#footerLegalText").slideToggle(250);
		return false;
	});
})


// Animated Page Scroll
$(document).ready(function() {
	$('.scrollable').click(function() {
	   var clickedLink = $(this).attr("href");
	   var scrollAnchor = $(clickedLink).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: scrollAnchor}, 700 );
	   return false;
	});
});

// Colorbox Activation
$(document).ready(function(){
	$("a[rel='homeGallery']").colorbox({initialWidth:200, initialHeight:75, opacity:0.75});
	$("#signIn a").colorbox({initialWidth:200, initialHeight:75, innerWidth:548, innerHeight:317, opacity:0.75, scrolling:false});
	$("#language a").colorbox({initialWidth:300, initialHeight:75, innerWidth:500, innerHeight:112, opacity:0.75, scrolling:false});
	$("a.featuredTrailerLink").colorbox({innerHeight:443, innerWidth:720, opacity:0.75, iframe:true});
	$("a[rel='videoGallery']").colorbox({innerHeight:443, innerWidth:720, opacity:0.75, iframe:true});
});

