$(document).ready(function() {

	$('a[rel*=facebox]').facebox();
	
	$('input:text.example').example(function() {
		return $(this).attr('title');
		}, {className: 'blur'});

	// -- place bootstrap specific jQuery above this line -- //	
	// -- place application specific jQuery below this line -- //
	
	$(".feature").equalizeCols();
	
	$('ul.spy').simpleSpy();
	
	$('textarea').livequery(function() {
		$(this).elastic();
	});
	
	$('.row:last-child').addClass('last');
	
	$('#footer a').tooltip({
		track: true,
		delay: 0,
		showURL: false
	});

	// Re-Tweet Source Manipulation
	$('.row.dmtweet_sources:first a.remove_dmtweet_source').hide();
	$('a.remove_dmtweet_source').click(function() {
		$(this).siblings('#bot_source_attributes__should_destroy').val(1);
		$(this).parent().hide();
		return false;
	});
	$('a.add_dmtweet_source').click(function() {
		$('.dmtweet_sources:first').clone(true).insertAfter(".dmtweet_sources:last");
		$('.dmtweet_sources:last #bot_source_attributes__uri').val('');
		$('.dmtweet_sources:last #bot_source_attributes__id').val('');
		$('.dmtweet_sources:last a.remove_dmtweet_source').show();
		return false;
	});

	$('#bot_dmtweet').click( function () {
		if ($(this).is(':checked')) {
			$('#dmtweet_sources').slideDown();
			$("#dmtweet_sources .sources").each(function () {
				 $(this).find("#bot_source_attributes__should_destroy").val(""); 
			});
		} else {
			$('#dmtweet_sources').slideUp();
			$("#dmtweet_sources .sources").each(function () {
				 $(this).find("#bot_source_attributes__should_destroy").val(1); 
			});
		}
	});

	// FeedTweet Source Manipulation
	$('.row.feedtweet_sources:first a.remove_feedtweet_source').hide();
	$('a.remove_feedtweet_source').click(function() {
		$(this).siblings('#bot_source_attributes__should_destroy').val(1);
		$(this).parent().hide();
		return false;
	});
	$('a.add_feedtweet_source').click(function() {
		$('.feedtweet_sources:first').clone(true).insertAfter(".feedtweet_sources:last");
		$('.feedtweet_sources:last #bot_source_attributes__uri').val('');
		$('.feedtweet_sources:last #bot_source_attributes__id').val('');
		$('.feedtweet_sources:last a.remove_feedtweet_source').show();
		return false;
	});

	$('#bot_feed').click( function () {
		if ($(this).is(':checked')) {
			$('#feedtweet_sources').slideDown();
			$("#feedtweet_sources .sources").each(function () {
				 $(this).find("#bot_source_attributes__should_destroy").val(""); 
			});
		} else {
			$('#feedtweet_sources').slideUp();
			$("#feedtweet_sources .sources").each(function () {
				 $(this).find("#bot_source_attributes__should_destroy").val(1); 
			});
		}
	});

});

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