
    <!--

    var currClockField;
    var currHours;
    var currMinutes;
    var currSeconds;

    var setHours;
    var setMinutes;
    var setSeconds;

    var alarmHours;
    var alarmMinutes;
    var alarmSeconds;

    var alarmSound;
    var waitCount;
    var alarmState;
    var alarmStartTime;
    var maxRepeatMinutes=480;
    var snoozeTime=5;

    var playSoundStr;
    var blinkFlag=0;

    var testSoundFld;
    var table1Fld;
    var stopTestFlag;
  
    function HoursInit() 
    {
      if ( currHours < 10 )
      {
        document.getElementById("hourOptions").value="0"+currHours;
      }
      else
      {
        document.getElementById("hourOptions").value=currHours;
      }
    }

    function MinutesInit() 
    {
      if ( currMinutes < 10 )
      {
        document.getElementById("minuteOptions").value = "0"+currMinutes;
      }
      else
      {
        document.getElementById("minuteOptions").value = currMinutes;
      }
    }

    function SecondsInit() 
    {
      if ( currSeconds < 10 )
      {
        document.getElementById("secondOptions").value = "0"+currSeconds;
      }
      else
      {
        document.getElementById("secondOptions").value = currSeconds;
      }
    }

    function HoursSet() 
    {
      setHours = document.getElementById("hourOptions").value;
    }

    function MinutesSet() 
    {
      setMinutes = document.getElementById("minuteOptions").value;
    }

    function SecondsSet() 
    {
      setSeconds = document.getElementById("secondOptions").value;
    }

    function HoursChange() 
    {
      HoursSet();
      StopAlarm();
    }

    function MinutesChange() 
    {
      MinutesSet();
      StopAlarm();
    }

    function SecondsChange() 
    {
      SecondsSet();
      StopAlarm();
    }

    function SetSnoozeTime() 
    {
      var tmpTime = new Date();
      tmpTime = tmpTime.getTime();
      tmpTime = tmpTime + (snoozeTime * 60 * 1000);
      tmpTime = new Date(tmpTime);
      setHours    = (tmpTime.getHours()).toString();
      setMinutes  = (tmpTime.getMinutes()).toString();
      setSeconds  = (tmpTime.getSeconds()).toString();
      SetAlarmOn();
    }


    function ShowClock() 
    {
      var currTime = new Date();
      currHours    = currTime.getHours();
      currMinutes  = currTime.getMinutes();
      currSeconds  = currTime.getSeconds();

      var currTimeStr = "  "+currHours;

      if ( currMinutes < 10 )
      {
        currTimeStr += ":0" + currMinutes;
      }
      else
      {
        currTimeStr += ":" + currMinutes;
      }

      if ( currSeconds < 10 )
      {
        currTimeStr += ":0" + currSeconds;
      }
      else
      {
        currTimeStr += ":" + currSeconds;
      }

      currClockField.value = currTimeStr;
      setTimeout("ShowClock()",1000);

      if ( waitCount> 0)
      {
        waitCount--;
        if ( waitCount == 0)
        {
          RestoreCusor();
        }
      }

      if ( alarmState == 1 )
      {
        if ( stopTestFlag == 1 )
        {
          StopTestSound();
          stopTestFlag=0;
        }
      }

      if ( alarmState == 2 )
      {
        if (blinkFlag==0)
        {
          document.getElementById("StopAlarm").className = 'sac';
          blinkFlag=1;
        }
        else
        {
          document.getElementById("StopAlarm").className = 'sac1';
          blinkFlag=0;
        }
        cTime = new Date();
        cTime = cTime.getTime();
        if ( ( ( cTime - alarmStartTime )/1000 )/60 > maxRepeatMinutes )
        {
          StopAlarm();
        }
      }

      else
      {
        obj1 = document.getElementById("AlarmOnOff1");
        val=RadioCheckedValue(obj1);

        if ( val == 1 )
        {
          if ( alarmHours == currHours )
          {
            if ( alarmMinutes == currMinutes )
            {
              if ( alarmSeconds == currSeconds )
              {
                alarmStartTime = new Date();
                alarmStartTime = alarmStartTime.getTime();
                ActivateAlarm();
  //              window.location='http://gifs.msn.co.il/media/glz.asx';
  //              window.location='http://switch3.castup.net/cunet/gm.asp?clipmediaid=30795';
              }
            }
          }
        }
      }
    } 

    function HandleAlarmOnOff(obj)
    {
      HoursSet();
      MinutesSet();
      SecondsSet();
      val=RadioCheckedValue(obj);
      SetAlarmOnOff(val)
    }

    function SoundSourceSelect(obj)
    {
      obj1 = document.getElementById("SoundType1");
      val=RadioCheckedValue(obj1);

      if (val!=1)
      {
        SetMelodySelection();
      }
      else
      {
        SetRadioSelection();
      }
    }

    function SetRadioSelection()
    {
      ChangeSoundTest();
      document.getElementById("SoundType0").checked = 0;
      document.getElementById("SoundType1").checked = 1;
      document.getElementById("aa2").style.borderTop = '3px red solid';
      document.getElementById("aa2").style.borderBottom = '3px red solid';
      document.getElementById("aa2").style.borderLeft = '3px red solid';
      document.getElementById("aa2").style.borderRight = '3px red solid';

      document.getElementById("aa1").style.borderTop = '3px white solid';
      document.getElementById("aa1").style.borderBottom = '3px white solid';
      document.getElementById("aa1").style.borderLeft = '3px white solid';
      document.getElementById("aa1").style.borderRight = '3px white solid';
      document.getElementById("alarmAudio1").disabled = true;
      document.getElementById("alarmAudio2").disabled = false;
    }

    function SetMelodySelection()
    {
      ChangeSoundTest();
      document.getElementById("SoundType0").checked = 1;
      document.getElementById("SoundType1").checked = 0;
      document.getElementById("aa2").style.borderTop = '3px white solid';
      document.getElementById("aa2").style.borderBottom = '3px white solid';
      document.getElementById("aa2").style.borderLeft = '3px white solid';
      document.getElementById("aa2").style.borderRight = '3px white solid';

      document.getElementById("aa1").style.borderTop = '3px red solid';
      document.getElementById("aa1").style.borderBottom = '3px red solid';
      document.getElementById("aa1").style.borderLeft = '3px red solid';
      document.getElementById("aa1").style.borderRight = '3px red solid';
      document.getElementById("alarmAudio1").disabled = false;
      document.getElementById("alarmAudio2").disabled = true;
    }

    function ChangeSoundTest()
    {
      if ( alarmState == 1 )
      {
        stopTestFlag=1;
      }
    }

    function SetAlarmOnOff(val)
    {
      if ( val == 1 )
      {
        SetAlarmOn();
      }
      else
      {
        document.getElementById("ap1").innerHTML = "Allarme e` spanto";
        document.getElementById("imgoff").style.visibility = 'visible';
        document.getElementById("imgon").style.visibility = 'hidden';
      }
    }

    function SetAlarmOn()
    {
      alarmHours   = setHours;
      alarmMinutes = setMinutes;
      alarmSeconds = setSeconds;
      document.getElementById("imgon").style.visibility = 'visible';
      document.getElementById("imgoff").style.visibility = 'hidden';
      var str =  "L`allarme e` impostato sulle";

      var alarmTimeStr = "  "+alarmHours;

      if ( alarmMinutes.length < 2 )
      {
        alarmTimeStr += ":0" + alarmMinutes;
      }
      else
      {
        alarmTimeStr += ":" + alarmMinutes;
      }

      if ( alarmSeconds.length < 2 )
      {
        alarmTimeStr += ":0" + alarmSeconds;
      }
      else
      {
        alarmTimeStr += ":" + alarmSeconds;
      }

      document.getElementById("ap1").innerHTML = "<table><tr><td align='center'><div class='text4'>"+str+"</div></td><td align='center'>&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE='text' Id='AlarmTime' SIZE ='10' readonly class='clockcss'></td>";
      document.getElementById("AlarmTime").value = alarmTimeStr;
    }

    function BuildSoundStrPrev(val) 
    {
      if (val!=1)
      {
        alarmSound = document.getElementById("alarmAudio1").value;
        playSoundStr = "<object height='0%' width='0%' data='audio/"+alarmSound+".mid'> <param name='AutoStart' value='1' /> <param name='AutoPlay' value='true'/><param name='FileName' value='audio/"+alarmSound+".mid' /><param name='loop' value='true'> You do not have a MIDI player on your computer.</object>";
      }

      else
      {
        alarmSound = document.getElementById("alarmAudio2").value;
//        playSoundStr="<OBJECT width='0' height='0' ID='mediaPlayer' CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' TYPE='application/x-oleobject'> <PARAM NAME='fileName' VALUE='http://switch3.castup.net/cunet/gm.asp?ai=31&ar=Reshet%5FBet'><PARAM NAME='animationatStart' VALUE='true'><PARAM NAME='transparentatStart' VALUE='true'><PARAM NAME='autoStart' VALUE='true'><PARAM NAME='showControls' VALUE='true'></OBJECT>";
        playSoundStr="<OBJECT width='0' height='0' ID='mediaPlayer' CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' TYPE='application/x-oleobject'> <PARAM NAME='fileName' VALUE='"+alarmSound+"'><PARAM NAME='animationatStart' VALUE='true'><PARAM NAME='transparentatStart' VALUE='true'><PARAM NAME='autoStart' VALUE='true'><PARAM NAME='showControls' VALUE='true'></OBJECT>";
      }

    }

    function BuildSoundStr(val) 
    {
      if (val!=1)
      {
        alarmSound = document.getElementById("alarmAudio1").value;
        playSoundStr = "<object id='MediaPlayer' CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows® Media Player components...' type='application/x-oleobject' width='0' height='0'><param name='fileName' value='audio/"+alarmSound+".mid'><param name='animationatStart' value='true'><param name='transparentatStart' value='true'><param name='autoStart' value='true'><param name='showControls' value='true'><param name='loop' value='true'><param name='Volume' value='-450'><embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='audio/"+alarmSound+".mid' name='MediaPlayer1' width=0 height=0 autostart=1 showcontrols=1 volume=-450></embed></object>";
      }

      else
      {
        alarmSound = document.getElementById("alarmAudio2").value;
        playSoundStr = "<object id='MediaPlayer' CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows® Media Player components...' type='application/x-oleobject' width='0' height='0'><param name='fileName' value='"+alarmSound+"'><param name='animationatStart' value='true'><param name='transparentatStart' value='true'><param name='autoStart' value='true'><param name='showControls' value='true'><param name='Volume' value='-450'><embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='"+alarmSound+"' name='MediaPlayer1' width=0 height=0 autostart=1 showcontrols=1 volume=-450></embed></object>";
      }

    }

    function Init() 
    {
      alarmState=0;
      waitCount=0;

      stopTestFlag=0;

//      document.getElementById("AlarmOnOff").checked = 1;
//      document.getElementById("AlarmOnOff").checked = 0;

      var currTime = new Date();
      currHours    = currTime.getHours();
      currMinutes  = currTime.getMinutes();
      currSeconds  = currTime.getSeconds();

      HoursInit();
      MinutesInit();
      SecondsInit();

      currClockField = document.getElementById("Clock");
      HoursSet();
      MinutesSet();
      SecondsSet();
      document.getElementById("alarmAudio1").disabled = true;

      testSoundFld = document.getElementById("TestSound");
      table1Fld = document.getElementById("Table1");
    } 

    function ActivateAlarm()
    {      
      alarmState=2;
      obj1 = document.getElementById("SoundType1");
      val=RadioCheckedValue(obj1);
      BuildSoundStr(val);

      document.getElementById("ap2").innerHTML = playSoundStr;
      document.getElementById("StopAlarm").style.visibility = 'visible';
      document.getElementById("Snooze").style.visibility = 'visible';
      document.getElementById("TestSound").disabled = true;
      document.getElementById("AlarmOnOff0").disabled = true;
      document.getElementById("AlarmOnOff1").disabled = true;
      document.getElementById("SoundType0").disabled = true;
      document.getElementById("SoundType1").disabled = true;
      document.getElementById("hourOptions").disabled = true;
      document.getElementById("minuteOptions").disabled = true;
      document.getElementById("secondOptions").disabled = true;
      document.getElementById("alarmAudio1").disabled = true;
      document.getElementById("alarmAudio2").disabled = true;
    }


    function RestoreCusor()
    {
      document.body.style.cursor = "default";
      testSoundFld.style.cursor="default";
      table1Fld.style.cursor="default";
    }

    function TestSound()
    {      
      if ( alarmState == 0 )
      {
        document.getElementById("Table1").style.cursor="wait";
        document.getElementById("TestSound").style.cursor="wait";

        obj1 = document.getElementById("SoundType1");
        val=RadioCheckedValue(obj1);
        if ( val!=1 )
        {
          waitCount=2;
        }
        else
        {
          waitCount=10;
        }

        BuildSoundStr(val);

        document.getElementById("ap2").innerHTML = playSoundStr;
        document.getElementById("TestSound").value="Stop Test";
        document.getElementById("TestSound").className = 'stc';
        alarmState=1;
      }
      else
      {
        StopTestSound();
      }
    }

    function StopTestSound()
    {      
      waitCount=0;
      document.getElementById("ap2").innerHTML = "&nbsp;";
      document.getElementById("TestSound").value="Prova il Suono";
      document.getElementById("TestSound").className = 'tsc';
      alarmState=0;
      RestoreCusor();
    }

    function StopAlarm()
    {
      document.getElementById("ap1").innerHTML = "Alarm e` spento";
      document.getElementById("ap2").innerHTML = "&nbsp;";
      document.getElementById("StopAlarm").style.visibility = 'hidden';
      document.getElementById("Snooze").style.visibility = 'hidden';
      document.getElementById("TestSound").disabled = false;
      document.getElementById("AlarmOnOff0").disabled = false;
      document.getElementById("AlarmOnOff1").disabled = false;
      document.getElementById("SoundType0").disabled = false;
      document.getElementById("SoundType1").disabled = false;

      document.getElementById("hourOptions").disabled = false;
      document.getElementById("minuteOptions").disabled = false;
      document.getElementById("secondOptions").disabled = false;

      obj1 = document.getElementById("SoundType1");
      val=RadioCheckedValue(obj1);

      if ( val == 1 )
      {  
        document.getElementById("alarmAudio1").disabled = true;
        document.getElementById("alarmAudio2").disabled = false;
      }
      else
      {
        document.getElementById("alarmAudio1").disabled = false;
        document.getElementById("alarmAudio2").disabled = true;
      }

      alarmState = 0;
      document.getElementById("AlarmOnOff0").checked = 1;
      document.getElementById("AlarmOnOff1").checked = 0;
      document.getElementById("imgoff").style.visibility = 'visible';
      document.getElementById("imgon").style.visibility = 'hidden';
    }

    function Snooze()
    {
      document.getElementById("ap2").innerHTML = "&nbsp;";
      document.getElementById("StopAlarm").style.visibility = 'hidden';
      document.getElementById("Snooze").style.visibility = 'hidden';
      document.getElementById("TestSound").disabled = false;
      document.getElementById("AlarmOnOff0").disabled = false;
      document.getElementById("AlarmOnOff1").disabled = false;
      document.getElementById("SoundType0").disabled = false;
      document.getElementById("SoundType1").disabled = false;
      document.getElementById("hourOptions").disabled = false;
      document.getElementById("minuteOptions").disabled = false;
      document.getElementById("secondOptions").disabled = false;
      document.getElementById("alarmAudio1").disabled = false;
      document.getElementById("alarmAudio2").disabled = false;
      SetSnoozeTime();
      SetAlarmOnOff(1);
      alarmState = 0;
    }

    function HandleMouseEnter()
    {
      document.getElementById("StopAlarm").className = 'sac1';
    }
    function HandleMouseOut()
    {
      document.getElementById("StopAlarm").className = 'sac';
    }

    function HandleMouseEnter2()
    {
      if ( alarmState == 0 )
      {
        document.getElementById("TestSound").className = 'tsc1';
      }
      else
      {
        document.getElementById("TestSound").className = 'stc1';
      }
    }

    function HandleMouseOut2()
    {
      if ( alarmState == 0 )
      {
        document.getElementById("TestSound").className = 'tsc';
      }
      else
      {
        document.getElementById("TestSound").className = 'stc';
      }
    }

    function HandleMouseEnter3()
    {
      document.getElementById("Snooze").className = 'sac1';
    }

    function HandleMouseOut3()
    {
      document.getElementById("Snooze").className = 'sac';
    }

    function RadioCheckedValue(obj) 
    {
      if(!obj)
      {
	return "";
      }

      var radioLength = obj.length;

      if(radioLength == undefined)
      {
        if(obj.checked)
        {
          return obj.value;
        }
        else
        {
          return "";
        }
      }

      for(var i = 0; i < radioLength; i++) 
      {
        if(obj[i].checked) 
        {
          return obj[i].value;
        }
      }
      return "";
    }


      //-->
