$(document).ready(function(){
	
	var pause;
	var interval;

	$("#header3 li:first").css({paddingLeft: '10px'});
	$("#header3 li:last").css({backgroundImage: 'none', paddingRight: '0'});
	

	$(".recentcomment:last").css({backgroundImage: 'none'});

	// roll-overs on main navigation
	$(function() {
		$('#header3 a').hover(function(){	
				$(this).not('.on').css("backgroundImage", "url(/image/nav_over.gif)");
			}, function(){
				$(this).not('.on').css("backgroundImage", "url(/image/spacer.gif)");
		});
	});
	
	
	//portfolio hover	
	$(function() {
		$('.folio').hover(function(){	
			$('.folio').not(this).stop(true,true).css({"opacity":"0.5"});
		}, function(){
			$('.folio').delay(300).stop(false,true).css({"opacity":"1"});
		});
	});
	
	// show green labels
	$('.foliocats:contains("Green,")').parent().siblings('.isgreen').fadeIn(800);
	
	$(function() {
		if ($('#projectcatsr').children(':contains("Green")').length > 0) {
			$('.isgreen').fadeIn(800);
		}
	});


	
	
	
	//header hover	
	$(function() {
		$('#header2').hover(function(){	
			pauseResume('pause');
			$('#headerpopupwrapper').css({"opacity":"0.8"});
			$('#headerpopupcontainer').stop(true,true).animate({"height":"toggle","opacity":"toggle"});
			
		}, function(){
			pauseResume();
			$('#headerpopupcontainer').stop(false,true).animate({"height":"toggle","opacity":"toggle"});
			
		});
	});

	startBannerRotation();

});

changeimage = function() {
	var _currentID = parseInt($('#currentprojectid').text());
	$('#ajreturner').load('/_ajax/banner/'+_currentID, function() {
  			updateHomeBanner(_currentID);
	});
}

updateHomeBanner = function(xID) {
	$('#'+xID).fadeOut('slow', function() {
    	$('#'+xID).remove();
  	});
	$('#bannertitle').text($('#newtitle').text());
	$('#bannercaption').text($('#newcaption').text());
	$('#bannerimage').prepend($('#newimage').html());
	$('#currentprojectid').text($('#newentryid').text());
	doCleanUp();
}

doCleanUp = function() {
	$('#ajreturner').html('');
}

startBannerRotation = function() {
  interval = setInterval('changeimage()',5000);
}

pauseResume = function(pause) {
  if(pause) {
    clearInterval(interval);
    pause = false;
  } else {
    interval = setInterval('changeimage()',5000);
    pause = true;
  }
}









