var i = 1;
var videoCount=5;

// javascript arrays are 1 based
linkVideos = new Array;
linkVideos[1] = "/videos/Chat.avi";
linkVideos[2] = "/videos/Message-Persistence.avi";
linkVideos[3] = "/videos/Player-Profiles.avi";
linkVideos[4] = "/videos/Content-Sharing.avi";
linkVideos[5] = "/videos/World-Persistence.avi";



images = new Array;
images[1] = "/videos/chat_thumbnail.jpg";
images[2] = "/videos/email_thumbnail.jpg";
images[3] = "/videos/profile_thumbnail.jpg";
images[4] = "/videos/share_thumbnail.jpg";
images[5] = "/videos/world_thumbnail.jpg";


function gallery()
{
   if (i == 1)
   {
      //document.gallery.previous.value="";
   }
   document.getElementById('downloadVideo').href = linkVideos[i];
}

function prevvid()
{
   if (i != 1) 
   {
      i--;
      //document.gallery.next.value = "Next";
   }
   else
   {
	  i = videoCount;
   }
   document.img.src = images[i];   
   document.getElementById('downloadVideo').href = linkVideos[i];
      //if (i == 1) 
      //   document.gallery.previous.value="";
}

function nextvid()
{
   if (i != videoCount) 
   {
      i++;
      //document.gallery.previous.value="Previous";
      //image = images[i];
   }
   else
   {
	  i = 1;
	  //image = images[i];
   }
   document.img.src = images[i];
   document.getElementById('downloadVideo').href = linkVideos[i];
   
   //if (i == 6)
   //{
      //document.gallery.next.value="";
   //}
}

function randvid()
{
   var videonumber = videoCount;
   var randomnumber = Math.random();
   var rand1 = Math.round( (videonumber-1) * randomnumber) + 1;
   var randimage = images[rand1];
   
   document.img.src = randimage;
   i = rand1;
   
   //if (i == 1)
   //   document.gallery.previous.value="";
   //else 
   //   document.gallery.previous.value="Previous";

   //if (i == 6)
   //   document.gallery.next.value="";
   //else
   //   document.gallery.next.value="Next";
}

function firstvid()
{
   i = 1;
   document.img.src = images[i];
   //document.gallery.previous.value="";
   //document.gallery.next.value="Next";
}

function lastvid()
{
   i = videoCount;
   document.img.src = images[i];
   //document.gallery.next.value="";
   //document.gallery.previous.value="Previous";
}

function showCurrentVideo()
{
   window.open(linkVideos[i]);
}

/*function getCurrentVideo()
{
   document.link.href = linkVideos[i];
}*/

window.attachEvent("onload", gallery);