/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function Tick(){
    $('.time-tracker').each(function(index, value){
        var h = parseInt($(value).find('span.hour').text().replace('h', ''),10);
        var m = parseInt($(value).find('span.minutes').text().replace('m',''),10);
        var s = parseInt($(value).find('span.seconds').text().replace('s', ''),10);
        if(h > 0){
            if(s > 0){
                s--;
                if(s < 10){
                    s = '0' + s;
                }
            }else{
                s=59;
                if(m > 0){
                    m--;
                    if(m < 10){
                        m = '0' + m;
                    }
                }else{
                    m=59;
                    if(h > 0){
                        h--;
                        if(h < 10){
                            h = '0' + h;
                        }
                    }
                }
            }
            
        }

        if(h <= 0 && m <= 0 && s <= 0){
            location.reload(true);
        }

        if(h < 10){
            h = '0' + h;
        }
        if(m < 10){
            m = '0' + m;
        }
        if(s < 10){
            s = '0' + s;
        }
        $(value).find('span.hour').text(h + 'h');
        $(value).find('span.minutes').text(m + 'm');
        $(value).find('span.seconds').text(s + 's');

    });
}

$(window).load(function(){
    setInterval(function(){
        Tick();
    }, 1000);
});



