/* #############################################################
	Credit Union
		- scripts.js 
			jQuery JavaScript Scripts
############################################################# */

$(document).ready(function() {
		$.fn.cycle.defaults.timeout = 6000;
		$(function() {
			$('#fp-slideShow').after('<div id="fp-slideShow-nav">').cycle({
				fx:      'fade',
				speed:   500,
				timeout: 3000,
				pager:   '#fp-slideShow-nav'
			});
		});
		
		
		/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		 * function 'cleaverHeights'
		 * 	 (origional @ stackoverflow)
		 * 		Modified to allow equal heights on DIVs with specific class
		 * 		on a per-row basis to ensure large heights not kept throughout
		 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 
		$.fn.cleverHeights = function(onlyOn, px) {
			$(this).each(function(){
			    var currentTallest = 0;
			    var width = 0;
			    var row = new Array();
				
			    $(this).children().each(function(i){
					
			     	if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
			        width += parseInt($(this).outerWidth(), 10);
			        row[++row.length] = $(this);
			        if (width > 900) {
			            $.each( row , function() {
							
							if ($(this).hasClass(onlyOn)) {
				                $(this).css({'min-height': currentTallest});
				                // for ie6, set height since min-height isn't supported
				                if ($.browser.msie && $.browser.version == 6.0) { $(this).css({'height': currentTallest}); }
							}
			            });
			            row.length = 0;
			            width = 0;
			            currentTallest = 0;
			        }   
					
			    });
				
			});
			return this;
		};
			
		/* Call cleaverHeights to equal heights on divs */
		$(".hpGridHolder").cleverHeights("hpGridBox");
		
		$(".landing-group3").cleverHeights("landingBox");
		$(".landing-group2").cleverHeights("landingBox");
			
	
});		
