function ChineseTradition()
{
}

ChineseTradition.prototype.onNavReady = function()
{
  // install click handler
  $('#clsfd_scroll_prev').click(function() { return ct.scrollBackground('prev') });
  $('#clsfd_scroll_next').click(function() { return ct.scrollBackground('next') });
  return this.scrollBackground("today");
}

ChineseTradition.prototype.fadeBackground = function(imgurl, speed)
{
  if(!speed) speed = "slow";
  // load the image
  var toimg = new Image();
  toimg.src = imgurl;

  $('#clsfd_bg').fadeTo(speed, 0.2, function() {
    $(this).css('background', 'url('+toimg.src+') no-repeat top left');
    $(this).fadeTo(speed, 1);
  });
}

ChineseTradition.prototype.scrollBackground = function(direction)
{
  var args = new Array(3);
  args[0] = "scroll_background";
  args[1] = direction;
  if(direction != 'today')
    args[2] = $('#clsfd_bg').attr('title');
  else 
    args[2] = '';
  xajax.call("ajax_server", args, null, { 'uri': '/:site/ajax/ct' });
  return false;
}

var ct = new ChineseTradition();
