function callTreePopup(selector_name, class_select, folder_select)
{
    var category_id = 0;
    var selector;

    if (document.form1)
    	selector = document.form1.elements[selector_name];
    else
    	selector = document.getElementById(selector_name);
	if(selector != null && selector.options[0] != null)
        category_id = selector.options[0].value;

	if(class_select == null) class_select = 1;
	if(folder_select == null) folder_select = 1;

    top.newWin = window.open('../common/folderstree_popup.php?folder_select='+folder_select+'&class_select='+class_select+'&edit_select=1&category='+category_id+'&selector_name='+selector_name, 'tree',
        'dependent=yes,width=450,height=430,screenX=200,screenY=300,titlebar=yes, scrollbars=yes,status=yes,resizable=yes');
    return false;
}

function callTreeViewPopup(selector_name, class_select, folder_select, try_admin_mode)
{
    var category_id = 0;
    if (document.form1)
    	selector = document.form1.elements[selector_name];
    else
    	selector = document.getElementById(selector_name);

    if(selector != null && selector.options[0] != null)
        category_id = selector.options[0].value;

	if(class_select == null) class_select = 1;
	if(folder_select == null) folder_select = 1;

    top.newWin = window.open('../common/folderstree_popup.php?folder_select='+folder_select+'&class_select='+class_select+'&view_select=1&category='+category_id+'&selector_name='+selector_name+'&try_admin_mode='+try_admin_mode, 'tree',
        'dependent=yes,width=450,height=430,screenX=200,screenY=300,titlebar=yes, scrollbars=yes,status=yes,resizable=yes');
    return false;
}

function addTreeCategory(category_id, category_aggregation, category_name, selector_name)
{
	if(selector_name == null || selector_name == '')
		selector_name = 'cat_id';

	if (document.form1)
    	selector = document.form1.elements[selector_name];
    else
    	selector = document.getElementById(selector_name);

	selector.options[0] = new Option(category_name, category_id, false, false);
    selector.options[0].selected = true;

    //delete_button = document.getElementById("delete_" + selector_name);
    //document.getElementById("delete_" + selector_name).style.display = "inline";
    return true;
}

function onSubmit(form, selector_name) {
	if(selector_name == null || selector_name == '') selector_name = 'cat_id';
    form.elements[selector_name].options[0].selected = true
}

function EnableFolderSelect(){
    var sel = document.form1.elements["cat_id"];
    var btn = document.form1.elements["select_cat"];
    sel.disabled = false;
    btn.disabled = false;
}

function DisableFolderSelect(){
    var sel = document.form1.elements["cat_id"];
    var btn = document.form1.elements["select_cat"];
    sel.disabled = true;
    btn.disabled = true;
}
