
/*
function updateClock ($clock, $time)
{      
    var currentTime   = new Date ( parseInt($time.val()) ) ;
    
    var currentHours = currentTime.getUTCHours ( );
    var currentMinutes = currentTime.getUTCMinutes ( );
    var currentSeconds = currentTime.getUTCSeconds ( );
    
    // Pad the minutes and seconds with leading zeros, if required
    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
    
    // Choose either "AM" or "PM" as appropriate
    //var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
    
    // Convert the hours component to 12-hour format if needed
    //currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
    // Convert an hours component of "0" to "12"
    //currentHours = ( currentHours == 0 ) ? 12 : currentHours;
    
    // Compose the string for display
    var currentTimeString = currentHours + ":" + currentMinutes;
    
    // Update the time display
    $clock.text(currentTimeString);
      
    // Increment stored time by 1 second
    $time.val(currentTime.getTime()+1000);
}
*/

$(document).ready(function () {
 
    var $hoursDialog  =  $('#hoursDialog');
    $hoursDialog.dialog({
        autoOpen: false,
        modal: true,
        width: 610,
        resizable: false,
        draggable: true,
        title: 'Opening Hours',
        buttons: {
            'Send Email': function() {
                $(this).dialog('close');
                var email = $('input[name=site_email]', this).val();
                location.href='mailto:' + email + '?subject=Website Enquiry';
            },
            'Submit Enquiry': function() {
                $(this).dialog('close');
                location.href='/about#page=contact';
            },
            'Close': function() { $(this).dialog('close'); }
        }
    });
    
    // Want to put in dialogcreate event but it isn't firing.
    /* Clock no longer required
    var $clockSpan          = $('span.current-time', $hoursDialog);
    var $tsContainer        = $('input[name=timestamp_ms]', $hoursDialog);
    updateClock($clockSpan, $tsContainer);
    setInterval(function() {
        updateClock($clockSpan, $tsContainer);
    }, 1000);
    */
    
    // Bind to links    
    $('.hours-dialog').click(function() {
        $hoursDialog.dialog('open');
        return false;
    });
    
});
