go = true

$(function() {
  
  firstItem = $('#feature-list li:visible:first');
  subject = firstItem.attr('id');
  
  $('#feature-list li p').hide();
  cycle();
  
  $('#feature-list li').click(function() {
    go = false
    $('#feature-list h4').css('top', 0)
    $('#feature-box .inner .content').fadeOut().attr('class', 'content');
    firstItem.appendTo('#feature-list').slideDown(400);
    
    firstItem = $(this);
    cycle();
  });
  
  $(function() {
    $('input#member_login').attr('value','Screen name').css('color', '#ccc').focus(function() {
      if ($(this).attr('value') == 'Screen name') {
        $(this).attr('value', '').css('color', '#000');
      }
    });

    $('input#member_password').attr('value','Password').css('color', '#ccc').focus(function() {
      if ($(this).attr('value') == 'Password') {
        $(this).attr('value', '').css('color', '#000');
      }
    });


    $('input#member_login').blur(function() {
      if ($(this).attr('value') == '') {
        $(this).attr('value', 'Screen name').css('color', '#ccc');
      }
    });

    $('input#member_password').blur(function() {
      if ($(this).attr('value') == '') {
        $(this).attr('value', 'Password').css('color', '#ccc');
      }
    });

  });
});



function cycle() {   
  if (go) {
    firstItem = $('#feature-list li:first:visible');
    time = setTimeout('next();', 8000);
  }     
  firstItem.slideUp();
  firstItem.children('h4').animate({
    top: -200
  }, 500, function() {
    $('#feature-box .inner .content').addClass(firstItem.attr('class')).html(firstItem.html()).hide().fadeIn();
    $('#feature-box .inner p').show();  
    $('#feature-box h4').css('top', 0)
  });


};

function next() {
  if (go) {
    $('#feature-list h4').css('top', 0)
    $('#feature-box .inner .content').attr('class', 'content');
    firstItem.appendTo('#feature-list').slideDown(400); 
    $('#feature-box .inner .content').animate({
      top: -300,
      opacity: 0
    }, 500, function() {
      $('#feature-box .inner .content').hide().css({top: 0, opacity: 1});
    });

    cycle();
  }
}