/*
 * Плагин для обратного отсчета
 * 2011, Бронников Саша (alexandr.brn@gmail.com)
*/
    jQuery.fn.datetimer = function(opt){

        var opt = jQuery.extend({
            start : 1,//начальное время в секундах
            stop : 10 //конечное время в секундах
    },opt);
        
    
    var timerBlock = this;

    var hour = (opt.stop/3600);
    var minut = hour*60;
    //var second = (opt.stop/);
    var dates = new Date(opt.stop*1000);
    var minut = 0;
    var second = 0;
    var hour = 0;
    var day = 0;

    setInterval(function(){
    
        dates.setUTCSeconds(dates.getUTCSeconds()-1);
        
        result = "";
        second = dates.getSeconds();
        minut = dates.getMinutes();
        day = dates.getDate();
        //hour = parseInt(((Math.round(day))*24)+dates.getHours());
        
        hour = Math.round(opt.stop/3600);
        opt.stop -= 1;
        

        if(day > 0){
            //result+=day+"   ";
        }

        if(hour < 10){
            hour="0"+hour;
        }

        if(hour > 0){
            result+=hour+":";
        }

        result+=minut+"";


        if(second < 10){
            second="0"+second;
        }

    result+= "<small>:"+second+"</small>";
    $(timerBlock).html(result);

    }, 1000);

}


