$(document).ready(function(){

	/**
	 * jQuery Lazy Load
	 */

	$("img").lazyload({ 
		effect : "fadeIn" 
	});


	/**
	 * search field
	 * clear on focus, replace with default on blur
	 */

	$.fn.search = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	$("#searchfield").search();


	/**
	 * external links
	 *
	 * filters href != hostname or rel="external"
	 * adds .external to elements not containing img, div or mailto
	 * opens external links in new window/tab
	 */

	$('a, area').filter(function() {
		return this.hostname && (this.hostname).split(":")[0] !== (location.hostname).split(":")[0] || $(this).attr('rel') == 'external';
	})
	.not(':has(img, div, mailto)')
	.addClass('external')
	.end()
	.click(function(e) {
		open(this.href); 
		e.preventDefault();
	});


});