﻿// odpocet casu v pruvodci
var IntervalCountDown = 0;

function fmmStartTimeCountDown(Seconds, TimeElementId)
{
    var leave = Seconds;
    var AlertOnTime = 60;
        
    CounterTimer();
    IntervalCountDown = window.setInterval(CounterTimer,1000);

    function CounterTimer()
    {
        var day = Math.floor(leave / ( 60 * 60 * 24))
        var hour = Math.floor(leave / 3600) - (day * 24)
        var minute = Math.floor(leave / 60) - (day * 24 *60) - (hour * 60)
        var second = Math.floor(leave) - (day * 24 *60*60) - (hour * 60 * 60) - (minute*60)

        hour=hour<10 ? "0" + hour : hour;
        minute=minute<10 ? "0" + minute : minute;
        second=second<10 ? "0" + second : second;

        var remain=hour + ":"+minute+":"+second;
        leave=leave-1;

        $(TimeElementId).html(remain);
        
        if(leave == AlertOnTime-1 || leave < AlertOnTime - 1)
        {
            // co se ma stat minutu pred koncem. Alert to byt nemuze nebot stopne odpocet. Zobrazeni hlasky prehozenim CSS display?
            $(TimeElementId).html(remain + "<div class='TimeCountdownAlert'>Zbývá poslední minuta!</div>");
        }
        if(leave == -1)
        {
            window.clearInterval(IntervalCountDown);
            window.location.href = "/error-timeout.aspx";
        }
    }
}

function fmmStopTimeCountDown(TimeElementId, TimeElementLabelId) {
    $(TimeElementLabelId).css("display", "none");
    $(TimeElementId).html("");
    window.clearInterval(IntervalCountDown);
}

// cufon
$(document).ready(function () {
});

function pageLoad() {
    // CUFON
    Cufon.replace('h2');

	// crolling text - cekaci doby
    $(function() {
        $("#cekaciDobyMarqueee").marqueee();
	});
    
    // validatory
    $('.validation_message').click(function () {
        $(this).css("display", "none");
        $(this).prev('input').focus();
    });
    $('.validation_box').click(function () {
        $(this).focus(function () { $(this).next('.validation_message').css("display", "none"); });
    });
    $('.validation_box').focus(function () {
        $(this).next('.validation_message').css("display", "none");
    });

    // pridani tooltip i do aktivniho kliku v kalendari
    $('.datePicker .dateView .calDen a').attr("title", function () { return $(this).parent("td.calDen").attr("title") });
}
