jQuery(document).ready(function()
{	
	jQuery("#block-block-12 input[type='text']").placeholder();

	//START FIND A BUSINESS BY NAME SEARCH RESULTS CODE
	jQuery('#findABusinessByNameSubmitButton').click(function()
	{		
		var businessName = jQuery('#findABusinessByNameSearchBox').val();
		var cityState = jQuery('#finaABusinessByNameLocationSearchBox').val();	
		var newVal = jQuery("#cityNameFromIP").val(); 
		var actionURL = "http://berryinetdev.com/FrontierPages_Test/results.aspx?term=" + businessName + "&location=" + cityState + "&page=1&s=bn&userLoc=" + newVal + "";			
		jQuery('#findABusinessSearchBarDiv form').attr("action", actionURL);		
	});
	
	jQuery('#findABusinessSearchBarDiv input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var businessName = jQuery('#findABusinessByNameSearchBox').val();
			var cityState = jQuery('#finaABusinessByNameLocationSearchBox').val();	
			var newVal = jQuery("#cityNameFromIP").val();	
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/results.aspx?term=" + businessName + "&location=" + cityState + "&page=1&s=bn&userLoc=" + newVal + "";			
			jQuery('#findABusinessSearchBarDiv form').attr("action", actionURL);
			jQuery('#findABusinessSearchBarDiv form').submit();
		}
	});
	//END FIND A BUSINESS BY NAME SEARCH RESULTS CODE
	
	//START FIND A BUSINESS BY PHONE SEARCH RESULTS CODE
	jQuery('#findABusinessByPhoneSubmitButton').click(function()
	{		
		var businessName = jQuery('#findABusinessByPhoneNumberSearchBox').val();
		var newVal = jQuery("#cityNameFromIP").val();	
		var actionURL = "http://berryinetdev.com/FrontierPages_Test/results.aspx?term=" + businessName + "&page=1&s=bn&userLoc=" + newVal + "";		
		jQuery('#findABusinessSearchBarDiv form').attr("action", actionURL);		
	});
	
	jQuery('#findABusinessByPhoneSubmitButton input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var businessName = jQuery('#findABusinessByPhoneNumberSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();	
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/results.aspx?term=" + businessName + "&page=1&s=bn&userLoc=" + newVal + "";		
			jQuery('#findABusinessSearchBarDiv form').attr("action", actionURL);
			jQuery('#findABusinessSearchBarDiv form').submit();
		}
	});
	//END FIND A BUSINESS BY PHONE SEARCH RESULTS CODE
	
	//START FIND A PERSON BY NAME SEARCH RESULTS CODE
	jQuery('#findAPersonByNameSubmitButton').click(function()
	{		
		var firstName = jQuery('#findAPersonByFirstNameSearchBox').val();	
			var lastName = jQuery('#findAPersonByLastNameSearchBox').val();
			var location = jQuery('#findAPersonByLocationSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/personresults.aspx?fname=" + firstName + "&lname=" + lastName + "&cz=" + location + "&s=pn&userLoc=" + newVal + "";		
			jQuery('#findAPersonSearchBarDiv form').attr("action", actionURL);	
	});
	
	jQuery('#findABusinessByPhoneSubmitButton input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var firstName = jQuery('#findAPersonByFirstNameSearchBox').val();	
			var lastName = jQuery('#findAPersonByLastNameSearchBox').val();
			var location = jQuery('#findAPersonByLocationSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/personresults.aspx?fname=" + firstName + "&lname=" + lastName + "&cz=" + location + "&s=pn&userLoc=" + newVal + "";		
			jQuery('#findAPersonSearchBarDiv form').attr("action", actionURL);
			jQuery('#findAPersonSearchBarDiv form').submit();
		}
	});
	//END FIND A PERSON BY NAME SEARCH RESULTS CODE
	
	//START FIND A PERSON BY ADDRESS SEARCH RESULTS CODE
	jQuery('#findAPersonByAddressSubmitButton').click(function()
	{		
		var address = jQuery('#findAPersonByAddressSearchBox').val();	
		var location = jQuery('#findAPersonByLocationSearchBox').val();
		var newVal = jQuery("#cityNameFromIP").val();
		var actionURL = "http://berryinetdev.com/FrontierPages_Test/personresults.aspx?address=" + address + "&cz=" + location + "&s=pa&userLoc=" + newVal + "";		
		jQuery('#findAPersonSearchBarDiv form').attr("action", actionURL);	
	});
	
	jQuery('#findAPersonByAddressSubmitButton input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var address = jQuery('#findAPersonByAddressSearchBox').val();	
			var location = jQuery('#findAPersonByLocationSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/personresults.aspx?address=" + address + "&cz=" + location + "&s=pa&userLoc=" + newVal + "";		
			jQuery('#findAPersonSearchBarDiv form').attr("action", actionURL);
			jQuery('#findAPersonSearchBarDiv form').submit();
		}
	});
	//END FIND A PERSON BY NAME ADDRESS RESULTS CODE
	
	//START FIND A MAP BY ADDRESS SEARCH RESULTS CODE
	jQuery('#mapsAndDirectionsGetMapSubmitButton').click(function()
	{		
		var address = jQuery('#mapsAndDirectionsLocationSearchBox').val();	
		var newVal = jQuery("#cityNameFromIP").val();
		var actionURL = "http://berryinetdev.com/FrontierPages_Test/mapsanddirections.aspx?saddress=" + address + "&s=mm&userLoc=" + newVal + "";		
		jQuery('#mapsAndDirectionsSearchBarDiv form').attr("action", actionURL);	
	});
	
	jQuery('#mapsAndDirectionsGetMapSubmitButton input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var address = jQuery('#mapsAndDirectionsLocationSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();	
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/mapsanddirections.aspx?saddress=" + address + "&s=mm&userLoc=" + newVal + "";		
			jQuery('#mapsAndDirectionsSearchBarDiv form').attr("action", actionURL);
			jQuery('#mapsAndDirectionsSearchBarDiv form').submit();
		}
	});
	//END FIND A MAP BY ADDRESS SEARCH RESULTS CODE
	
	//START FIND DIRECTIONS BY ADDRESS SEARCH RESULTS CODE
	jQuery('#mapsAndDirectionsGetDirectionsSubmitButton').click(function()
	{		
		var startAddress = jQuery('#mapsAndDirectionsStartLocationSearchBox').val();	
		var endAddress = jQuery('#mapsAndDirectionsFinishLocationSearchBox').val();
		var newVal = jQuery("#cityNameFromIP").val();
		var actionURL = "http://berryinetdev.com/FrontierPages_Test/mapsanddirections.aspx?saddress=" + startAddress + "&eaddress=" + endAddress + "&s=md&userLoc=" + newVal + "";		
		jQuery('#mapsAndDirectionsSearchBarDiv form').attr("action", actionURL);	
	});
	
	jQuery('#mapsAndDirectionsGetDirectionsSubmitButton input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var startAddress = jQuery('#mapsAndDirectionsStartLocationSearchBox').val();	
			var endAddress = jQuery('#mapsAndDirectionsFinishLocationSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/mapsanddirections.aspx?saddress=" + startAddress + "&eaddress=" + endAddress + "&s=md&userLoc=" + newVal + "";		
			jQuery('#mapsAndDirectionsSearchBarDiv form').attr("action", actionURL);
			jQuery('#mapsAndDirectionsSearchBarDiv form').submit();
		}
	});
	//END FIND DIRECTIONS BY ADDRESS SEARCH RESULTS CODE
	
	//START REVERSE LOOKUP CODE
	jQuery('#reverseLookupSubmitButton').click(function()
	{		
		var phone = jQuery('#reverseLookupByPhoneNumberSearchBox').val();
		var newVal = jQuery("#cityNameFromIP").val();
		var actionURL = "http://berryinetdev.com/FrontierPages_Test/personresults.aspx?phone=" + phone + "&s=rl&userLoc=" + newVal + "";		
		jQuery('#reverseLookupSearchBarDiv form').attr("action", actionURL);	
	});
	
	jQuery('#reverseLookupSubmitButton input').bind('keypress', function(e) {
		if(e.keyCode==13) {
			var phone = jQuery('#reverseLookupByPhoneNumberSearchBox').val();
			var newVal = jQuery("#cityNameFromIP").val();
			var actionURL = "http://berryinetdev.com/FrontierPages_Test/personresults.aspx?phone=" + phone + "&s=rl&userLoc=" + newVal + "";		
			jQuery('#reverseLookupSearchBarDiv form').attr("action", actionURL);
			jQuery('#reverseLookupSearchBarDiv form').submit();
		}
	});
	//END REVERSE LOOKUP CODE
	
	jQuery('#block-block-12 input:text').focus(function () { jQuery(this).val(""); });
	
	function hideOtherSearchBars()
	{
		jQuery('#findABusinessSearchBarDiv').css('display', 'none');
		jQuery('#findAPersonSearchBarDiv').css('display', 'none');
		jQuery('#mapsAndDirectionsSearchBarDiv').css('display', 'none');
		jQuery('#reverseLookupSearchBarDiv').css('display', 'none');
		jQuery('#findABusinessSearchBarDiv').css('display', 'none');
	}
		
	hideOtherSearchBars();
	
	jQuery('#findABusinessSearchBarDiv').css('display', 'block');
	jQuery('#findABusinessByPhoneNumberDiv').css('display', 'none');
	jQuery('#findABusinessByNameLink').addClass('active');
	jQuery('#findABusinessRadio').attr('checked', 'checked');
	
	jQuery('#findAPersonByNameLink').addClass('active');
	jQuery('#mapsAndDirectionsGetMapLink').addClass('active');
	jQuery('#reverseLookupByPhoneNumberLink').addClass('active');
	
	jQuery('.page-node-15 #findAPersonSearchBarDiv').css('display', 'block');
	jQuery('.page-node-15 #findAPersonByAddressDiv').css('display', 'none');
	jQuery('.page-node-15 #findABusinessSearchBarDiv').css('display', 'none');
	jQuery('.page-node-15 #findAPersonByPhoneNumberDiv').css('display', 'none');
	
	jQuery('.page-node-16 #mapsAndDirectionsSearchBarDiv').css('display', 'block');
	jQuery('.page-node-16 #mapsAndDirectionsGetDirectionsDiv').css('display', 'none');
	jQuery('.page-node-16 #findABusinessSearchBarDiv').css('display', 'none');
	
	jQuery('.page-node-17 #reverseLookupSearchBarDiv').css('display', 'block');
	jQuery('.page-node-17 #findABusinessSearchBarDiv').css('display', 'none');
	
	jQuery('#block-block-12 #findABusinessSearchBarDiv a.searchTextLink').click(function()
	{
		hideOtherSearchBars();
		var linkID = jQuery(this).attr('id');
		var popSearchClass = jQuery(this).hasClass('popularSearchLink');
		
		jQuery('#findABusinessSearchBarDiv').css('display', 'block');
		jQuery('#findABusinessByPhoneNumberDiv').css('display', 'none');
		jQuery('#findABusinessRadio').attr('checked', 'checked');
		
		if ( linkID == "findABusinessByNameLink" )													
		{
			jQuery('#findABusinessByNameDiv').css('display', 'none');
			jQuery('#findABusinessByPhoneNumberDiv').css('display', 'none');
			jQuery('#findABusinessByNameDiv').css('display', 'block');
			jQuery("#findABusinessSearchBarDiv").removeClass('byPhone');
			jQuery("#findABusinessSearchBarDiv").addClass('byName');
			jQuery("#findABusinessSearchBarDiv a").removeClass('active');
			jQuery(this).addClass('active');
		}
		
		else if ( linkID == "findABusinessByPhoneNumberLink" )
		{
			jQuery('#findABusinessByNameDiv').css('display', 'none');
			jQuery('#findABusinessByPhoneNumberDiv').css('display', 'none');
			jQuery('#findABusinessByPhoneNumberDiv').css('display', 'block');
			jQuery("#findABusinessSearchBarDiv").removeClass('byName');
			jQuery("#findABusinessSearchBarDiv").addClass('byPhone');
			jQuery("#findABusinessSearchBarDiv a").removeClass('active');
			jQuery(this).addClass('active');
		}	
	});
	
	jQuery('#block-block-12 #findAPersonSearchBarDiv a.searchTextLink').click(function()
	{
		hideOtherSearchBars();		
		var linkID = jQuery(this).attr('id');
		var popSearchClass = jQuery(this).hasClass('popularSearchLink');
		
		jQuery('#findAPersonSearchBarDiv').css('display', 'block');
		jQuery('#findAPersonByNameDiv').css('display', 'block');
		jQuery('#findAPersonByAddressDiv').css('display', 'none');
		jQuery('#findAPersonByPhoneNumberDiv').css('display', 'none');
		if ( popSearchClass == false ) { jQuery('#findAPersonByNameLink').addClass('active'); }
		jQuery('#findAPersonRadio').attr('checked', 'checked');
		
		if ( linkID == "findAPersonByNameLink" )
		{
			jQuery('#findAPersonByNameDiv').css('display', 'none');
			jQuery('#findAPersonByAddressDiv').css('display', 'none');
			jQuery('#findAPersonByPhoneNumberDiv').css('display', 'none');
			jQuery('#findAPersonByNameDiv').css('display', 'block');
			jQuery("#findAPersonSearchBarDiv").removeClass('byAddress');
			jQuery("#findAPersonSearchBarDiv").addClass('byName');
			jQuery("#findAPersonSearchBarDiv a").removeClass('active');
			jQuery(this).addClass('active');
		}
		
		else if ( linkID == "findAPersonByAddressLink" )
		{
			jQuery('#findAPersonByNameDiv').css('display', 'none');
			jQuery('#findAPersonByAddressDiv').css('display', 'none');
			jQuery('#findAPersonByPhoneNumberDiv').css('display', 'none');
			jQuery('#findAPersonByAddressDiv').css('display', 'block');
			jQuery("#findAPersonSearchBarDiv").removeClass('byName');
			jQuery("#findAPersonSearchBarDiv").addClass('byAddress');
			jQuery("#findAPersonSearchBarDiv a").removeClass('active');
			jQuery(this).addClass('active');
		}
		
		else if ( linkID == "findAPersonByPhoneNumberLink" )
		{
			jQuery("a b.active").css('display', 'none');
			jQuery('#findAPersonByNameDiv').css('display', 'none');
			jQuery('#findAPersonByAddressDiv').css('display', 'none');
			jQuery('#findAPersonByPhoneNumberDiv').css('display', 'none');
			jQuery('#findAPersonByPhoneNumberDiv').css('display', 'block');		  
		}
	});
	
	jQuery('#block-block-12 #mapsAndDirectionsSearchBarDiv a.searchTextLink').click(function()
	{
		hideOtherSearchBars();
		var linkID = jQuery(this).attr('id');
		var popSearchClass = jQuery(this).hasClass('popularSearchLink');
		
		jQuery('#mapsAndDirectionsSearchBarDiv').css('display', 'block');
		jQuery('#mapsAndDirectionsGetDirectionsDiv').css('display', 'none');
		jQuery('#mapsAndDirectionsGetMapDiv').css('display', 'block'); 
		if ( popSearchClass == false ) { jQuery('#mapsAndDirectionsGetMapLink').addClass('active'); }
		jQuery('#mapAndDirectionsRadio').attr('checked', 'checked');
			
		if ( linkID == "mapsAndDirectionsGetMapLink" )
		{
			jQuery('#mapsAndDirectionsGetDirectionsDiv').css('display', 'none');
			jQuery('#mapsAndDirectionsGetMapDiv').css('display', 'none');
			jQuery('#mapsAndDirectionsGetMapDiv').css('display', 'block');
			jQuery("#mapsAndDirectionsSearchBarDiv").addClass('getMap');
			jQuery("#mapsAndDirectionsSearchBarDiv").removeClass('getDirections');
			jQuery("#mapsAndDirectionsSearchBarDiv a").removeClass('active');
			jQuery(this).addClass('active');
		}
		
		else if ( linkID == "mapsAndDirectionsGetDirectionsLink" )
		{
			jQuery('#mapsAndDirectionsGetDirectionsDiv').css('display', 'none');
			jQuery('#mapsAndDirectionsGetMapDiv').css('display', 'none');
			jQuery('#mapsAndDirectionsGetDirectionsDiv').css('display', 'block');
			jQuery("#mapsAndDirectionsSearchBarDiv").removeClass('getMap');
			jQuery("#mapsAndDirectionsSearchBarDiv").addClass('getDirections');
			jQuery("#mapsAndDirectionsSearchBarDiv a").removeClass('active');
			jQuery(this).addClass('active');
		}
	});
	
	jQuery('#block-block-12 #reverseLookupSearchBarDiv a.searchTextLink').click(function()
	{
		hideOtherSearchBars();
		jQuery("#reverseLookupByPhoneNumberLink").text('Find By Phone Number');
		jQuery('#findABusinessSearchBarDiv').css('display', 'none');
		jQuery('#reverseLookupSearchBarDiv').css('display', 'block');
		jQuery('#reverseLookupByPhoneNumberDiv').css('display', 'block');
		var popSearchClass = jQuery(this).hasClass('popularSearchLink');
		if ( popSearchClass == false ) { jQuery('#reverseLookupByPhoneNumberLink').addClass('active'); }
		jQuery('#reverseLookupRadio').attr('checked', 'checked');	
	});
	
	jQuery('.findABusinessRadio').click(function()
	{
		jQuery("#findABusinessSearchBarDiv").removeClass('byPhone');
		jQuery("#findABusinessSearchBarDiv").removeClass('byName');
		jQuery("#findAPersonSearchBarDiv").removeClass('byAddress');
		jQuery("#findAPersonSearchBarDiv").removeClass('byName');
		jQuery("#mapsAndDirectionsSearchBarDiv").removeClass('getDirections');
		
		jQuery('#findAPersonSearchBarDiv').css('display', 'none');
		jQuery('#mapsAndDirectionsSearchBarDiv').css('display', 'none');
		jQuery('#reverseLookupSearchBarDiv').css('display', 'none');
		jQuery('#findABusinessSearchBarDiv').css('display', 'block');
		jQuery('#findABusinessRadio').attr('checked', 'checked');
		
		jQuery('#findABusinessByNameDiv').css('display', 'none');
		jQuery('#findABusinessByPhoneNumberDiv').css('display', 'none');
		jQuery('#findABusinessByNameDiv').css('display', 'block');
		jQuery("#findABusinessSearchBarDiv a").removeClass('active');
		jQuery("#findABusinessByNameLink").addClass('active');
	});
	
	jQuery('.findAPersonRadio').click(function()
	{
		jQuery("#findABusinessSearchBarDiv").removeClass('byPhone');
		jQuery("#findABusinessSearchBarDiv").removeClass('byName');
		jQuery("#findAPersonSearchBarDiv").removeClass('byAddress');
		jQuery("#findAPersonSearchBarDiv").removeClass('byName');
		jQuery("#mapsAndDirectionsSearchBarDiv").removeClass('getDirections');
		
		jQuery('#findAPersonSearchBarDiv').css('display', 'block');
		jQuery('#mapsAndDirectionsSearchBarDiv').css('display', 'none');
		jQuery('#reverseLookupSearchBarDiv').css('display', 'none');
		jQuery('#findABusinessSearchBarDiv').css('display', 'none');
		jQuery('#findAPersonRadio').attr('checked', 'checked');
		
		jQuery('#findAPersonByNameDiv').css('display', 'none');
		jQuery('#findAPersonByAddressDiv').css('display', 'none');
		jQuery('#findAPersonByPhoneNumberDiv').css('display', 'none');
		jQuery('#findAPersonByNameDiv').css('display', 'block');
		jQuery("#findAPersonSearchBarDiv a").removeClass('active');
		jQuery("#findAPersonByNameLink").addClass('active');
	});
	
	jQuery('.mapAndDirectionsRadio').click(function()
	{
		jQuery("#findABusinessSearchBarDiv").removeClass('byPhone');
		jQuery("#findABusinessSearchBarDiv").removeClass('byName');
		jQuery("#findAPersonSearchBarDiv").removeClass('byAddress');
		jQuery("#findAPersonSearchBarDiv").removeClass('byName');
		jQuery("#mapsAndDirectionsSearchBarDiv").removeClass('getDirections');
		
		jQuery('#findAPersonSearchBarDiv').css('display', 'none');
		jQuery('#mapsAndDirectionsSearchBarDiv').css('display', 'block');
		jQuery('#reverseLookupSearchBarDiv').css('display', 'none');
		jQuery('#findABusinessSearchBarDiv').css('display', 'none');
		jQuery('#mapAndDirectionsRadio').attr('checked', 'checked');
		
		jQuery('#mapsAndDirectionsGetDirectionsDiv').css('display', 'none');
		jQuery('#mapsAndDirectionsGetMapDiv').css('display', 'none');
		jQuery('#mapsAndDirectionsGetMapDiv').css('display', 'block');
		jQuery("#mapsAndDirectionsSearchBarDiv a").removeClass('active');
		jQuery('#mapsAndDirectionsGetMapLink').addClass('active');
	});
	
	jQuery('.reverseLookupRadio').click(function()
	{		
		jQuery("#findABusinessSearchBarDiv").removeClass('byPhone');
		jQuery("#findABusinessSearchBarDiv").removeClass('byName');
		jQuery("#findAPersonSearchBarDiv").removeClass('byAddress');
		jQuery("#findAPersonSearchBarDiv").removeClass('byName');
		jQuery("#mapsAndDirectionsSearchBarDiv").removeClass('getDirections');
		
		jQuery('#mapsAndDirectionsSearchBarDiv').css('display', 'none');
		jQuery('#findABusinessSearchBarDiv').css('display', 'none');
		jQuery('#findAPersonSearchBarDiv').css('display', 'none');
		jQuery('#reverseLookupSearchBarDiv').css('display', 'block');
		jQuery('#reverseLookupRadio').attr('checked', 'checked');
		
		jQuery('#reverseLookupByPhoneNumberDiv').css('display', 'block');
		jQuery("#reverseLookupSearchBarDiv a").removeClass('active');
		jQuery('#reverseLookupByPhoneNumberLink').addClass('active');
	});	
	
});
