var NSsound = navigator.plugins && navigator.plugins["LiveAudio"];
var IEsound = navigator.plugins && document.all;
var audioEnabled = NSsound || IEsound;

//onload = init;
timerID = null;

function init() {
  if (!navigator.javaEnabled()) return;
  if (!audioEnabled) return;
  document.display.soundcard.value = (IEsound) ?
document.audiopanel.isSoundCardEnabled() : "not supported";
  document.display.filename.value = (IEsound) ?
document.audiopanel.fileName : "not supported";
  endTime = (IEsound) ? 
document.audiopanel.selectionEnd : "not supported"; // global variable
  }

function showPosition() {
  if (!navigator.javaEnabled()) return;
  if (!audioEnabled) return;
 }

function playIt() {
  if (!navigator.javaEnabled()) return;
  if (!audioEnabled) return;
  if (IEsound) document.audiopanel.play()
  else 
  if (NSsound) document.audiopanel.play(true);
document.display.state.value=1;
//  timerID = setTimeout("showPosition()", 1000);
}

function stopIt() {
  if (!navigator.javaEnabled()) return;
  if (!audioEnabled) return;
  document.audiopanel.stop();
  //state();
  document.display.state.value=0;
  clearInterval(timerID);
}

function pauseIt() {
  if (!navigator.javaEnabled()) return;
  if (!audioEnabled) return;
  document.audiopanel.pause();
  state();
  clearInterval(timerID);
}

function state() {
  if (!navigator.javaEnabled()) return;
  
  var field = document.display.state;
  if (IEsound) {
    var cur = document.audiopanel.currentState;
    if (cur == 0) field.value = "stopped";
    if (cur == 1) field.value = "paused";
    if (cur == 2) field.value = "playing";
  } else if (NSsound) {
      if (document.audiopanel.IsReady()) field.value = "stopped";
      if (document.audiopanel.IsPlaying()) field.value = "playing";
      if (document.audiopanel.IsPaused()) field.value = "paused";
  }
}

function toggleControls() {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.showControls = !document.audiopanel.showControls;
}

function startAtGivenSec(sec) {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.selectionStart = sec
  else if (NSsound)
         document.audiopanel.start_time(sec);
}

function stopAtGivenSec(sec) {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.selectionEnd = sec
  else if (NSsound)
    document.audiopanel.end_time(sec);
}

function stopAtEnd() {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.selectionEnd = endTime
  else if (NSsound)
    document.audiopanel.stop_at_end();
}

function decreaseVolume() {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.volume -= 10
  else if (NSsound)
    document.audiopanel.setvol(parseInt(document.audiopanel.GetVolume() - 10))
}

function increaseVolume() {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.volume += 10
  else if (NSsound)
    document.audiopanel.setvol(document.audiopanel.GetVolume() + 10)
}

function setDefaultVolume() {
  if (!navigator.javaEnabled()) return;
  if (IEsound)
    document.audiopanel.volume = 50
  else if (NSsound)
    document.audiopanel.setvol(50)
}
function PlayPause(path,on,off) 
{
	media_d = document.getElementById('audio_control');

if(document.display.state.value==1)
	{
		stopIt();
	img_str='<img src="'+ path + off +' "  onclick="PlayPause(\''+path+ '\',\'' +on+ '\',\''+off+ '\' )" >';
	media_d.innerHTML=img_str;														
	} 
	
	else 
	
	{
	playIt();
	
	img_str='<img src="'+ path + on +' "  onclick="PlayPause(\''+path+ '\',\'' +on+ '\',\''+off+ '\' )" >';
	media_d.innerHTML=img_str;														
	}


}
function stopVideo() {
	//alert("stop");
   document.videopanel.pause();
 }

function startVideo(vol) {
//	video_d = document.getElementById('divvideo');
//	video_d.visibility=true;
	//document.videopanel.hidden = false;
	//document.videopanel.width=vol;
    document.videopanel.play();
 }

function closeVideo(vol) {
   // alert(":(");
	document.videopanel.pause();
	document.videopanel.hidden = true;
//document.videopanel.width=0;
//	document.videopanel.heigth=0;
 	document.getElementById('menuvideo').innerHTML = '';
 	document.getElementById('menuvideoo').innerHTML = '';
//	alert(video_d);
 }
