$(document).ready(function(){

	   // Actions for all pages
	   
	   
	   // Menu-related:
	   $('div.menu ul li a[href="services"]').click(function(e) {
		    e.preventDefault();
		    //do other stuff when a click happens
		});


		// CSS override 
		$('ul li[level="2"] a').each(function() {
		    $(this).css("background-image","url(assets/components/images/globalnav_menu_background_hover-width_160px.png)");
		});
		$('ul li[level="3"] a').each(function() {
		    $(this).css("background-image","url(assets/components/images/globalnav_menu_background_hover-width_160px.png)");
		});
		$('div.menu ul li ul li a').each(function() {
		    $(this).css("background-image","url(assets/components/images/globalnav_menu_background_hover-width_160px.png)");
		    $(this).css("background-color","transparent");
		});
		/*
		$('div.menu ul li ul li.last a').each(function() {
		    $(this).css("border-width","0 1px 1px 0");
		    $(this).css("-moz-border-radius-bottomright","5px");
		});
		*/


/*
		// Tooltips via jQuery Tools
		$("#what_is_eoc[title]").tooltip({
		   offset: [10, 2],
		   effect: 'slide'
		}).dynamic({ bottom: { direction: 'down', bounce: true } });
		
		
		// More Tooltips:          // Select by id only
		$("#tooltip[title]").tooltip({
		   offset: [10, 2],
		   effect: 'slide'
		}).dynamic({ bottom: { direction: 'down', bounce: true } });
		
*/

	    
	    
	    // EoC: Check for city match from geolocation vs list on page
	    if($('.eoc_coverage_column')){
	    
	       var $cities_array = [];
	   	   var $cities_text_string = "";
	   
	       $('.eoc_coverage_column').each(function(){

	       		$cities_text_string = $cities_text_string + $(this).text();
	       
	       });
	       
	       
	       $cities_array = $cities_text_string.split(/\n/);



		   var $detected_city = $('#city_invisible').text();
		   
		   
		   $detected_city = toTitleCase($detected_city);
		   
		   
		   
		   if(jQuery.inArray($detected_city, $cities_array) > -1){
		   		$('#detected_message').html("Yes, EoC is AVAILABLE in your city: " + $detected_city);
		   }
		   
		   
	   
	    }
	    
	    
	    
	    
	    

	    
	    
		
});



function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}

