jQuery(document).ready(function() {
	
	// ===========
	// = Nav Aux =
	// ===========
	
	// if first-load, fade out nav-aux	
	jQuery(".first-load #nav-aux").animate({opacity: 1.0}, 5000).fadeOut();
	
	showAux = function() {
		jQuery(this).find('#nav-aux').animate({opacity: 1.0}, 500).fadeIn();
	}
	hideAux = function() {
		jQuery(this).find('#nav-aux').animate({opacity: 0}, 2000).fadeOut();
	}
	
	var config = {    
	     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
	     interval: 200, // number = milliseconds for onMouseOver polling interval    
	     over: showAux, // function = onMouseOver callback (REQUIRED)    
	     timeout: 500, // number = milliseconds delay before onMouseOut    
	     out: hideAux // function = onMouseOut callback (REQUIRED)    
	};
	
	jQuery("#logo-wrap").hoverIntent(config)
	
	SetupTooltips();

	jQuery("#nav-phone a").click(function() { return false; });	


	// =================
	// = nav animation =
	// =================	
	if (!jQuery.browser.safari) { // change to webkit after jquery 1.4 (wp 2.9 using 1.3)
		jQuery("#nav a").each(function(){
			jQuery(this).mouseover(function(){
				jQuery(this).stop().animate({ backgroundColor: "#e8d1fe" }, 'slow');
			})
			.mouseout(function(){
				jQuery(this).stop().animate({ backgroundColor: "#fff" }, 'slow');
			})
		});
 	} else {
		jQuery("ul#nav li a").hover(    
			function() {  
		   jQuery(this).addClass('hover');  
		  },  
		  function() {  
		   jQuery(this).removeClass('hover');  
		  }  
		);
	}




	jQuery("#subnav li:last").prev().addClass("last");
	
	jQuery(".page-item-413 a").append("<div>Web Design, Print &amp; Identity</div>")
	// jQuery(".page-item-426 a").append("<div>Landscapes &amp; Abstract</div>")
	jQuery(".page-item-475 a").append("<div>Painting &amp; Illustration</div>")
	// jQuery(".page-item-416 a").append("<div>Pen &amp; Ink, Portraiture &amp; Editorial</div>")
	jQuery(".page-item-418 a").append("<div>Contact, Resume, Photos &amp; Links</div>")


	// ========
	// = Misc =
	// ========

	//show grid
	txt = window.location.host;
	// if(txt.match(/local/g)) { showGridUnder() }
	
	// remove tooltip from nav
	jQuery("#nav a").each( function() {
		jQuery(this).attr('title', '');
	})
	
	jQuery(".subscribe a").click(function () {
		jQuery(".subscribe form").toggle("slow")
	})


	//painting email signup toggle
	jQuery('.default-value').each(function() {
	    var default_value = this.value;
	    jQuery(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
	        }
	    });
	    jQuery(this).blur(function() {
	        if(this.value == '') {
	            this.value = default_value;
	        }
	    });
	});

});



	
	

// http://designreviver.com/tutorials/jquery-css-tooltip-example/	
ShowTooltip = function(e) {
	var text = jQuery(this).next('.show-tooltip-text');
	if (text.attr('class') != 'show-tooltip-text')
		return false;
	text.fadeIn()
	//delay fade out
	.animate({opacity: 1.0}, 2500)
	return false;
}

HideTooltip = function(e) {
	var text = jQuery(this).next('.show-tooltip-text');
	if (text.attr('class') != 'show-tooltip-text')
		return false;
		text.fadeOut();
}

SetupTooltips = function(){
	var config2 = {    
	     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
	     interval: 200, // number = milliseconds for onMouseOver polling interval    
	     over: ShowTooltip, // function = onMouseOver callback (REQUIRED)    
	     timeout: 500, // number = milliseconds delay before onMouseOut    
	     out: HideTooltip // function = onMouseOut callback (REQUIRED)    
	};
	jQuery('.show-tooltip')
		.each(function(){
			jQuery(this)
				.after(jQuery('<span/>')
					.attr('class', 'show-tooltip-text')
					.html(jQuery(this).attr('title')))
				.attr('title', '');
		})
		.hoverIntent(config2);
}

function showGrid() {
	jQuery("#container").append("<div id='grid'></div>");
	jQuery("#container").css("position","relative");
}

function showGridUnder() {
	jQuery("#container").css({'background':'url(/wp-content/themes/aas-theme/images/grid2.png) repeat-y 0 0' });
}
