$(document).ready(function(){
	
	// 'populate' input field plugin from: http://theandystratton.com/examples/jquery/populate/
	$.fn.populate = function ( user_options ) {
		var defaults = {}, settings = $.extend({}, defaults, user_options);
		this.each(function(){
			var $this = $(this);
			var title = this.title;
			var color = $this.css('color');
			if ( $this.val() == '' || $this.val() == title ) {
				$this.val(title);
				if ( settings.color != '' ) {
					$this.css('color', settings.color);
				}
			}
			$this.blur(function(){
				if ( $this.val() == '' ) {
					$this.val(title);
					if ( settings.color != '' ) {
						$this.css('color', settings.color);
					}
				}
			});
			$this.focus(function(){
				if ( $this.val() == title ) {
					$this.val('');
					$this.css('color', color);
				}
			});
				
		});
		return this;
	}
	// initialize the populate plugin
	$(".populate").populate({
		color: "#999"
	});


	/* !open external links in new windows */
	$("a[href^=http]").each(function(){
		if(this.href.indexOf(location.hostname) == -1) {
			$(this).attr('target', '_blank');
		}
	});
	$('.targetBlank').each(function(){
		$(this).attr('target', '_blank');
	});


	/* !Set body bg effects */
	// $('div#shadow').css('height',$(document).height());
	// $('div#shadow').show();


	/* !LazyLoad images */
	$("img").lazyload({ 
		placeholder : "images/assets/placeholder.png" ,
		effect : "fadeIn"
	});


	/* !homepage work list items */	
	// initialize the list by fading out all but the first item
	$('div#home-work ul li:not(.first)').fadeTo('fast',0.5);
	// start the hover effect
	$('div#home-work ul li:not(.latest)').hover(
		function(){
			$(this).fadeTo('fast',1.0);
		},
		function(){
			$(this).fadeTo('fast',0.5);
		}
	);


	/* !work index items */
	$('#work-index #column1 .entry').hover(
		function(){
			$(this).children('.entryInfo').fadeTo('fast',1);
		},
		function(){
			$(this).children('.entryInfo').fadeTo('fast',0);		
		}
	);
	
});