    // File list routines
function fileWindow(filestorage,file)  {
    if (file.length!=0) {
        vmrl = window.open('','fileview','location=0,menubar=0,resizable=yes,status=0,menubar=no,width=400,height=500,scrollbars=no');
        vmrl.document.write('<html><head><title></title></head><body bgcolor="#ffffff" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">');
        vmrl.document.write('<table border="0" cellpadding="15" cellspacing="7" width="100%" height="100%" align="center" bgcolor="#CECECE"><tr><td bgcolor="#FFFFFF" valign="middle" align="center">');
        vmrl.document.write('<a href="javascript: window.close()" title="Click to close"><img src="'+filestorage+file+'" border=0></a>');
        vmrl.document.write('</td></tr></table>');
        vmrl.document.write('</body></html>');
        vmrl.focus();
    }
}

    // File list routines
    function doChangeAll(form, state) {
        for (var i = 0; i < form.elements.length; i++) {
            var e = form.elements[i];
            if (e.name != 'check_all' && e.type == 'checkbox')
                e.checked = state;
        }
    }

    function doSelectAll(form) {
        doChangeAll(form, form.elements['check_all'].checked);
    }

    function syncSelected(form, element) {
        var checkAll = form.elements['check_all'];
        if (element.checked) {
            var allChecked = true;
            for (var i = 0; i < form.elements.length; i++) {
                var e = form.elements[i];
                if (e.name != 'check_all' && e.type == 'checkbox' && !e.checked) {
                    allChecked = false;
                    break;
                }
            }
            checkAll.checked = allChecked;
        }
        else {
            if (checkAll.checked)
                checkAll.checked = false;
        }
    }

    function doDeleteSingleFile(form, element) {
        if (confirm('Are you sure ?')) {
            doChangeAll(form, false);
            element.checked = true;
            form.elements['event'].value = 'DeleteFiles';
            form.submit();
        }
    }

    function checkSelected(form, event, message) {
        for (var i = 0; i < form.elements.length; i++) {
            var e = form.elements[i];
            if (e.name != 'check_all' && e.type == 'checkbox' && e.checked) {
                if (confirm('Are you sure ?')) {
                form.elements['event'].value = event;
                form.submit();
                return;
                }
                else {
                return;
                }
            }
        }
        alert(message);
    }

    // Preview dialog routines
    function PreviewDlg(id) {
        window.open('preview.dlg.php?id=' + id,
            'PreviewDlg', 'height=400,width=400,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=1');
    }

       // File list dialog routines
    function FilesDlg(form, element,directory) {
        window.open('?__page=filestoragedlg&isOpen=1&form=' + form + '&element=' + element + '&directory=' + directory,
            'FilesDlg', '');
    }

    function FilePreview(fieldname,filestorage) {
       str='tmp=document.editform.'+fieldname+'.value;';
       eval(str);
      if (tmp.length!=0) 
        window.open(filestorage+tmp,'win2','menubar=no,width=400,height=400,scrollbars=yes');
    }

    
    // File list dialog routines
    function UploadDlg(directory, element, form) {
        document.location.href='?__page=uploaddlg&directory=' + directory+"&form="+form+"&element="+element;//,
            //'UploadDlg', 'height=105,width=325,status=no,toolbar=no,menubar=no,location=no,resizable=yes';
    }

    function FilesDlg_View(appPath) {
                var selectedIndex = document.hiddenForm.fileList.selectedIndex;
                if (selectedIndex != -1) {
                    window.open(appPath + document.hiddenForm.fileList.options[selectedIndex].value,
                        'Viewer', '');
                }
    }

    function FilesDlg_Cancel() {
                window.close();
    }


    // File list dialog routines
    function CancelUploadDlg(directory, element, form) {
        document.location.href='?__page=filestoragedlg&directory=' + directory+"&form="+form+"&element="+element;//,
            //'UploadDlg', 'height=105,width=325,status=no,toolbar=no,menubar=no,location=no,resizable=yes';
    }



    function EditorDlg() {
        window.open('editor/deditor.html', 'EditorDialog',
            'height=500,width=600,status=no,toolbar=no,menubar=no,location=no,resizable=yes');
    }

    // Confirm functionality

    function DoDelete(formName) {
        if (confirm('Are you sure ?')) {
            document.forms[formName].elements['event'].value = 'delete';
            document.forms[formName].submit();
        }
    }
    function DoNoFormDelete(target) {
        if (confirm('Are you sure ?')) {
            document.location.href = target;
        }
    }
    
    function ChkPsw(f) {
        if((f.userPassword.value==f.userPassword1.value) && (f.userPassword.value!='')) return true;
        else {
            alert('Fields \'Password\' and \'Confirm password\' should coincide');
            return false;
        }
    }

    function printwin(url_win){
        print_window=window.open(url_win,'win2','menubar=yes,width=600,height=600,scrollbars=yes'); 
        return false;
    }
    
    function pr(){
        a=1
        print();
    }
    
    function cb_SaveFilePath(form, element, value) {    
     document.forms[form].elements[element].value = value;
    }
    
    
    function cb_LoadContent(form, element, value) { 
      return document.forms[form].elements[element].value;
    }

    function cb_SaveContent(form, element,value) {
                 document.forms[form].elements[element].value = value;
    }
    
    function ClearField(form, element) {
     document.forms[form].elements[element].value ="";
    }
    


