var vol,mu,fdown,step ; 

function widgetOnInit()
{
  vol = -2;
  mu = -2;
  
  bg.src = GetSetting('bg'); 
  step = parseInt( GetSetting('step') );
  
  tmOnTimer();
  
}

function widgetOnDBClick()
{
  print(  system.volume );
}


function tmOnTimer()
{
  if((system.volume == vol)&&( system.mute==mu ))
    return;
                       
  LockRefresh;                     
                       
  Print('set volmue'); 
  vol = system.volume;
  mu  = system.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()
{
  fdown = false;
  system.volume = system.volume - step;
  tmOnTimer(); 
}

function widgetOnMouseWheelUp()
{
  fdown = false;
  system.volume = system.volume + step;
  tmOnTimer(); 

}

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

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

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

function volbgOnMouseUp()
{
  fdown = false;
}


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


function volbgOnClick()
{
  fdown = false;
}

function widgetOnClick()
{
   fdown = false;
}