| /* | 
| * To change this license header, choose License Headers in Project Properties. | 
| * To change this template file, choose Tools | Templates | 
| * and open the template in the editor. | 
| */ | 
| var timer = { | 
| lastDate: null, | 
| timerIntervalId: null, | 
| blockStatus: false, | 
| timeShowBlock: { | 
| hourse: 8, | 
| minutes: 0, | 
| seconds: 0 | 
| }, | 
| timeHideBlock: { | 
| hourse: 20, | 
| minutes: 0, | 
| seconds: 0 | 
| }, | 
| dom: { | 
| hourse: null, | 
| minutes: null, | 
| second: null, | 
| checkVars: function () { | 
| if (this.hourse && this.minutes && this.second) { | 
| return true; | 
| } else { | 
| return false; | 
| } | 
| }, | 
| init: function () { | 
| if (this.checkVars()) { | 
| return true; | 
| } | 
| this.hourse = document.getElementById('h'); | 
| this.minutes = document.getElementById('m'); | 
| this.second = document.getElementById('s'); | 
| if (this.checkVars()) { | 
| return true; | 
| } else { | 
| return false; | 
| } | 
| }, | 
| hide: function () { | 
| timer.start(30000); | 
| if (timer.blockStatus == true) { | 
| document.getElementById('second-blank').className += 'hidden'; | 
| timer.blockStatus = false; | 
| } | 
| }, | 
| show: function () { | 
| if (timer.blockStatus == false) { | 
| document.getElementById('second-blank').className = ''; | 
| timer.blockStatus = true; | 
| timer.start(1000); | 
| } | 
| } | 
| }, | 
| setLastDate: function(d) { | 
| if (d) { | 
| this.lastDate = d; | 
| } else { | 
| this.lastDate = new Date(); | 
| } | 
| this.lastDate.setHours(this.timeHideBlock.hourse, this.timeHideBlock.minutes, this.timeHideBlock.second); | 
| }, | 
| range: function (h, m, s) { | 
| if (!this.dom.init()) { | 
| return false; | 
| } | 
| this.dom.hourse.innerHTML = h; | 
| this.dom.minutes.innerHTML = m; | 
| this.dom.second.innerHTML = s; | 
| }, | 
| arrToSec: function (h, m, s) { | 
| if (m>0) s+= m*60; | 
| if (h>0) s+=h*60*60; | 
| return s; | 
| }, | 
| interval: function () { | 
| if (!this.dom.init()) { | 
| return false; | 
| } | 
|  | 
| d = new Date(); | 
| lastTime = new Date(); | 
| lastTime.setHours(this.timeHideBlock.hourse, this.timeHideBlock.minutes, this.timeHideBlock.seconds) | 
| lastSecond = lastTime - d; | 
| firstTime = new Date(); | 
| firstTime.setHours(this.timeShowBlock.hourse, this.timeShowBlock.minutes, this.timeShowBlock.seconds) | 
| firstSecond = d - firstTime; | 
| if ( firstSecond > 0 && lastSecond > 0) { | 
| this.dom.show(); | 
| } else { | 
| this.dom.hide(); | 
| return; | 
| } | 
|  | 
| rem = new Date(lastSecond); | 
| h = rem.getHours() + (d.getTimezoneOffset() / 60); | 
| m = rem.getMinutes(); | 
| s = rem.getSeconds(); | 
|  | 
|  | 
| if (h<10) h = '0'+h; | 
| if (m<10) m = '0'+m; | 
| if (s<10) s = '0'+s; | 
| this.range(h, m, s); | 
| }, | 
| start: function (time) { | 
| clearInterval(this.timerIntervalId); | 
| this.timerIntervalId = setInterval(function () {timer.interval()}, (time?time:1000)); | 
|  | 
| } | 
| }; | 
| window.onload = function () { | 
| timer.start(5000); | 
| } |