function CurrentTime(containerNode, startTimeStamp, timeFormat) {
    var self = this,
        timer,
        weekDays = ["niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"],
        months = ["styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"],
        now = new Date(),
        prevTickTimeStamp,
        currTickTimeStamp;
        

    function addLeadingZero(v) {
        var s = v < 0 ? "-" : "";
        v  = Math.abs(v);

        return s + (v < 10 ? "0" + v : v);
    }

    function generateTimeString24H() {
	return addLeadingZero(now.getUTCHours()) + ":" + addLeadingZero(now.getUTCMinutes()) + ":"
	     + addLeadingZero(now.getUTCSeconds()) + ", " + weekDays[now.getUTCDay()] + " " + addLeadingZero(now.getUTCDate()) + ", " + months[now.getUTCMonth()] + " "
	     + now.getUTCFullYear();
    }

    function generateTimeString12H() {
	var hours = now.getUTCHours(),
	    dayPart = "AM";

	if (hours > 12) {
		hours -= 12;
		dayPart = "PM";
	}
    if (hours == 0) {
        hours = 12;
    }
	return addLeadingZero(hours) + ":" + addLeadingZero(now.getUTCMinutes()) + ":"
	     + addLeadingZero(now.getUTCSeconds()) + " " + dayPart + ", " + weekDays[now.getUTCDay()] + " " + addLeadingZero(now.getUTCDate()) + ", " + months[now.getUTCMonth()] + " "
	     + now.getUTCFullYear();
    }

    function secondTick() {
        currTickTimeStamp = new Date().getTime();
        now.setTime((currTickTimeStamp - prevTickTimeStamp) + startTimeStamp);

        containerNode.nodeValue = self.timeFormat == CurrentTime.F24 ? generateTimeString24H() : generateTimeString12H();
    }

    this.timeFormat = typeof timeFormat == "undefined" ? CurrentTime.F24 : timeFormat;

    this.start = function () {
        clearInterval(timer);
        prevTickTimeStamp = (new Date()).getTime();
        timer = setInterval(secondTick, 1000);
    }
}

CurrentTime.F24 = 0;
CurrentTime.F12 = 1;

CurrentTime.setTimeFormat = function (timeFormat) {
	this.timeFormat = timeFormat;
}

CurrentTime.getTimeFormat = function () {
	return this.timeFormat;
}