/**
 * Additional onload functionality
 */
$(document).ready(function() {
	if(typeof(pageMode)=='undefined') return;
	
	$('#firstname').inputToggle('First Name');
	$('#lastname').inputToggle('Last Name');
	$('#people-city').inputToggle('City');
	$('#people-state').inputToggle('State');
	
	if(pageMode == 'index') {
		var map = new GMap2($('#mapContainer')[0]);
		map.setCenter(new GLatLng(35.384,-77.993), 8);
		$('#mapContainer').append('<div id="mapBlock"><div>Please select one of the icons above to search.</div></div>');
	}

	if($('#location_input').isDefined()) {
		
		$('#location_input').suggest();
	}
	
});

jQuery.fn.inputToggle = function(phrase) {
	var t = $(this);
	if(t.val() == '') t.val(phrase);
	t.bind("focus", function(e) {
		if(t.val() == phrase) t.val('');
	});
	t.bind("blur", function(e) {
		if(t.val() == '') t.val(phrase);
	});
}

jQuery.fn.isDefined = function() {
	return typeof($(this)[0]) != 'undefined';
}