var effects = new Object();

effects.fps = 25;

effects.slide = function(element, newHeight, newWidth, time, callback)
{
  var el = document.getElementById(element);

  if(el == null)
    return;

  el.style.display = 'block';

  if (newHeight == -2)
  {
    el.style.height = null;
    // el.style.overflow = null;
    newHeight = el.offsetHeight;
    el.style.height = 0;
  }

  if (newWidth == -2)
  {
    el.style.width = '100%';
    // el.style.overflow = null;
    newWidth = el.offsetWidth;
    el.style.width = 0;
  }

  el.style.overflow = 'hidden';

  var curWidth = el.offsetWidth;
  if (newWidth == -1)
    newWidth = curWidth;
  var curHeight = el.offsetHeight;
  if (newHeight == -1)
    newHeight = curHeight;

  var totalFrames = 1;
  if(time > 0)
    totalFrames = time / effects.fps;

  var frameWidth = newWidth - curWidth;
  if(frameWidth != 0)
    frameWidth /= totalFrames;

  var frameHeight = newHeight - curHeight;
  if(frameHeight != 0)
    frameHeight /= totalFrames;

  effects.move(element, curHeight, newHeight, frameHeight, curWidth, newWidth, frameWidth, callback);
}

effects.move = function(element, curHeight, newHeight, frameHeight, curWidth, newWidth, frameWidth, callback)
{
  var el = document.getElementById(element);

  curWidth = effects.calcUnit(curWidth, newWidth, frameWidth);
  curHeight = effects.calcUnit(curHeight, newHeight, frameHeight);

  el.style.width = Math.round(curWidth) + 'px';
  el.style.height = Math.round(curHeight) + 'px';

  if(curHeight == newHeight && curWidth == newWidth)
  {
    if(callback != null)
      callback();
    return;
  }

  setTimeout( 'effects.move("' + element + '",' + curHeight + ',' + newHeight + ',' + frameHeight + ',' + curWidth + ',' + newWidth + ',' + frameWidth + ',' + callback + ')', effects.fps);
}

effects.calcUnit = function(cur, tar, rate)
{
  if (rate == 0 || cur == tar)
    return tar;

  cur += rate;

  if ((rate > 0 && cur >= tar) || (rate < 0 && cur <= tar))
    return tar;

  return cur;
}