var w = window, 
    d, 
    intervalNum = 0, 
    day = new Array('So','Mo','Di','Mi','Do','Fr','Sa'),
    now, 
    sec, 
    min, 
    hour, 
    date;

/****************  design configuration  ******************/

var radius           = 28;
var dateColor        = '#3366CC';
var digitColor       = '#3366CC';
var hHandBorderColor = '#3366CC';
var hHandColor       = '#3366CC';
var mHandBorderColor = '#3366CC';
var mHandColor       = '#3366CC';
var sHandColor       = '#3366CC';
var topPadding       = 8;     // the clock's spacing to the top of the page. Must be null to vertical-center the clock automatically
var xOffset          = null;      // horizontal offset from the page´s center in pixels

/*** don't change anything below this line if you aren't shure about the consequences :) ***/


if (parent && parent.radius && parent.radius != '') radius = parent.radius;

var digitW = Math.floor(radius*.03)*2;
var digitL = Math.round(radius/5);
var hHandW = Math.round(radius*.06)*1;
var mHandW = Math.round(radius*.04)*2;
var sHandW = Math.round(Math.round(radius*.05)*2);
var hHandL = Math.round(radius*4/5);
var mHandL = Math.round(radius+(digitL-mHandW)/2);
var dateSiz = radius/4;
var dateHtm = new Array('<nobr><font color="'+dateColor+'" face="verdana,geneva,sans-serif" style="font-size1:'+dateSiz+'px;"><b>','<\/b><\/font><\/nobr>');
if (digitW<1) digitW = 1;
if (hHandW<1) hHandW = 1;
if (mHandW<1) mHandW = 1;
if (sHandW<1) sHandW = 1;
if (dateSiz<3) dateSiz = 3;

/************  end design configuration  *********************/




function TIME()
{
    now = new Date();
    sec = Math.round(now.getSeconds());
    min = now.getMinutes();
    hour = (now.getHours())%12 + min/60;
    date = day[now.getDay()] + ' ' + now.getDate() + '. ' + (now.getMonth()+1) + '.';
}
TIME();




function W(init,fin,id,lat,color)
{
    for (var i=init; i<fin; i++) 
    {
        c += DIV(id+i,
                 Math.round(xCentr-lat/2), 
                 Math.round(yCentr-lat/2),
                 Math.round(lat),
                 Math.round(lat),
                 color
                 );
    }             
    return;
}




function DIV(id, left, top, width, height, color)
{
    var y = '<div';
    if (id != null) y += ' id="' + id + '"';
    y += ' style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
    y += 'width:' + width + 'px;height:' + height + 'px;';
    y += 'clip:rect(0,' + width + 'px,' + height + 'px,0);';
    if (d.layers)
    {
        y += 'layer-background-color:' + color;
    }    
    else
    {
        y += 'overflow:hidden;background:' + color;
    }
    y += ';"><\/div>';
    return y;
}




function DATE()
{
    if (d.layers)
    {
        with (d.Datum.document)
        {
            open(); write(dateHtm[0] + date + dateHtm[1]); close();
        }
    }
    else
    {
        var dD = (d.all)? Datum : (d.getElementById)? d.getElementById('Datum') : null;
        if (dD!=null)
        {
            if ( dD.innerHTML) dD.innerHTML = dateHtm[0] + date + dateHtm[1];
            else if (hour<1 && min<1 && sec<5) location.reload();
        }
    }
    return;
}




function POS(id,lat,ang,init,fin)
{
    for(var i=init; i<fin; i++)
    {
        var x = (d.layers)? d.layers[id+i] : (d.all)? eval(id+i+'.style') : (d.getElementById)? d.getElementById(id+i).style : null;
        x.left = Math.round(xCentr - lat/2 + Math.sin(ang)*i);
        x.top = Math.round(yCentr - lat/2 - Math.cos(ang)*i);
    }
    return;
}




function HAND()
{
    if (sec==0 || intervalNum==0)
    {
        POS('M', mHandW, min*6/57.2958, 0, mHandL);
        POS('MI', mHandW-2, min*6/57.2958, 1, mHandL-1);
        if (Math.round(min%5)==0 || intervalNum==0)
        {
            POS('H', hHandW, hour*30/57.2958, 0, hHandL);
            POS('HI', hHandW-2, hour*30/57.2958, 1, hHandL-1);
        }
    }
    POS('S', sHandW, sec*6/57.2958, Math.round(radius-sHandW/2), Math.round(1+radius-sHandW/2));
    return;
}




function ADMIN()
{
    TIME();
    if (intervalNum==0 || (hour<1&&min<1&&sec<5)) DATE();
    HAND();
    intervalNum = 1;
    w.setTimeout('ADMIN()', 50);
}
