	$(document).ready(function() {
	
		$('.testscroll').jScrollHorizontalPane({scrollbarHeight:9, showArrows:true});

		$("a.fancybox").fancybox({
			'padding' : 0
		});
		
		$("a.fancybox_inline").fancybox({
			'hideOnContentClick': false
		});

		$('h1#sitetitle a').removeClass('nojs');
		$('h1#sitetitle a').hover(
			function() {
				$(this).stop().fadeTo('1000', 0);
			},
			function() {
				$(this).stop().fadeTo('1000', 1);
			}
		);
		
		if(typeof(disableDropdown) == 'undefined')
		{
			$('.addons a').click(function() {
				if($('#nav_dropdown:visible').length > 0)
				{
					$(this).removeClass('active');
					$('#nav_dropdown').slideUp();
				}
				else
				{
					$(this).addClass('active');
					$('#nav_dropdown').slideDown();
				}
				return false;
			});	
		}
		
		$('body').click(function() {
			if($('#nav_dropdown:visible').length > 0)
			{
				$('.addons a').removeClass('active');
				$('#nav_dropdown').slideUp();
			}			
		});
		
		$('#nav_dropdown').click(function(event){event.stopPropagation();});

		$('code span:first-child').each(function(index) {
			if($(this).parent('code').length > 0)
			{
				$(this).addClass('scrollableCode');
				$(this).jScrollHorizontalPane({scrollbarHeight:5});
			}
		});
		
		$("#download_items").css('display', 'none');
		$("#action_toggle a").click(function() {
			$("#buy_items, #download_items").slideToggle();
			if($(this).hasClass('return_link'))
			{
				$(this).html('Download Now').removeClass('return_link');
				$("#action_toggle #link_prefix_text").css('visibility', 'visible');
			}
			else
			{
				$(this).html('Return to buy now').addClass('return_link');
				$("#action_toggle #link_prefix_text").css('visibility', 'hidden');
			}
			return false;
		});
		
		$("#download_items .input").focusin(function() {
			if($(this).val() == 'License Code')
			{$(this).val('');}
		});
		
		$("#download_form").submit(function() {
			var license = $(".input", this).val();
			if(license == '' || license == 'License Code')
			{
				alert('Please enter a valid license code.');
				return false;
			}
		});

	});