/*---------------------------------
 * Initiate Jquery Functions
 *---------------------------------
 */

//Kick-off / Page Load Functions
$(document).ready(function(){
	
	//AutoPopulate by Andy Stratton (http://www.andystratton.com/)
	$("input.populate").each( function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this).attr("title") );
		}
	});
	$("input.populate").focus(function(){
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("");
		}
	});
	$("input.populate").blur(function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
	//Encrypt mailto addresses by Andy Stratton (http://theandystratton.com/2009/accessibly-cloak-email-addresses-with-jquery/)
	$(".email-replace").each(function(){
		var ats, dots, address, i;
		ats = [ ' at ', ' (at) ', ' [at] ' ];
		dots = [ ' dot ', ' (dot) ', ' [dot] ' ];
		address = $(this).html();
		for ( i = 0; i < ats.length; i++ ) {
			address = address.replace(ats[i], '@');
		}
		for ( i = 0; i < dots.length; i++ ) {
			address = address.replace(dots[i], '.');
		}
		$(this).html('<a href="mailto:' + address + '">' + address + '</a>');
	});

});

// Initialize JQuery Superfish
jQuery(function(){
	jQuery('ul.sf-menu').superfish();
});

