﻿function GetOpeningTimes(indate, Ctrl) {

    // get Date Element in the right format
    Ctrl.innerText = "";
    var results = indate.split("/");

    var mydate = new Date(results[2],results[1]-1,results[0]);

    if (!isNaN(mydate))
    {
        switch (mydate.getDay()) {
            case 1:
                // Mon
                Ctrl.innerText = "09:30-1200 & 16:00-18:30";
                break;
            case 2:
                // Tue
                Ctrl.innerText = "09:30-1200 & 16:00-18:30";
                break;
            case 3:
                // Wed
                Ctrl.innerText = "09:30-1200 & 16:00-18:30";
                break;
            case 4:
                // Thu
                Ctrl.innerText = "09:30-1200 & 16:00-18:30";
                break;
            case 5:
                // Fri
                Ctrl.innerText = "09:30-1200 & 16:00-18:30";
                break;
            case 6:
                // Sat
                Ctrl.innerText = "09:30-1200";
                break;
            default:
                // Sun
                Ctrl.innerText = "10:00-1200 & 16:00-18:00";
                break;
        }
    }
}

  function ClearOptions(OptionList) {

       // Always clear an option list from the last entry to the first
       for (x = OptionList.length; x >= 0; x--) {
          OptionList[x] = null;
       }
    }

    function AddToOptionList(OptionList, OptionValue, OptionText) {
       // Add option to the bottom of the list
       OptionList[OptionList.length] = new Option(OptionText, OptionValue);
    }
    
    
    function PopulateRooms(SourceList, DestList){
     ClearOptions(DestList);
    
     for(x = 1; x <= SourceList.value; x++)
     {
        AddToOptionList(DestList,x,x);
     }
        form1.testSelect.disabled = ('1' == SourceList.value);
    }
    
    function isNumericKeyStroke()
    {
     var returnValue = false;
     var keyCode = (window.event.which) ? window.event.which : window.event.keyCode;

     if ( ((keyCode >= 48) && (keyCode <= 57)) || // All numerics
               (keyCode ==  8) ||     // Backspace
               (keyCode == 13) )     // Carriage Return
             returnValue = true;

     if ( window.event.returnValue )
      window.event.returnValue = returnValue;

     return returnValue;
    }

    function ShowGoogleHelp(evt)
    {
        var popUp = $get("GoogleHelp");
        popUp.style.top = window.event.clientY ;
        popUp.style.left = window.event.clientX - 305 ;
        popUp.style.visibility = "visible";
           
    }

    function HideGoogleHelp() {
        var popUp = $get("GoogleHelp");
        popUp.style.visibility = "hidden";
    }

    function ToggleDetails(CtrlID, LblName) {
        var Tester = new Fx.Slide(CtrlID);
        Tester.toggle();
        //Get Label to change text
        var lbl = $get(LblName);
        if (lbl != null) {
            if (lbl.innerHTML == "Show Details")
            { lbl.innerHTML = "Hide Details" }
            else
            { lbl.innerHTML = "Show Details" }
        }
        return false;
    }

    function HideDetails(CtrlID) {
        var H = new Fx.Slide(CtrlID);
        H.hide();
        return false;
    }    