stopPulse = false;

$(document).ready(function() {

  // Secure email address  
  $('.secure').amail('[secure1]','{secure2}');

  // Slide the center posts column up and down
  // 3 posts at a time.

	$(".up").click(function() {
	  $("#posts").clearQueue();
	  $("#posts").animate({scrollTop : "-=330px"}, 800, 'easeInOutCubic');
	});

	$(".down").click(function() {
	  $("#posts").clearQueue();
	  $("#posts").animate({scrollTop : "+=330px"}, 800, 'easeInOutCubic');
	});

  // Pulse Arrows

  function runIt() {
    if(stopPulse) return;
    
    if($.browser.msie && parseInt($.browser.version) < 9) {
      $('#header .arrow').fadeTo(1800, 0.5);
      $('#header .arrow').fadeTo(1800, 1);
    } else {
      $('.arrow').fadeTo(1800, 0.5);
      $('.arrow').fadeTo(1800, 1);
    }
      
    window.setTimeout(runIt, 3600);
  }

  if($('#header .up:visible').length > 0) {
    runIt();
  }
  
  $('.arrow').click(function() {
    stopPulse = true;
  });

  // Show the comments box if the user has liked the WFN page.
  // Facebook doesn't allow anyone except the Page owner to
  // comment or like on a page that they haven't liked... 

	$("#refresh").click(function() {
    $.get('/likes.php', function(data) {
      if(data == 'true') {
    	  $(".hide").hide();
    	  $(".reveal").fadeIn();
      } else {
        alert("Click the like button to enable comments!");
      }
    });
	});


  // Handle default value for comments textarea...

  $('textarea.js').focus(function() {
    if($(this).text() == $(this).attr('data-default')) {
      $(this).text('');
    }
  });

  if($('textarea.js').text() == '') {
    $('textarea.js').text($('textarea.js').attr('data-default'));
  }


});


