// JavaScript Document
$(document).ready(function() {
						   
	//SCROLL PANE
		
		$(function() {
			$('.content-text').jScrollPane({dragMaxHeight:10, dragMinHeight:20, scrollbarMargin:10, scrollbarWidth: 15});
		});


	
	//LAVA NAV

	$("#lava-nav").lavaLamp({
			fx: "easeOutBack",
			speed: 900,
			click: function(event, menuItem) {
				return false;
			}
		});
	
	
	//SLIDER

		var nextSlider;
		var nextSliderPos;
	
		$("ul#lava-nav li a").click(function(e) {
			contentAnimate($(this));
			//alert(nextSliderPos);
			
		});//END Click
		
		contentAnimate("#home");
		
		function contentAnimate(id) {
			
			nextSlider = $(id).attr("id");
			//alert(nextSlider);
			nextSlider = "#"+nextSlider+"-box";
			nextSliderPos = ($(window).width() - $(".content-box").width()) / 2;	
					
			$(".content-box.active").animate({ left: -4000 }, 1000);
			$(".content-box.active").removeClass("active");
			$(nextSlider).css("left", "4000px");
			$(nextSlider).animate({ left: nextSliderPos }, 800, "easeOutBack" );
			$(nextSlider).addClass("active");
			$('.small_scroll').jScrollPane({dragMaxHeight:10, dragMinHeight:10, scrollbarMargin:10});
		}
	
	
	//HANG HOVER
		
		/*$("#home-hang-right").hover(function() {
			$("#home-hang-right-overlay").animate({ left: 15 }, 300)
		}, function() {
			$("#home-hang-right-overlay").animate({ left: -100 }, 300)
		});*/

		//Left
		$("#home-hang-left").click(function() {
			contentAnimate("#videos");
		});
		
		//Both
		$("#home-hang-left, #home-hang-right").hover(function() {
			$(this).animate({ marginTop: 30 }, 100, function() {
				$(this).animate({ marginTop: 0 }, 600, "easeOutBounce" );
			});
		}, function() {
	
		});
			
	//CITY ANIMATE
		var cityAmount = -700;
		var cityAnimateContinue = true;
		cityAnimate();
		function cityAnimate() {
			//$("#header-clouds").animate( { backgroundPosition: "("+cityAmount+"px 0px)"}, 20000, "easeInOutQuad");
			$("#header-city").animate( { backgroundPosition: "("+cityAmount+"px bottom)"}, 20000, "easeInOutQuad", function(){
				cityAmount = cityAmount - 700;
				if(cityAmount <= -20000) { 
					cityAmount = -700;
					$("#header-city").animate( { backgroundPosition: "("+0+"px bottom)"}, 1)
				}
				if(cityAnimateContinue == true) {
					cityAnimate();
				}
			});
		}
		/*$("#header-clouds").animate( { backgroundPosition: "(500px bottom)"}, 20000, "easeOutCubic", function(){
			$("#header-clouds").animate( { backgroundPosition: "(-500px bottom)"}, 20000, "easeInCubic")
		});*/
		
	
	//PHOTOS
	
		var selectedOverlay;	
		var triggers = $(".ssp").overlay({ 
			// some expose tweaks suitable for modal dialogs 
			expose: { 
				color: '#230349', 
				loadSpeed: 200, 
				opacity: 0.8 
			}, 
			closeOnClick: true,
			onBeforeLoad: function(event) {
				selectedOverlay = this.getTrigger().attr("title");
				$("#ssp").html("");
				cityAnimateContinue = false;
				//$("#header-clouds").stop();
				$("#header-city").stop();
				swfobject.embedSWF("swf/slideshowpro.swf", "ssp", "550", "450", "9.0.0", false, eval("flashvars_photos_"+selectedOverlay), params_photos, attributes_photos);
			},
			onClose: function(event) {
				cityAnimateContinue = false;
				cityAnimate();
			}
			
			});
		

	//NOMINEES
	
		var triggers = $(".nominee-category").overlay({ 
		// some expose tweaks suitable for modal dialogs 
		expose: { 
			color: '#230349', 
			loadSpeed: 200, 
			opacity: 0.8 
		}, 
		closeOnClick: true,
		onBeforeLoad: function(event) {
			cityAnimateContinue = false;
			$("#header-city").stop();
		},
		onClose: function(event) {
			cityAnimateContinue = false;
			cityAnimate();
		}
		
		});


});//END Jquery