var sound,vol,mu,fdown ; 

function widgetOnInit()
{
  vol = -1;
  mu = -1;

  regSvr( widgetPath + "volumeObj.dll") ;
  try
  {
    sound  =  new  ActiveXObject("volumeobj.volume");
    sound.init();
  }
  catch(e)
  {
    alert( e.message);
    return;
  }    
  
  bg.src = GetSetting('bg'); 
  
  tmOnTimer();
  
}

function widgetOnDBClick()
{
  //sound.mute = !sound.mute;
  print(  sound.volume );
}

function widgetOnClose()
{
   sound.free;

}

function tmOnTimer()
{
  if((sound.volume == vol)&&( sound.mute==mu ))
    return;
                       
  LockRefresh;                     
                       
  Print('set volmue'); 
  vol = sound.volume;
  mu  = sound.mute;
  
  pbvol.percent = vol;
  
  if(mu==0)
  {
    cross.Visible = false;
    icon.tooltip = '¾²Òô';
    txt.caption = 'ÒôÁ¿: ' + vol + ' %';
    
  }
  else
  {
    cross.Visible = true;
    icon.tooltip = 'È¡Ïû¾²Òô';
    txt.caption = '¾²Òô';
  }
  UnLockRefresh;                     
   
}



function widgetOnMouseWheelDown()
{
  sound.volume = sound.volume - 7;
  tmOnTimer(); 
}

function widgetOnMouseWheelUp()
{
  sound.volume = sound.volume + 7;
  tmOnTimer(); 

}

function volbgOnMouseDown()
{
  fdown = true;
  
  sound.volume = mouseX - widget.Left - volbg.left;
  tmOnTimer(); 
}

function iconOnMouseDown()
{
   sound.mute = !sound.mute;
   tmOnTimer();
  
}

function OnAllSettingsSaved()
{
  vol = -1;
  mu = -1;
  
  bg.src = GetSetting('bg'); 
  tmOnTimer();
}

function volbgOnMouseUp()
{
  fdown = false;
}


function volbgOnMouseMove()
{
  if(fdown)
  {
    sound.volume = mouseX - widget.Left - volbg.left;
    tmOnTimer(); 
  }
  
}

function volbgOnMouseLeave()
{
  fdown = false;
}

function volbgOnClick()
{
  fdown = false;
}