home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / ProPlus.WW / ProPsWW.cab / UTILITYFUNCTIONS.JS3 < prev    next >
Text File  |  2007-02-04  |  28KB  |  958 lines

  1. /*********************************************************************
  2.                                  Notice
  3.  
  4. You may not modify, use, copy or distribute this file or its contents. 
  5. Internal interfaces referenced in this file are nonpublic, unsupported 
  6. and subject to change without notice. These interfaces may not be 
  7. utilized in other software applications or components.
  8.  
  9.  
  10. *********************************************************************/
  11.  
  12. var g_arrTabContents = null;
  13. var g_arrIntervals = new Array();
  14. var g_AlertShown = false;
  15. var g_IsMacro = false;
  16.  
  17. // This enum is defined in code, but we
  18. // can't access it from here, so just redeclare it.
  19. var FormsUIState_Unknown            = 0;
  20. var FormsUIState_HomePage            = 1;
  21. var FormsUIState_ViewDesign            = 2;
  22. var FormsUIState_FormDesign            = 3;
  23. var FormsUIState_MacroDesign        = 4;
  24. var FormsUIState_SettingsAndOptions    = 5;
  25. var FormsUIState_ViewData            = 6;
  26. var FormsUIState_DocumentDisplay    = 7;
  27.  
  28. // These enums are defined in IDL, but we
  29. // can't access them from here, so just redeclare it.
  30. var GrooveFormsToolFieldSizeType_Characters = 0;
  31. var GrooveFormsToolFieldSizeType_Pixels = 1;
  32. var GrooveFormsToolFieldSizeType_Percent = 2;
  33.  
  34. var GrooveFormsToolTextFieldInitialValueType_Static = 0;
  35. var GrooveFormsToolTextFieldInitialValueType_Unique = 1;
  36. var GrooveFormsToolTextFieldInitialValueType_UserDisplayName = 2;
  37. var GrooveFormsToolTextFieldInitialValueType_TelespaceDisplayName = 3;
  38. var GrooveFormsToolTextFieldInitialValueType_ToolDisplayName = 4;
  39. var GrooveFormsToolTextFieldInitialValueType_Function = 5;
  40.  
  41. var GrooveFormsToolDateFieldInitialValueType_Static = 0;
  42. var GrooveFormsToolDateFieldInitialValueType_Today = 1;
  43. var GrooveFormsToolDateFieldInitialValueType_Tomorrow = 2;
  44. var GrooveFormsToolDateFieldInitialValueType_Function = 3;
  45.  
  46. var GrooveFormsToolDateTimeFieldInitialValueType_Static = 0;
  47. var GrooveFormsToolDateTimeFieldInitialValueType_Now = 1;
  48. var GrooveFormsToolDateTimeFieldInitialValueType_Function = 2;
  49.  
  50. // These enums are defined in IDL, but we can't access them
  51. // from here, so just redeclare them
  52. var    GrooveFormsToolContactOutputInformation_Fingerprint = 0;
  53. var    GrooveFormsToolContactOutputInformation_EmailAddress = 1;
  54. var    GrooveFormsToolContactOutputInformation_Affiliation = 2;
  55. var    GrooveFormsToolContactOutputInformation_FullName = 3;
  56. var    GrooveFormsToolContactOutputInformation_Alias = 4;
  57. var    GrooveFormsToolContactOutputInformation_ExplanatoryURL = 5;
  58. var    GrooveFormsToolContactOutputInformation_Title = 6;
  59. var    GrooveFormsToolContactOutputInformation_Role = 7;
  60. var    GrooveFormsToolContactOutputInformation_GivenName = 8;
  61. var    GrooveFormsToolContactOutputInformation_FamilyName = 9;
  62. var    GrooveFormsToolContactOutputInformation_OrganizationName = 10;
  63. var    GrooveFormsToolContactOutputInformation_OrganizationUnit = 11;
  64. var    GrooveFormsToolContactOutputInformation_AuthenticationColorString = 12;
  65. var    GrooveFormsToolContactOutputInformation_AuthenticationTooltip = 13;
  66. var GrooveFormsToolContactOutputInformation_WorkPhoneNumber = 14;
  67.  
  68. // NOTE: Input types are only used for new contacts.  Once
  69. // the contact has been set in the record it cannot be changed.
  70. // An exception will be generated if SetContactInfo is called
  71. // on a persisted contact.
  72. var    GrooveFormsToolContactInputInformation_FullName = 0;
  73. var    GrooveFormsToolContactInputInformation_EmailAddress = 1;
  74. var    GrooveFormsToolContactInputInformation_WorkPhoneNumber = 2;
  75. var    GrooveFormsToolContactInputInformation_ExplanatoryURL = 3;
  76. var    GrooveFormsToolContactInputInformation_Title = 4;
  77. var    GrooveFormsToolContactInputInformation_Role = 5;
  78. var    GrooveFormsToolContactInputInformation_GivenName = 6;
  79. var    GrooveFormsToolContactInputInformation_FamilyName = 7;
  80. var    GrooveFormsToolContactInputInformation_OrganizationName = 8;
  81. var    GrooveFormsToolContactInputInformation_OrganizationUnit = 9;
  82.  
  83.  
  84. // Defined in tom.idl.
  85. var tomUndefined = -9999999;
  86.  
  87. var tomFalse = 0;
  88. var tomTrue = -1;
  89.  
  90. var tomListBullet = 1;
  91.  
  92. var tomSingle = 1;
  93.  
  94. var tomAlignLeft = 0;
  95. var tomAlignCenter = 1;
  96. var tomAlignRight = 2;
  97. var tomAlignJustify = 3;
  98.  
  99. var GrooveTextParaFlag_AlignLeft = 0x00000000;
  100. var GrooveTextParaFlag_AlignCenter = 0x00000001;
  101. var GrooveTextParaFlag_AlignRight = 0x00000002;
  102. var GrooveTextParaFlag_AlignJustify = 0x00000003;
  103. var GrooveTextParaFlag_NumberNone = 0x00000000;
  104. var GrooveTextParaFlag_NumberBullet = 0x00000010;
  105. var GrooveTextParaFlag_IndentRelative = 0x00001000;
  106. var GrooveTextParaFlag_UseAlign = 0x01000000;
  107. var GrooveTextParaFlag_UseNumber = 0x02000000;
  108.  
  109.  
  110. function getScriptHostQI(i_Interface)
  111. {
  112.     try
  113.     {
  114.         if (typeof g_IsSearch != "undefined")
  115.         {
  116.             // If these variables are valid, then you are in a form.
  117.             if (!g_IsSearch && !g_IsFormPreview)
  118.                 return eval("window.external." + i_Interface);
  119.             else if (g_IsSearch)
  120.             {
  121.                 if (i_Interface.indexOf("IGrooveFormsToolUIDelegate") != -1)
  122.                 {
  123.                     var UIDelegate = window.external.IGrooveFormsToolSearchDialogDelegatePrivate.GetUIDelegate();
  124.                     return eval("UIDelegate." + i_Interface);
  125.                 }
  126.                 else
  127.                     return eval("window.external." + i_Interface);
  128.             }
  129.             else if (g_IsMacro)
  130.             {
  131.                 var ScriptDispatch = window.external.IGrooveFormsToolUIMacroWindowPrivate;
  132.                 if (ScriptDispatch != null)
  133.                     return eval("ScriptDispatch.GetUIDelegate()." + i_Interface);
  134.             }
  135.         }
  136.         else
  137.             return eval("window.external." + i_Interface);
  138.     }
  139.     catch (error)
  140.     {
  141.         if (!g_AlertShown)
  142.         {
  143.             alert("This web page should only be opened from within Groove. Please close the window.");
  144.             g_AlertShown = true;
  145.         }
  146.         return null;
  147.     }
  148. }
  149.  
  150. function getImageBindableURLByID(i_ID)
  151. {
  152.     return getScriptHostQI("IGrooveFormsToolUIDelegateFormPrivate").GetBindableURLByID(i_ID);
  153. }
  154.  
  155. function processCallout(i_Function)
  156. {
  157.     try
  158.     {
  159.         var blnContinue = true;
  160.         if (typeof i_Function == "function" && i_Function() == false)
  161.             blnContinue = false;
  162.     }
  163.     catch (error) { }
  164.     finally
  165.     {
  166.         return blnContinue;
  167.     }
  168. }
  169.  
  170. function processCalloutWithParameter(i_Function, i_Parameter)
  171. {
  172.     try
  173.     {
  174.         var blnContinue = true;
  175.         if (typeof i_Function == "function" && i_Function(i_Parameter) == false)
  176.             blnContinue = false;
  177.     }
  178.     catch (error) { }
  179.     finally
  180.     {
  181.         return blnContinue;
  182.     }
  183. }
  184.  
  185. function getValueFromQueryString(i_Key, i_Querystring, i_Default)
  186. {
  187.     var strReturn = "";
  188.     if (typeof i_Default != "undefined")
  189.         strReturn = i_Default;
  190.  
  191.     var objRegExp = new RegExp(i_Key + "=[^&]*", "");
  192.     if (objRegExp.test(i_Querystring))
  193.     {
  194.         var strPair = objRegExp.exec(i_Querystring);
  195.         var arrPair = strPair[0].split("=");
  196.         if (arrPair.length == 2 && arrPair[0] == i_Key)
  197.             strReturn = unescape(arrPair[1]);
  198.     }
  199.  
  200.     return strReturn;
  201. }
  202.  
  203.  
  204. // === status bar functions ============================
  205. // these functions control the display of the status bar
  206. function displayStatusBar(i_Message, i_Icon)
  207. {
  208.     if (!g_IsSearch && !g_IsPreviewPane && !g_IsPrinting)
  209.         getScriptHostQI("IGrooveFormsToolUIDelegate").DisplayStatusBarMessage(i_Message, i_Icon);
  210. }
  211.  
  212. function clearStatusBar()
  213. {
  214.     if (!g_IsSearch && !g_IsPreviewPane && !g_IsPrinting)
  215.         getScriptHostQI("IGrooveFormsToolUIDelegate").ClearStatusBarMessage();
  216. }
  217.  
  218. // === event handlers ============================
  219. // these functions handle events for form elements
  220. function onBlurHandler()
  221. {
  222.     eventHandler("OnBlur");
  223. }
  224.  
  225. function onFocusHandler()
  226. {
  227.     eventHandler("OnFocus");
  228. }
  229.  
  230. function onClickHandler()
  231. {
  232.     eventHandler("OnClick");
  233. }
  234.  
  235. function onChangeHandler()
  236. {
  237.     eventHandler("OnChange");
  238. }
  239.  
  240. function eventHandler(i_strEvent)
  241. {
  242.     try
  243.     {
  244.         var objElement = event.srcElement;
  245.         if (eval("typeof " + objElement.name + "_" + i_strEvent) != "undefined")
  246.             eval(objElement.name + "_" + i_strEvent + "(objElement)");
  247.     }
  248.     catch (error) {}
  249. }
  250.  
  251. function eventHandlerById(i_strEvent, i_strId)
  252. {
  253.     try
  254.     {
  255.         if (g_BypassEventCallouts)
  256.             return;
  257.  
  258.         if (i_strId != null && i_strId != "")
  259.         {
  260.             var objElement = document.getElementById(i_strId);
  261.             if (eval("typeof " + i_strId + "_" + i_strEvent) != "undefined")
  262.                 eval(i_strId + "_" + i_strEvent + "(objElement)");
  263.         }
  264.     }
  265.     catch (error) { }
  266. }
  267.  
  268. // === object replacement ==========================================
  269. // these functions are called to replace object tags with empty divs
  270. function subInDivs()
  271. {
  272.     g_arrTabs = new Array();
  273.     g_arrTabContents = new Array();
  274.  
  275.     // Display the contents of all tabs when printing.
  276.     var arrDivs = document.getElementsByTagName("DIV");
  277.     for (var i = 0; i < arrDivs.length; i++)
  278.     {
  279.         var strObjectType = arrDivs[i].getAttribute("OBJECTTYPE");
  280.         if (strObjectType == "TabContents" && arrDivs[i].style.display == "none")
  281.         {
  282.             arrDivs[i].insertAdjacentHTML("beforeBegin", "<HR ID=\"" + arrDivs[i].id + "_line\" SIZE=\"1\" COLOR=\"#000000\">");
  283.             arrDivs[i].style.display = "";
  284.             g_arrTabContents.push(arrDivs[i]);
  285.         }
  286.     }
  287.  
  288.     // Hide all tabs when printing.
  289.     var arrDivs = document.getElementsByTagName("SPAN");
  290.     for (var i = 0; i < arrDivs.length; i++)
  291.     {
  292.         var strObjectType = arrDivs[i].getAttribute("OBJECTTYPE");
  293.         if (strObjectType == "Tab")
  294.         {
  295.             arrDivs[i].style.display = "none";
  296.             g_arrTabs.push(arrDivs[i]);
  297.         }
  298.     }
  299.  
  300.     // Replace all textarea and input boxes.
  301.     var arrInputs = document.getElementsByTagName("INPUT");
  302.     for (var i = 0; i < arrInputs.length; i++)
  303.     {
  304.         if (arrInputs[i].type == "text" || arrInputs[i].type == "password")
  305.             Object2Div(arrInputs[i], null, "inputPreview");
  306.     }
  307.  
  308.     var arrTextAreas = document.getElementsByTagName("TEXTAREA");
  309.     for (var i = 0; i < arrTextAreas.length; i++)
  310.         Object2Div(arrTextAreas[i], null, "textareaPreview");
  311.  
  312.     var arrSelects = document.getElementsByTagName("SELECT");
  313.     for (var i = 0; i < arrSelects.length; i++)
  314.         Object2Div(arrSelects[i], null, "selectPreview");
  315.  
  316.     // Handle rich text objects.
  317.     var arrObject = document.getElementsByTagName("OBJECT");
  318.     var strDataType, RTFContent;
  319.     for (var i = 0; i < arrObject.length; i++)
  320.     {
  321.         strDataType = arrObject[i].getAttribute("DataType");
  322.         if (strDataType != null && strDataType == "RichText")
  323.         {
  324.             RTFContent = getScriptHostQI("IGrooveFormsToolUIDelegatePrintFormPrivate").OpenRTFContent(arrObject[i], true);
  325.             Object2Div(arrObject[i], RTFContent);
  326.         }
  327.     }
  328.  
  329.     // Hide all buttons on the form.
  330.     var arrButtons = document.getElementsByTagName("BUTTON");
  331.     for (var i = 0; i < arrButtons.length; i++)
  332.     {
  333.         arrButtons[i].style.display = "none";
  334.     }
  335. }
  336.  
  337. function putBackTextAreas()
  338. {
  339.     var arrInputs = document.getElementsByTagName("INPUT");
  340.     for (var i = 0; i < arrInputs.length; i++)
  341.     {
  342.         if (arrInputs[i].type == "text" || arrInputs[i].type == "password")
  343.             DivBackToObject(arrInputs[i]);
  344.     }
  345.  
  346.     var arrTextAreas = document.getElementsByTagName("TEXTAREA");
  347.     for (var i = 0; i < arrTextAreas.length; i++)
  348.         DivBackToObject(arrTextAreas[i]);
  349.  
  350.     var arrSelects = document.getElementsByTagName("SELECT");
  351.     for (var i = 0; i < arrSelects.length; i++)
  352.         DivBackToObject(arrSelects[i]);
  353.  
  354.     // Handle rich text objects.
  355.     var arrObject = document.getElementsByTagName("OBJECT");
  356.     var strDataType;
  357.     for (var i = 0; i < arrObject.length; i++)
  358.     {
  359.         strDataType = arrObject[i].getAttribute("DataType");
  360.         if (strDataType == "RichText")
  361.             DivBackToObject(arrObject[i]);
  362.     }
  363.     
  364.     // Display all buttons on the form.
  365.     var arrButtons = document.getElementsByTagName("BUTTON");
  366.     for (var i = 0; i < arrButtons.length; i++)
  367.     {
  368.         arrButtons[i].style.display = "";
  369.     }
  370.  
  371.     // Display all tabs on a form.
  372.     for (var i = 0; i < g_arrTabs.length; i++)
  373.     {
  374.         g_arrTabs[i].style.display = "";
  375.     }
  376.  
  377.     // Re-hide the contents of all tabs that should be hidden.
  378.     for (var i = 0; i < g_arrTabContents.length; i++)
  379.     {
  380.         var objLine = document.getElementById(g_arrTabContents[i].id + "_line");
  381.         if (objLine != null)
  382.             objLine.removeNode(true);
  383.         g_arrTabContents[i].style.display = "none";
  384.     }
  385. }
  386.  
  387. function Object2Div(i_Object, i_Content, i_ClassName)
  388. {
  389.     var oNewDiv;
  390.  
  391.     oNewDiv = document.createElement("DIV");
  392.     oNewDiv.className = i_ClassName;
  393.     oNewDiv.id = i_Object.uniqueID + "_div";
  394.  
  395.     if (i_Content != null)
  396.     {
  397.         oNewDiv.innerHTML = i_Content;
  398.     }
  399.     else
  400.     {
  401.         var ObjectValue = i_Object.value;
  402.         if (i_Object.type == "password")
  403.         {
  404.             var ObjectValueLength = ObjectValue.length;
  405.             ObjectValue = "";
  406.             for (var i = 0; i < ObjectValueLength; i++)
  407.             {
  408.                 ObjectValue += "*";
  409.             }
  410.         }
  411.         else if (i_Object.type == "select-multiple")
  412.         {
  413.             var OptionValueArray = new Array();
  414.             for (var i = 0; i < i_Object.options.length; i++)
  415.             {
  416.                 if (i_Object.options[i].selected)
  417.                     OptionValueArray.push(i_Object.options[i].text);
  418.             }
  419.  
  420.             ObjectValue = OptionValueArray.join(", ");
  421.         }
  422.         oNewDiv.innerText = ObjectValue;
  423.     }
  424.  
  425.     i_Object.parentNode.insertBefore(oNewDiv, i_Object);
  426.     i_Object.style.display = "none";
  427. }
  428.  
  429. function DivBackToObject(i_Object)
  430. {
  431.     var oDivToRemove = document.all(i_Object.uniqueID + "_div");
  432.     if (oDivToRemove != null)
  433.         oDivToRemove.removeNode(true);
  434.  
  435.     i_Object.style.display = "";
  436. }
  437.  
  438. // === button handlers ============================================
  439. // these functions are called in response to a button being clicked
  440. function doCalendar(i_Name)
  441. {
  442.     try
  443.     {
  444.         // Get the INPUT object that the date value will be put into.
  445.         var objDate = document.GrooveFormBase.elements(i_Name);
  446.         if (objDate != null)
  447.         {
  448.             var DateValue = objDate.value;
  449.  
  450.             // Clear any errors that the current date may have.
  451.             clearError(objDate, "Required");
  452.             clearError(objDate, "InvalidDate");
  453.             clearError(objDate, "Date");
  454.  
  455.             var bIsDateTime = false;
  456.             var FieldTypeAttribute = objDate.getAttribute("FIELDTYPE");
  457.             if (FieldTypeAttribute == FormObjectType_DateTime)
  458.                 bIsDateTime = true;
  459.  
  460.             // Get the new date from the choose date sub-form.
  461.             var FormatAttribute = objDate.getAttribute("FORMAT");
  462.             if (FormatAttribute != null)
  463.             {
  464.                 var intDateFormat = getScriptHostQI("IGrooveFormsToolUIDelegateFormPrivate").CreateDateFormatStyleFromAttributeValue(FormatAttribute);
  465.                 // Ignore errors that occur in ParseDate/ParseDateTime in case the user typed in a bogus date.
  466.                 try
  467.                 {
  468.                     var intDate;
  469.                     if (DateValue != "")
  470.                     {
  471.                         if (bIsDateTime)
  472.                             intDate = getScriptHostQI("IGrooveFormsToolUIDelegate").ParseDateTime(DateValue, intDateFormat, 3); //GrooveIntlDateFormatStyle_Short);
  473.                         else
  474.                             intDate = getScriptHostQI("IGrooveFormsToolUIDelegate").ParseDate(DateValue, intDateFormat);
  475.                     }
  476.                 }
  477.                 catch (error) { }
  478.  
  479.                 var DateResult = getScriptHostQI("IGrooveFormsToolUIDelegate").DisplayDatePickerDialog(intDate, intDateFormat, bIsDateTime);
  480.                 if (DateResult.Result == GrooveDialogBoxResultCode_OK)
  481.                 {
  482.                     objDate.value = DateResult.Data;
  483.  
  484.                     // Set the dirty bit if it needs to be set.
  485.                     int_setIsDirty(true);
  486.  
  487.                     // Call onblur to validate the date.
  488.                     objDate.fireEvent("onblur");
  489.  
  490.                     // Call onchange if the value has changed.
  491.                     if (objDate.value != DateValue)
  492.                         objDate.fireEvent("onchange");
  493.                 }
  494.             }
  495.         }
  496.     }
  497.     catch (error)
  498.     {
  499.         var strError = "There was an error saving the date value, most likely caused by the form reloading in response to a design change. Please try choosing the date again.";
  500.         getScriptHostQI("IGrooveFormsToolUIDelegate").DisplayError(strError);
  501.     }
  502. }
  503.  
  504. // Rich text command bar button handlers.
  505. function doBold(i_Name)
  506. {
  507.     submitControlChar(i_Name, "B");
  508. }
  509.  
  510. function doItalic(i_Name)
  511. {
  512.     submitControlChar(i_Name, "I");
  513. }
  514.  
  515. function doUnderline(i_Name)
  516. {
  517.     submitControlChar(i_Name, "U");
  518. }
  519.  
  520. function submitControlChar(i_Name, i_String)
  521. {
  522.     var objTextView = document.getElementById(i_Name);
  523.     if (objTextView != null)
  524.     {
  525.         var CharCode = i_String.charCodeAt(0) & 0x1F;
  526.         objTextView.SubmitText(String.fromCharCode(CharCode));
  527.         objTextView.focus();
  528.     }
  529. }
  530.  
  531. function doAlignLeft(i_Name)
  532. {
  533.     submitParaChange(i_Name, GrooveTextParaFlag_UseAlign | GrooveTextParaFlag_AlignLeft, tomUndefined);
  534. }
  535.  
  536. function doCenter(i_Name)
  537. {
  538.     submitParaChange(i_Name, GrooveTextParaFlag_UseAlign | GrooveTextParaFlag_AlignCenter, tomUndefined);
  539. }
  540.  
  541. function doAlignRight(i_Name)
  542. {
  543.     submitParaChange(i_Name, GrooveTextParaFlag_UseAlign | GrooveTextParaFlag_AlignRight, tomUndefined);
  544. }
  545.  
  546. function doJustify(i_Name)
  547. {
  548.     submitParaChange(i_Name, GrooveTextParaFlag_UseAlign | GrooveTextParaFlag_AlignJustify, tomUndefined);
  549. }
  550.  
  551. function doBullets(i_Name)
  552. {
  553.     var objTextView = document.getElementById(i_Name);
  554.     if (objTextView != null)
  555.     {
  556.         var Flags = GrooveTextParaFlag_UseNumber;
  557.         var ListType = objTextView.TextCache.Document.Selection.Para.ListType;
  558.         if (ListType == tomUndefined)
  559.             Flags |= GrooveTextParaFlag_NumberBullet;
  560.         else if ((ListType & 0xFFFF) != tomListBullet)
  561.             Flags |= GrooveTextParaFlag_NumberBullet;
  562.         else
  563.             Flags |= GrooveTextParaFlag_NumberNone;
  564.  
  565.         submitParaChange(i_Name, Flags, tomUndefined);
  566.     }
  567. }
  568.  
  569. function doIncreaseIndent(i_Name)
  570. {
  571.     submitParaChange(i_Name, GrooveTextParaFlag_IndentRelative, 18.0);
  572. }
  573.  
  574. function doDecreaseIndent(i_Name)
  575. {
  576.     submitParaChange(i_Name, GrooveTextParaFlag_IndentRelative, -18.0);
  577. }
  578.  
  579. function doChooseFont(i_Name)
  580. {
  581.     var objTextView = document.getElementById(i_Name);
  582.     if (objTextView != null)
  583.         objTextView.ChooseFont();
  584. }
  585.  
  586. function doChooseColor(i_Name)
  587. {
  588.     var objTextView = document.getElementById(i_Name);
  589.     if (objTextView != null)
  590.         objTextView.ChooseColor();
  591. }
  592.  
  593. function submitParaChange(i_Name, i_Flags, i_Left)
  594. {
  595.     var objTextView = document.getElementById(i_Name);
  596.     if (objTextView != null)
  597.     {
  598.         var TabPositionEnum = getScriptHostQI("IGrooveFormsToolUIDelegatePrivate").CreateDoubleEnum();
  599.         var TabFlagsEnum = getScriptHostQI("IGrooveFormsToolUIDelegatePrivate").CreateLongEnum();
  600.  
  601.         objTextView.SubmitParaChange(i_Flags, tomUndefined, tomUndefined, i_Left, tomUndefined, tomUndefined, tomUndefined, TabPositionEnum, TabFlagsEnum);
  602.         objTextView.focus();
  603.     }
  604. }
  605.  
  606. function startInterval(i_Name)
  607. {
  608.     for (var i = 0; i < g_arrIntervals.length; i++)
  609.     {
  610.         if (g_arrIntervals[i].Name == i_Name)
  611.         {
  612.             g_arrIntervals[i].Stop();
  613.             break;
  614.         }
  615.     }
  616.  
  617.     var Interval = new CommandBarInterval();
  618.     Interval.Start(i_Name);
  619.     g_arrIntervals.push(Interval);
  620. }
  621.  
  622. function stopInterval(i_Name)
  623. {
  624.     for (var i = 0; i < g_arrIntervals.length; i++)
  625.     {
  626.         if (g_arrIntervals[i].Name == i_Name)
  627.         {
  628.             g_arrIntervals[i].Stop();
  629.             g_arrIntervals[i] = null;
  630.             g_arrIntervals.splice(i, 1);
  631.         }
  632.     }
  633. }
  634.  
  635. function updateCommandBar(i_Name)
  636. {
  637.     var objTextView = document.getElementById(i_Name);
  638.     if (objTextView != null)
  639.     {
  640.         setCommandPressedState(i_Name + "Bold", objTextView.SelectionFont.Bold == tomTrue);
  641.         setCommandPressedState(i_Name + "Italic", objTextView.SelectionFont.Italic == tomTrue);
  642.         setCommandPressedState(i_Name + "Underline", objTextView.SelectionFont.Underline == tomSingle);
  643.         setCommandPressedState(i_Name + "AlignLeft", objTextView.TextCache.Document.Selection.Para.Alignment == tomAlignLeft);
  644.         setCommandPressedState(i_Name + "Center", objTextView.TextCache.Document.Selection.Para.Alignment == tomAlignCenter);
  645.         setCommandPressedState(i_Name + "AlignRight", objTextView.TextCache.Document.Selection.Para.Alignment == tomAlignRight);
  646.         setCommandPressedState(i_Name + "Justify", objTextView.TextCache.Document.Selection.Para.Alignment == tomAlignJustify);
  647.  
  648.         var ListType = objTextView.TextCache.Document.Selection.Para.ListType;
  649.         if (ListType == tomUndefined || ((ListType & 0xFFFF) != tomListBullet))
  650.             setCommandPressedState(i_Name + "Bullets", false);
  651.         else
  652.             setCommandPressedState(i_Name + "Bullets", true);
  653.     }
  654. }
  655.  
  656. // Object to store command bar interval data.
  657. function CommandBarInterval()
  658. {
  659.     this.Name;
  660.     this.ID;
  661. }
  662.  
  663. CommandBarInterval.prototype.Start = IntervalStart;
  664. CommandBarInterval.prototype.Stop = IntervalStop;
  665.  
  666. function IntervalStart(i_Name)
  667. {
  668.     this.Name = i_Name;
  669.     this.ID = window.setInterval("updateCommandBar('" + i_Name + "')", 250);
  670. }
  671.  
  672. function IntervalStop()
  673. {
  674.     window.clearInterval(this.ID);
  675. }
  676.  
  677. // Attachment command bar button handlers.
  678. function doAddAttachments()
  679. {
  680.     try
  681.     {
  682.         if (g_AttachmentsObject != null && g_AttachmentsElement != null)
  683.             getScriptHostQI("IGrooveFormsToolUIDelegateFormPrivate").AddAttachments(g_AttachmentsObject, g_AttachmentsElement);
  684.     }
  685.     catch (error)
  686.     {
  687.         var strError = "There was an error adding the attachment, most likely caused by the form reloading in response to a design change or because the file may be in use by another program. Please try adding the attachment again, after correcting the issue.";
  688.         getScriptHostQI("IGrooveFormsToolUIDelegate").DisplayError(strError);
  689.     }
  690. }
  691.  
  692. function doDeleteSelectedAttachments()
  693. {
  694.     if (g_AttachmentsObject != null)
  695.         getScriptHostQI("IGrooveFormsToolUIDelegateFormPrivate").DeleteAttachments(g_AttachmentsObject);
  696. }
  697.  
  698. function doLaunchSelectedAttachments()
  699. {
  700.     if (g_AttachmentsObject != null)
  701.         getScriptHostQI("IGrooveFormsToolUIDelegateFormPrivate").LaunchAttachments(g_AttachmentsObject, g_AttachmentsObject.name, g_RecordID);
  702. }
  703.  
  704. function doSaveSelectedAttachments()
  705. {
  706.     if (g_AttachmentsObject != null)
  707.         getScriptHostQI("IGrooveFormsToolUIDelegateFormPrivate").SaveAttachments(g_AttachmentsObject);
  708. }
  709.  
  710. // Add a trim method to the String object.
  711. String.prototype.trim = function()
  712. {
  713.     // Replace leading and trailing spaces with an empty string.
  714.     return this.replace(/(^\s*)|(\s*$)/g, "");
  715. }
  716.  
  717. // A utility function to get the top or left position of a given object.
  718. function getOffset(i_objPos, i_strDir)
  719. {
  720.     var intOffset = 0;
  721.     var objOffset = i_objPos;
  722.     while (objOffset.tagName != "BODY")
  723.     {
  724.         if (i_strDir == "top")
  725.             intOffset += objOffset.offsetTop;
  726.         else if (i_strDir == "left")
  727.             intOffset += objOffset.offsetLeft;
  728.  
  729.         objOffset = objOffset.offsetParent;
  730.     }
  731.     return intOffset;
  732. }
  733.  
  734. // === tab handlers ================
  735. // these functions handle tab events
  736.  
  737. function tabClick(i_objTab, i_objTabGroup)
  738. {
  739.     var strOldTabName = i_objTabGroup.ActiveTabName;
  740.     var strNewTabName = i_objTab.id;
  741.     if (strNewTabName != strOldTabName)
  742.     {
  743.         var objOldTab = document.getElementById(strOldTabName);
  744.         if (objOldTab != null)
  745.             objOldTab.className = "inactiveTab";
  746.         var objOldTabContents = document.getElementById(strOldTabName + "Contents");
  747.         if (objOldTabContents != null)
  748.             objOldTabContents.style.display = "none";
  749.  
  750.         i_objTab.className = "activeTab";
  751.         var objNewTabContents = document.getElementById(strNewTabName + "Contents");
  752.         if (objNewTabContents != null)
  753.             objNewTabContents.style.display = "block";
  754.  
  755.         i_objTabGroup.ActiveTabName = strNewTabName;
  756.  
  757.         int_RefreshErrorIcons();
  758.     }
  759.  
  760.     event.cancelBubble = true;
  761. }
  762.  
  763. // Misc functions
  764. function getUniqueID()
  765. {
  766.     // format is firstpart-second part where first part is:
  767.     //     First letter of first name+ first two letters of last name + last letter
  768.     // Last part is:
  769.     //    Number of ticks- always increasing so entries you create are always ascending
  770.     //    in sequence.
  771.     // Example: JOZE-5WWTYC
  772.  
  773.     // Extract ticks in milliseconds, converted to base16 uppercase string
  774.     var d = new Date();
  775.     var HexMilliseconds = d.getTime().toString(16);
  776.     HexMilliseconds = HexMilliseconds.toUpperCase();
  777.  
  778.     // take the high order characters, e.g. the last nine characters 
  779.     var HexUnique = HexMilliseconds.slice(-9);
  780.  
  781.     // get current user name
  782.     var UserName = getCurrentAuthorName();
  783.  
  784.     // clean the name.  First replace x.500 OU slashes with spaces
  785.     var filteredUserName = UserName.replace(/\//,"\x20");
  786.  
  787.     // upcase
  788.     filteredUserName = filteredUserName.toUpperCase();
  789.  
  790.     // handle special cases for name for short length
  791.     var AlphaUnique;
  792.     if (filteredUserName.length <= 4)
  793.     {
  794.         AlphaUnique = filteredUserName;
  795.     }
  796.     else
  797.     {
  798.         // split the username into it's possible token parts. 
  799.  
  800.         // Use the first and second tokens as likely unique first name, last name.
  801.         // It's possible in the worst case to have first/middle/last/OU/.../, but 
  802.         // just use first two tokens since we don't have specific structured 
  803.         // fields in the user name -it's just a string!
  804.  
  805.         // split tokens separated by one or more spaces
  806.         var TokenArray = filteredUserName.split(/\s+/);
  807.         
  808.         // first char of 1st token
  809.         var Prefix1 = TokenArray[0].slice(0,1); 
  810.  
  811.         // first 2 chars of 2nd token if there is one, else remainder of 1st token
  812.         var Prefix2;
  813.         if (TokenArray.length > 1 && TokenArray[1].length >= 2)
  814.         {
  815.             Prefix2 = TokenArray[1].slice(0,2);
  816.  
  817.             // last char of 2nd token
  818.             LastChar = TokenArray[1].slice(-1);
  819.  
  820.             Prefix2 = Prefix2+LastChar;
  821.         }
  822.         else
  823.             Prefix2 = TokenArray[0].slice(1,2);
  824.  
  825.         AlphaUnique = Prefix1 + Prefix2;
  826.     }
  827.  
  828.     return (AlphaUnique + "-" + HexUnique);
  829. }
  830.  
  831. function grooveNavigate(i_URL)
  832. {
  833.     getScriptHostQI("IGrooveFormsToolUIDelegatePrivate").GrooveNavigate(i_URL);
  834. }
  835.  
  836. function int_GetLookupStringForObject(i_ObjectName)
  837. {
  838.     var TargetString = getScriptHostQI("IGrooveFormsToolUIDelegatePrivate").GetLookupTargetString(i_ObjectName);
  839.     return TargetString;
  840. }
  841.  
  842. function int_GetLookupStringForObjectFromMacro(i_ObjectName, i_FormsToolUIDelegate)
  843. {
  844.     var TargetString = i_FormsToolUIDelegate.IGrooveFormsToolUIDelegatePrivate.GetLookupTargetString(i_ObjectName);
  845.     return TargetString;
  846. }
  847.  
  848. // Pass through functions called from PublicFunctions.js.
  849. function int_GetApp()
  850. {
  851.     return getScriptHostQI("IGrooveFormsToolUIDelegate");
  852. }
  853.  
  854. function int_CreateBSTREnumFromArray(i_Array)
  855. {
  856.     var BSTREnumCreate = getScriptHostQI("IGrooveFormsToolUIDelegatePrivate").CreateBSTREnum();
  857.     
  858.     for (var i = 0; i < i_Array.length; i++)
  859.     {
  860.         BSTREnumCreate.IGrooveBSTREnumCreate.Add(i_Array[i]);
  861.     }
  862.     
  863.     return BSTREnumCreate.IGrooveBSTREnum;
  864. }
  865.  
  866. function int_SetFieldLabel(i_FieldName, i_Label)
  867. {
  868.     var objTd = null;
  869.     var objLabelTd = document.getElementById(i_FieldName + "_label");
  870.     if (objLabelTd != null)
  871.         objTd = objLabelTd;
  872.     else
  873.     {
  874.         var objFieldTd = document.getElementById(i_FieldName + "_field");
  875.         if (objFieldTd != null)
  876.             objTd = objFieldTd;
  877.     }
  878.  
  879.     if (objTd != null)
  880.     {
  881.         var arrFont = objTd.getElementsByTagName("FONT");
  882.         if (arrFont.length > 0)
  883.         {
  884.             var objFont = arrFont[0];
  885.             objFont.innerText = i_Label;
  886.         }
  887.     }
  888. }
  889.  
  890. function int_HideField(i_FieldName, i_bHide)
  891. {
  892.     var objLabel = document.getElementById(i_FieldName + "_label");
  893.     if (objLabel != null)
  894.     {
  895.         if (i_bHide)
  896.             objLabel.style.display = "none"
  897.         else
  898.             objLabel.style.display = "inline";
  899.     }
  900.  
  901.     var objField = document.getElementById(i_FieldName + "_field");
  902.     if (objField != null)
  903.     {
  904.         if (i_bHide)
  905.             objField.style.display = "none"
  906.         else
  907.             objField.style.display = "inline";
  908.     }
  909. }
  910.  
  911. function int_DisableField(i_FieldName, i_bDisable)
  912. {
  913.     var objField = document.getElementById(i_FieldName);
  914.     if (objField != null && typeof objField.disabled != "undefined")
  915.         objField.disabled = i_bDisable;
  916. }
  917.  
  918. function int_RefreshErrorIcons()
  919. {
  920.     // Blur all fields that have errors to re-validate.
  921.     var arrFields = new Array();
  922.     for (var i = 0; i < g_arrErrors.length; i++)
  923.     {
  924.         var objError = g_arrErrors[i];
  925.         var objField = document.getElementById(objError.FieldName);
  926.         if (objField != null)
  927.             arrFields.push(objField);
  928.     }
  929.  
  930.     for (var i = 0; i < arrFields.length; i++)
  931.     {
  932.         arrFields[i].fireEvent("onblur");
  933.     }
  934. }
  935.  
  936. function int_RefreshPreviewPane()
  937. {
  938.     if (g_IsPreviewPane)
  939.         initFormPage(g_RecordID);
  940. }
  941.  
  942. // These functions used to be in PublicFunctions.js, so a copy is left here for
  943. // backward compatibility.
  944. function NavigateToForm(i_FormID, i_RecordID, i_SelectedID)
  945. {
  946.     if (typeof i_RecordID == "undefined" || i_RecordID == null)
  947.         i_RecordID = -1;
  948.     if (typeof i_SelectedID == "undefined" || i_SelectedID == null)
  949.         i_SelectedID = -1;
  950.  
  951.     getScriptHostQI("IGrooveFormsToolUIDelegate").NavigateToForm(i_FormID, i_RecordID, i_SelectedID);
  952. }
  953.  
  954. function NavigateToView(i_ViewID)
  955. {
  956.     getScriptHostQI("IGrooveFormsToolUIDelegate").NavigateToView(i_ViewID);
  957. }
  958.