$(document).ready(function()
{
    if(v.mode == 'list')
    {
        /* expand active tree. */
        $('.tree li.active:last .hitarea').click();
    }

    if(v.mode == 'list' || v.mode == 'create' || v.mode == 'edit')
    {
        $('#menu .nav li').removeClass('active').find('a[href*=setssf][href*=list]').parent().addClass('active');
    }

    $('.ssf').change(function()
    {
        var totalPersonal = 0;
        var totalCompany  = 0;
        var moneyList     = $('.amount');
        var companyRates  = $('.companyRate');
        var personalRates = $('.personalRate');
        for(i = 0; i < moneyList.size(); i++)
        {
            if($.isNumeric(moneyList[i].value) && $.isNumeric(personalRates[i].value) && $.isNumeric(companyRates[i].value))
            {
                totalCompany  += parseFloat(moneyList[i].value * companyRates[i].value / 100);
                totalPersonal += parseFloat(moneyList[i].value * personalRates[i].value / 100);
            }
        }

        totalCompany  = formatCurrency(totalCompany, 2, ',');
        totalPersonal = formatCurrency(totalPersonal, 2, ',');

        $('#totalCompany').html(totalCompany);
        $('#totalPersonal').html(totalPersonal);
    });

    $('.ssf:first').change();
});
