/*-----------------------------------------------
severStorey Core JS
Author: Andy Sherman
Created: 11/24/09
Description: Core JS function include [all pages]
-------------------------------------------------*/


jQuery(document).ready(function() {

	/*-----------------------------------------
	contact form append onclick functionality
	------------------------------------------*/
	//for main form button
	var cLink = $("div#banner form > p a");
	
	if(cLink) {
		//set href to javascript:void(0);
		$(cLink).attr('href', 'javascript:void(0);');
	
		$(cLink).bind('click',function(){
		    contactFormAnim();
		    return false;
		 });
	}	
	
	/*-------------------------------------------
	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";
		}
	 }
	
	/*------------------------------------------------------------------------------
	quick connect clearField -> NOT used, assigned attribute dont fire clear funct
	------------------------------------------------------------------------------*/
	/*
	$('form#qCForm input').each(
		function(){
			if(!$(this).is("#qCSubmit")) {
				$(this).attr('onfocus','clearField(this);');
			}
		}
	);
	*/


//end jqueryReady statement	
});

/*-----------------------
formField on focus clear
------------------------*/
function clearField(inputObj) {
     if (inputObj.value == inputObj.defaultValue || inputObj.value == "Required") {
         inputObj.value = "";
     }
}

/*-----------------------------------
quickconnect animate [non-home page]
------------------------------------*/

function contactFormAnim() {
	jQuery(document).ready(function() {
		//toggle add/remove of form class
		if($("div#banner form").is('.open')) {
			//form is open so remove class to close
			$("div#banner form").removeClass("open");
		}else{
			//form closed so add class to open
			$("div#banner form").addClass("open");
		}
	});
}


