﻿            
            /*
            Nice little JS for telling you the world time!
            Use the following codes in the site to produse the world time in that place.
            Made in England By Ozwold!

                    #clockUTC#  = UK              0
                    #clockGMT#  = London          0
                    #clockBEL#  = Belgium         1
                    #clockMET#  = Paris           1
                    #clockEET#  = Cape Town       2
                    #clockBGT#  = Moscow          3
                    #clockIST#  = India           4.5
                    #clockJVT#  = Bangkok         7
                    #clockJST#  = Tokyo           9
                    #clockAEST# = Sydney          11
                    #clockNZT#  = Auckland        12
                    #clockNAT#  = Tonga          -11
                    #clockAHST# = Hawaii         -10
                    #clockPST#  = Seattle        -7
                    #clockCST#  = Mexico         -5
                    #clockEST#  = New York       -4
                    #clockBZT#  = Reo de Janeiro -3
            */  
            
            function calcTime(city, offset) {

                // create Date object for current location
                d = new Date();

                // convert to msec
                // add local time zone offset 
                // get UTC time in msec
                utc = d.getTime() + (d.getTimezoneOffset() * 60000);

                // create new Date object for different city
                // using supplied offset
                nd = new Date(utc + (3600000*offset));

                var hrs = nd.getHours();
                var min = nd.getMinutes();
                var sec = nd.getSeconds();

                
                var APM = " "
               /*  Put // infront of this line (and the STAR/ below) if you want to use 12 hour clock insted of 24
                    
                    // Convert the hours component to 12-hour format if needed
                    hrs = ( hrs > 12 ) ? hrs - 12 : hrs;
                    
                    // Choose either "AM" or "PM" as appropriate space is included here otherwise causes a double space in the span when turned off
                    var APM = ( hrs < 12 ) ? " AM" : " PM";
                */
                
                // Pad the minutes and seconds with leading zeros, if required

                hrs = ( hrs < 10 ? "0" : "" ) + hrs;
                min = ( min < 10 ? "0" : "" ) + min;
                sec = ( sec < 10 ? "0" : "" ) + sec;

                // return time as a string
                return "<span class='clockcity'>" + city + "</span>" + "<span class='clocktime'>" + hrs + ":" + min + ":" + sec + "</span>" + "<span class='clockampm'>" + APM + "</span>";
            
            } //End of calcTime
            
            function updateClock ()
            {
                // Check the object exists and Update the time display if it's there

                if (document.getElementById("clockUTC") != null) {
                    document.getElementById("clockUTC").innerHTML = calcTime("UK ",0);
                    }
                if (document.getElementById("clockGMT") != null) {
                    document.getElementById("clockGMT").innerHTML = calcTime("London ",0);
                    }
                if (document.getElementById("clockBEL") != null) {
                    document.getElementById("clockBEL").innerHTML = calcTime("Belgium ",1);
                    }
                if (document.getElementById("clockMET") != null) {
                    document.getElementById("clockMET").innerHTML = calcTime("Paris ",1);
                    }
                if (document.getElementById("clockEET") != null) {
                    document.getElementById("clockEET").innerHTML = calcTime("Cape Town ",2);
                    }
                if (document.getElementById("clockBGT") != null) {
                    document.getElementById("clockBGT").innerHTML = calcTime("Moscow ",3);
                    }
                if (document.getElementById("clockIST") != null) {
                    document.getElementById("clockIST").innerHTML = calcTime("India ",4.5);
                    }
                if (document.getElementById("clockJVT") != null) {
                    document.getElementById("clockJVT").innerHTML = calcTime("Bangkok ",7);
                    }
                if (document.getElementById("clockJST") != null) {
                    document.getElementById("clockJST").innerHTML = calcTime("Tokyo ",9);
                    }
                if (document.getElementById("clockAEST") != null) {
                    document.getElementById("clockAEST").innerHTML = calcTime("Sydney ",11);
                    }
                if (document.getElementById("clockNZT") != null) {
                    document.getElementById("clockNZT").innerHTML = calcTime("Auckland ",12);
                    }
                if (document.getElementById("clockNAT") != null) {
                    document.getElementById("clockNAT").innerHTML = calcTime("Tonga ",-11);
                    }
                if (document.getElementById("clockAHST") != null) {
                    document.getElementById("clockAHST").innerHTML = calcTime("Hawaii ",-10);
                    }
                if (document.getElementById("clockPST") != null) {
                    document.getElementById("clockPST").innerHTML = calcTime("Seattle ",-7);
                    }
                if (document.getElementById("clockCST") != null) {
                    document.getElementById("clockCST").innerHTML = calcTime("Mexico ",-5);
                    }
                if (document.getElementById("clockEST") != null) {
                    document.getElementById("clockEST").innerHTML = calcTime("New York ",-4);
                    }
                if (document.getElementById("clockBZT") != null) {
                    document.getElementById("clockBZT").innerHTML = calcTime("Reo de Janeiro ",-3);
                    }
            }  //End of updateClock

            
            //This function to keep the clock ticking.
            setclockinter = function ()
            {
                setInterval('updateClock()', 1000 )
            }

            // Determin browser version and add to Events
            if (window.addEventListener){
                    window.addEventListener("DOMContentLoaded",updateClock,false);
                    window.addEventListener("DOMContentLoaded",setclockinter,false);
                } 
                else if (window.attachEvent)
                {
                    window.attachEvent("onload", updateClock);
                    window.attachEvent("onload", setclockinter);
            } 