function Bingish()
{
}

Bingish.prototype.onPageReady = function()
{
  // install click handler
  $('#bg_scroll_prev').click(function() { return bingish.scrollBackground('prev') });
  $('#bg_scroll_next').click(function() { return bingish.scrollBackground('next') });
  return this.scrollBackground("today");
}

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

  // fade background image
  $('#page_view_bg').fadeTo(speed, 0.1, function() {
    $(this).css('background', 'url('+toimg.src+') no-repeat top left');
    $(this).attr('title', params.title);
    $(this).fadeTo(speed, 1);
  });

  // do desc
  if(params.desclen > 0) $('#bingish_desc').css({'display': 'block' });
  else $('#bingish_desc').css({'display': 'none'});
}

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

Bingish.prototype.doNavMenu = function()
{
  $("#menu_panel").accordion({
    event: "mouseover", header: ".top_item", active: false, animated: 'easeslide',
    fillSpace: false, autoHeight: false
  });
}

Bingish.prototype.showContent = function()
{
  var options = {}
  $('#content').effect('slide', options, 500, null);
}

var bingish = new Bingish();
$(function() { 
  bingish.doNavMenu();
  bingish.onPageReady();
  /*bingish.showContent();*/
});

