$(function() {
	if ($('#news').length) {
		var heightTotal = 0; 
		$('#news li').each(function(){ 
			heightTotal += +$(this).height(); 
		}); 
		if (heightTotal >= "514") {
			$('#news').jcarousel({
				vertical: true,
				auto:5,
				wrap:"circular",
				scroll:1,
				buttonNextHTML:null,
				buttonPrevHTML:null
			});
		}
	}
	
	$('input[title]').each(function() {
			var $this = $(this);
			if($this.val() === '') {
				$this.val(this.title); 
			}
			
			$this.focus(function() {
				if($this.val() === this.title) {
					$this.val(''); 
				}
			});
			
			$this.blur(function() {
				if($this.val() === '') {
					$this.val(this.title); 
				}
			});
		});	
	
	if ($('.slideshow').length) {
		function slideSwitch() {
		    var $active = $('.slideshow .active');
		
		    if ( $active.length == 0 ) $active = $('.slideshow img:last');
		
		    // use this to pull the images in the order they appear in the markup
		    var $next =  $active.next().length ? $active.next()
		        : $('.slideshow img:first');
		
		
		    $active.addClass('last-active');
		
		    $next.css({opacity: 0.0})
		        .addClass('active')
		        .animate({opacity: 1.0}, 1000, function() {
		            $active.removeClass('active last-active');
		        });
		}	
		setInterval( function() {slideSwitch();}, 5000 );
	}
	
	$('#slider').nivoSlider({directionNav: false, controlNav:false, animSpeed: 500, pauseTime: 3000,  slices: 8, effect: 'fold'});
	
});
		   
