var obj = null;
var proj = 0;
function checkHover() {
	if (obj) {
		obj.find('ul').fadeOut('fast');
	}
}
function ufadeIn(num) {
	jQuery('.details').children('li:eq('+num+')').fadeIn();
}

jQuery(function() {
	
	jQuery('.photo p').cycle({
		fx: 'scrollRight',
		speed: 500,
		timeout: 0,
		next: '.nextproject'
	});
	
	jQuery('.nextproject').click(function() {
		jQuery('.details').children('li:eq('+proj+')').fadeOut(400);
		proj++;
		var i = jQuery('.details li').size() - 1;
		if (proj>i) proj = 0;
		setTimeout('ufadeIn('+proj+')', 400);
	});
	
	jQuery('#nav > li').hover(
	
		function() {
			if (obj) {
				obj.find('ul').css('display', 'none');
				obj = null;
			}
			jQuery(this).find('ul').fadeIn(500);
		},
		
		function() {
			obj = jQuery(this);
			setTimeout("checkHover()", 400);
		}
		
	);
	
});
