function Topclock() {



    this.idIndex = parseInt(Math.random() * 1000);

    this.imagesPath = 'http://vtoto.ru/img/clock/';


    var currentTime = new Date();
    this.curTime = currentTime.getTime();

    this.styleGeneral = "width:157px; padding:5px 8px; margin:0px; overflow:hidden; ";

    this.styleDate = "font:normal 9px Arial; color:#045f20; margin:0px; padding:0px; height:10px; float:left; display:inline; overflow:hidden; width:55px; text-decoration:none;";

    this.styleSunMoon = "text-decoration:none;font:24px Webdings; font-weight:normal;color:#045f20; margin:0px; padding:0px; height:17px; float:left; display:inline; overflow:hidden; width:20px; text-decoration:none;";

    this.styleCity = "font:normal 10px Arial; color:#7c4900; margin:0px 0px 1px 0px; padding:0px; overflow:hidden; height:10px; text-transform:uppercase; text-decoration:none;";

    this.styleTime = "font:normal 18px Arial; color:#045f20; margin:0px; position:relative; top:-2px; padding:0px; float:left; display:inline; overflow:hidden; width:70px; height:18px; text-decoration:none;";

    this.styleClearBoth = "clear:both; height:7px; overflow:hidden;";

    this.styleTop = 'overflow:hidden; height:' + ((1 * 32) + 5 + (1 - 1) * 5) + 'px; width:160px;background: #a4d49d 0px 0px repeat-x url(' + this.imagesPath + 'bg.png);-background-image:none;';

    this.styleHL = 'width:145px;margin-top:2px;height:1px; border-top:dotted 1px #045f20';

}



Topclock.prototype.__get = function(id, noAddon) {



    if (!noAddon) id += '__' + this.idIndex;

    if (document.layers) { return document.layers[id]; }

    if (document.getElementById) { return document.getElementById(id); }       

    if (document.all) { return document.all[id]; }

}





Topclock.prototype.isDay = function(h) {



    if (h > 21) return false;

    if (h < 9) return false;

    return true;

}



Topclock.prototype.showTime = function() {



    var moon = '&#xF0E0;';//  '&#x263E;';

    var sun = '&#xF0D5;'; // '&#x263E;&#x263C;';



    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){

    

       var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number

       //if (ieversion < 8) {

            

            var moon = '&#x00E0;';

            var sun = '&#x00D5;';

       //}

    }    

    if (navigator.userAgent.toLowerCase().indexOf('safari')!=-1) {

        

        if (navigator.userAgent.toLowerCase().indexOf('chrome') == -1) {

            

            var moon = '';

            var sun = '';

        }

    }



            this.curTime1 = this.curTime1 + 1000;

        var dLocal = new Date();

        dLocal.setTime(this.curTime1 + (dLocal.getTimezoneOffset() * 60000));



        try {

            this.__get('__topclock__timeDate1').innerHTML = dLocal.format("d.m.Y");

            this.__get('__topclock__sunmoon1').innerHTML = this.isDay(dLocal.format("H")) ? sun : moon;

            this.__get('__topclock__time1').innerHTML = dLocal.format("H:i:s");

        } catch (E) {}

    }





Topclock.prototype.render = function() {



    try {

        

        var c = this.__get('top_clock_caption', true);

        c.id += this.idIndex;

        c.innerHTML = ''; 

    } catch (E) {};



    document.write('<style> .__topclock__city { text-align:left; } .__topclock__city a { color:#7c4900; text-decoration:none; } .__topclock__date a { color:#999; text-decoration:none; }  #__topclock__main div a { text-decoration:none !impotrant; } </style> '

        + '<div style="' + this.styleTop + '" id="__topclock__main__' + this.idIndex + '"><div style="' + this.styleGeneral + '">');



    

        this.curTime1 = (this.curTime + 14400000);

        document.write('<div style="' + this.styleCity + '" class="__topclock__city">Москва</div><div id="__topclock__timeDate1__' + this.idIndex + '" style="' + this.styleDate + '" class="__topclock__date"></div><div id="__topclock__sunmoon1__' + this.idIndex + '" style="' + this.styleSunMoon + '"></div><div id="__topclock__time1__' + this.idIndex + '" style="' + this.styleTime + '"></div><div style="' + this.styleClearBoth + '"></div>');

    

    this.showTime();

    var $this = this;

    setInterval(function() { $this.showTime() }, 1000);



    document.write('</div></div>');

}



var topClock = new Topclock();

topClock.render();

