var digitdir="images/readout/"
//Change "digitdir" to the directory for your digit images
//Change "height" to the height of your images
//Don't use quotation marks around the number.
var height=20

//Change "digitw" to the width of the images "0.gif" through "9.gif"
//Change "ampmw" to the width of the images "am.gif" & "pm.gif"
//Change "colonw" to the width of the images "colona.gif" & "colonb.gif"
//Don't use quotation marks around the number.
var digitw=13
var ampmw=30
var colonw=6

//Choose an option for the number separators
//  "FLASH" - flashes between "colona.gif" & "colonb.gif"
//  "A" - just "colona.gif"
//  "B" - just "colonb.gif"
//  "NO" - no image
//then change "colon" to that option
var colon="FLASH"

//Turn seconds "ON" or "OFF"
var seconds="ON"

//Change "timezone" to your time zone's standard (not daylight savings time) offset from GMT
//  Don't use quotation marks around the number
//  Positive timezones should not have a '+' in front of them
//  You may use 'half-hour' timezones by adding '.5' to the number
//Some Time Zones:
//  Greenwich Mean Time: 0
//  America: Eastern -5; Central -6; Mountain -7; Pacific -8
//  Europe: England 0; France 1; Germany 1; Italy 1; Spain 1
//  Asia: China 8; Japan 9
//EXAMPLES: 'var timezone=-3','var timezone=3','var timezone=3.5','var timezone=-3.5'
var timezone=-7

//If your country or region uses "Daylight Savings Time" you will need this
//During "Daylight Savings Time" set daylight to "ON"
//When it's not "Daylight Savings Time" set daylight to "OFF"
var daylight="ON"

//-----------------------------------------------------------
//------------------------END OPTIONS------------------------
//-----------------------------------------------------------


function imageArray(length,imageWidth,imageHeight){
    this.length=length
    for (i=0;i<length;i++){this[i]=new Image(imageWidth,imageHeight)}
}
if (parseInt(navigator.appVersion.substring(0,1))>=3&&!(parseInt(navigator.appVersion.substring(0,1))==3&&navigator.userAgent.indexOf("MSIE")!=-1)) {
    digits=new imageArray(10, digitw, height)
    digits[0].src=digitdir+"0.gif"
    digits[1].src=digitdir+"1.gif"
    digits[2].src=digitdir+"2.gif"
    digits[3].src=digitdir+"3.gif"
    digits[4].src=digitdir+"4.gif"
    digits[5].src=digitdir+"5.gif"
    digits[6].src=digitdir+"6.gif"
    digits[7].src=digitdir+"7.gif"
    digits[8].src=digitdir+"8.gif"
    digits[9].src=digitdir+"9.gif"
    ampmimg=new imageArray(2, ampmw, height)
    ampmimg[0].src =digitdir+"am.gif"
    ampmimg[1].src =digitdir+"pm.gif"
    colonimg=new imageArray(2, colonw, height)
    colonimg[0].src =digitdir+"colona.gif"
    colonimg[1].src =digitdir+"colonb.gif"

    var daylightModifier=0
    if (daylight=="ON") {daylightModifier=1*60*60*1000}
    var tempDate=new Date()
    var macfix=(new Date(tempDate.toLocaleString())).getTime()-tempDate.getTime()
    var communicatorfix=0
  if (
      (navigator.userAgent.indexOf("Mozilla")!=-1&&navigator.userAgent.indexOf("MSIE")==-1)&&
      parseInt(navigator.appVersion.substring(0,1))==4&&
      parseFloat(navigator.appVersion)<=4.05&&
      (tempDate.toString()).indexOf("Daylight")!=-1
    ) {
      communicatorfix=60*60*1000
    }
}
function goClock() {
    if (parseInt(navigator.appVersion.substring(0,1))>=3&&!(parseInt(navigator.appVersion.substring(0,1))==3&&navigator.userAgent.indexOf("MSIE")!=-1)) {
      var tempDate=new Date()
      var now=new Date(tempDate.getTime()+(tempDate.getTimezoneOffset()*60*1000)+(timezone*60*60*1000)+daylightModifier-(2*macfix)+communicatorfix)

      var amPm=0
      var nowHours=now.getHours()
      var nowMinutes=now.getMinutes()
      var nowSeconds=now.getSeconds()

      if (nowHours<0) {nowHours+=24}
      if (nowHours>23) {nowHours-=24}
      var nowSecondshalf=parseInt(nowSeconds)/2
      var colonnum="0"
      
      if (nowHours>12) {nowHours-=12; amPm=1}
      if (nowHours==12) {amPm=1}
      if (nowHours==0) {nowHours=12}
      if (nowHours<=9) {nowHours="0"+nowHours} else {nowHours=""+nowHours}
      if (nowMinutes<=9) {nowMinutes="0"+nowMinutes} else {nowMinutes=""+nowMinutes}
      if (nowSeconds<=9) {nowSeconds="0"+nowSeconds} else {nowSeconds=""+nowSeconds}

      if (colon=="FLASH") {if (nowSecondshalf==parseInt(nowSecondshalf)) {colonnum="0"} else {colonnum="1"}}
      if (colon=="A") {colonnum="1"}
      if (colon=="B") {colonnum="0"}
      
      if (nowHours.charAt(0)!=0) {document.Hourspic0.src=digits[nowHours.charAt(0)].src}
      document.Hourspic1.src=digits[nowHours.charAt(1)].src
      document.Colonpic0.src=colonimg[colonnum].src
      document.Minutespic0.src=digits[nowMinutes.charAt(0)].src
      document.Minutespic1.src=digits[nowMinutes.charAt(1)].src
      if (seconds=="ON") {
        document.Colonpic1.src=colonimg[colonnum].src
        document.Secondspic0.src=digits[nowSeconds.charAt(0)].src
        document.Secondspic1.src=digits[nowSeconds.charAt(1)].src
      }
      document.Ampmpic.src=ampmimg[amPm].src
      setTimeout("goClock()",1000)
    }
}
