// jQuery tabs.
// Thanks for the help, http://jqueryfordesigners.com/jquery-tabs/

$(function () {
	var tabContainers = $('div.tabs .attention_inner > div');
	tabContainers.hide().filter(':first').show();
	
	$('div.tabs ul.tabNavigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		
		$('div.tabs ul.tabNavigation a').removeClass('active');
		$(this).addClass('active');
		
		return false;
	}).filter(':first').click();
}); 


// EQUAL COLUMNS

function setEqualHeight(columns)  
	{  
		var tallestcolumn = 0;  
		columns.each(  
		function()  
	{  
	currentHeight = $(this).height();  
	if(currentHeight > tallestcolumn)  
		{  
			tallestcolumn  = currentHeight;  
		}  
	}  
);  
		
columns.height(tallestcolumn);  
	 }  
	$(document).ready(function() {  
	 setEqualHeight($(".3cols div  > div.col_inner"));  
	 setEqualHeight($(".equalHeight div > div.col_inner"));  
	}
);  
	
//	CONTACT FORM
        
$(document).ready(function() {
	
    $("#ajax-contact-form").submit(function() {
        $('#load').append('<center><img src="assets/ajax-loader.gif" alt="Currently Loading" id="loading" /></center>');

        var fem = $(this).serialize(),
			note = $('#note');
	
        $.ajax({
            type: "POST",
            url: "sendMail/contact.php",
            data: fem,
            success: function(msg) {
				if ( note.height() ) {			
					note.slideUp(1000, function() { $(this).hide(); });
				} 
				else note.hide();

				$('#loading').fadeOut(300, function() {
					$(this).remove();

					// Message Sent? Show the 'Thank You' message and hide the form
					result = (msg === 'OK') ? '<div class="success">Your message has been sent. Thank you!</div>' : msg;

					var i = setInterval(function() {
						if ( !note.is(':visible') ) {
							note.html(result).slideDown(1000);
							clearInterval(i);
						}
					}, 40);    
				}); // end loading image fadeOut
            }
        });

        return false;
    });
});



// TABBED CONTENT
$(document).ready(function() {
	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
		
	//On Click Event
	$("ul.tabs li").click(function() {
	$("ul.tabs li").removeClass("active"); //Remove any "active" class
	$(this).addClass("active"); //Add "active" class to selected tab
	$(".tab_content").hide(); //Hide all tab content
	var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
}); 

