$(function() {
if ($('#id').val() == '0') { $('#file16').attr('disabled', false); }
if ($('#newtasktype').val()=="True")
    $.post(base + "tasktype.ivp/removesession");
$("form").validate();
});


function setTab(id) {
    if (!documentReady) return;
    $('#tab').val(id);
    $('.tab').each(function(i, el) { if (el.id == id) $(el).show(); else $(el).hide(); });
    $('#tabid').val(id);
    $('#tabs>ul>li>a').each(function(i, el) { if (el.id == 'a' + id) $(el).addClass('selected'); else $(el).removeClass('selected'); });
    if (id != 'general') {
        $('.save').attr('disabled', true);
        $('.saveandreturn').attr('disabled', true);
    }
    else {
        $('.save').attr('disabled', false);
        $('.saveandreturn').attr('disabled', false);
    }
    return false;
}

function loadFields(reload) {
    DisableSaveButtons();
    if (reload || !$.trim($('#fields').html())) {
        $('#fields').load(base + 'tasktypefield.ivp/list', { tb_tasktypeid: $('#id').val(), reset: true, timestamp: new Date().toString() }, function() { setTab('fields'); initTable(); });
    }
    else setTab('fields');
    return false;
}

function editField(id) {
    var url = id ? 'tasktypefield.ivp/view/' + id : 'tasktypefield.ivp/create/'+$('#id').val();
    openDialog(url, 'field', { width: 800, height: 490 });
    return false;
}

function selectTaskTypeDescriptionLanguage() {
    var url = 'fieldlanguage.ivp/load?textarea=true&table=TaskTypes&field=DescriptionXml&id=' + $('#id').val();
    openDialog(url, 'selectlanguage', { width: 900, height: 650 });
    return false;
}

function selectTaskTypeNameLanguage() {
    var url = 'fieldlanguage.ivp/load?required=true&table=TaskTypes&field=NameXml&id=' + $('#id').val();
    openDialog(url, 'selectlanguage', { width: 900, height: 650 });
    return false;
}