jQuery(window).load(function(){

// place footer ALWAYS at bottom of document
 jQuery(function(){
	function positionFooter(){
		
			var docHeight = jQuery(document).height();
			var footPos   = parseInt(jQuery('#footer').offset().top);
			var footHeight =jQuery('#footer').height();
			var footTotal = footPos + footHeight;
			
			
			if(footTotal < docHeight){
				
				footerDifference = docHeight - footTotal;
				newPos = footPos + footerDifference;
				
					jQuery('#footer').offset({
						top: newPos
					});
			}				
		}
			
	positionFooter();
	
	// make left ('picture') side of leadership
	// profile match height of right side
	// necessary because of wacky layout

		var leaderCopyHeight = jQuery('.leader_copy').height();
		var leaderImageHeight = jQuery('.leader_image').height();
		
		if (leaderImageHeight < leaderCopyHeight) {
		// difference between image and height so we can apply the remainder
		// to the div below
		
			newSetHeight = leaderCopyHeight - 276;
			
			jQuery('#leader_details').css('height', newSetHeight);
	
		}
	
	})
});




jQuery(document).ready(function($){
	
	

	
	
	
	// start home page hero cycle
	$('#inner_hero').cycle({
		fx: 'fade',
		pager: '#dot_pager',
		timeout: 20000
	});
	
	// carousel on recent transactions page
	$('#transaction_slider').cycle({
		fx: 'scrollHorz',
		next: '.trans_right_nav',
		prev: '.trans_left_nav',
		timeout: 0
	});
	
	// carousel on home page 
	
	//remove last slider set on recent transactions (on home page) if
	// it is blank
	
	 var checkIfEmpty = $('#recent_slider div:last ul').children().length;
	
	if(checkIfEmpty == 0){
		$('#recent_slider div:last').remove();
	} 
	
	$('#recent_slider').cycle({
		fx: 'scrollHorz',
		next: '#feature_nav_right',
		prev: '#feature_nav_left',
		pause: true,
		timeout: 7000
	});
	
	
	
	
	// modal for mailing list 
	
	$('#mail_signup span').click(function(){
		
		var body = $("html body")[0];
        $("div.ui-dialog").each(function() {
            $(this).appendTo(body);
        });
		
		$('#mail_dialog').dialog('open');
		return false;
	});
	
	$("#mail_dialog").dialog({
		width: 775,
		modal: true,
		resizable: false,
		 autoOpen: false
	});	
	
	// modal when clicking 'view all experience' on about-us page
	
	$('#past_experience a').click(function(){
		
		var body = $("html body")[0];
        $("div.ui-dialog").each(function() {
            $(this).appendTo(body);
        });
		
		$('#past_experience_dialog').dialog('open');
		return false;
	});
	
	$("#past_experience_dialog").dialog({
		width: 775,
		modal: true,
		resizable: false,
		 autoOpen: false
	});	
	
	// modal for business continuity disclosure
	
	$('.business_cont').click(function(){
		
		var body = $("html body")[0];
        $("div.ui-dialog").each(function() {
            $(this).appendTo(body);
        });
		
		$('#bus_dialog').dialog('open');
		return false;
	});
	
	$("#bus_dialog").dialog({
		width: 775,
		modal: true,
		resizable: false,
		 autoOpen: false
	});	
	
	
	// enable the "small caps with larger first letter" on various headers
	
	/* $.fn.capitalize = function(){
		return this.each(function() {
		// single out the first letter of each word and wrap in span for styling
		$(this).html( $(this).text().replace(/(^| )(\w)/g, "<span class='caps'>$1$2</span>" ) );
	});
	} 
	
	$("#feature_nav_inner h1").capitalize();*/
	
	//color name on hover on leadership profiles. For some weird reason it's
	
	
	$('.leadership_image:last').css('margin-right','0');
	
	$('.leadership_image').hover(
		function(){
			$(this).find('span').addClass('hoverColor');
		},
		function(){
			$(this).find('span').removeClass('hoverColor');
		}
		);
	
}); 
