// GorClock.js
//  Displays an analog Gorean Chronometer, in Ahn/Ehn/Ihn, with hands moving counter-clockwise
//  09-Feb-05/ 1st of the 11th Passage Hand 10,155 C.A.
//  Oryx con Lara, the Lara Inn
// 2011-08-31 Oryx          Deal with CSS errors because of missing 'px', and color specs w/o #
//
// Based on code whose source is unknown, this version is from tLi --
// http://the-lara-ORG (that's ORG as in ORGASM)
// When you copy this code, please leave in the above lines :)
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// To use the Analog GorClock, your BODY tag must have an OnLoad attribute that includes
//
//      onLoad="PostAnaClock()"
//
//  This initializes and starts the clock running.
//
// To PLACE the clock on your page, create a block-type area (TABLE, or DIV), then
//   include this HTML/Javascript
//
//     <DIV ID="AnaCLOCK" style="position: absolute;  visibility: hidden; display:block">
//     <SCRIPT type="text/javascript">
//     <!--
//         insertGorClockDiv()
//     -->
//     </SCRIPT>
//     </DIV>
//
// The exact placement of the clock face depends on the Global Variables GorClock_x and
//   GorClock_y which are the x,y coords of the upper left corner of the face. (OK, this
//   isn't My code originally, so it ISN'T an object, neener neener). The size of the
//   clock face is in GorClockHeight and GorClockWidth
//
// set these variables to your values *AFTER* you invoke this .js file, like--
//
//     <SCRIPT SRC="GorClock.js" type="text/javascript"></SCRIPT>
//     <SCRIPT type="text/javascript">
//     <!-- // hide from old browsers
//     GorClockHeight=30;
//     GorClockWidth=30;
//     GorClock_x=100;
//     // end hide -->
//     </SCRIPT>
//
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

fCol='#000000';//face color.
sCol='#FF0000';//seconds color.
mCol='#22ddaa';//minutes color.
hCol='#0000FF';//hours color.
GorClockHeight=40;
GorClockWidth=80;

H="\u2022\u2022\u2022\u2022";
H=H.split('');
M="\u2022\u2022\u2022\u2022\u2022";
M=M.split('');
S='·····o';
S=S.split('');
Face='19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 20';
Face=Face.split(' ');
n=Face.length;
font='Arial';
size=1;
sz10=size*10;
szpx=size*16;
props="<font face="+font+" size="+size+" color="+fCol+"><B>";

ns=(document.layers);
ie=(document.all);
o=false;    // assume primitive, non-Opera browser use
mz=false;   // assume not Mozilla
if (ie) {
    ieS = ie.toString();
    o = (ieS == "[object HTMLCollection]")
}
else
if (ns) {
}
else {
    mz=true;
}

Split=360/n;
HandHeight=GorClockHeight/6.0
HandWidth=GorClockWidth/6.0
HandY=-7;
HandX=-2.5;
GorClock_y=GorClockHeight;
GorClock_x=-GorClockWidth-30;

//
// Based on code whose source is unknown, this version is from tLi --
// http://the-lara-ORG (that's ORG as in ORGASM)
// When you copy this code, please leave in the above lines :)
//
function GorClock() {
    var top,left;
    kF = -1.25;
    kI = -1.57;
    kE = -1.57;
    kA = -1.575;
    now = new Date();
    getGorTime(now);
    ihn = kI - Math.PI * (GorTime.Ihn/40);            // 80 Ihn
    ehn = kE - Math.PI * (GorTime.Ehn/20);            // 40 Ehn
    ahn = kA - Math.PI * (GorTime.Ahn/10)  -Math.PI*GorTime.Ehn/360; //20 Ahn
    for (i=0; i < n; i++) {
        var X=(ns)?document.layers['lyFace'+i]:(ie)?dvFace[i].style:findObj('dvFace'+i).style;
        X.top =(GorClock_y + GorClockHeight        *Math.sin(kF + i*Split*Math.PI/180))+'px';
        X.left=(GorClock_x + GorClockWidth         *Math.cos(kF + i*Split*Math.PI/180))+'px';
    }
    for (i=0; i < H.length; i++) {
        var X=(ns)?document.layers['lyHours'+i]:(ie)?dvHours[i].style:findObj('dvHours'+i).style;
        X.top =(GorClock_y+HandY+ (i*HandHeight)*Math.sin(ahn))+'px';
        X.left=(GorClock_x+HandX+ (i*HandWidth) *Math.cos(ahn))+'px';
    }
    for (i=0; i < M.length; i++) {
        var X =(ns)?document.layers['lyMinutes'+i]:(ie)?dvMinutes[i].style:findObj('dvMinutes'+i).style;
        X.top =(GorClock_y+HandY+ (i*HandHeight)*Math.sin(ehn))+'px';
        X.left=(GorClock_x+HandX+ (i*HandWidth) *Math.cos(ehn))+'px';
    }
    for (i=0; i < S.length; i++) {
        var X =(ns)?document.layers['lySeconds'+i]:(ie)?dvSeconds[i].style:findObj('dvSeconds'+i).style;
        X.top =(GorClock_y+HandY+ (i*HandHeight)*Math.sin(ihn))+'px';
        X.left=(GorClock_x+HandX+ (i*HandWidth) *Math.cos(ihn))+'px';
    }
}

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// your BODY tag must have an OnLoad attribute that includes
//
//      onLoad="PostAnaClock()"
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function PostAnaClock() {
    GorClock();
    ShowHide('AnaCLOCK','visible');
    setTimeout('PostAnaClock()',20);
}

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Below are the DIV's that are created where you want the clock to appear on your page
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Create a block-type area (TABLE, or DIV), then include this HTML/Javascript
//
//     <DIV ID="AnaCLOCK" style="position: absolute;  visibility: hidden; display:block">
//     <SCRIPT type="text/javascript">
//     <!--
//         insertGorClockDiv()
//     -->
//     </SCRIPT>
//     </DIV>
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Based on code whose source is unknown, this version is from tLi --
// http://the-lara-ORG (that's ORG as in ORGASM)
// When you copy this code, please leave in the above lines :)
//

function insertGorClockDiv() {
    if (ns) {
        for (i=0; i < n; i++)
            document.write('<layer name="lyFace'+i+'" top=0 left=0 height='+sz10+'px width='+sz10+'px><center>'+
                props+Face[i]+'<\/font><\/center><\/layer>');
        for (i=0; i < S.length; i++)
            document.write('<layer name=lySeconds'+i+' top=0 left=0 width='
                +szpx+'px height='+szpx+'px>'
                +'<font face="'+font+'" size=3 color='+sCol+'><center><b>'+S[i]+'<\/b><\/center><\/font><\/layer>');
        for (i=0; i < M.length; i++)
            document.write('<layer name=lyMinutes'+i+' top=0 left=0 width='
                +szpx+'px height='+szpx+'px>'
                +'<font face="'+font+'" size=3 color='+mCol+'><center><b>'+M[i]+'<\/b><\/center><\/font><\/layer>');
        for (i=0; i < H.length; i++)
            document.write('<layer name=lyHours'  +i+' top=0 left=0 width='
                +szpx+'px height='+szpx+'px>'
                +'<font face="'+font+'" size=3 color='+hCol+'><center><b>'+H[i]+'<\/b><\/center><\/font><\/layer>');
    }
    else
    if (ie) {
        document.write('<div id="Of" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < n; i++)
            document.write('<div id="dvFace" style="position:absolute;top:0px;left:0;'
                    +'height:'+sz10+'px;width:'+sz10+'px;text-align:center">'+props+Face[i]+'<\/B><\/font><\/div>');
        document.write('<\/div>');
        document.write('<div id="Oh" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < H.length; i++)
            document.write('<div id="dvHours" style="position:absolute;'
                +'width:'+szpx+'px;height:'+szpx+'px;font-family:'+font+';font-size:'+szpx+'px;'
                +'color:'+hCol+';text-align:center;font-weight:bold">'+H[i]+'<\/div>');
        document.write('<\/div>');
        document.write('<div id="Om" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < M.length; i++)
            document.write('<div id="dvMinutes" style="position:absolute;'
                +'width:'+szpx+'px;height:'+szpx+'px;font-family:'+font+';font-size:'+szpx+'px;'
                +'color:'+mCol+';text-align:center;font-weight:bold">'+M[i]+'<\/div>');
        document.write('<\/div>')
        document.write('<div id="Os" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < S.length; i++)
            document.write('<div id="dvSeconds" style="position:absolute;'
                +'width:'+szpx+'px;height:'+szpx+'px;font-family:'+font+';font-size:'+szpx+'px;'
                +'color:'+sCol+';text-align:center;font-weight:bold">'+S[i]+'<\/div>');
        document.write('<\/div>')
    }   
    else
    if (mz) {
        document.write('<div id="Of" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < n; i++)
            document.write('<div id="dvFace'+i+'" style="position:absolute;top:0px;left:0px;'
                    +'height:'+sz10+'px;width:'+sz10+'px;text-align:center">'+props+Face[i]+'<\/B><\/font><\/div>');
        document.write('<\/div>');
        document.write('<div id="Oh" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < H.length; i++)
            document.write('<div id="dvHours'+i+'" style="position:absolute;'
                +'width:'+szpx+'px;height:'+szpx+'px;font-family:'+font+';font-size:'+szpx+'px;'
                +'color:'+hCol+';text-align:center;font-weight:bold">'+H[i]+'<\/div>');
        document.write('<\/div>');
        document.write('<div id="Om" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < M.length; i++)
            document.write('<div id="dvMinutes'+i+'" style="position:absolute;'
                +'width:'+szpx+'px;height:'+szpx+'px;font-family:'+font+';font-size:'+szpx+'px;'
                +'color:'+mCol+';text-align:center;font-weight:bold">'+M[i]+'<\/div>');
        document.write('<\/div>')
        document.write('<div id="Os" style="position:absolute;top:0px;left:0px">');
        for (i=0; i < S.length; i++)
            document.write('<div id="dvSeconds'+i+'" style="position:absolute;'
                +'width:'+szpx+'px;height:'+szpx+'px;font-family:'+font+';font-size:'+szpx+'px;'
                +'color:'+sCol+';text-align:center;font-weight:bold">'+S[i]+'<\/div>');
        document.write('<\/div>')
    }
    else
        alert("Sorry, unknown browser, please contact Oryx@Loryx.com");
}

//
// Based on code whose source is unknown, this version is from tLi --
// http://the-lara-ORG (that's ORG as in ORGASM)
// When you copy this code, please leave in the above lines :)
//
//-=END-OF-GorClock.js-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


