document.write('<img id="paci" class="Vis0 abs" style="width:272px; height:272px;" src="img/clk/patience.gif" />');

 var E=document.getElementById('paci');
     E.style.zIndex =       100;
     E.style.left = 240;
     E.style.top  = 112;
     E.style.visibility = "visible";



iii=0
var z;
             
	function Sextime(a) {
    if (iii==0) z = a, iii = 1;
var now = new Date();
var msG = now.getTime();
var msF = msG + 2700 * 1000;

var mTZ = now.getTimezoneOffset();
var msL = msF - (mTZ + 45) *60000;
var sT2 = new Date(msG).toGMTString().split(" "); var s42 = sT2[4];
var sT1 = new Date(msF).toGMTString().split(" "); var s41 = sT1[4];
var sT3 = new Date(msL).toGMTString().split(" "); var s43 = sT3[4];
var tx2 = "UTC.Greenwich."
var tx1 = "UTC.Florence."
var tx3 = "Local Time."

    document.frm.Tra0.value = "Corresponding to " + eval('s4'+''+z+'') + " " + eval('tx'+''+z+'');

var TO = 675/1.024/4
    setTimeout("Sextime()", TO);

}




function InitAll()  { Sextime(3); showtime(); }

    

window.focus();

function ReInit() {  
for (i=0; i<=128; i++) document.getElementById("imgS"+i).style.visibility = "hidden";
}

    var ObjLft = 256;
    var ObjTop = 128;

    var ST =3;
    var hitDX;
    var hitLT;
    var hitGT;
    var hitST;
    var fDegS;

    var F0_ex = -1;
    var F1_ex = -1;
    var F2_ex = -1;
    var F3_ex = -1;
    var F4_ex = -1;

    var fOldS = -1;
    var fOldM = -1;
    var fOldH = -1;

    var HitInit = 0;

    var IniTM  =  new Date();
    var IniOS  =  IniTM.getTimezoneOffset();

    

function setLocalTitle()  {
    var MinOS = eval(IniOS+45);
var SgnOS  = "plus "; if (MinOS > 0) SgnOS  = "minus ";
var FmtHH  =  Math.abs(parseInt(MinOS/60));
var FmtMM  = "00"; if (MinOS%60!=0) FmtMM = Math.abs(MinOS%60);
var Part2  =  SgnOS + FmtHH + "H" + FmtMM;
if (ST==3) document.form4.txtI.value = "Your local time offset is UTC.F " + Part2 + ".  Thus your local hexadecimal time is:"
if (MinOS == 0) Part2 = "(!)";
document.getElementById('Btt3').title = " Your current time:  « Florence Mean Time " + Part2 + " ».";
}




function Slct(n) {

     F0_ex = F1_ex = F2_ex = F3_ex = F4_ex = -1

     if (ST*n > 2) document.getElementById("imgS"+(fOldS+1)*1).style.visibility="hidden";
         ST   = 0;
    for (i=1; i<=3; i++) document.getElementById('Btt'+i).style.border = 'outset';
                         document.getElementById('Btt'+n).style.border = 'inset';
    ST = n;              document.form2.hexT.focus();

     if (ST == 1) document.form4.txtI.value = "The new Universal Time of Florence in hexadecimal time format:",  iii=0, Sextime(1);
else if (ST == 2) document.form4.txtI.value = "The old Universal Time of Greenwich in hexadecimal time format:", iii=0, Sextime(2);
else                                                                                            setLocalTitle(), iii=0, Sextime(3);

     }




    Format = "LT"
    FMT    = "L"



// IMG
    for (i=0; i<=128; i++) document.write('<img border="0" id="imgS'+i+'" src="img/clk/sdh/S'+i+'.gif" style="position:absolute; visibility:hidden; left:256; top:128; z-index:1;" width="240" height="240">');
                           
    var timerID = null;
    var timerRunning = false;


    function showtime(){

if (ST != 0) {

// getTime();

     var now    =  new Date();
     var m1970  =  now.getTime();
     var µut70  = (m1970 * 16.384 /675);
         µutDX  =  Math.round(µut70 + 0x1216E10000)
         hitFT  =  Math.round(µutDX/16 %0x100000 + 0x20000000);

      if (ST == 2) hitGT = eval(hitFT - 0x1000), hitST = hitGT;
 else if (ST == 3) {
     var hitOS  =  Math.round(now.getTimezoneOffset()*0x1000/45);
         hitLT  =  Math.round(µutDX/16 %0x100000 + 0x1FFFF000) - hitOS;
         hitST  =  hitLT; F0_ex = -1;
         }
 else    hitST  =  hitFT; F0_ex = -1;


// CalcValues(Binary, Finary, Octave);
var B = new Array(); for (i=0; i<=16; i++) { B[i] = (hitST &    Math.pow( 2,i)) >>   i; }       // Binary = Math.pow(P,B)
var F = new Array(); for (i=0; i<= 4; i++) { F[i] = (hitST & 15*Math.pow(16,i)) >> 4*i; }       // Finary = Math.pow(P,F)
var O = new Array(); for (i=0; i<= 5; i++) { O[i] = (hitFT & 15*Math.pow(16,i)) >> 4*i; }       // OctaveValues always FT



// CallUpdateFunctions();
     if (F0_ex != F[0]) { CtrPt  ( B[0]);  S_txt(F[0]);  F0_ex = F[0];  var Continue = 1;
     if (F1_ex != F[1]) { M_txt  ( F[1], F[2]);          F1_ex = F[1];
     if (F2_ex != F[2]) {                                F2_ex = F[2];
     if (F3_ex != F[3]) { H_txt  ( B[16],F[3]);          F3_ex = F[3];
     if (F4_ex != F[4]) { hutFc  ( B[16]);               F4_ex = F[4];
     }}}}};


if (Continue == 1) {

   setLocalTitle();
   document.getElementById('paci').style.visibility = "hidden";
   document.getElementById('wait').style.visibility = "hidden";
   document.getElementById('hexT').style.visibility = "visible";
   document.getElementById('txtH').style.visibility = "visible";
   document.getElementById('txtM').style.visibility = "visible";
   document.getElementById('txtS').style.visibility = "visible";

// DecToSHOL(); (=Système hexadécimal omni-littéral)
var F_dgt  =  new Array();  for (i=0; i<5; i++) F_dgt[i] = DecToSHOL(O[i],0);
var F_DGT  =  new Array();  for (i=0; i<5; i++) F_DGT[i] = DecToSHOL(O[i],1);
var S_DGT  =  new Array();  for (i=0; i<4; i++) S_DGT[i] = DecToSHOL(F[i],1);


// CalcHexQuarterDegree(S_Hand, M_Hand, H_Hand);
     var fDegS  =  Math.round(hitST %0x00100 /0x002)%128; 
     var fDegM  =  Math.round(hitST %0x01000 /0x020);
     var fDegH  =  Math.round(hitST %0x10000 /0x200);


// UpdateSecondHandByVisibilityStyle();
     if (fOldS != fDegS-1) { fOldS  =(fDegS+127)%128;
                             document.getElementById("imgS"+fOldS).style.visibility="hidden";
                             document.getElementById("imgS"+fDegS).style.visibility="visible";
                            }

     if (fOldM != fDegM-1 ||
         fOldH != fDegH-1) { fOldM = (fDegM+127)%128;
                             fOldH = (fDegH+127)%128;  updateM(fDegM,fDegH); }



// ShowDirectly OctaveValues and SelectedTimeValue;
     var S_DGT_4_ = " "; if (B[16] != 0) S_DGT_4_ = "B";  // CreateAM/PM_Digits(" ", "B");
     document.form2.hexT.value = S_DGT_4_ +       S_DGT[3] + "." + S_DGT[2] +       S_DGT[1] + "’" + S_DGT[0].toLowerCase() + " H";

}


// else directly to the end;

var TO = 675/1.024/4
    timerID = setTimeout("showtime()", TO);
    timerRunning = true;
    }

    }













var C010 = new Array (     "",      "Onety",     "Twonety",   "Thirty",    "Forty",     "Fifty",     "Sixty",     "Seventy",   "Eighty",    "Ninety",   "Tenty",      "Eleventy",  "Twelfty",  "Thirteenty", "Forteenty", "Fifteenty")
var A010 = new Array (     "",      "onety",     "twonety",   "thirty",    "forty",     "fifty",     "sixty",     "seventy",   "eighty",    "ninety",   "tenty",      "eleventy",  "twelfty",  "thirteenty", "forteenty", "fifteenty")
var A000 = new Array (" zero    ", " one     ", " two     ", " three   ", " four    ", " five    ", " six     ", " seven   ", " eight   ", " nine    ", " ten     ", " eleven  ", " twelve  ", "thirteen ",  "forteen  ", "fifteen  ")
var C001 = new Array ( "Zero",      "One",       "Two",       "Three",     "Four",      "Five",      "Six",       "Seven",     "Eight",     "Nine",      "Ten",       "Eleven",    "Twelve",   "Thirteen",   "Forteen",   "Fifteen")
var B001 = new Array ( "zero",      "one",       "two",       "three",     "four",      "five",      "six",       "seven",     "eight",     "nine",      "ten",       "eleven",    "twelve",   "thirteen",   "forteen",   "fifteen")
var A001 = new Array (     "",      "one",       "two",       "three",     "four",      "five",      "six",       "seven",     "eight",     "nine",      "ten",       "eleven",    "twelve",   "thirteen",   "forteen",   "fifteen")



// UpdatePoints();
/////////////////////////////////////////

function hutFc(B16) {if (B16==0) document.getElementById("LetH").style.visibility = "hidden";
                     else        document.getElementById("LetH").style.visibility = "visible"; };

function CtrPt(B0)  {if  (B0==0) document.getElementById("Pt01").style.visibility = "hidden";
                     else        document.getElementById("Pt01").style.visibility = "visible"; }



// DecToSHOL;
///////////////////////////////////////////////////
function DecToSHOL(dec,c) { var SHOL = "QBPVFZSDTJCGKYXW".substr(dec & 0xF, 1); if (c==0) SHOL = SHOL.toLowerCase(); return SHOL }



// UpdateEnglishTimeTxt;
////////////////////////////////////////////////////

function S_txt(F0) {
     var s    = "s"; var Plur = (F0 >> 1);  if (Plur==0) s = " ";
     document.form4.txtS.value = "and " + A000[F0] + "sixteenth" + s + " of minute.";
}

function M_txt(F1, F2) {
     var M_T0 = A010[F2];
     var hyph = "-";
     var m_T0 = A001[F1]; 
     var unit = " minute";
     var plur = "s";
     if (F2==0 ||     F1==0) hyph = "";
     if (F2==0) { if (F1<=1) plur = "";
                  if (F1==0) m_T0 = "zero"; };
     document.form4.txtM.value = M_T0 + hyph + m_T0 + unit + plur;
}

function H_txt(B16, F3) {
     var H_T0 = "Onety";
     var hyph = "-";
     var h_T0 = A001[F3];
     var unit = " hour";
     var plur = "s";
     if (B16==0) { H_T0 = "", h_T0 = C001[F3];
     if (F3 <=1)              plur = ""; }
     if (B16==0 || F3==0)     hyph = "";
     document.form4.txtH.value = H_T0 + hyph + h_T0 + unit + plur + ",";
}


function updateM(m,h) {

    canvas = document.createElement("canvas");
    div1 = document.getElementById("cvs1");
    canvas.setAttribute("width",  div1.offsetWidth);
    canvas.setAttribute("height", div1.offsetHeight);
    div1.appendChild(canvas);
    if (!canvas.getContext) canvas = G_vmlCanvasManager.initElement(canvas);

    var ctx = canvas.getContext("2d");

    var t =  120;
    var M = (Math.PI/64)*(96+m);
    var H = (Math.PI/64)*(96+h);

    ctx.save();
    ctx.arc(t,t,67,0,2*Math.PI,false);
    ctx.fillStyle="#FFC";
    ctx.fill();
    ctx.restore();

    ctx.save();
    ctx.translate(t,t);
    ctx.rotate(H);
    ctx.beginPath();
    ctx.strokeStyle="#EEE";
    ctx.lineWidth = 16;
    ctx.moveTo(-24,0);
    ctx.lineTo( 48,0);
    ctx.stroke();
    ctx.restore();

    ctx.save();
    ctx.translate(t,t);
    ctx.rotate(H);
    ctx.beginPath();
    ctx.strokeStyle="#111";
    ctx.lineWidth = 15;
    ctx.moveTo(-23,0);
    ctx.lineTo( 48,0);
    ctx.stroke();
    ctx.restore();

    ctx.save();
    ctx.translate(t,t);
    ctx.rotate(M);
    ctx.beginPath();
    ctx.strokeStyle="#EEE";
    ctx.lineWidth = 14;
    ctx.moveTo(-21,0);
    ctx.lineTo( 65,0);
    ctx.stroke();
    ctx.restore();

    ctx.save();
    ctx.translate(t,t);
    ctx.rotate(M);
    ctx.beginPath();
    ctx.strokeStyle="#119";
    ctx.lineWidth = 12;
    ctx.moveTo(-20,0);
    ctx.lineTo( 64,0);
    ctx.stroke();
    ctx.restore();
}


