$(document).ready( function() {
	
	// TICKER //
	$.get('inc/retriever_feed.php', function(data) {
		
		// Build HTML for ticker
		var html = '<ul id="loaded_ticker">\n';
		$(data).find('item').each( function() {
			var $item = $(this);
			var date = new Date($item.find('pubDate').text());
						
			html += '  <li><span>' + date.toLocaleDateString() + ' - ' + date.toLocaleTimeString() + '</span><a href="' + $item.find('link').text()+ '" target="_blank">' + $item.find('title').text() +  '</a></li>\n';
		})
		html += '</ul>\n';
		
		// Append HTML
		$('#main_ticker').append($(html)) ;
		
		// Add ticker functionality
		$('ul#loaded_ticker').liScroll();
	});
	
	function isReady(){
		return true;
	}

	// PRESENTATION //
	// If HTML content still in #presentation, swfobject did not trigger
	if ($("#presentation .slide").length > 0) {
		var currentSlide = 1;
		var slideAmount = 8;
		var $presentation = $("#presentation");

		function getSlide(offset) {
			$presentation.children("#slide" + currentSlide).hide();
			currentSlide += offset;
			$presentation.children("#slide" + currentSlide).show();
		}

		$presentation.children(".slide").each(function(){
			$(this).children(".bckBtn").click(function() {
				getSlide(-1);
			});
			$(this).children(".fwdBtn").click(function() {
				getSlide(1);
			});
			$(this).hide();
		});

		$presentation.children("#slide1").show();
	}
});

function updateFolderText(id){
	$("#foldertext").load("inc/picture_text.php?id="+id);
	//$("#foldertxthead").text(heading);
	console.log("head: " + heading);
}
	
function updateProjectDescription(id){
	$("#foldertext").load("inc/picture_text.php?article=true&id="+id);
}
	
function updateFolderTextHeading(heading){
	$("#foldertxthead").text(heading);
}
