/*-------------------
Author: Visual Blaze
Description: Core JS
-------------------*/

jQuery(document).ready(function() {

	/*-------------------------------------------
	assign new window funct to external links
	-Allows removal of nonstandard target="_blank"
	--------------------------------------------*/
	var extLinks = $('a');
	 for (var i=0; i<extLinks.length; i++) {
	   var extLink = extLinks[i];
	   if ($(extLink).attr("href") && $(extLink).attr("rel") == "external") {
		extLink.target = "_blank";
		}
	 }
	
	/*-------------------------------------------------
	form submit js overrides/hijack onsubmit 
	- all fs forms [non-donate currently] have same id
	-------------------------------------------------*/
	$('form#contactForm').submit(function(e) {
		formSubmit($(this));
	  	e.preventDefault();
	  	return false;
	});
	
	/*-----------------------
	formField on focus clear
	------------------------*/
	function clearField(inputObj) {
		//array access operator used as jq obj passed to standard js properties fails
	     if ($(inputObj)[0].value == $(inputObj)[0].defaultValue || $(inputObj)[0].value == "Required") {
	         $(inputObj)[0].value = "";
	     }
	}
	
	/*----------------------------------------------
	form clearField function attachment
	----------------------------------------------*/
	$('form#contactForm input').focus(function(){
		//check not submit button and assign clearField()
		if($(this).attr('type') != "submit") {
			clearField($(this));
			$(this).addClass('focus');
		}
	});

}); 
