jQuery(function(){
	//delay function
	$.fn.delay = function(time, callback){
		// Empty function:
		jQuery.fx.step.delay = function(){};
		// Return meaningless animation, (will be added to queue)
		return this.animate({delay:1}, time, callback);
	}

	//loads drop menu
	$("#nav > div > ul > li > a").wrapInner("<span class='hover'><span></span></span>");
	$("#nav ul").superfish();
	
	//hover fade in
	$('#nav ul li a').append('').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(500, 1);
	  }, function () {
		$span.stop().fadeTo(500, 0);
	  });
	});

	//hover fade out with drop down
	$('#nav ul li ul').each(function() {
	$(this).hover (
		function() {
		  $(this).prev().addClass('active');
		},
		function() {
		  $(this).delay(800, function() {
		  $(this).prev().removeClass('active');
		});
	  })
	});
	
	//quotes
	$('.testimonials blockquote').prepend('<span class="quote">&ldquo;</span>');
	$('.testimonials blockquote').append('<span class="quote">&rdquo;</span>');
	$('blockquote p').prepend('<span class="quote">&ldquo;</span>');
	$('blockquote p').append('<span class="quote">&rdquo;</span>');
	
	//hr replacement
	$("hr").replaceWith("<div class='hr'></div>");
	
	//form focus styling
	 $('input[type="text"]').focus(function() {
		 $(this).addClass("focusField");
		 if (this.value == this.defaultValue){
			 this.value = '';
		 }
		 if(this.value != this.defaultValue){
			 this.select();
		 }
	 });
	 $('input[type="text"]').blur(function() {
		 $(this).removeClass("focusField");
	 });
	 
	//email spam protection
    $('.email').each(function() {
		var $email = $(this);
		var address = $email.text()
        .replace(/\s*\[at\]\s*/, '@')
        .replace(/\s*\[dot\]\s*/g, '.');
		$email.html('<a href="mailto:' + address + '">'
        + address +'</a>');
    });
	
	//footer links
	$('.title a').click(function() {
		if ($(this).attr('href') == '#') {
			return false;
		} else {
			return true;
		}
	});
	
	//hides submit button text
	$('#searchButton').attr('value','');
	
});