// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var current = 0;

function clearme_triggers() {
  $('input.clearme').focus(function(i) {
    if (this.value == this.title) {
      this.value = "";
      $(this).removeClass('clearme');
    }
  });

  $('input.clearme').blur(function(i) {
    if (this.value == "") {
      this.value = this.title;
      $(this).addClass('clearme')
    }
  });
}

function button_rotate() {
  var elem = $('ul.rotate_supporter');
  var list_count = elem.children('li').size() - 1;

  $('ul.rotate_supporter .fc'+current).fadeOut(300, function(){
    if (current == list_count) current = 0;
    else current++;
    $('ul.rotate_supporter .fc'+current).fadeIn();
  });


  tar = setTimeout('button_rotate()', 10000);
}

$(document).ready(function() {

  clearme_triggers();

  $('#subscriber_form').submit(function() {
    $.post('/subscribers', $(this).serialize(), function(data) {
      if (data.status == "success") {
        $('#subscriber_form_wrap').html(data.message);
      }
    }, "json");
    return false;
  });

  $('#subscriber_form_splash').submit(function() {
    $.post('/subscribers', $(this).serialize(), function(data) {
      if (data.status == "success") {
        $('#subscriber_form_wrap_splash').html(data.message);
      }
    }, "json");
    return false;
  });

  $('.flash').hide().slideDown().animate({opacity: 1.0}, 3000).slideUp();

  tar = setTimeout('button_rotate()', 10000);

  if ($("input#total_money")) {
    var total = $("input#total_money").val() * 1
    $("#red").animate({width: Math.round((total/21000)*540)}, total/1.5);
  }
});

function buttonText(issue)
{
  $('#issue'+issue).toggle();
  var element = document.getElementById('rm'+issue).getElementsByTagName('a')[0].childNodes[0];
  if(element.nodeValue == 'Read More »') element.nodeValue = 'Hide';
  else element.nodeValue = 'Read More »';
}
FB.init("2a1b73bde9547c09d3167d5c4137b7dd");

