$(document).ready(function(){
	var rh = $('#wrap').height();
	var fh = $('#footer').height();
	if($(window).height()>(rh+fh)) {
		$('#footer').css("height",$(window).height()-rh);
	}
	
   	$('a[rel=external]').attr('target', '_blank');
	$("a.fb_img").fancybox({'titleShow':true});
	$(".sait_gallery").click(function() {
		$.fancybox([
			{
				'href'	: '_cs/sait-training-1.jpg',
				'title'	: 'SAIT Training Website - Joomla CMS Implementation'
			},
			{
				'href'	: '_cs/sait-training-2.jpg',
				'title'	: 'Custom Course Calendar and Search built with PHP/MySQL'
			},
			{
				'href'	: '_cs/saitnow.jpg',
				'title'	: 'SAIT Corporate Internet<br>Joomla CMS with custom modules and components'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 100
		});
	});
	$(".catuso_gallery").click(function() {
		$.fancybox([
			{
				'href'	: '_cs/catuso-products.jpg',
				'title'	: 'Catuso - Custom Flash with AS3 and XML Backend'
			},
			{
				'href'	: '_cs/catuso-detail.jpg',
				'title'	: 'Catuso - Custom Flash with AS3 and XML Backend'
			}
		], {
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'              : 'image',
			'changeFade'        : 100
		});
	});
	
	var ww = $(window).width();
	var bn = 1;
	setInterval(function() {
		var rn = Math.floor(Math.random()*5);
		var rh = Math.floor(Math.random()*380)+20;
		var rhw = Math.floor(Math.random()*10)+10;
		var rt = (Math.floor(Math.random()*7))*(100*(10-(rhw-10)))+8000;
		$('#birds').append('<div class="bird" id="bird'+bn+'"><img src="_img/birdy.gif"></div>');
		$('#bird'+bn).css('left',	ww+20);
		$('#bird'+bn).css('top',	rh);
		$('#bird'+bn+' img').height(rhw);
		$('#bird'+bn+' img').width(rhw);
		$('#bird'+bn).delay(rn*1000).animate({left:-50},rt,'linear',function() {
			$(this).hide();	
		});	
		bn++;
	}, 8000);
	$(window).resize(function() {
		ww = $(window).width();
	});
	
	$('#clouds').css('opacity',.5);
	$('#birds').css('opacity',.4);

});



