$(document).ready(function() {
	
	$("#tweets").tweet({
		username: "medeavodka",
	    count: 4,
	    loading_text: "loading tweets..."
	});
	
	$('#get-on-the-list a').click(function() {
		return false;
	});
	
	$('#get-on-the-list form').submit(function() {
		$.post(
            "/newsletter-signup.php",  
            $("#ajax-form").serialize(),  
            function(){  
            	alert("Thank you for signing up for the Medea newsletter!  Your email has been added to our records and you will be kept up to date with all of the latest Medea news.");  
            }  
        );  
        return false;
	});
	
	// Open all links in new windows
	$('a').attr('target', '_blank');
	
	// Scroll bottle text
	var listLength = $('#bottle-mask ul').text().replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '').length - 120;
	var scrollDistance = '-' + listLength * 27 + 'px';
	var scrollTime = listLength * 300;
	$('#bottle-mask ul').css('left', '660px');
	$('#bottle-mask ul').load(scrollWords());
	
	// scrollWords();
	
	function scrollWords() {
		$('#bottle-mask ul').css('left', '135px');
		$('#bottle-mask ul').animate({left: scrollDistance}, scrollTime, 'linear', scrollWords2);
	}
	
	function scrollWords2() {
		$('#bottle-mask ul').css('left', '135px');
		$('#bottle-mask ul').animate({left: scrollDistance}, scrollTime, 'linear', scrollWords);
	}

});
