var i = 1;
var t;
var duration = 4000;
	
function rotate() {
	
	// loop the increment
	if (i > 3) { i = 1;}
	
	// fade item-i in and all others out
	$('#content div.item-' + (i-2)).fadeOut('slow');
	$('#content div.item-' + (i-1)).fadeOut('slow');
	$('#content div.item-' + i).fadeIn('slow');
	$('#content div.item-' + (i+1)).fadeOut('slow');
	$('#content div.item-' + (i+2)).fadeOut('slow');
	
	i++;
}

function killMessage() {
		$('#message').delay(4000).fadeOut(500);
}

function confirmDelete(pageId) {
	var answer = confirm ("Are you sure?")
	if (!answer) {
		return false;
	} else {
		window.location = 'delete_portfolio_item.php?item='+pageId;
	}
}

$(document).ready(function(){
	
	$('#content div.item-1, #content div.item-2, #content div.item-3').fadeOut(0);
		
	$('#latest_work').parents('col-3').fadeTo(0, 0);
	$('#latest_work').load(function() {
		alert('done');
	});
	
	killMessage();
			
	$("#contact, #info").hide();
					  
	$('.hover').hover(
		function() { $(this).children('.text').fadeIn("fast"); },
		function() { $(this).children('.text').fadeOut("fast"); }
	);
		
	var height;
	height = $('#page-text').height();
	$('#page-image').css('height', height);
	
});

$(window).load(function () {
	
	t = setInterval("rotate()", duration);
	
	$('#content #latest_work').hover(
		function() { clearInterval(t); },
		function() { t = setInterval("rotate()", duration); }
	);

});
