Cufon.replace('.helvetica-neue, #page-resources li p', { hover: true });

$(document).ready(function() {
  //Correct cufon
  $('h2.helvetica-neue').css({
    //marginBottom:'-1.5em',
    position:'relative',
    left:'-3px'
  });
  $('h2.helvetica-neue .title').css({
    display:'inline',
    position:'relative',
    left:'-2px'
  });
  $('h2.helvetica-neue .tagline').css({
    height:'auto',
    display:'block'
  });
  
  //Highlight appropriate button
  var a=self.document.location.hash.substring(1);
  $('#nav li').each(function(i,item) {
    if($(item).hasClass(a)) {
      $(item).addClass('selected');
    } 
  });
  
  //Signup button animation
  $('a.signup').click(function() {
    $('.canvases').animate({
      left:[0,'easeOutCirc',900]
    });
    $.scrollTo('#signup',{duration:500});
    return false;
  });
  
  //Scroll animation for #anchors
  $(document).localScroll();
  $('#nav li a').click(function() {
    $('#nav li.selected').removeClass('selected');
    $(this).parent().addClass('selected');
  });
  
  //Auto-fadeouts
  setTimeout('$(".fadeout").slideUp(1000)',2000);
  
  //Replace church position field with checkbox
  if($('#form-position').length>0) {
    $('#form-position *').addClass('pcb-unhide').fadeTo(0,0);
    
    $('<label/>').attr('for','position-checkbox')
    .addClass('pcb-hide')
    .text('On staff at a church/ministry?')
    .prependTo('#form-position');
    
    $('<input/>').attr({
      id:'position-checkbox',
      type:'checkbox'
    })
    .addClass('pcb-hide checkbox-input')
    .click(function() {
      $('.pcb-hide').stop().fadeOut(300,function() {
        $('.pcb-unhide').stop().fadeTo(300,1);
      });
    })
    .prependTo('#form-position');
    
    $('<div/>').addClass('checkbox-push pcb-hide').prependTo('#form-position');
  }
  
  // Resources Page
  $('#page-resources .hover-box').hover(function() {
		$(this).children('.default').hide();
		$(this).children('.over').stop().fadeIn('slow');	
	}, function() {
		if(lightbox_progress !== true) {
			$(this).children('.default').show();
			$(this).children('.over').css('opacity','1').stop().hide();	
		}
	});
	
	// Refresh Tweets
	$("#refresh").click(function(e) {
		e.preventDefault();
		$("#twitter #twitter_feed").css('visibility','hidden');
		$.ajax({
		  url: "application/views/behind-the-scenes/refresh_tweets.php",
		  type: "POST",
		  dataType: "html",
		  success: function(data) {
				$("#twitter #twitter_feed").html(data);
				$("#twitter #twitter_feed").css('visibility','visible');
			}
		});
	});


  //Open external links in new window
  $("a[rel='external']").live("click", function() {
    window.open($(this).attr('href'));
    return false;
  });
  
  if (typeof $.fn.checkbox == "function") { $('.tag input:checkbox').checkbox(); }
});
