// Global stuff to do after page load
$(document).ready(function() {

	// set up ticker
	c = 0;
	tick = 10000;

	// make sure there are some news somewhere
	if(typeof feeds != "undefined") {
		window.setInterval(function() {
			if(feeds.length>0) {
				$("#ticker").fadeOut(400, function() {
					if(c>=feeds.length) c = 0;
					$(this).html(feeds[c]);
					$(this).fadeIn(600);
				});
				c++;
			}
		}, tick);
	}

	// set up photo flicker
	thisc = 0;
	thistick = 5000;

	// make sure there are some news somewhere
	function photoAlbum(){
		if(typeof galleryImages != "undefined") {
			if(galleryImages.length>0) {
				$("#gallery").fadeOut(400, function() {
					if(thisc>=galleryImages.length) thisc = 0;
					$(this).html(galleryImages[thisc]);
					$(this).fadeIn(600);
				});
				thisc++;
			}
		}
		window.setTimeout(function() {
			photoAlbum();
		}, thistick);
	}

	setTimeout(function() {
		photoAlbum();
	}, 1000);
});
