




/* MISC */

$(document).ready(function(){

// align each grid with the the grid of maximum height
	var gridHeight = 0;
		// get max height of available grids
	$(".grid_1,.grid_2,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9,.grid_10,.grid_11,.grid_12").each(function(){
				if ($(this).height() > gridHeight)
					gridHeight = $(this).height();
		 });
		// adjust height of each available grid
	$(".grid_1,.grid_2,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9,.grid_10,.grid_11,.grid_12").css({'height' : gridHeight+'px'});
});



function slideSwitch() {
		var $active = $('#slider IMG.active');

		if ( $active.length == 0 ) $active = $('#slider IMG:last');

		// use this to pull the images in the order they appear in the markup
		var $next =  $active.next().length ? $active.next()
				: $('#slider IMG:first');

		// uncomment the 3 lines below to pull the images in random order

		var $sibs  = $active.siblings();
		var rndNum = Math.floor(Math.random() * $sibs.length );
		var $next  = $( $sibs[ rndNum ] );


		$active.addClass('last-active');

		$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
						$active.removeClass('active last-active');
				});
}

$(function() {
		setInterval( "slideSwitch()", 5000 );
});
