var myfont_webfont_test = false;
var woffEnabled = true;

function slideSwitch() {
    var $active = $('#topscreen img.active');
    if ( $active.length == 0 ) $active = $('#topscreen img:last');
    var $next =  $active.next().length ? $active.next() : $('#topscreen img:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

function showClock(set, t1, t2) {
    if (($("#ot").val() != undefined) && ($("#ot").val() != undefined)) {


        var thetime=new Date();
        var nhours=thetime.getHours();
        var nmins=thetime.getMinutes();
        var nsecn=thetime.getSeconds();
        if (nhours<10) nhours="0"+nhours;
        if (nsecn<10) nsecn="0"+nsecn;
        if (nmins<10) nmins="0"+nmins;
        //if (((nhours==0) && (nmins==0) && (nsecn==0)) && (document.location.href == $("#www").val())) location.reload(true);
        $("#actualtime").html(nhours+":"+nmins+":"+nsecn);
        if (($("#actualdate").html() == '01.05.2011') && ((nhours >= 8) && (nhours < 17))) {
            $("#poh").html("Zatvorené pre konanie medzinárodného workshop-u.").addClass("cred");
            $("#opentime").html("<br /><b>pohotovosť od 17:00 hod.</b>");
            return;
        } 

        if (((nmins==0) && (nsecn==0)) || (set)) {
            $("#actualdate").html((thetime.getDate()<10?"0":"")+thetime.getDate()+"."+((thetime.getMonth()+1)<10?"0":"")+(thetime.getMonth()+1)+"."+thetime.getFullYear());
            $.getJSON('/pages/get_bt.php?val=?', function(data) {
                if ((data.ot == "00:00") && (data.ct=="00:00")) {
                    if (data.cl == 1) {
						$("#timetxt").html("");
                        $("#opentime").html("dnes zatvorené celý deň");
                    }else {
                        $("#opentime").html("iba pohotovosť");
                    }
                }else{
                    if (data.cl == 1) {
						$("#timetxt").html("");
                        $("#opentime").html("dnes zatvorené v čase od "+data.ot+" - "+data.ct);
                    }else {				
						$("#opentime").html(data.ot+" - "+data.ct);
					}
                }
                $("#ot").val(data.ot);
                $("#ct").val(data.ct);
                $("#cl").val(data.cl);
            });
        }
        var todayx = new Date();
        t1s = $("#ot").val().split(":");
        t2s = $("#ct").val().split(":");
        var open = new Date(todayx.getFullYear(),todayx.getMonth(),todayx.getDate(),t1s[0],t1s[1],0,0);
        var close = new Date(todayx.getFullYear(),todayx.getMonth(),todayx.getDate(),t2s[0],t2s[1],0,0);
        if ((todayx>=open) && (close>todayx)) {
            $(".otv").removeClass("dn").addClass("db");
            $(".poh").removeClass("db").addClass("dn");
			
        } else {
            $(".otv").removeClass("dn");
            $(".poh").removeClass("dn");
            $(".zat").removeClass("dn");
            if ($("#cl").val() == 1) {
                $(".zat").addClass("db");
				$(".otv").addClass("dn");
				$(".poh").addClass("dn");
            
            } else {
                $(".poh").removeClass("dn").addClass("db");
                $(".otv").removeClass("db").addClass("dn");
            }
        }
    }
}

$(function() {
    var thetime=new Date();
    var t1=$("#st").val();
    var t2=$("#et").val();
    showClock(true,t1,t2);
    $("#actualdate").html((thetime.getDate()<10?"0":"")+thetime.getDate()+"."+((thetime.getMonth()+1)<10?"0":"")+(thetime.getMonth()+1)+"."+thetime.getFullYear());
    setInterval( "slideSwitch()", 10000 );
    setInterval( "showClock(false,'"+t1+"','"+t2+"')", 1000 );
});






