//<!--
var gid, tid, isec
function setUpdate(){ update(0); tid = setTimeout("update(1)", 1000 * 60); }
function update(p){
    var dt = new Date()
    isec = parseInt(dt.getTime() / 1000)
    if(p){
        updateGraph(isec)
    }
}
function updateGraph(i){
    if(i == 0) return;
    window.status = 'Refreshing Data..';
    reload_graph(1);
    $('img#t_inf2').attr('src', 'inf/41?' + isec);
    $('div#page_head_temp').load('load_table_current', function(){});
    $('div#block_stat_main').load('load_table_stat', function(){});
    $.get("data.txt?" + i, function(data){
        document.title = 'termo.tomsk.ru - Температура в г.Томске: ' + data.substr(0, 10);
    });
    window.status = 'http://termo.tomsk.ru';
    setUpdate();
}
function reload_graph(is_update){
    var src = 'img/' + $('table#table_graph_head td.sel').attr('id') + '?' + isec;
    if(!is_update) $('img#graph').hide();
    $('img#graph').attr('src', src);
}
function p_load(){
    $('img#graph').bind('load', function(){
        $(this).fadeIn();
    });
    $('table#table_graph_head td.tab').mouseover(function() {
        $(this).addClass('over');
    }).mouseout(function() {
        $(this).removeClass('over');
    }).click(function(){
        $('table#table_graph_head td.sel').removeClass('sel');
        $(this).addClass('sel');
        reload_graph(0);
    });
    window.status = 'http://termo.tomsk.ru';
    setUpdate(); 
}
$(document).ready(p_load);
//-->
