  var curr_pos = 0;
  var max_pos  = 0;
  var anim;
  var dbox;
  

  $(document).ready(function() {
    dbox = new dialogBox('dbox');
    dbox.dHeight = 400;
    dbox.dWidth = 550;
    dbox.scheme = '<table id="{ID}_table" style="margin:0px auto; text-align: center;"><tr><td style="vertical-align: top;">{DATA}</td></tr></table>';
    dbox.init('info','dialogScreens','dialog');
    
    
    $("#screenshots div").hide();
    $("#screenshots div#screens_"+curr_pos).show();
    $("#screenshots div img").bind({
      click: function() {
        dbox.setData(this.title,'<img onclick="dbox.close();" src="'+this.src.replace('/thumbs/','/full/')+'" border="0">');
        dbox.show(1);
      },
      mouseenter: function() {
        clearInterval(anim);
      },
      mouseleave: function() {
        anim = setInterval('do_animation()',5000);
      }
    });
    
    max_pos = $("#screenshots div").length;
    anim = setInterval('do_animation()',5000);
  });
  
  function do_animation(val) {
    $("#screenshots div#screens_"+curr_pos).fadeOut("slow");
    
    curr_pos = (val!='undefined' && val<0 ? curr_pos-1 : curr_pos+1);
    if(curr_pos<0) curr_pos = max_pos+curr_pos;
    if(curr_pos>=max_pos) curr_pos = 0;
    
    $("#screenshots div#screens_"+curr_pos).fadeIn("slow");
  }
  
  function animation_move(val) {
    clearInterval(anim);
    do_animation(val);
    anim = setInterval('do_animation()',5000);
  }
