// 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();	
	
	$(".flash_notice, .flash_error, .flash_success").fadeIn("slow");
	$("a.close_notify").click(function() {
	    $(".flash").fadeOut("slow");
	    return false;
	});

	$(":input[type=textarea]").textCounting({lengthExceededClass: 'count_over'});

	$("#petition_target_login").DefaultValue("Their Twitter Name");
	$("#petition_name").DefaultValue("What they should do");
	$("#retweet_tweet_text").DefaultValue("What do you want people to retweet?");	
	$("#hp_event_name").DefaultValue("Event Name (#hashtags work too)");
	$("#hp_event_start_time, #tag_event_start_time").DefaultValue("Tomorrow 8pm");
	$("#hp_event_venue_name, #tag_event_venue_name").DefaultValue("Venue");
	$("#event_city").DefaultValue("City");
	$("#event_region").DefaultValue("State/Region");
	$("#event_postal_code").DefaultValue("Postal Code");		
	$("#event_street_1").DefaultValue("Street address");	
		
	$('.rounded').corners("10px");
	$('.rounded').corners(); /* test for double rounding */
	$('.rsvp_tab_selected').corners("5px top");
	$('#contentbox, .tagcontentbox, .tagcontentbox_detail').corners("10px");
	$('.contentboxtop').corners("10px top");
	$('.contentboxbottom').corners("10px bottom");
	$('.contentboxboth').corners("10px");
	$('.eventdescriptionbody, .noresponsehead_loggedin, .noresponsebody, .responsebody, .tagdescriptionbody').corners("10px bottom");

	$('#petition_content, #reply_content, #event_content, #retweet_content').autoResize({extraSpace : 20})

	$('.whowrap_popup, .userbox_popup, .inline_popup').bt({ 
		padding: 8,
		width: 250,
		spikeLength: 8,
		spikeGirth: 12,
		cornerRadius: 10,
	  	fill: 'rgba(186, 38, 38, 100)',
		strokeWidth: 3,
		strokeStyle: '#541010',
     	cssStyles: {color: '#FFF', fontWeight: 'normal', fontSize: '12px'}
	});
	
	$('a.yelpincorrect').click(function() {
    $("#event_street_1, #event_street_2, #event_city, #event_region, #event_postal_code").val('');
		$("#event_city").DefaultValue("City");
		$("#event_region").DefaultValue("State/Region");
		$("#event_postal_code").DefaultValue("Postal Code");		
		$("#event_street_1").DefaultValue("Street address");
    return false;
	});
	
});
