var loadImages = {
    beginCycle: function() {       
	    $("li#trees").fadeIn(1500, function() {
	        $("li#building").fadeIn(1500, function() {
	            $("li#beach").fadeIn(1500, function() {
	                
	                $("li#trees, li#building, li#beach").animate({opacity: 1.0}, 3500).fadeOut(2000);
	                
	                loadImages.beginCycle();
	            });
	        });
	    });
    }
};
var scrollMarquee = {
	beginScroll: function($lengthScroll) {
		$(".hpAnnouncements div#scroll_marquee ul").animate({
			top: $lengthScroll
			}, 30000, function() {
				$(".hpAnnouncements div#scroll_marquee ul").css("top", "70px");
				scrollMarquee.beginScroll($lengthScroll);
		});
	}
};


$(function() {
    $("li#trees, li#building, li#beach").hide();
    loadImages.beginCycle();
    $countLi = $(".hpAnnouncements div#scroll_marquee ul li").length;
    switch($countLi) {
    		case 3: 
    			$lengthScroll = "-=195";
    			break;
    		case 4: 
    			$lengthScroll = "-=220";
    			break;
    		case 5:
    			$lengthScroll = "-=245";
    			break;
    		case 6:
    			$lengthScroll = "-=270";
    			break;
    		case 7:
    			$lengthScroll = "-=295";
    			break;
    		case 8:
    			$lengthScroll = "-=320";
    			break;
    		case 9:
    			$lengthScroll = "-=345";
    			break;
    		default:
    			$lengthScroll = "-=245";
    }
    
    if ($countLi > 2) {
    		$(".hpAnnouncements div#scroll_marquee ul").css("top", "70px");
    		scrollMarquee.beginScroll($lengthScroll);
    	}

});
