;(function($) {
	$(document).ready(function() {	
		function logoShine() {
			$('#shine-logo').css('background-position', '-350px 0');
			$('#shine-logo').animate({backgroundPosition : '120px 0'}, 300, 'linear');
			setTimeout(logoShine, 2000);
		}
		logoShine();
		function buttonShine() {
			$('#button-box').find('#button-shine').css('background-position', '-350px 0');
			$('#button-box').find('#button-shine').animate({backgroundPosition : '120px 0'}, 400, 'linear');
			setTimeout(buttonShine, 3000);
		}
		buttonShine();
		
		// Hovering and active states for Download and Instant Play buttons		
		
		$('#download div#button-top-layer').hover(
			function() {
				$('#download h2').addClass('hovered');
			},
			function() {
				$('#download h2').removeClass('hovered');
			}
		);
		$('#download div#button-top-layer').mousedown(function(){
			$('#download h2').addClass('activated');
		}).mouseup(function() {
			$('#download h2').removeClass('activated');
		});
		
		$('#instant-play div#button-top-layer').hover(
			function() {
				$('#instant-play h2').addClass('hovered');
			},
			function() {
				$('#instant-play h2').removeClass('hovered');
			}
		);
		$('#instant-play div#button-top-layer').mousedown(function(){
			$('#instant-play h2').addClass('activated');
		}).mouseup(function() {
			$('#instant-play h2').removeClass('activated');
		});
		
		$('#menu li a').hover(
			function() {
				$(this).find('span').addClass('hovered');
			},
			function() {
				$(this).find('span').removeClass('hovered')
			}
		);
		
		$('a.overlay').click(function() {
			$('#iframe-container').html(' ');
			setTimeout(function() {
					$('.pp_close').click(function() {
						$('#iframe-container').html('<iframe width="420" height="315" src="http://www.youtube.com/embed/NdE0oUyF97c" frameborder="0" allowfullscreen></iframe>');      
					});
				}, 1000
			);
		});
		
		$('select.downloads').change(function() {
			document.location.href = $('select.downloads').val();
		});
		
		$('.dropdown dt a').click(function(e){
			$(this).parents('.dropdown').find('ul').toggle();
			e.preventDefault();
		});
		$('.dropdown dd ul li a').click(function(e){
			$('.dropdown dd ul').hide();
		});
		$(document).bind('click', function(e) {
			var $clicked = $(e.target);
    		if (! $clicked.parents().hasClass("dropdown"))
        	$(".dropdown dd ul").hide();
		});

	});	
})(jQuery);
