// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})
$(document).ready(function() {
	

  // UJS authenticity token fix: add the authenticy_token parameter
  // expected by any Rails POST request.
  $(document).ajaxSend(function(event, request, settings) {
    // do nothing if this is a GET request. Rails doesn't need
    // the authenticity token, and IE converts the request method
    // to POST, just because - with love from redmond.
    if (settings.type == 'GET') return;
    if (typeof(AUTH_TOKEN) == "undefined") return;
    settings.data = settings.data || "";
    settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
  });
	
	$('input#page_title, input#article_title, input#testimonial_title').keyup(function() {
		var str = $(this).attr('value'); 
		str = str.replace(/\s/g, '-');
		str = str.replace(/([#!_:.,*|\\'?+=&%@!\/])+/g,'');
		str = str.toLowerCase();
		$('input#page_permalink, input#article_permalink, input#testimonial_permalink').attr({value : str});
		$('span#permalink').text(str);
	}); 
	$('#home-body p').hide();
	$('#home-body p:lt(3)').show();
	$('.show-more').click(function(){
		$('#home-body p').show();
		$('.show-more').hide();
		return false;
	})
	
	
});
