$.ajaxSetup({cache: false});

function format(s) {
    m = 0;
    while(s >= 60) {
        m++;
        s -= 60;
    }

    s_fixed = s.toFixed(1);
    if (m == 0)
        return s_fixed;

    if (s_fixed.length < 4)
        s_fixed = "0" + s_fixed;

    h = 0;
    while(m >= 60) {
        h++;
        m -= 60;
    }

    m_fixed = m.toFixed(0);
    if(h == 0)
        return m_fixed + ":" + s_fixed;

    if (m_fixed.length < 2)
        m_fixed = "0" + m_fixed;

    h_fixed = h.toFixed(0);

    return h_fixed + ":" + m_fixed + ":" + s_fixed;
}

function format_date(dt) {
    month = dt.getMonth() + 1;
    day = dt.getDate();
    year = dt.getFullYear();
    hours = dt.getHours();
    mins = dt.getMinutes();
    secs = dt.getSeconds();

    formatted = month + "/" + day + "/" + year;
    return formatted;
    //return dt.toLocaleString();
}

function init_tags_autocomplete(input) {
    $.getJSON("/tags", "", function(data) {
        input.autocomplete(data,
        {
            delay: 10,
            minChars: 0,
            multiple: true,
            highlightItem: true,
            multipleSeparator: " "
        });
    });
}


