var Video = Class.create();

/*
  videos is an array of objects
  the object should have an id and url propert
  +[{id:1, url: "foo/bar"}]+
*/
Video.prototype = {
  initialize: function()
  {
    
    this.videos = new Array();
    this.current = null;
    this.active_marker = null;
  },
  
  register: function(video)
  {
    this.videos.push(video)
  },
  
  show: function(src)
  {
    new Effect.Move ($('page'),{ x: -295, y: 32, mode: 'absolute'});
    $('video').show()
    $('frame').src = src
    $('close_button').show()
    $("contact_button").hide()
    $("back_button").show()
  },
  
  /* Play a clip */
  clip: function(id)
  {    
    this.show("/works/clip/"+id)    
    this.mark_link(id)
  },
  
  /* Play a reel */
  reel: function(id)
  {
    this.show("/works/reel/"+id)
    this.unmark_link();
  },
  
  /* Close the video player */
  close: function(id)
  {
    $('video').hide();
    $('close_button').hide()
    $('frame').src = '/works/blank'
  },
  
  next: function()
  {
  
  },
  
  unmark_link: function()
  {
    if(this.active_marker != null)
    {
      this.active_marker.hide();
    }
  },
  
  /* Marks a link with a check mark graphic */
  mark_link: function(id)
  {
    this.unmark_link();
    try{
      this.active_marker = $('marker_'+id)
      this.active_marker.show();      
    }catch(err){alert(id)}
  },
  
  /* Return the page to the default position */
  default_position: function()
  {
    new Effect.Move ($('page'),{ x: 95, y: 32, mode: 'absolute'});
  }
}

var top_num = null;

function new_doodle()
{
  //var n = top_num  
  //while(n == top_num) {
  var n = Math.round(7*Math.random())+1
  //top_num = n
  
  $('top_doodle_image').src = "/images/doodles/"+n+".jpg"
  //Element.setOpacity('top_doodle', 0);
  
  //$('bottom_doodle_image').src = "/images/doodles/"+n+".jpg"
  
  //$('bottom_doodle_image').onload = function() 
  {     
    //new Effect.Opacity('top_doodle', {duration:0.5, from:1.0, to:0}); 
  }
}

function reel_over(e)
{
  $('play_reel').style.backgroundImage = "url(/images/doodles/play_reel_over.gif)"
}

function reel_out(e)
{
  $('play_reel').style.backgroundImage = "url(/images/doodles/play_reel.gif)"
}

