$(document).ready(function()
{
    var tt_selector = ".Calendar";
    var tt_daySelector = ".tt-week";
    
    
    var tt_calWidth = $(tt_selector).css('width');
    if(tt_calWidth == null)
    {
        tt_selector = ".Timeboard";
        tt_calWidth = $(tt_selector).css('width');
        tt_daySelector = ".tt-tboardcol";
    }
    
    if(tt_calWidth != null)
    {
        var tt_width = $(".tt-col").first().css('width');
        
        tt_width = tt_width.substring(0, tt_width.length -2);
        tt_calWidth = tt_calWidth.substring(0, tt_calWidth.length -2) -80;
        
        var tt_days = $(".tt-col").size() / $(tt_daySelector).size();
        
        $("input[name*='tt-width']").keyup(function()
        {
            if($(this).val() > 0)
            {
                var n = Math.round($(this).val());
                var w = Math.round(tt_width / 100 * n);
                
                $(tt_selector).css('width', (tt_days * w) + 80);
                
                $(".tt-col").css('width', w);
                $(".tt-colcontent").css('width', (w -2) + "px");
                $(".tt-event").css('width', (w -2) + "px");
                $(".tt-eventborder").css('width', (w -2) + "px");
                $(".tt-background").css('width', (w -2) + "px");
                
                $(tt_daySelector).each(function()
                {
                    $(this).children(".tt-eventborder").css('width', (w -2) + "px");
                    $(this).children(".tt-event").css('width', (w -4) + "px");
                    $(this).children(".tt-wdb_header").children().css('width', (w -4) + "px");
                    $(this).children(".tt-wdb_header").children().first().css('width', (w -2) + "px");
                    $(this).children(".tt-wdb_header").children().last().css('width', (w -2) + "px");
                });
            }
        });
    }
});
