// JavaScript Document
$(document).ready(function() {
	var headNumb = Math.floor(Math.random()*3)+1;
	$('body').addClass('head'+headNumb);
	//Let's make the navs dance.
	$("#primaryNav li a:not(.selected)").hover(function(){
		$(this).stop().animate({marginTop:"-3px"},"fast");
	},function(){
		$(this).stop().animate({marginTop:"0px"},"fast");
		}
	);
	$("#secondaryNav li a:not(.selected)").hover(function(){
		$(this).stop().animate({marginTop:"-3px"},"fast");
	},function(){
		$(this).stop().animate({marginTop:"0px"},"fast");
		}
	);
	$("#socialNetworking li a").hover(function(){
		$(this).stop().animate({marginTop:"-3px"},"fast");
	},function(){
		$(this).stop().animate({marginTop:"0px"},"fast");
		}
	);
});

//clear input box plugin 
$.fn.search=function(){return this.focus(function(){if(this.value==this.defaultValue){this.value=""}}).blur(function(){if(!this.value.length){this.value=this.defaultValue}})};

//validate form on submit
$.fn.validform=function(){return this.submit(function(){
	if(this.elements['name'].value==''||this.elements['name'].value==this.elements['name'].defaultValue){$("p.nameValidation").html("C'mon man, everybody's got one. If you don't want to use your real name, make one up.").fadeIn(300);setTimeout('$("p.nameValidation").fadeOut()', 5000);return false}
	if(this.elements['email'].value==''||this.elements['email'].value==this.elements['email'].defaultValue){$("p.emailValidation").html("What's the purpose in contacting me if you don't provide a means for my response?").fadeIn(300);setTimeout('$("p.emailValidation").fadeOut()', 5000);return false}
	if(this.elements['message'].value==''||this.elements['message'].value==this.elements['message'].defaultValue){$("p.messageValidation").html("For Christ's sake say <em>something</em>! Even &quot;Hi.&quot; will suffice.").fadeIn(300);setTimeout('$("p.messageValidation").fadeOut()', 5000);return false}
})};

// hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+ <http://cherne.net/brian/resources/jquery.hoverIntent.html | author Brian Cherne <brian@cherne.net>
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:6000,interval:150,timeout:500};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

// Random Bio Images
function random_thumb(){
	var images=new Array()
	images[1]='<img src="images/jayDelGreco01.jpg" width="300" height="400" border="0" class="bioPic" alt="Me" title="Me">'
	images[2]='<img src="images/jayDelGreco02.jpg" width="300" height="400" border="0" class="bioPic" alt="Me at the Bromfield Gallery in Boston, MA" title="Me at the Bromfield Gallery in Boston, MA">'
	images[3]='<img src="images/jayDelGreco03.jpg" width="300" height="400" border="0" class="bioPic" alt="Me working on a piece." title="Me working on a piece.">'
	images[4]='<img src="images/jayDelGreco04.jpg" width="300" height="400" border="0" class="bioPic" alt="Me and Indiscretion" title="Me and Indiscretion">'
	images[5]='<img src="images/jayDelGreco05.jpg" width="300" height="400" border="0" class="bioPic" alt="Me and Everything in Flight" title="Me and Everything in Flight">'
	var foo=Math.floor(Math.random()*images.length);
	if (foo==0){
		foo=1;
	}
	document.write(images[foo])
}

function get_cookie ( cookie_name ) {
	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	if ( results )
		return ( unescape ( results[2] ) );
	else
		return null;
};
function delete_cookie ( cookie_name ) {
	var cookie_date = new Date ( );  
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
};

