function largeBannerAnimation() {
	var a = $('#animation');
	var i = $(a).find('.images');
	var r = $(a).find('.red-box').hide();
	var l = $(a).find('.large-text').hide();
	var s = $(a).find('.small-text').hide();
	
	var is = $(i).find('img');
	$(i).empty().append(is);
	
	$(r).delay(500).slideDown(1500, 'easeOutCubic', function() {
		$(l).fadeIn(800, 'easeOutBounce', function() {
			$(s).fadeIn(1200, 'easeOutBounce', function() {
				$(i).cycle({timeout:5000, duration:1000});
			});
		});
	});
}

function latestNews() {
	$('#latest-news .news').cycle({timeout:4000, speed:1000, sync:false, cleartypeNoBg:true});
}

function searchText() {
	var q = $('#search .query');
	var dq = $(q).attr('value');
	$(q).focus(function() {
		if ($(q).attr('value') == dq) {
			$(q).attr('value', '');
		}
	});
	$(q).blur(function() {
		if ($(q).attr('value') == '') {
			$(q).attr('value', dq);
		}
	});
}

function projectGallery() {
	var f = 300;
	var s = $('#slideshow').css({position:'relative'});
	var i = $(s).find('img').css({position:'absolute', left:'10px', top:'10px', zIndex:'1'});	
	$('#thumbnails a').each(function() {
		var h = $(this).attr('href');
		var o = $('<img>').attr('src', h).css({
			display:'none',
			position:'absolute',
			left:'10px',
			top:'10px',
			zIndex:'2'
		});
		$(s).append(o);
		$(this).hover(
			function() { $(o).css({zIndex:9999}).fadeIn(f); },
			function() { $(o).css({zIndex:2}).fadeOut(f); }
		);
		$(this).click(function(e) { e.preventDefault(); });
	});	
}

$(function() {
	$('.no-js').removeClass('no-js');
	
	largeBannerAnimation();
	latestNews();
	searchText();
	projectGallery();
});
