$(document).ready(function(){ 

	$('a[rel="external"]').attr("target", "_blank");
	
	$("input.populate").each( function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this).attr("title") );
		}
	});
	$("input.populate").focus(function(){
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("");
		}
	});
	$("input.populate").blur(function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
	$(".hide").hide();

	// Portfolio
	//-----------
	// preloads main images
	$("body").append('<div id="preloader"></div>')
	$("div.graphics #thumbs a").each(function(){
		$("#preloader").append('<img src="' + $(this).attr("href") + '" />' );
	});
	
	// handle hover and click events
	$("div.graphics #thumbs a").hover(
		function(){
			$("div.graphics #main img").attr("src", $(this).attr("href"));
		},
		function(){
			$("div.graphics #main img").attr("src", $("div.graphics #thumbs a.active").attr("href"));
		}
	);
	$("div.graphics #thumbs a").click(function(){
		$("div.graphics #main img").attr("src", $(this).attr("href"));
		$("div.graphics #thumbs a").removeClass("active");
		$(this).addClass("active");
		return false;
	});
	
	$("#feature ul li a img.lighten").hover(
		function (){
			var src = $(this).attr("src");
			src = src.replace(/\.gif$/, '_lt.gif');
			$(this).attr("src", src);
		},
		function(){
			var src = $(this).attr("src");
			src = src.replace(/_lt\.gif$/, '.gif');
			$(this).attr("src", src);
		}
	);
	
	// navigate portfolio via drop-down
	$("select#navigate").change(function(){
		window.location = $(this).val();
	});
	
});