// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

jQuery.ajaxSetup({
	'beforeSend': function(xhr) { xhr.setRequestHeader("Accept", "text/javascript")}
})

jQuery.fn.submitWithAjax = function() {
	this.submit(function() {
	    $.post($(this).attr("action"), $(this).serialize(), null, "script");
		return false;
	});
};

jQuery(document).ready(function() {
	
	$("abbr[class*=timeago]").timeago();	
	$("#repSearchBox").DefaultValue("Search Offices...");
	$("#repSearchBoxSplash").DefaultValue("Search Offices...");	
	$("#repSearchBox, #repSearchBoxSplash").autocomplete("/offices/search.js");
	$(".flash_notice, .flash_error, .flash_success").fadeIn("slow");
	$("a.close_notify").click(function() {
	    $(".flash").fadeOut("slow");
	    return false;
	});
	$("#signup_address").DefaultValue("Your full street address");
	$("#signup_address_splash").DefaultValue("Your full street address");	
	$("#signup_content").charCounter(140, {container: "#signup_contentDown", classname: "signup_content_counter", format: "%1", pulse: false, delay: 100});
		
	$('.whowrap_popup').bt({ 
		padding: 8,
		width: 200,
		spikeLength: 5,
		spikeGirth: 12,
		cornerRadius: 10,
	  	fill: 'rgba(237, 30, 121, 100)',
		strokeWidth: 3,
		positions: ['left'],
		strokeStyle: '#ED1E79',
     	cssStyles: {color: '#FFF', fontWeight: 'normal', fontSize: '12px'}
	});
	
	function addMega(){ 
	  $(this).addClass("hovering"); 
	} 

	function removeMega(){ 
	  $(this).removeClass("hovering"); 
	}
	var megaConfig = {
	     interval: 50,
	     sensitivity: 4,
	     over: addMega,
	     timeout: 250,
	     out: removeMega
	};
	$(".filters").hoverIntent(megaConfig);
	
});