var eval_json = function(data){
    return eval("(" + data + ")");
};

var hotspots_counter = 59;

var ClassHotspots = function(){};
ClassHotspots.prototype = {
    
    initialize: function() {
       window.hotspots.initialize_counter();
    },
    get_hotspots: function(e) {
        $.get('/site/hotspots_ajax',window.hotspots.get_hotspots_response_handler);
    },
    get_hotspots_response_handler: function(data){
        $("#hotspot_url > ul").fadeOut("slow");
        $("#hotspot_url > ul").html(data);
        $("#hotspot_url > ul").fadeIn("slow");
    },
    initialize_counter: function() {
        hotspots_counter = 29;
        $("#hotspots-counter").html(hotspots_counter);        
        window.setTimeout(window.hotspots.count_down_tick, 1000);
    },
    count_down_tick: function() {
        hotspots_counter -= 1;
        $("#hotspots-counter").html(hotspots_counter);
        if (hotspots_counter == 0){
            hotspots_counter = 29;
            $("#hotspots-counter").html(hotspots_counter);
            window.hotspots.get_hotspots();
            
        }
        window.setTimeout(window.hotspots.count_down_tick, 1000);
        
    }
 };


$(document).ready(function(){
    window.hotspots = new ClassHotspots();
    window.hotspots.initialize();
});