home *** CD-ROM | disk | FTP | other *** search
/ ftp.f-secure.com / 2014.06.ftp.f-secure.com.tar / ftp.f-secure.com / support / hotfix / fsav-server / FSAVSRV900_HF07.fsfix / iuwebui / forms / common / commonscripts.js < prev    next >
Text File  |  2010-09-07  |  20KB  |  802 lines

  1.     function clickHelpButton(pane_name)
  2.     {
  3.         if(pane_name == '')
  4.         {
  5.             alert(localized_strings.NoHelpIndex);
  6.             return;
  7.         }
  8.         var h_index = GetHelpContext(pane_name);
  9.         if(h_index == '')
  10.             alert(localized_strings.HelpIndexIsEmpty.replace("%PAGE_NAME%", pane_name));
  11.         else
  12.             window.open(h_index);
  13.     } 
  14.  
  15.     function refreshTabPage(tabname) 
  16.     {
  17.         var tabpage = dojo.widget.byId(tabname)
  18.         if (tabpage) {
  19.             var oldrefresh = tabpage.refreshOnShow;
  20.             tabpage.refreshOnShow = true;
  21.             tabpage.refresh();
  22.             tabpage.refreshOnShow = oldrefresh;
  23.         }
  24.     }
  25.  
  26.     function EnableExtraDialog(dlg_page)
  27.     {
  28.         if( typeof(beforeNodeChange) == 'function')
  29.             beforeNodeChange();
  30.  
  31.         var pane = dojo.widget.byId('lists_dialog');
  32.         dojo.byId('lists_dialog').style.background="#f3f3f3";        
  33.         if (!pane)
  34.             return;
  35.         pane.setUrl(dlg_page);
  36.         pane.show();
  37.     }
  38.  
  39.     function TweakFormEntry(setting_name) 
  40.     {
  41.         eval('document.form.' + setting_name).value = 1;
  42.         document.form.submit();
  43.     }
  44.     function ClickedRestore() 
  45.     {
  46.         document.form.RESTORE_TABLE.value = 1;
  47.         document.form.submit();
  48.     }
  49.     function ClickedEmptyTable(table_name) 
  50.     {
  51.         eval('document.form.EMPTY_TABLE' + table_name).value = 1; 
  52.         document.form.submit();
  53.     }
  54.     function ClickedNewEntry(table_name) 
  55.     {
  56.         eval('document.form.ENTRIES_TABLE' + table_name).value++; 
  57.         document.form.submit();
  58.     }
  59.     function ClickedUpload(table_id) 
  60.     {
  61.         openFrameless('/common/copypaste2.php?' + table_id , 540, 345);
  62.     }
  63.     function UploadContent(content, table_index) 
  64.     {
  65.         document.form.VAR_UPLOAD_CONTENT.value = content;
  66.         if(document.form.VAR_UPLOAD_ID)
  67.             document.form.VAR_UPLOAD_ID.value = table_index;
  68.         document.form.submit();
  69.     }
  70.  
  71.     function setCookie(name, value, expires, path, domain, secure) 
  72.     {
  73.         var curCookie;
  74.         
  75.         if(!expires)  
  76.         { 
  77.             var expires = new Date ();
  78.             expires.setTime (expires.getTime() + 86400000);
  79.             curCookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString();
  80.         }
  81.         else
  82.         {
  83.             curCookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString() +
  84.                 ((path) ? ";path=" + path : "") +
  85.                 ((domain) ? ";domain=" + domain : "") +
  86.                 ((secure) ? ";secure" : "")
  87.         }
  88.  
  89.         document.cookie = curCookie;
  90.     }
  91.     function getCookie(name) 
  92.     {
  93.          var value = null;
  94.         if(document.cookie)       //only if exists
  95.         {
  96.                var arr = document.cookie.split((escape(name) + '=')); 
  97.             if(2 <= arr.length)
  98.                {
  99.                    var arr2 = arr[1].split(';');
  100.                    value  = unescape(arr2[0]);
  101.                }
  102.         }
  103.         return value;
  104.     }
  105.     function deleteCookie(name) 
  106.     {
  107.          var tmp = getCookie(name);
  108.         if(tmp) 
  109.             setCookie(name,"",(new Date(1))); 
  110.     }
  111.  
  112.     function fixDate(date) 
  113.     {
  114.         var base = new Date(0)
  115.         var skew = base.getTime()
  116.         if (skew > 0)
  117.             date.setTime(date.getTime() - skew)
  118.     }
  119.  
  120.     function makeArray(length) 
  121.     {
  122.         this.length = length // length of array (integer)
  123.     }
  124.  
  125.  
  126.     function isValidNumber() 
  127.     {
  128.         if(demo_mode)
  129.             return true;
  130.  
  131.         var numargs = arguments.length;
  132.  
  133.         var retVal = new RegExp("^(\\d{1,})$").test(arguments[0]) ||
  134.                      new RegExp("^(\\d{1,})[.](\\d{1,})$").test(arguments[0]);
  135.         
  136.         if(!retVal)// || RegExp.$1 > 2147483647) // maximum long
  137.             return false;
  138.         
  139.         if(numargs == 1)
  140.             return true;                  // just check is it a number
  141.  
  142.         if(arguments[1] != '' && RegExp.$1 < arguments[1])
  143.             return false;
  144.  
  145.         if(numargs == 2)
  146.             return true;                  // check left bound of the number only
  147.  
  148.         if(arguments[2] != '' && RegExp.$1 > arguments[2])
  149.             return false;
  150.  
  151.         return true;
  152.     }
  153.  
  154.     function isValidHour() 
  155.     {
  156.         if(demo_mode)
  157.             return true;
  158.  
  159.         if(!new RegExp("^(\\d{1,2})$").test(arguments[0]) || arguments[0] > 24)
  160.             return false;
  161.         
  162.         return true;
  163.     }
  164.  
  165.     function isValidMinute() 
  166.     {
  167.         if(demo_mode)
  168.             return true;
  169.  
  170.         if(!new RegExp("^(\\d{1,2})$").test(arguments[0]) || arguments[0] > 60)
  171.             return false;
  172.         
  173.         return true;
  174.     }
  175.  
  176.     function isValidDirName() 
  177.     {
  178.         if(demo_mode)
  179.             return true;
  180.  
  181.         if(navigator.appName.indexOf("Netscape") > -1)
  182.             return true;
  183.         
  184.         if(    !new RegExp('^[a-zA-Z]:\\\\[^:*?"<>|]{0,}$').test(arguments[0]))
  185.         {
  186.             return false;
  187.         }
  188.         return true;
  189.     }
  190.  
  191.     function CheckTable(table_name, control_column) 
  192.     {
  193.         return true;
  194.     
  195.         if(demo_mode)
  196.             return true;
  197.  
  198.         var table_size = eval('document.form.ENTRIES_TABLE' + table_name).value;
  199.  
  200.         // is the table disabled (networked mode) ? 
  201.         if(eval('document.form.VAR_TABLE' + table_name + '__0__' + control_column).disabled == true)
  202.             return true;
  203.  
  204.         for(i = 0; i < table_size; i++)
  205.         {
  206.             var entry1 = eval('document.form.VAR_TABLE' + table_name + '__' + i + '__' + control_column);
  207.             if(entry1 && entry1.value == "")
  208.             {
  209.                 entry1.focus();
  210.                 return false;
  211.             }
  212.             
  213. /*            for(j = i + 1; j < table_size; j++)
  214.             {
  215.                 var entry2 = eval('document.form.VAR_TABLE' + table_name + '__' + j + '__' + control_column);
  216.                 if(entry1.value == entry2.value)
  217.                 {
  218.                     entry2.focus();
  219.                     alert('Entries '+ ++i + ' and ' + ++j + ' column ' + ++control_column + ' are identical which is incorrect. Changes have not been submitted into policy.');
  220.                     return false;
  221.                 }
  222.             }
  223. */
  224.         }
  225.         
  226.         return true;
  227.     }
  228.  
  229.     function getItem(id)
  230.     {
  231.         var itm = false;
  232.         if(document.getElementById)
  233.             itm = document.getElementById(id);
  234.         else if(document.all)
  235.             itm = document.all[id];
  236.         else if(document.layers)
  237.             itm = document.layers[id];
  238.         return itm;
  239.     }
  240.  
  241.  
  242. var currentPopup = null;    
  243. function setCurrentPopup(popup_window){    currentPopup = popup_window;}
  244. function getCurrentPopup(){return currentPopup;}
  245.  
  246. function openFrameless() 
  247. {
  248.     var windowW = 330;
  249.     var windowH = 160;
  250.     
  251.     var current_popup = getCurrentPopup();
  252.     if(current_popup && !current_popup.closed)
  253.     {
  254.         current_popup.location.href = arguments[0];
  255.         current_popup.focus();  
  256.         return;
  257.     }
  258.     
  259.     if(arguments.length > 1)
  260.     {
  261.         windowW = arguments[1];
  262.         windowH = arguments[2];
  263.     }
  264.     
  265.     var windowX = (screen.width/2) - (windowW/2);
  266.     var windowY = (screen.height/2) - (windowH/2);
  267.     
  268.     var position = "width="+windowW+",height="+windowH+",left="+windowX+",top="+windowY;
  269.  
  270.     if(arguments.length > 3 && arguments[3] == true)
  271.         position += ",scrollbars=yes";
  272.  
  273.     var NFW = window.open(arguments[0],"", "resizable=yes," + position);
  274.     if(NFW)
  275.     {
  276.         NFW.blur();
  277.         NFW.focus();  
  278.         setCurrentPopup(NFW);
  279.     }
  280.     else
  281.     {
  282.         alert(localized_strings.CannotOpenPopup);
  283.     }
  284. }
  285.  
  286. function processClicks(e) 
  287. {
  288.     if(document.all)
  289.         Key = window.event.keyCode;
  290.     else
  291.         Key = e.which;
  292.     if(Key == 112) // F1
  293.     {
  294.         if(parent.buttons && typeof(parent.buttons.clickHelpButton)=="function"){
  295.             var help_wind = parent.buttons.clickHelpButton();
  296.             help_wind.focus();
  297.         }
  298.         else if(typeof(clickHelpButton)=="function"){
  299.             var help_wind = clickHelpButton();
  300.             help_wind.focus();
  301.         }
  302.         disableEvent(e);
  303.         return false;
  304.     }
  305.     if((navigator.appName != "Microsoft Internet Explorer" && Key == 0) || Key == 116 || Key == 57349) // F5
  306.     {
  307.         if(parent && parent.parent && parent.parent.workarea && parent.parent.workarea.basis)
  308.             parent.parent.workarea.basis.location.href = parent.parent.workarea.basis.location.href;
  309.         disableEvent(e);
  310.         return false;
  311.     }
  312. }
  313.  
  314. function disableEvent(e) 
  315. {
  316.     if(document.releaseEvents)
  317.     {
  318.         document.releaseEvents(e);
  319.         e.returnValue=false;   
  320.     }
  321.     else if(document.all)
  322.         window.event.keyCode = 505; // remap it or browser will force refresh
  323. }
  324.  
  325. trash_marked_allowed = true;
  326. trash_marked_denied = true;
  327. function markall(formname)
  328. {
  329.     var target='';
  330.     var form = eval('document.' + formname);
  331.     if(!form)
  332.         return;
  333.  
  334.     var arr_size = eval('form.ENTRIES_TABLE' + target).value;
  335.     if(!arr_size || arr_size <= 0)
  336.         return;
  337.  
  338.     var flag_toset = (target == '') ? trash_marked_allowed : trash_marked_denied;
  339.  
  340.     for(var i = 0; i < arr_size; i++)
  341.     {
  342.         var element = eval('form.EMPTY_TABLE' + target + '__' + i);
  343.         if(element)                  
  344.             element.checked = flag_toset;
  345.     }
  346.     if(target == '')
  347.          trash_marked_allowed = !trash_marked_allowed;
  348.     else
  349.          trash_marked_denied = !trash_marked_denied;
  350. }
  351.  
  352. function markall_simple(formname)
  353. {
  354.     var form = eval('document.' + formname);
  355.     if(!form)
  356.         return;
  357.     var arr_size = form.ENTRIES_TABLE.value;
  358.     if(!arr_size || arr_size <= 0)
  359.         return;
  360.     var should_mark = true;
  361.     var should_mark_set = false;
  362.     for(var i = 0; i < arr_size; i++)
  363.     {
  364.         var element = eval('form.EMPTY_TABLE__' + i);
  365.         if(element)                  
  366.         {
  367.             if(!should_mark_set)
  368.             {
  369.                 should_mark = !element.checked;
  370.                 should_mark_set = true;
  371.             }
  372.             element.checked = should_mark;
  373.         }
  374.     }
  375. }
  376.  
  377. function mark_column(form)
  378. {
  379.     var tobe_checked = eval('document.' + form + '.marker').checked;
  380.     var new_index = 0;
  381.     var element = eval('document.' + form + '.VAR_TABLE_' + new_index);
  382.     while(element)
  383.     {
  384.         element.checked = tobe_checked;
  385.         new_index++;
  386.         element = eval('document.' + form + '.VAR_TABLE_' + new_index);
  387.     }
  388. }
  389.  
  390. /*
  391. **  Replace a token in a string
  392. **    s  string to be processed
  393. **    t  token to be found and removed
  394. **    u  token to be inserted
  395. **  returns new String
  396. */
  397. function replace(s, t, u) 
  398. {
  399.     i = s.indexOf(t);
  400.     r = "";
  401.     if (i == -1) 
  402.         return s;
  403.     r += s.substring(0,i) + u;
  404.     if ( i + t.length < s.length)
  405.         r += replace(s.substring(i + t.length, s.length), t, u);
  406.     return r;
  407. }
  408.  
  409. // this function is need to work around 
  410. // a bug in IE related to element attributes
  411. function hasClass(obj)
  412. {
  413.     var result = false;
  414.     if (obj.getAttributeNode("class") != null) 
  415.     {
  416.         result = obj.getAttributeNode("class").value;
  417.     }
  418.     return result;
  419. }
  420.  
  421. function stripeTable(id)
  422. {
  423.     var table = document.getElementById(id);
  424.     if (!table) return; // quit if not found
  425.  
  426.     var trs = table.getElementsByTagName("tr");
  427.  
  428.     for (var i = 0; i < trs.length; i++)
  429.     {
  430.         // avoid rows that have a class attribute
  431.         // or backgroundColor style
  432.         if (!hasClass(trs[i])) 
  433.         {
  434.             trs[i].className += (i % 2) ? "tr_stats" : "tr_stats_even";
  435.         }
  436.     }
  437. }
  438.  
  439. function open_window_max(aURL, allwindows)
  440. {
  441.    var wOpen;
  442.    var sOptions;
  443.  
  444.    if(arguments.length > 1 && allwindows)
  445.        sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';
  446.    else    
  447.        sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
  448.  
  449.  
  450.    sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
  451.    sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
  452.    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
  453.  
  454.    wOpen = window.open( aURL, '', sOptions );
  455.    wOpen.focus();
  456.    wOpen.moveTo( 0, 0 );
  457.    wOpen.resizeTo( screen.availWidth, screen.availHeight );
  458. }
  459.  
  460. function GetHelpContext(pane_name) 
  461. {
  462.     FillProjectHelpIDs();
  463.     
  464.     for (x in ProjectHelpIDs)
  465.     {
  466.         if(ProjectHelpIDs[x][0] == pane_name)
  467.             return ProjectHelpIDs[x][1];
  468.     }
  469.     alert(localized_strings.HelpIndexIsEmpty.replace("%PAGE_NAME%", pane_name));
  470.     return '';
  471. }
  472.  
  473. function RefreshContentPane(name)
  474. {
  475.     var pane = dojo.widget.byId(name)
  476.     if(pane)
  477.         pane.refresh();
  478. }
  479. function HideContentPane(name)
  480. {
  481.     var pane = dojo.widget.byId(name)
  482.     if(pane)
  483.         pane.hide();
  484. }
  485. function ShowContentPane(name)
  486. {
  487.     var pane = dojo.widget.byId(name)
  488.     if(pane)
  489.         pane.show();
  490. }
  491. function have_such_entry(in_array, name)
  492. {
  493.     if(!in_array)
  494.         return -1;
  495.     for(var i = 0; i < in_array.length; i++)
  496.         if(in_array[i].name == name)
  497.             return i;
  498.     return -1;
  499. }
  500. function have_such_entry_simple(in_array, name)
  501. {
  502.     if(!in_array)
  503.         return false;
  504.     for(var i = 0; i < in_array.length; i++)
  505.         if(in_array[i] == name)
  506.             return true;
  507.     return false;
  508. }
  509.  
  510. function control_enabler(formn, id, defv, f_arr)
  511. {
  512.     if(have_such_entry_simple(f_arr, id))
  513.         defv = true;        
  514.  
  515.     var element = eval('document.form_' + formn + '.VAR_PAGE_SETTINGS_' + id);
  516.     if(!element) return;
  517.  
  518.     if(element[1] && element[1].type == 'checkbox') element[1].disabled = defv; 
  519.     else element.disabled = defv;
  520. }
  521. function control_enabler_arr(form, arr, defv, f_arr)
  522. {
  523.     for(var i = 0; i < arr.length; i++)
  524.         control_enabler(form, arr[i], defv, f_arr);
  525. }
  526. function disable_form_setting(tab_name, k)
  527. {
  528.     var ve = eval('document.form_' + tab_name + '.VAR_PAGE_SETTINGS_' + k);
  529.     if(ve)
  530.     {
  531.         if(ve[1] && (ve[1].type == 'checkbox' || ve[1].type == 'text')) ve[1].disabled = true; 
  532.         else ve.disabled = true;
  533.     }
  534. }
  535.  
  536.  
  537. function isNumeric(elem){
  538.     var numericExpression = /^[0-9]+$/;
  539.     var ivalue = (elem.value) ? elem.value : elem;
  540.     if(ivalue.match(numericExpression)){
  541.         return true;
  542.     }else{
  543.         return false;
  544.     }
  545. }
  546.  
  547. function SetInnerText(elem, txt)
  548. {
  549.     var n = null;
  550.     for (var i = 0; i < elem.childNodes.length; ++i) 
  551.     {
  552.         var c = elem.childNodes[i];
  553.         if (c.nodeType != 3)
  554.             continue;
  555.         c.nodeValue = "";
  556.         if (n == null)
  557.             n = c;
  558.     }
  559.     if (n==null)
  560.         n = elem.appendChild(document.createTextNode(""));
  561.     n.nodeValue = txt;
  562. }
  563.  
  564. var webui_message_box_text = '';
  565. var webui_message_box_title = '';
  566. function get_webui_message_box_text()
  567. {
  568.     return webui_message_box_text;
  569. }
  570. function get_webui_message_box_title()
  571. {
  572.     return webui_message_box_title;
  573. }
  574.  
  575. function show_webui_message_box(title, msg, width)
  576. {
  577.     webui_message_box_title = title;
  578.     webui_message_box_text = msg;
  579.     var mbox_url = '/common/messagebox.php?' + ((width == 0) ? 300 : width);
  580.     if(arguments.length > 3)
  581.     {
  582.         mbox_url += '&';
  583.         if(arguments[3].length > 0)
  584.             mbox_url += 'Msg_b_action_' +  arguments[3];
  585.             
  586.         // Button names is localized at MessageBox.php, because we put them in URL.
  587.         mbox_url += '&';
  588.         if(arguments.length == 5)
  589.             mbox_url += 'Msg_b_name_' +  arguments[4];
  590.         else
  591.             mbox_url += 'Msg_b_name_two_' +  arguments[4] + '*' +  arguments[5];
  592.  
  593.     }
  594.     EnableExtraDialog(mbox_url);
  595. }
  596.  
  597. function parse_and_validate_int(str, min, max)
  598. {
  599.     if(!isNumeric(str))
  600.         return localized_strings.InvalidInterger.replace("%VALUE%", str);
  601.     min = Math.ceil(min);
  602.     max = Math.floor(max);
  603.     var iv = parseInt(str, 10);
  604.     if (iv < min || iv > max)
  605.         return localized_strings.ValueOutOfRange.replace("%VALUE%", str).replace("%MIN%", min).replace("%MAX", max);
  606.     return null;
  607. }
  608.  
  609. function validate_string(str)
  610. {
  611.     if(/^[^\"\<\>]*$/.test(str) == false)
  612.     {
  613.         return localized_strings.StringContainsInvalidChars.replace("%VALUE%", str);
  614.     }
  615.     return null;
  616. }
  617.  
  618.     function EnableTemplateDialog(dialog_type, param)
  619.     {
  620.         EnableListsDialog('/common/templates.php', dialog_type, param);
  621.     }
  622.     function EnableMatchlistDialog(dialog_type, param)
  623.     {
  624.         EnableListsDialog('/common/matchlists.php', dialog_type, param);
  625.     }
  626.     function EnableListsDialog(dialog_id, dialog_type, param)
  627.     {
  628.         if(param == '' && dialog_type != 'NewItem')
  629.         {
  630.             show_webui_message_box(localized_strings.Warning, localized_strings.SelectTheItemToEdit, 0);
  631.             return;
  632.         }    
  633.         var pane = dojo.widget.byId('lists_dialog');
  634.         if (!pane)
  635.         {
  636.             pane.setContent(localized_strings.PageCannotBeLoaded);
  637.         } 
  638.         else
  639.         {
  640.             // Use double URL escaping here. Single escaping doesn't work if the param contains '&'.
  641.             pane.setUrl(dialog_id + '?' + dialog_type + '&' + encodeURIComponent(encodeURIComponent(param)));
  642.         }
  643.         pane.show();
  644.     }
  645.     
  646.     function EnableFileTypesDialog(dialog_type, param)
  647.     {
  648.         var dialog_id = '/common/filetypes.php';
  649.         var pane = dojo.widget.byId('fileTypes_dialog');
  650.         if (!pane)
  651.         {
  652.             pane.setContent(localized_strings.PageCannotBeLoaded);
  653.         } 
  654.         else
  655.         {
  656.             dojo.byId('fileTypes_dialog').style.background="#f3f3f3";        
  657.             pane.setUrl(dialog_id + '?' + dialog_type + '&' + param);
  658.         }
  659.         pane.show();        
  660.     }
  661.  
  662.     function EnableExclusionsDialog(dialog_type, param)
  663.     {
  664.         var dialog_id = '/common/av_exclusions.php';
  665.         var pane = dojo.widget.byId('exclusions_dialog');
  666.         dojo.byId('exclusions_dialog').style.background="#f3f3f3";
  667.         pane.setUrl(dialog_id + '?' + dialog_type + '&' + param);
  668.         pane.show();        
  669.     }
  670.     
  671.     var debugFormsSubmissionFlag = false;
  672.     
  673.     function disableEnterKey(e)
  674.     {
  675.         if (typeof(document.activeElement) != "undefined")
  676.             if (document.activeElement.nodeName.toUpperCase() == "TEXTAREA")
  677.                 return true;
  678.  
  679.         var key;
  680.         if (window.event)
  681.             key = window.event.keyCode; //IE/Opera/Safari
  682.         else
  683.             key = e.which; //firefox
  684.         if (debugFormsSubmissionFlag && key == 13)
  685.             alert("ENTER caught");
  686.         return key != 13;
  687.     }
  688.     
  689.     // Creates dojo binder object for form with formId.
  690.     // Also safeFormBind assigns onSubmit handler to the binder.
  691.     // Handling submits thru binders' onSubmit is the only fully 
  692.     // right way to catch submit of binded form. It catches submits 
  693.     // caused by: clicking on submit input, manual call to myForm.submit(),
  694.     // manual call to mySubmitInput.click(), ENTER key on the input inside the form.
  695.     function safeFormBind(formId, loadFunction)
  696.     {
  697.         // check if form exists
  698.         var form = eval('document.' + formId);
  699.         if (!form)
  700.             return null;
  701.  
  702.         // create new binding
  703.         var rv = new dojo.io.FormBind({formNode: formId, load: loadFunction});
  704.  
  705.         // extract form name postfix
  706.         if (formId.indexOf("form_")==0)
  707.             formId = formId.slice(5);
  708.         
  709.         // try to find submit handler for this form
  710.         var submitFnName = formId + "_submitit_hit";
  711.         var submitFn = eval("typeof("+submitFnName+")=='function' ? "+submitFnName+" : null");
  712.         
  713.         // if handler hasn't been found
  714.         if (submitFn == null)
  715.             // assign handler suppressing form submission by ENTER key
  716.             form.onkeypress = disableEnterKey;
  717.         else
  718.             // attach handler to binder
  719.             rv.onSubmit = submitFn;
  720.  
  721.         // if handler has been found
  722.         if (submitFn != null)
  723.         { // wrap it to do some extra work
  724.             
  725.             // save current handler
  726.             var wrapTmp = rv.onSubmit;
  727.             rv.onSubmit = function(f) // create new one
  728.             {
  729.                 // call saved handler
  730.                 var ret = wrapTmp(f);
  731.                 // if it doesn't return any value, treat that as 'true' (submit allowed)
  732.                 if (typeof(ret) == "undefined")
  733.                     ret = true;
  734.                 
  735.                 // do wrappers' extra work:
  736.                 
  737.                 // set submit table flag automatically
  738.                 if (ret && form.SUBMIT_TABLE)
  739.                     form.SUBMIT_TABLE.value = 1;
  740.                     
  741.                 return ret;
  742.             }
  743.         }
  744.  
  745.         // attach debugging stuff to submit handler if required
  746.         if (debugFormsSubmissionFlag)
  747.         {
  748.             var dbgTmp = rv.onSubmit;
  749.             rv.onSubmit = function (f) 
  750.             { 
  751.                 alert("submit!\nf.name="+f.name+"\nonSubmit="+submitFn); 
  752.                 if (dbgTmp != null)
  753.                     return dbgTmp(f); 
  754.                 return true;
  755.             };
  756.         }
  757.         
  758.         return rv;
  759.     }
  760.  
  761. function support_disabled_checkboxes(myform)
  762. {
  763.      var mycheckboxes = myform.getElementsByTagName('INPUT');  
  764.      for (f7_0 = 0; f7_0 < mycheckboxes.length; f7_0++)
  765.      { 
  766.          if (mycheckboxes[f7_0].type == 'checkbox' && mycheckboxes[f7_0].disabled)
  767.         {
  768.                 var hidden_elem = eval('myform.' + mycheckboxes[f7_0].name + '[0]');
  769.                 var visible_elem = eval('myform.' + mycheckboxes[f7_0].name + '[1]');
  770.             if(hidden_elem && visible_elem)
  771.                 hidden_elem.value = (visible_elem.disabled && visible_elem.checked) ? 1 : 0;    
  772.             i = mycheckboxes[f7_0].name.indexOf('_2');
  773.             j = mycheckboxes[f7_0].name.indexOf('S');
  774.             if (i != -1 && j != -1 && i > j+1) 
  775.             {
  776.                 var real_name = mycheckboxes[f7_0].name.substring(0, i);
  777.                 if(real_name == 'VAR_PAGE_SETTINGS') continue;
  778.                     var hidden_elem2 = eval('myform.' + real_name + '[0]');
  779.                     var visible_elem2 = eval('myform.' + real_name + '[1]');
  780.                 if(hidden_elem2 && visible_elem2)
  781.                     hidden_elem2.value = (visible_elem2.disabled) ? visible_elem2.value : 0;    
  782.             }
  783.           }
  784.         
  785.      } 
  786. }
  787. function change_tab_state(tabname, settingname, new_status) 
  788. {
  789.     if(new_status == 0)
  790.         dojo.widget.byId('mainTabContainer').tablist.pane2button[dojo.widget.byId(tabname)].titleNode.innerHTML = '<font color=#999999>' + settingname + '</font>';
  791.     else
  792.         dojo.widget.byId('mainTabContainer').tablist.pane2button[dojo.widget.byId(tabname)].titleNode.innerHTML = settingname;
  793.     var warn_div = dojo.byId('DepDis' + tabname);
  794.     if(warn_div)
  795.     {    
  796.         warn_div.style.display=(new_status == 0 ? 'block' : 'none');
  797.         warn_div.style.visibility=(new_status == 0 ? 'visible' : 'hidden');
  798.     }
  799. }
  800.  
  801.  
  802.