<!--
/* --------------------- Copyright Marcin Zadęcki - WSZYSTKIE PRAWA ZASTRZEŻONE --------------------- */
/* ---------- Wykorzystywanie całości lub fragmentów kodu wyłącznie za zgodą Marcin Zadęcki --------- */
// ---------- Funkcja antyspam do wysyłania e-mail'a ----------- //
function sendEmail(sAlias, sDomain)
{
    if(sAlias != '' && sDomain != '') window.open('mailto:'+sAlias+'@'+sDomain, '_blank');
    return;
}
function switchClasses()
{
    var n             = this.className;
    this.className    = this.altClassName;
    this.altClassName = n;
}
function setRowHover(sClassLight, sClassHoverLight, sClassDark, sClassHoverDark)
{
    var oTR = document.getElementsByTagName('tr');
    if(!oTR) return;
    if(!sClassHoverDark) sClassHoverDark = sClassHoverLight;
    for (var i = 0; i < oTR.length; i++)
    {
        if(sClassLight != '' && oTR[i].className.indexOf(sClassLight) != -1)
        {
            oTR[i].onmouseover  = switchClasses;
            oTR[i].onmouseout   = switchClasses;
            oTR[i].altClassName = oTR[i].className+' '+sClassHoverLight;
        }
        if(sClassDark != '' && oTR[i].className.indexOf(sClassDark) != -1)
        {
            oTR[i].onmouseover  = switchClasses;
            oTR[i].onmouseout   = switchClasses;
            oTR[i].altClassName = oTR[i].className+' '+sClassHoverDark;
        }
    }
}
//Date - Time
function setDateProp(oDate)
{
    this.year    = oDate.getFullYear();
    this.month   = oDate.getMonth()+1;
    this.day     = oDate.getDate();
    this.hour    = oDate.getHours();
    this.minutes = oDate.getMinutes();
    this.seconds = oDate.getSeconds();
    this.zone    = oDate.getTimezoneOffset();
    this.time    = oDate.getTime();
    return this;
}
function setEstDateProp()
{
    var oDate    = new setDateProp(new Date());
    var oGmtDate = new setDateProp(new Date(oDate.time+(oDate.zone*60*1000)));
    return new setDateProp(new Date(oGmtDate.time-(4*60*60*1000)));
}
function dateFormat(oDate)
{
    var sYear    = new String(oDate.year);
    var sMonth   = new String(oDate.month);
    var sDay     = new String(oDate.day);
    var sHour    = new String(oDate.hour);
    var sMinutes = new String(oDate.minutes);
    var sSeconds = new String(oDate.seconds);
    //Date parts formating
    if(sMonth.length   == 1) sMonth   = '0'+sMonth;
    if(sDay.length     == 1) sDay     = '0'+sDay;
    if(sHour.length    == 1) sHour    = '0'+sHour;
    if(sMinutes.length == 1) sMinutes = '0'+sMinutes;
    if(sSeconds.length == 1) sSeconds = '0'+sSeconds;
    return sYear+'-'+sMonth+'-'+sDay+' '+sHour+':'+sMinutes+':'+sSeconds;
}
function setContestTimer()
{
    var oEstNow    = setEstDateProp();
    var oEnd       = new Date(2007, 4, 1, 18, 0, 0);
    var iSecToEnd  = Math.floor(Math.abs(parseInt((oEnd.getTime()-oEstNow.time)/1000)));
    var iSecInDay  = 60*60*24;
    var iSecInHour = 60*60;
    var iSecInMin  = 60;
    var iSecLeft   = iSecToEnd;
    var iDays      = Math.floor(iSecLeft/iSecInDay);
    iSecLeft      -= iDays*iSecInDay;
    var iHours     = Math.floor(iSecLeft/iSecInHour);
    iSecLeft      -= iHours*iSecInHour;
    var iMinutes   = Math.floor(iSecLeft/iSecInMin);
    var iSeconds   = iSecLeft-(iMinutes*iSecInMin);
    document.getElementById('timer_days').innerHTML    = (new String(iDays).length    == 1 ? ('0'+iDays)    : iDays);
    document.getElementById('timer_hours').innerHTML   = (new String(iHours).length   == 1 ? ('0'+iHours)   : iHours);
    document.getElementById('timer_minutes').innerHTML = (new String(iMinutes).length == 1 ? ('0'+iMinutes) : iMinutes);
    document.getElementById('timer_seconds').innerHTML = (new String(iSeconds).length == 1 ? ('0'+iSeconds) : iSeconds);
    return;
}
function runClock()
{
    document.getElementById('user_time').innerHTML = dateFormat(new setDateProp(new Date()));
    document.getElementById('est_time').innerHTML  = dateFormat(setEstDateProp());
//    setContestTimer();
    clockTimerID = window.setTimeout(function() {runClock()}, 1000);
}
//-->
