$(document).ready(function(){ 	
    setInterval( "slideSwitch()", 5000 );
	
	$(".social .fb").click( function() {
		var u=location.href;
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&src=sp', '','');
		return false;
	});
	
	$(".social .tw").click( function() {
		var u=location.href;
		window.open('http://twitter.com/home?status=Currently%20reading%20'+encodeURIComponent(u), '','');
		return false;
	});
	
	$("#newsletter").blur( function() {
		if($(this).attr("value") == "" || $(this).attr("value") == "email" ) $(this).attr("value", "email");
	});
	$("#newsletter").focus( function() { 
		if( $(this).attr("value") == "email" ) $(this).attr("value", "");	
	});
	
}); 

function slideSwitch() {
    var $active = $('#slideshow li.active');

    if ( $active.length == 0 ) $active = $('#slideshow li:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow li:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
