//weekDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
//months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],

function CurrentTime(containerNode, startTimeStamp) {
    var self = this,
        timer,
        weekDays = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
        months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
        now = new Date(),
        prevTickTimeStamp,
        currTickTimeStamp;

    function addLeadingZero(v) {
        var s = v < 0 ? "-" : "";
        v  = Math.abs(v);

        return s + (v < 10 ? "0" + v : v);
    }

    function generateTimeString() {
        var hours = now.getUTCHours();
        if (hours > 11) {
            hours -= 12;
            dayPart = "PM";
        }else{
            dayPart = "AM";
        }
        if (hours == 0) {
            hours = 12;
        }
        if(hours < 10)
            hours = "0" + hours;
//        return hours + ":" + addLeadingZero(now.getUTCMinutes()) + " " + dayPart + " - " + weekDays[now.getUTCDay()] + ", " + months[now.getUTCMonth()] + " " + now.getUTCDate();

        return hours + ":" + addLeadingZero(now.getUTCMinutes()) + ":" + addLeadingZero(now.getUTCSeconds())
             + " " + dayPart + " - " + weekDays[now.getUTCDay()] + ", " + months[now.getUTCMonth()] + " " + now.getUTCDate() + ", "
             + now.getUTCFullYear();
    }

    function secondTick() {
        currTickTimeStamp = new Date().getTime();

        now.setTime((currTickTimeStamp - prevTickTimeStamp) + startTimeStamp);
        document.getElementById("idtimezone_seoul").innerHTML = generateTimeString();
        if (document.getElementById("idtimezone_newyork") != null){
            now.setTime((currTickTimeStamp - prevTickTimeStamp) + (startTimeStamp - (14 * 60 * 60)*1000));
            document.getElementById("idtimezone_newyork").innerHTML = generateTimeString();
        }
    }

    this.start = function () {
        clearInterval(timer);
        prevTickTimeStamp = (new Date()).getTime();
        secondTick();
        timer = setInterval(secondTick, 1000);
    }
}
