
var fieldHelpers = [];

$(function() {
	$(".fieldHelper").focus(function() {
		if ($(this).hasClass('fieldHelperInactive')) {
			fieldHelpers[$(this).attr('id')] = $(this).val(); 
			$(this).val('');
			$(this).removeClass('fieldHelperInactive');
			$(this).addClass('fieldHelperActive');
		}
	});  
	$(".fieldHelper").blur(function() {
		if ($(this).val() == '') {
			$(this).removeClass('fieldHelperActive');
			$(this).addClass('fieldHelperInactive');
			$(this).val(fieldHelpers[$(this).attr('id')]);
		}
	});
	$('form').submit(function() {
		$(".fieldHelperInactive").val('');
	});
	$('#logout a').click(function() {
		if (!confirm('Are you sure you wish to logout?'))
			return false;	
	});
	$('#miniProfile').click(function() {
		location.href = $("#viewProfile").attr('href');
	});
	
	$("#topSearch").autocomplete(baseUrl+'/search/auto/name', {
    	matchContains:true,
        matchSubset:false,
        width: 180,
        formatResult: function(row) {
			return row[1];
		}
    }).result(goToProfile);
    
	function goToProfile(event, data, formatted) {
		location.href=baseUrl+'/profile/view/'+escape(data[1]);
	}
});
