/**
* Clears the input on focus if it has a particular value
*/
$.fn.clearInput = function(inputVal){

	return this.focus(function(){
		obj = $(this);
		
		if(obj.val() == inputVal)
		{
			obj.val('');
		}
	})
	.blur(function(){
		obj = $(this);
		
		if(obj.val() == "")
		{
			obj.val(inputVal);
		}
	});

};

$("#searchText").clearInput("Search");
$("#username").clearInput("Username");
$("#password").clearInput("Password");


$(function()
{

	// Any tracking info here can be found within analytics under the content menu, event tracking.

	// form popup links with class="form-link" track it via google analytics.
	$('a[class*="form-link"]').click(function()
	{
		var linkHTML = $(this).html();
		pageTracker._trackEvent('Form', 'Popup Form', '' + linkHTML + '');
	});
	
	
	// remove target _blank off any link and replace with class="external".
	$('a[target^=_blank]')
		.addClass('external')
		.removeAttr('target', '_blank');
		
		
	// any links with rel="external" open in a new window
	$('a[class*="external"]').click(function()
	{
		$('a[class*="external"]').attr('target', '_blank');
		
		// also track outbound links and send info to google analytics.
		var linkHTML = $(this).html();
		pageTracker._trackEvent('Link', 'Outgoing',  '' + $(this).attr('href') + '');
	});
	
});

