﻿
function showWait()
{
    document.getElementById('waitMsg').style.display='block';
}

function hideWait()
{
    document.getElementById('waitMsg').style.display='none';
}

function menuClick(loc)
{
    document.location.href = loc + ".aspx";
    return;
}


var clockDisplayer = "";

function setClock(formField)
{
    clockDisplayer = document.getElementById(formField);
}

function clock() 
{
    if (!document.layers && !document.all) return;
    var hex = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
    var ticktock = new Date();
    var month = ticktock.getMonth()+1;
    var date = ticktock.getDate();
    var day = ticktock.getDay();
    var year = ticktock.getFullYear();
    var utime = ticktock.getTime();
    var hours = ticktock.getHours();
    var minutes = ticktock.getMinutes();
    var seconds = ticktock.getSeconds();

    var GMTmonth = ticktock.getUTCMonth()+1;
    var GMTdate = ticktock.getUTCDate();
    var GMTday = ticktock.getUTCDay();
    var GMTyear = ticktock.getUTCFullYear();
    var GMThours = ticktock.getUTCHours();
    var GMTminutes = ticktock.getUTCMinutes();
    var GMTseconds = ticktock.getUTCSeconds();

    var milliseconds = (utime*1000).toString().substring(10,13);
    var apm = "am";

    var Swatch = "@" + (((utime/86400000)%1)+(1/24)).toString().substring(2,5);

    var decimaltime = ((hours/24)+(minutes/1440)+(seconds/86400)+(milliseconds/86400000));
    decimaltime = decimaltime.toString().substring(1,7);
    
    var udect = ((utime/86400000)%1).toString().substring(1,7);
    var totalseconds = (hours * 3600 + minutes * 60 + seconds + milliseconds / 1000);
    var gotime = utime/864 + 50000;
    var umt1 = gotime.toString().substring(5,7);
    var umt2 = gotime.toString().substring(7,10);

    with (Math) 
    {
        var hextime = floor(totalseconds / 1.318359375);
        var hex1 = floor(hextime / 4096);
        hextime -= 4096 * hex1;
        var hex2 = floor(hextime / 256);
        hextime -= 256 * hex2;
        var hex3 = floor(hextime / 16);
        hextime -= 16 * hex3;
        var hex4 = hextime;
    }

    var hexadecimalValue = hex[hex1] + "_"+ hex[hex2] + hex[hex3] + "_" + hex[hex4];

    if (day==0)
        day="Sun";
    if (day==1)
        day="Mon";
    if (day==2)
        day="Tue";
    if (day==3)
        day="Wed";
    if (day==4)
        day="Thu";
    if (day==5)
        day="Fri";
    if (day==6)
        day="Sat";

    if (GMTday==0)
        GMTday="Sun";
    if (GMTday==1)
        GMTday="Mon";
    if (GMTday==2)
        GMTday="Tue";
    if (GMTday==3)
        GMTday="Wed";
    if (GMTday==4)
        GMTday="Thu";
    if (GMTday==5)
        GMTday="Fri";
    if (GMTday==6)
        GMTday="Sat";

    if (month <= 9) month = "0" + month;
    if (date <= 9) date = "0" + date;
    if (hours > 11) apm = "pm";
    if (hours > 12) hours = hours - 12;
    if (hours == 0) hours = 12;
    if (hours <= 9) hours = "0" + hours;
    if (minutes <= 9) minutes = "0" + minutes;
    if (seconds <= 9) seconds = "0" + seconds;

    if (GMTmonth <= 9) GMTmonth = "0" + GMTmonth;
    if (GMTdate <= 9) GMTdate = "0" + GMTdate;
    if (GMThours <= 9) GMThours = "0" + GMThours;
    if (GMTminutes <= 9) GMTminutes = "0" + GMTminutes;
    if (GMTseconds <= 9) GMTseconds = "0" + GMTseconds;

    var NETbase = utime/86400000*360;
    var NETdegrees = Math.floor(NETbase%360);
    var NETminutes = Math.floor((NETbase*60)%60);
    if (NETminutes <= 9) NETminutes = "0" + NETminutes;
    var NETstring = NETdegrees + "°" + NETminutes + "' NET";

    var localValue = month + "." + date + "." + year + " " + day + " " + hours + ":" + minutes + ":" + seconds; // + "." + milliseconds + " " + apm;
    var GMTValue = "GMT/UTC Date/Time: " + GMTyear + "." + GMTmonth + "." + GMTdate + " " + GMTday + " " + GMThours + ":" + GMTminutes + ":" + GMTseconds + "." + milliseconds;
    var dtimeValue = "Local Decimal Time: " + decimaltime;
    var udtimeValue = "Decimal Time GMT: " + udect; // decimaltime.hynes.net
    var umtValue = "Universal Metric Time: " + umt1 + "." + umt2; // More at Zapatopi.net
    var hexValue = "Hexadecimal Time: " + hexadecimalValue; // More at intuitor.com/hex
    var unixValue = "Milliseconds since 1/1/1970 00:00 GMT: " + utime;
    var SwatchValue = "Swatch Internet Time: " + Swatch + " .beats"; // More at Swatch.com
    var NETValue = "New Earth Time: " + NETstring; // More at Newearthtime.net

    clockDisplayer.innerText = localValue;

    //Countdown
    var cyear = 2008;  //  enter 4-digit year
    var cmonth = 0;    //  0 for January, 1 for February ... 11 for December
    var cdate = 1;   //  day of the month
    var chours = 0;    //  24-hour only
    var cminutes = 0;
    var cseconds = 0;
    var cms = 0;   //  milliseconds

    var description = "New Year's 2008";
    var future = new Date(cyear,cmonth,cdate,chours,cminutes,cseconds,cms);
    var future2 = future.getTime();
    countdown = future - utime;
    countsec = Math.floor(countdown/1000);
    countdays = Math.floor(countdown/86400000*1000)/1000;
    var csValue = "Seconds until " + description + ": " + countsec;
    var cdValue = "Days until " + description + ": " + countdays;

    setTimeout("clock()", 1);
}


function GetCurrentFormattedDate()
{
    var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

    var d = new Date();
    var curr_day = d.getDay();
    var curr_date = d.getDate();
    var sup = "";
    
    if (curr_date == 1 || curr_date == 21 || curr_date ==31)
    {
       sup = "st";
    }
    else if (curr_date == 2 || curr_date == 22)
    {
       sup = "nd";
    }
    else if (curr_date == 3 || curr_date == 23)
    {
       sup = "rd";
    }
    else
    {
       sup = "th";
    }
    var curr_month = d.getMonth();
    var curr_year = d.getFullYear();

    var output = d_names[curr_day] + " " + curr_date + "<SUP>" + sup + "</SUP> " + m_names[curr_month] + " " + curr_year;
    
    return output;

}
