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

$(document).ready(function(){
	// add class to links depending on extension
	$("a[@href$=pdf]").addClass("pdf");
	$("a[@href$=zip]").addClass("zip");
	$("a[@href$=doc]").addClass("doc");
	$("a[@href$=xls]").addClass("xls");
	$("a[@href$=psd]").addClass("psd");
	
	
	// automatically create external link class and open in new window if link is not local or ID anchor
	$("a[@href^='http']").not("[@href*=http://www.weareamplify.com]").not("[@href*=http://weareamplify.com]").not("[href^=#]").addClass("external").attr('target','_blank');
	
	$(document).pngFix(); 
	
	//handle the sliding malarkey on the RHS menu
	$('#article_features div.feature_content').hide();
	$('#article_features div.feature_content h3').show();
	$('#article_features .feature_item').hover(function(){
		$(this).find('div:first').slideDown(400);
	},
	function(){
		$(this).find('div:first').slideUp(400);
	});
	$('.article_features div.feature_content').hide();
	$('.article_features div.feature_content h3').show();
	$('.article_features .feature_item').hover(function(){
		$(this).find('div:first').slideDown(400);
	},
	function(){
		$(this).find('div:first').slideUp(400);
	});

	$(function() {
		$('#pr_clippings a').lightBox();
	});

	//Do the business on all input fields (text defaults)
	$("input").clearField();
	
	$("#stuff_content").load("/stuff/");
	$('#stuff a.pag')
		.livequery('click', function() { 
		$("#stuff_content").load(this.href);
		return false;
	});

	$("#article_filter select").change(function(){
		window.location = $("select").val(); 
	});

	$('#about_flash').flash(
		{
			src: '/interface/flash/aboutuspanel/aboutuspanel.swf',
			width: 500,
			height: 500
		}
	);

});