(function($){
	// Tooltips
	this.tooltip = function(){	
		/* CONFIG */		
			xOffset = 10;
			yOffset = 20;		
			// these 2 variable determine popup's distance from the cursor
			// you might want to adjust to get the right result		
		/* END CONFIG */		
		$('a.tooltip[title]').hover(function(e){											  
			this.t = this.title;
			this.title = "";									  
			$("body").append("<p id='tooltip'>"+ this.t +"</p>");
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");		
	    },
		function(){
			this.title = this.t;		
			$("#tooltip").remove();
	    });	
		$("a.tooltip").mousemove(function(e){
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});			
	}; 
	jQuery(function(){
		// Not taking on projects
		if ($('form.wpcf7-form').length > 0){
			$('form.wpcf7-form').before('<p class="notice">My availability is currently booked out until <strong>March 2010</strong>.</p>');
		}
		// Browsers
		if($.browser.safari) {
			$('body').addClass('safari');
		}
		// Load Tooltips
		if ($('a.tooltip[title]').length > 0){
			tooltip();
		}
		// Advanced CSS
		$('#sidebar ul').each(function(){
			$(this).find('> li:last').addClass('last');
		});
		$('*.wp-caption').removeAttr('style');
		$('#primary-content #commentlist li:even').addClass('odd');
		$('.content h3:contains(Get Started)').addClass('get-started');
		
		$('#page #sidebar li h2:first, #process #sidebar li h2:first, #contact #sidebar li h2:first').addClass('top');
		$('body .content :first-child').addClass('top');
		// Search Submit
		$('#searchform a#searchsubmit').click(function(){
			return false;
			$(this).parent().submit();
		});
		// Value Blur / Focus Effects
	 	if ($('input.valueFx').length > 0){
			$('input.valueFx').valueFx();
		}
		// Mailto Script
		if ($('a.email').length > 0){
			$('a.email').mailto();
		}
		$('a').find('img').parent().addClass('img');
		// Animated anchors
		$('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
				var $target = $(this.hash);
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body').animate({scrollTop: targetOffset}, 1000);
					return false;
				}
			}
		});
		// Checkbox Filters
		$('#filters input[type="checkbox"]').click(function(){
			var $class = $(this).val();
			if($(this).attr('checked')) {
				$('#portfolio > li:not(.'+$class+'), #projects > li:not(.'+$class+')').fadeOut(function(){
					$('#portfolio > li:visible:first').find('a.backtotop').hide();
				});
			} else {
				$('#portfolio > li:hidden, #projects > li:hidden').fadeIn();
			}
		});
		// Rotating Quotes
		if ($('#quotes').length > 0){
			$('#quotes').cycle({ 
				fx: 'fade',
				cleartype: false,
				delay: 20000
			});
		}
	});
})(jQuery);