function ImgPlayer_Next(id){
  var ImgPlayer = GetBrowserObject(id).ImgPlayerData;
  ImgPlayer.Next();
}
function ImgPlayer_Prev(id){
  var ImgPlayer = GetBrowserObject(id).ImgPlayerData;
  ImgPlayer.Prev();
}
function ImgPlayer_Item(index, id){
  var ImgPlayer = GetBrowserObject(id).ImgPlayerData;
  ImgPlayer.Item(index);
}
function ImgPlayerEntry(fileName,text,width,height){
  this.FileName = fileName;
  this.Text = text;
  this.Width = width;
  this.Height = height;
}
function ImgPlayerData(id, ImgId){
  this.ID = id;
  this.ImgID = ImgId;
  this.CurrentIdx = 0;
  this.Entries = new Array();
  this.div = GetBrowserObject(id);
  this.div.ImgPlayerData = this;
}
ImgPlayerData.prototype.AddImg = function(fileName,text,width,height){
  var col = new ImgPlayerEntry(fileName,text,width,height);
  this.Entries[this.Entries.length] = col;
  return col;
}
ImgPlayerData.prototype.Img = function(){
  var img = GetBrowserObject(this.ImgID);
  if(img.tagName == "IMG") return img;
  return null;
}
ImgPlayerData.prototype.Prev = function(){
  if(this.CurrentIdx > 0) this.CurrentIdx --;
  else this.CurrentIdx = this.Entries.length - 1;
  this.SetItem();
}
ImgPlayerData.prototype.Next = function(){
  if(this.CurrentIdx < this.Entries.length - 1) this.CurrentIdx ++;
  else this.CurrentIdx = 0;
  this.SetItem();
}
ImgPlayerData.prototype.Item = function(index){
  if(this.CurrentIdx > this.Entries.length-1) this.CurrentIdx == 0;
  else this.CurrentIdx = index;
  this.SetItem();
}
ImgPlayerData.prototype.SetItem = function(){
  var img = this.Img();
  if(img == null) return;
  var entry = this.Entries[this.CurrentIdx];
  img.src=entry.FileName;
//  if(entry.Width != 0) img.width = entry.Width;
//  if(entry.Height != 0) img.height = entry.Height;
  for(var i=0; i < this.Entries.length; i++)
		if(i == this.CurrentIdx){
			GetBrowserObject('img_' + i).className = "imgPlayerNavActiveA";
		}
		else{
			GetBrowserObject('img_' + i).className = "imgPlayerNavPassiveA";
		}
}
function PlayMediaItem(url){
	document.location.href = url;
}

