
// Load on document ready ##############################################################

$(document).ready(function() {
	
	// Load navigation handler ####################################################
    $('#nav').droppy();
	
	// Handle form field focus (in lieu of :focus) ################################
	setTimeout(formFocusFix,2000); // Pauses for AJAX forms to fully load
	
	// Load contact form (if region present) ######################################
	if ($('#contact-form').length>0) { $('#contact-form').html('Loading...');$('#contact-form').load('includes/contact-form.php'); }
	
	// Load calendar (if region present) ##########################################
	if ($('#calendar-container').length>0) { $('#calendar-container').load('includes/calendar.php'); }
	
	// Fix column heights
	
	var leftHeight = $('#main_content_container').height();
	var rightHeight = $('#callouts').height();
	
	//alert(leftHeight);
	
	if (leftHeight>rightHeight){
		$('#callouts').css('height',(leftHeight+110)+'px');
	}
	
	// Callout bubbles (Homepage)
	$('#b1').click(function(){
		$(this).attr('src','images/b_help_on.png');
		$('#b2').attr('src','images/b_smart_off.png')
		$('#b3').attr('src','images/b_involved_off.png')
		$('.bubble_content').addClass('hide');
		$('#c1').removeClass('hide');
	});
	
	$('#b2').click(function(){
		$('#b1').attr('src','images/b_help_off.png');
		$(this).attr('src','images/b_smart_on.png')
		$('#b3').attr('src','images/b_involved_off.png')
		$('.bubble_content').addClass('hide');
		$('#c2').removeClass('hide');
	});
	
	$('#b3').click(function(){
		$('#b1').attr('src','images/b_help_off.png');
		$('#b2').attr('src','images/b_smart_off.png')
		$(this).attr('src','images/b_involved_on.png')
		$('.bubble_content').addClass('hide');
		$('#c3').removeClass('hide');
	});
	
	$('#c2').addClass('hide');
	$('#c3').addClass('hide');
	
});


// AJAX POST Processor ################################################################

function ajaxPost(url,formid,containerid)
  {
  $.post(url, $('#'+formid).serializeArray(), function(data)
    {
	  $('#'+containerid).html(data);
		$('#return-message').fadeOut(8000);
    });			
  }
	
// For Focus Fix #####################################################################

function formFocusFix()
  {
	$('input, textarea, select').focus(function(){ $(this).addClass('focus'); });
	$('input, textarea, select').blur(function(){ $(this).removeClass('focus'); });
	}