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

	//Email Obfuscation
	$(".replaceAt").replaceWith("@");
  	$(".obfuscate").each(function () {
  		$(this).attr("href", "mailto:"+$(this).text());
  		thisrel = $(this).attr("rel");
  		if (thisrel) $(this).text(thisrel);
  	});

	//Form Default Values
	$(".replacedefault input[type=text], .replacedefault textarea").bind('focus', function(){
		var currentValue = $(this).attr("value");
		var defaultValue = $(this).attr("defaultValue");
		if (currentValue == defaultValue) $(this).attr({ value: ""});
	});
	$(".replacedefault input[type=text], .replacedefault textarea").bind('blur', function(){
		var currentValue = $(this).attr("value");
		var defaultValue = $(this).attr("defaultValue");
		if (currentValue == '') $(this).attr({ value: defaultValue});
	});

	// HOMEPAGE SUB-CONTENT
	var currentRel = 0;
	$("#homesubnav li a").click( function() {
		var rel = $(this).attr("rel");
		var currentheight = $("#homesubcontentcontainer").height();
		$("#homesubcontentcontainer").css("min-height",currentheight + "px");

		$(".homesubcontent").hide();
		if (currentRel != rel) {
			$("#content"+rel).fadeIn();
			currentRel = rel;
		} else {
			currentRel = 0;
			$("#homesubcontentcontainer").css("min-height","0");
		}
	});
  
	$('#topnav li.page-item-7 a').popupmenu({
		target: "#ministrydropdown",
		time: 300,
		addStyle: 'ministryover'
	});

});

