home *** CD-ROM | disk | FTP | other *** search
/ Online Praxis 1998 March / Image.iso / CD-ROM / NETSCAPE / CCK / INSTBLDR.Z / asw.jar / globals1.js < prev    next >
Encoding:
Text File  |  1998-02-27  |  30.0 KB  |  854 lines

  1. <!--  to hide script contents from old browsers
  2.  
  3.  
  4.  
  5. compromisePrincipals();
  6. netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  7. enableExternalCapture();                                                 // This requires UniversalBrowserWrite access
  8. parent.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.DRAGDROP | Event.DBLCLICK);
  9. parent.onmousedown=cancelEvent;
  10. parent.onmouseup=cancelEvent;
  11. parent.ondragdrop=cancelEvent;
  12. parent.ondblclick=cancelEvent;
  13.  
  14.  
  15. function cancelEvent(e)
  16. {
  17.         var retVal=false;
  18.  
  19.     if ((e.which < 2) && (e.type != "dragdrop") && (e.type != "dblclick"))    {
  20.         retVal=routeEvent(e);
  21.         }
  22.  
  23.     return(retVal);
  24. }
  25.  
  26.  
  27.  
  28. function debug(theString)
  29. {
  30.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  31.  
  32.     if (document.vars.debugMode.value.toLowerCase() == "yes")    {
  33.         document.setupPlugin.debug(theString);
  34. //        Packages.java.lang.System.err.println(theString);
  35.         }
  36. }
  37.  
  38.  
  39.  
  40. function GetNameValuePair(file, section, variable)
  41. {
  42.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  43.  
  44.     var value = parent.globals.document.setupPlugin.GetNameValuePair(file, section, variable);
  45.     if (value == null)    value="";
  46.     debug("\tGetNameValuePair: [" +section+ "] " +variable+ "=" + value);
  47.     return(value);
  48. }
  49.  
  50.  
  51.  
  52. function SetNameValuePair(file, section, variable, data)
  53. {
  54.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  55.  
  56.     parent.globals.document.setupPlugin.SetNameValuePair(file, section, variable, data);
  57.     debug("\tSetNameValuePair: [" +section+ "] " +variable+ "=" + data);
  58. }
  59.  
  60.  
  61.  
  62. function getConfigFolder(theObject)
  63. {
  64.     var thePlatform = new String(navigator.userAgent);
  65.     var x=thePlatform.indexOf("(")+1;
  66.     var y=thePlatform.indexOf(";",x+1);
  67.     thePlatform=thePlatform.substring(x,y);
  68.  
  69.     var pathName;
  70.     if (thePlatform == "Macintosh")    {                // Macintosh support
  71.         pathName = getFolder(theObject) + "Config:";
  72.         }
  73.     else    {                                        // Windows support
  74.         pathName = getFolder(theObject) + "Config/";
  75.         }
  76.  
  77.     debug("getConfigFolder: " + pathName);
  78.     return(pathName);
  79. }
  80.  
  81.  
  82.  
  83. function getAcctSetupFilename(theObject)
  84. {
  85.     var thePlatform = new String(navigator.userAgent);
  86.     var x=thePlatform.indexOf("(")+1;
  87.     var y=thePlatform.indexOf(";",x+1);
  88.     thePlatform=thePlatform.substring(x,y);
  89.  
  90.     var theFile;
  91.     if (thePlatform == "Macintosh")    {                // Macintosh support
  92.         theFile = getConfigFolder(theObject) + "ACCTSET.INI";
  93.         }
  94.     else    {                                        // Windows support
  95.         theFile = getConfigFolder(theObject) + "ACCTSET.INI";
  96.         }
  97.  
  98.     debug("getAcctSetupFilename: " + theFile);
  99.     return(theFile);
  100. }
  101.  
  102.  
  103.  
  104. function getFolder(theObject)
  105. {
  106.     var thePlatform = new String(navigator.userAgent);
  107.     var x=thePlatform.indexOf("(")+1;
  108.     var y=thePlatform.indexOf(";",x+1);
  109.     thePlatform=thePlatform.substring(x,y);
  110.  
  111.     if (thePlatform == "Macintosh")    {                // Macintosh support
  112.  
  113.         var path=unescape(theObject.location.pathname);
  114.         if ((x=path.lastIndexOf("/"))>0)    {
  115.             path=path.substring(0,x+1);
  116.             }
  117.         var fileArray=path.split("/");
  118.         var newpath=fileArray.join(":");
  119.         if (newpath.charAt(0)==':')    {
  120.             newpath=newpath.substring(1,newpath.length);
  121.             }
  122.         newpath=unescape(newpath);
  123.         }
  124.     else    {                                        // Windows support
  125.  
  126.         // note: JavaScript returns path with '/' instead of '\'
  127.  
  128.         var path=unescape(theObject.location.pathname);
  129.  
  130.         // gets the drive letter and directory path
  131.  
  132.         if ((x=path.lastIndexOf("|"))>0)    {
  133.             var Drive = path.substring(path.indexOf('/')+1, path.indexOf('|'));
  134.             var dirPath = path.substring(path.indexOf('|')+1, path.lastIndexOf('/')+1);
  135.             }
  136.  
  137.         // construct newpath        
  138.  
  139.         newpath = Drive + ":" + dirPath;
  140.         }
  141.     return(newpath);
  142. }
  143.  
  144.  
  145.  
  146. function setFocus(theObject)
  147. {
  148.     theObject.focus();
  149.     theObject.select();
  150. }
  151.  
  152.  
  153.  
  154. function message(txt)
  155. {
  156.     window.status = txt;
  157.     setTimeout("remove_message()",10000);
  158. }
  159.  
  160.  
  161.  
  162. function remove_message()
  163. {
  164.     window.status="";
  165. }
  166.  
  167.  
  168.  
  169. function checkPluginExists(name,generateOutputFlag)
  170. {
  171.     /*
  172.     var myPlugin = navigator.plugins["name"];
  173.     if (myPlugin)    {
  174.         // do something here
  175.         }
  176.     else    {
  177.         document.writeln("<CENTER><STRONG>Warning! The '" +name+ "' plug-in is not installed!</STRONG></CENTER>\n");
  178.         }
  179.     */
  180.     
  181.     if (navigator.javaEnabled())    {
  182.         var myMimetype = navigator.mimeTypes[name]
  183.         if (myMimetype)    {
  184.              return true;
  185.              }
  186.         else    {
  187.             if (generateOutputFlag==true)    {
  188.                 document.writeln("<CENTER><STRONG>The 'Account Setup Plugin' is not installed!<P>\n");
  189.                 document.writeln("Please install the plugin, then run 'Account Setup' again.</STRONG></CENTER>\n");
  190.                 }
  191.              return false;
  192.             }
  193.         }
  194.     else    {
  195.         if (generateOutputFlag==true)    {
  196.             document.writeln("<CENTER><STRONG>Java support is disabled!<P>\n");
  197.             document.writeln("Choose Options | Network Preferences and enable Java, then try again.</STRONG></CENTER>\n");
  198.             }
  199.          return false;
  200.         }
  201. }
  202.  
  203.  
  204.  
  205. function forceReboot(pageName)
  206. {
  207.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  208.  
  209.     debug("go: Reboot needed before move to page " +pageName);
  210.  
  211.     alert("A reboot is needed. Account Setup will continue after the reboot.");
  212.  
  213.     navigator.preference("mail.check_new_mail",    false);
  214.  
  215.     document.vars.startupFile.value = pageName;
  216.  
  217.     saveGlobalData();
  218.  
  219.     // if rebooting and using magic profile, rename it so that it won't be automatically deleted at next launch
  220.  
  221.     var profileName = parent.parent.globals.document.setupPlugin.GetCurrentProfileName();
  222.     if (profileName != null && profileName != "")    {
  223.         profileName = profileName.toUpperCase();
  224.         if (profileName == '911' || profileName == 'USER1')    {
  225.             parent.parent.globals.document.setupPlugin.SetCurrentProfileName("912");
  226.             }
  227.         }
  228.  
  229.     parent.parent.globals.document.setupPlugin.Reboot(getFolder(self) + "start.htm");
  230. }
  231.  
  232.  
  233.  
  234. function findVariable(theVar)
  235. {
  236.     var theValue="";
  237.     var regData=parent.parent.globals.document.vars.regData.value;
  238.     var x=regData.indexOf(theVar+"=");
  239.     if (x>=0)    {
  240.         x = x + theVar.length + 1;
  241.         var y=regData.indexOf("\r",x);
  242.         if (y>x)    {
  243.             theValue=regData.substring(x,y);
  244.             debug("findVariable: " +theVar + "=" + theValue);
  245.             }
  246.         }
  247.     return(theValue);
  248. }
  249.  
  250.  
  251.  
  252. //    contentFile = "main.htm";
  253.  
  254.  
  255.  
  256. function getContentPage()
  257. {
  258. //    var file = contentFile;
  259. //    contentFile = null;
  260.     var file = parent.parent.globals.document.vars.startupFile.value;
  261.     parent.parent.globals.document.vars.startupFile.value = "";
  262.     return(file);
  263. }
  264.  
  265.  
  266.  
  267. function setContentPage(file)
  268. {
  269. //    contentFile = file;
  270.     parent.parent.globals.document.vars.startupFile.value = file;
  271. }
  272.  
  273.  
  274. function loadUserInput()
  275. {
  276.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  277.  
  278.     if (document.vars.inited.value != "yes")    {
  279.         document.vars.inited.value = "yes";
  280.  
  281.         var cookieWarning = navigator.preference("network.cookie.warnAboutCookies");
  282.         if (cookieWarning == true)    {
  283.             document.vars.cookieWarning.value = "yes";
  284.             }
  285.         else    {
  286.             document.vars.cookieWarning.value = "no";
  287.             }
  288.         navigator.preference("network.cookie.warnAboutCookies", false);
  289.  
  290.         document.vars.offlineMode.value = navigator.preference("offline.startup_mode");
  291.         navigator.preference("offline.startup_mode", 0);        // online
  292.         navigator.preference("network.online", true);
  293.  
  294.         var acctSetupFile = getAcctSetupFilename(self);
  295.         if (acctSetupFile != null && acctSetupFile != "")    {
  296.             var intlMode = parent.parent.globals.GetNameValuePair(acctSetupFile,"Mode Selection","IntlMode");
  297.             if (intlMode != null && intlMode != "")    {
  298.                 intlMode = intlMode.toLowerCase();
  299.                 }
  300.             }
  301.     
  302.         var userInputFile = document.setupPlugin.GetCurrentProfileDirectory();
  303.         if (userInputFile != null && userInputFile != "")    {
  304.             userInputFile = userInputFile + "ACCTSET.DAT";
  305.             var theSection="Account Setup User Input";
  306.         
  307.             var regServer = GetNameValuePair(userInputFile,theSection,"regServer");
  308.             if (regServer != null && regServer != "")    {
  309.                 document.vars.regServer.value = regServer;
  310.                 SetNameValuePair(userInputFile,theSection,"regServer", "");
  311.                 }
  312.             document.vars.first.value = GetNameValuePair(userInputFile,theSection,"first");
  313.             document.vars.last.value = GetNameValuePair(userInputFile,theSection,"last");
  314.             document.vars.company.value = GetNameValuePair(userInputFile,theSection,"company");
  315.             document.vars.address1.value = GetNameValuePair(userInputFile,theSection,"address1");
  316.             document.vars.address2.value = GetNameValuePair(userInputFile,theSection,"address2");
  317.             if (intlMode=="yes")    {
  318.                 document.vars.address3.value = GetNameValuePair(userInputFile,theSection,"address3");
  319.                 document.vars.city.value="";
  320.                 document.vars.state.value="";
  321.                 document.vars.zip.value="";
  322.                 document.vars.areaCode.value="";
  323.                 }
  324.             else    {
  325.                 document.vars.address3.value="";
  326.                 document.vars.city.value = GetNameValuePair(userInputFile,theSection,"city");
  327.                 document.vars.state.value = GetNameValuePair(userInputFile,theSection,"state");
  328.                 document.vars.zip.value = GetNameValuePair(userInputFile,theSection,"zip");
  329.                 document.vars.areaCode.value = GetNameValuePair(userInputFile,theSection,"areaCode");
  330.                 }
  331.             document.vars.phoneNumber.value = GetNameValuePair(userInputFile,theSection,"phoneNumber");
  332.             document.vars.country.value = GetNameValuePair(userInputFile,theSection,"country");
  333.             document.vars.countryCode.value = GetNameValuePair(userInputFile,theSection,"countryCode");
  334.                 
  335.             document.vars.cardname.value = GetNameValuePair(userInputFile,theSection,"cardname");
  336.             document.vars.cardtype.value = GetNameValuePair(userInputFile,theSection,"cardtype");
  337.             document.vars.cardcode.value = GetNameValuePair(userInputFile,theSection,"cardcode");
  338.             document.vars.cardnumber.value = GetNameValuePair(userInputFile,theSection,"cardnumber");
  339.             SetNameValuePair(userInputFile,theSection,"cardnumber", "");
  340.     
  341.             document.vars.month.value = GetNameValuePair(userInputFile,theSection,"month");
  342.             document.vars.year.value = GetNameValuePair(userInputFile,theSection,"year");
  343.     
  344.             document.vars.modem.value = GetNameValuePair(userInputFile,theSection,"modem");
  345.             document.vars.manufacturer.value = GetNameValuePair(userInputFile,theSection,"manufacturer");
  346.             document.vars.model.value = GetNameValuePair(userInputFile,theSection,"model");
  347.     
  348.     
  349.             document.vars.externalEditor.value = GetNameValuePair(userInputFile,theSection,"externalEditor");
  350.     
  351.     
  352.             if (intlMode=="yes")    {
  353.                 document.vars.modemAreaCode.value="";
  354.                 }
  355.             else    {
  356.                 document.vars.modemAreaCode.value = GetNameValuePair(userInputFile,theSection,"modemAreaCode");
  357.                 }
  358.             document.vars.modemPhoneNumber.value = GetNameValuePair(userInputFile,theSection,"modemPhoneNumber");
  359.             document.vars.cwData.value = GetNameValuePair(userInputFile,theSection,"cwData");
  360.             if (document.vars.cwData.value != null && document.vars.cwData.value != "")    {
  361. //                document.vars.prefix.cwOFF=1;
  362.                 }
  363.             else    {
  364. //                document.vars.prefix.cwOFF=0;
  365.                 }
  366.             document.vars.prefixData.value = GetNameValuePair(userInputFile,theSection,"prefixData");
  367.             if (document.vars.prefixData.value != null && document.vars.prefixData.value != "")    {
  368. //                document.vars.prefix.checked=1;
  369.                 }
  370.             else    {
  371. //                document.vars.prefix.checked=0;
  372.                 }
  373.             document.vars.dialMethod.value = GetNameValuePair(userInputFile,theSection,"dialMethod");
  374.     
  375.             document.vars.providername.value = GetNameValuePair(userInputFile,theSection,"providername");
  376.             if (intlMode=="yes")    {
  377.                 document.vars.accountAreaCode.value="";
  378.                 }
  379.             else    {
  380.                 document.vars.accountAreaCode.value = GetNameValuePair(userInputFile,theSection,"accountAreaCode");
  381.                 }
  382.             document.vars.accountPhoneNumber.value = GetNameValuePair(userInputFile,theSection,"accountPhoneNumber");
  383.     
  384.             document.vars.accountName.value = GetNameValuePair(userInputFile,theSection,"accountName");
  385.             document.vars.emailName.value = GetNameValuePair(userInputFile,theSection,"emailName");
  386.             document.vars.publishURL.value = GetNameValuePair(userInputFile,theSection,"publishURL");
  387.             document.vars.viewURL.value = GetNameValuePair(userInputFile,theSection,"viewURL");
  388.  
  389.             document.vars.accountPassword.value = GetNameValuePair(userInputFile,theSection,"accountPassword");        // existing path
  390.             document.vars.accountPasswordCheck.value = GetNameValuePair(userInputFile,theSection,"accountPasswordCheck");
  391.             document.vars.emailPassword.value = GetNameValuePair(userInputFile,theSection,"emailPassword");
  392.             document.vars.emailPasswordCheck.value = GetNameValuePair(userInputFile,theSection,"emailPasswordCheck");
  393.             document.vars.publishPassword.value = GetNameValuePair(userInputFile,theSection,"publishPassword");
  394.             document.vars.publishPasswordCheck.value = GetNameValuePair(userInputFile,theSection,"publishPasswordCheck");
  395.             document.vars.SMTP.value = GetNameValuePair(userInputFile,theSection,"SMTP");
  396.             document.vars.mailServer.value = GetNameValuePair(userInputFile,theSection,"mailServer");
  397.             document.vars.mailProtocol.value = GetNameValuePair(userInputFile,theSection,"mailProtocol");
  398.             document.vars.NNTP.value = GetNameValuePair(userInputFile,theSection,"NNTP");
  399.             document.vars.domainName.value = GetNameValuePair(userInputFile,theSection,"domainName");
  400.             document.vars.primaryDNS.value = GetNameValuePair(userInputFile,theSection,"primaryDNS");
  401.             document.vars.secondaryDNS.value = GetNameValuePair(userInputFile,theSection,"secondaryDNS");
  402.             document.vars.ipAddress.value = GetNameValuePair(userInputFile,theSection,"ipAddress");
  403.             document.vars.scriptEnabled.value = GetNameValuePair(userInputFile,theSection,"scriptEnabled");
  404.             document.vars.scriptFile.value = GetNameValuePair(userInputFile,theSection,"scriptFile");
  405.             document.vars.lckFilename.value = GetNameValuePair(userInputFile,theSection,"lckFilename");
  406.  
  407.             SetNameValuePair(userInputFile,theSection,"accountPassword", "");                                        // existing path
  408.             SetNameValuePair(userInputFile,theSection,"accountPasswordCheck", "");
  409.             SetNameValuePair(userInputFile,theSection,"emailPassword", "");
  410.             SetNameValuePair(userInputFile,theSection,"emailPasswordCheck", "");
  411.             SetNameValuePair(userInputFile,theSection,"publishPassword", "");
  412.             SetNameValuePair(userInputFile,theSection,"publishPasswordCheck", "");
  413.             }
  414.         }
  415. }
  416.  
  417.  
  418.  
  419. /*
  420.     loadGlobalData:        checks for the plugin; reads in any saved user input from a previous session
  421. */
  422.  
  423. function loadGlobalData()
  424. {
  425.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  426.  
  427.     if (document.setupPlugin == null)    return;
  428.  
  429.     if (document.vars.inited.value != "yes")    {
  430.  
  431.         // load globals here
  432.     
  433.         var acctSetupFile = getAcctSetupFilename(self);
  434.         if (acctSetupFile != null && acctSetupFile != "")    {
  435.             var intlMode = parent.parent.globals.GetNameValuePair(acctSetupFile,"Mode Selection","IntlMode");
  436.             if (intlMode != null && intlMode != "")    {
  437.                 intlMode = intlMode.toLowerCase();
  438.                 document.vars.intlMode.value = intlMode;
  439.                 }
  440.             var editMode = parent.parent.globals.GetNameValuePair(acctSetupFile,"Mode Selection","EditMode");
  441.             if (editMode != null && editMode != "")    {
  442.                 editMode = editMode.toLowerCase();
  443.                 document.vars.editMode.value = editMode;
  444.                 SetNameValuePair(acctSetupFile,"Mode Selection","EditMode", "no");
  445.                 }
  446.  
  447.             // if not in editMode, ensure that OS support is available (networking,dialer,etc)
  448.     
  449.             if (editMode != "yes")    {
  450.                 var installedFlag = document.setupPlugin.CheckEnvironment();
  451.                 if (installedFlag != true)    {
  452.                     document.setupPlugin.QuitNavigator();
  453.                     return;
  454.                     }
  455.                 }
  456.  
  457.             // set appropriate path info (if not prompting user)
  458.     
  459.             document.vars.path.value = "";
  460.             var newPathFlag = parent.parent.globals.GetNameValuePair(acctSetupFile,"Mode Selection","ForceNew");
  461.             newPathFlag = newPathFlag.toLowerCase();
  462.             var existingPathFlag = parent.parent.globals.GetNameValuePair(acctSetupFile,"Mode Selection","ForceExisting");
  463.             existingPathFlag = existingPathFlag.toLowerCase();
  464.     
  465.             if (newPathFlag == "yes" && existingPathFlag != "yes")    {
  466.                 document.vars.path.value = "New Path";
  467.                 }
  468.             else if (existingPathFlag == "yes" && newPathFlag != "yes")    {
  469.                 document.vars.path.value = "Existing Path";
  470.                 }
  471.             }
  472.     
  473.         if (document.vars.debugMode.value.toLowerCase() != "yes" && (document.vars.editMode.value.toLowerCase() != "yes"))    {
  474.             if (checkPluginExists("application/x-netscape-autoconfigure-dialer",false))    {
  475.                 document.setupPlugin.SetKiosk(true);
  476.                 }
  477.             }
  478.     
  479.         // load in user input (if any)
  480.     
  481.         var userInputFile = document.setupPlugin.GetCurrentProfileDirectory();
  482.         if (userInputFile != null && userInputFile != "")    {
  483.  
  484.             userInputFile = userInputFile + "ACCTSET.DAT";
  485.             var theSection="Account Setup User Input";
  486.     
  487.             document.vars.externalEditor.value = GetNameValuePair(userInputFile,theSection,"externalEditor");
  488.  
  489.             var startupFile = GetNameValuePair(userInputFile,theSection,"startupFile");
  490.             if (startupFile != null && startupFile != "")    {
  491.                 document.vars.startupFile.value = startupFile;
  492.                 document.vars.path.value = GetNameValuePair(userInputFile,theSection,"path");
  493.                 document.vars.pageHistory.value = GetNameValuePair(userInputFile,theSection,"pageHistory");
  494.  
  495.                 SetNameValuePair(userInputFile,theSection,"startupFile", "");
  496.                 SetNameValuePair(userInputFile,theSection,"path", "");
  497.                 SetNameValuePair(userInputFile,theSection,"pageHistory", "");
  498.  
  499.                 // if coming out of a reboot and using magic profile, rename it so that it won't be automatically deleted at next launch
  500.             
  501.                 var profileName = document.setupPlugin.GetCurrentProfileName();
  502.                 if (profileName != null && profileName != "")    {
  503.                     profileName = profileName.toUpperCase();
  504.                     if (profileName == '912')    {
  505.                         document.setupPlugin.SetCurrentProfileName("USER1");
  506.                         }
  507.                     }
  508.                 loadUserInput();
  509.                 }
  510.             else    {
  511.                 document.vars.startupFile.value = "main.htm";
  512.                 // defer loading user input until after main screen has loaded (faster speedup)
  513.                 }
  514.             parent.screen.location.replace("screen.htm");
  515.             }
  516.  
  517.         // QA support
  518.  
  519.         var qaMode = document.vars.qaMode.value;
  520.         if (qaMode != null && qaMode != "")    {
  521.             qaMode = qaMode.toLowerCase();
  522.             if (qaMode == "yes")    {
  523.                 if (confirm("Would you like to use a Milan data file to configure Communicator?") == true)    {
  524.                     if (document.setupPlugin.Milan(null,null,true,false) == true)    {
  525.                         document.vars.regMode.value = "yes";
  526.                         }
  527.                     }
  528.                 }
  529.             }
  530.  
  531.         }
  532.     if (document.vars.regMode.value == "yes")    {
  533.         setRegisterMode(1);
  534.         }
  535. }
  536.  
  537.  
  538.  
  539. function saveExternalEditor()
  540. {
  541.     // Since we don't do a saveGlobalData in editMode, we need an alternate way to save the externalEditor
  542.     // as a preference in ACCTSET.DAT.  This is it.
  543.     
  544.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  545.     var userInputFile = document.setupPlugin.GetCurrentProfileDirectory();
  546.     if (userInputFile != null && userInputFile != "")    {
  547.         userInputFile = userInputFile + "ACCTSET.DAT";
  548.         var theSection="Account Setup User Input";
  549.         SetNameValuePair(userInputFile,theSection,"externalEditor", document.vars.externalEditor.value);
  550.         }
  551. }
  552.  
  553.  
  554. function saveGlobalData()
  555. {
  556.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  557.  
  558.     if (document.vars.editMode.value.toLowerCase() == "yes")    return;
  559.  
  560.     if (document.setupPlugin == null)    return;
  561. /*
  562.     if (document.vars.debugMode.value.toLowerCase() != "yes" && (document.vars.editMode.value.toLowerCase() != "yes"))    {
  563.         if (checkPluginExists("application/x-netscape-autoconfigure-dialer",false))    {
  564.             document.setupPlugin.SetKiosk(false);
  565.             }
  566.         }
  567.     top.statusbar.visible=true;
  568.     top.scrollbars.visible=true;
  569.     top.toolbar.visible=true;
  570.     top.menubar.visible=true;
  571.     top.locationbar.visible=true;
  572.     top.personalbar.visible=true;                // was directory
  573. */
  574.         
  575.     if (document.vars.cookieWarning.value == "yes")    {
  576.         navigator.preference("network.cookie.warnAboutCookies", true);
  577.         }
  578.     else    {
  579.         navigator.preference("network.cookie.warnAboutCookies", false);
  580.         }
  581.  
  582.     if (document.vars.offlineMode.value != "undefined") {
  583.         navigator.preference("offline.startup_mode", document.vars.offlineMode.value);
  584.     }
  585.  
  586.  
  587.     // save user input (if any)
  588.  
  589.     var userInputFile = document.setupPlugin.GetCurrentProfileDirectory();
  590.     if (userInputFile != null && userInputFile != "")    {
  591.         userInputFile = userInputFile + "ACCTSET.DAT";
  592.         var theSection="Account Setup User Input";
  593.     
  594.         SetNameValuePair(userInputFile,theSection,"startupFile", document.vars.startupFile.value);
  595.         SetNameValuePair(userInputFile,theSection,"regServer", document.vars.regServer.value);
  596.  
  597.         SetNameValuePair(userInputFile,theSection,"first", document.vars.first.value);
  598.         SetNameValuePair(userInputFile,theSection,"last", document.vars.last.value);
  599.         SetNameValuePair(userInputFile,theSection,"company", document.vars.company.value);
  600.         SetNameValuePair(userInputFile,theSection,"address1", document.vars.address1.value);
  601.         SetNameValuePair(userInputFile,theSection,"address2", document.vars.address2.value);
  602.         SetNameValuePair(userInputFile,theSection,"address3", document.vars.address3.value);
  603.         SetNameValuePair(userInputFile,theSection,"city", document.vars.city.value);
  604.         SetNameValuePair(userInputFile,theSection,"state", document.vars.state.value);
  605.         SetNameValuePair(userInputFile,theSection,"zip", document.vars.zip.value);
  606.         SetNameValuePair(userInputFile,theSection,"areaCode", document.vars.areaCode.value);
  607.         SetNameValuePair(userInputFile,theSection,"phoneNumber", document.vars.phoneNumber.value);
  608.         SetNameValuePair(userInputFile,theSection,"country", document.vars.country.value);
  609.         SetNameValuePair(userInputFile,theSection,"countryCode", document.vars.countryCode.value);
  610.         
  611.         SetNameValuePair(userInputFile,theSection,"cardname", document.vars.cardname.value);
  612.         SetNameValuePair(userInputFile,theSection,"cardtype", document.vars.cardtype.value);
  613.         SetNameValuePair(userInputFile,theSection,"cardcode", document.vars.cardcode.value);
  614.         if (document.setupPlugin.NeedReboot() == true)    {
  615.             SetNameValuePair(userInputFile,theSection,"cardnumber", document.vars.cardnumber.value);
  616.             SetNameValuePair(userInputFile,theSection,"path", document.vars.path.value);
  617.             SetNameValuePair(userInputFile,theSection,"pageHistory", document.vars.pageHistory.value);
  618.  
  619.             SetNameValuePair(userInputFile,theSection,"accountPassword", document.vars.accountPassword.value);        // existing path
  620.             SetNameValuePair(userInputFile,theSection,"accountPasswordCheck", document.vars.accountPasswordCheck.value);
  621.             SetNameValuePair(userInputFile,theSection,"emailPassword", document.vars.emailPassword.value);
  622.             SetNameValuePair(userInputFile,theSection,"emailPasswordCheck", document.vars.emailPasswordCheck.value);
  623.             SetNameValuePair(userInputFile,theSection,"publishPassword", document.vars.publishPassword.value);
  624.             SetNameValuePair(userInputFile,theSection,"publishPasswordCheck", document.vars.publishPasswordCheck.value);
  625.             SetNameValuePair(userInputFile,theSection,"SMTP", document.vars.SMTP.value);
  626.             SetNameValuePair(userInputFile,theSection,"mailServer", document.vars.mailServer.value);
  627.             SetNameValuePair(userInputFile,theSection,"mailProtocol", document.vars.mailProtocol.value);
  628.             SetNameValuePair(userInputFile,theSection,"NNTP", document.vars.NNTP.value);
  629.             SetNameValuePair(userInputFile,theSection,"domainName", document.vars.domainName.value);
  630.             SetNameValuePair(userInputFile,theSection,"primaryDNS", document.vars.primaryDNS.value);
  631.             SetNameValuePair(userInputFile,theSection,"secondaryDNS", document.vars.secondaryDNS.value);
  632.             SetNameValuePair(userInputFile,theSection,"ipAddress", document.vars.ipAddress.value);
  633.             SetNameValuePair(userInputFile,theSection,"scriptEnabled", document.vars.scriptEnabled.value);
  634.             SetNameValuePair(userInputFile,theSection,"scriptFile", document.vars.scriptFile.value);
  635.             SetNameValuePair(userInputFile,theSection,"lckFilename", document.vars.lckFilename.value);
  636.             }
  637.         else    {
  638.             SetNameValuePair(userInputFile,theSection,"cardnumber", "");
  639.             SetNameValuePair(userInputFile,theSection,"path", "");
  640.             SetNameValuePair(userInputFile,theSection,"pageHistory", "");
  641.  
  642.             SetNameValuePair(userInputFile,theSection,"accountPassword", "");                                        // existing path
  643.             SetNameValuePair(userInputFile,theSection,"accountPasswordCheck", "");
  644.             SetNameValuePair(userInputFile,theSection,"emailPassword", "");
  645.             SetNameValuePair(userInputFile,theSection,"emailPasswordCheck", "");
  646.             SetNameValuePair(userInputFile,theSection,"publishPassword", "");
  647.             SetNameValuePair(userInputFile,theSection,"publishPasswordCheck", "");
  648.             }
  649.         SetNameValuePair(userInputFile,theSection,"month", document.vars.month.value);
  650.         SetNameValuePair(userInputFile,theSection,"year", document.vars.year.value);
  651.  
  652.         SetNameValuePair(userInputFile,theSection,"modem", document.vars.modem.value);
  653.         SetNameValuePair(userInputFile,theSection,"manufacturer", document.vars.manufacturer.value);
  654.         SetNameValuePair(userInputFile,theSection,"model", document.vars.model.value);
  655.  
  656.         SetNameValuePair(userInputFile,theSection,"modemAreaCode", document.vars.modemAreaCode.value);
  657.         SetNameValuePair(userInputFile,theSection,"modemPhoneNumber", document.vars.modemPhoneNumber.value);
  658.         SetNameValuePair(userInputFile,theSection,"cwData", document.vars.cwData.value);
  659.         SetNameValuePair(userInputFile,theSection,"prefixData", document.vars.prefixData.value);
  660.         SetNameValuePair(userInputFile,theSection,"dialMethod", document.vars.dialMethod.value);
  661.  
  662.         SetNameValuePair(userInputFile,theSection,"providername", document.vars.providername.value);
  663.         SetNameValuePair(userInputFile,theSection,"providerFilename", document.vars.providerFilename.value);        // existing path
  664.         SetNameValuePair(userInputFile,theSection,"accountAreaCode", document.vars.accountAreaCode.value);
  665.         SetNameValuePair(userInputFile,theSection,"accountPhoneNumber", document.vars.accountPhoneNumber.value);
  666.  
  667.         SetNameValuePair(userInputFile,theSection,"accountName", document.vars.accountName.value);
  668.         SetNameValuePair(userInputFile,theSection,"emailName", document.vars.emailName.value);
  669.         SetNameValuePair(userInputFile,theSection,"publishURL", document.vars.publishURL.value);
  670.         SetNameValuePair(userInputFile,theSection,"viewURL", document.vars.viewURL.value);
  671.         SetNameValuePair(userInputFile,theSection,"externalEditor", document.vars.externalEditor.value);
  672.         }
  673. }
  674.  
  675.  
  676.  
  677. function setRegisterMode(numSecondsElapsed)
  678. {
  679.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  680.  
  681.     var connectStatusFlag = document.setupPlugin.IsDialerConnected();
  682.     document.vars.regMode.value="yes";
  683.     var regData = document.setupPlugin.GetRegInfo(false);
  684.  
  685.     if ((numSecondsElapsed<10) || (connectStatusFlag == true))    {
  686.         numSecondsElapsed = numSecondsElapsed +1;
  687.  
  688.         if (regData == null)    {
  689.             setTimeout("setRegisterMode(" + numSecondsElapsed + ")",1000);    // check every second
  690.             }
  691.         else    {
  692.             // handle multi-line data differently
  693.  
  694.             var bookmarkTag = "BOOKMARK_FILE=";
  695.             var bookmarkTagLen = bookmarkTag.length;
  696.  
  697.             document.vars.regMode.value="no";
  698.             document.vars.regData.value="";
  699.             debug("\nRegistration Complete: " + regData.length + " item(s)");
  700.             for (var x=0; x<regData.length; x++)    {
  701.                 var data = "" + regData[x];
  702.                 var dataLen = data.length;
  703.  
  704.                 if (data.indexOf(bookmarkTag)==0)    {
  705.                     data = data.substring(bookmarkTagLen,dataLen);
  706.                     document.vars.regBookmark.value = data;
  707.                     }
  708.                 else    {
  709.                     document.vars.regData.value = document.vars.regData.value + regData[x] + "\r";
  710.                     }
  711.                 debug("        " + x + ": " + regData[x]);
  712.                 }
  713.             document.setupPlugin.GetRegInfo(true);
  714.  
  715.             // hang up (this will delete the dialer's
  716.             // reference to the Registration Server)
  717.  
  718.             document.setupPlugin.DialerHangup();
  719.  
  720.             // check status and go to appropriate screen
  721.  
  722.             var status = findVariable("STATUS");
  723.             if (status == "OK")    {
  724.                 configureNewAccount();
  725.  
  726.                 var rebootFlag = document.setupPlugin.NeedReboot();
  727.                 if (rebootFlag == true)    {
  728.                     setContentPage("okreboot.htm");
  729.                     }
  730.                 else    {
  731.                     setContentPage("ok.htm");
  732.                     }
  733.  
  734.                 }
  735.             else if (status == "EXIT")    {
  736.                 saveGlobalData();
  737.                 document.setupPlugin.QuitNavigator();
  738.                 }
  739.             else    {
  740.                 setContentPage("error.htm");
  741.                 }
  742.             parent.frames[0].location.replace("screen.htm");
  743.  
  744.             navigator.preference("security.warn_submit_insecure",    true);
  745.             navigator.preference("security.warn_entering_secure",    true);
  746.             navigator.preference("security.warn_leaving_secure",    true);
  747.             }
  748.         }
  749.     else    {
  750.         document.vars.regMode.value="no";
  751.  
  752.         // hang up (even if already disconnected, this will delete
  753.         // the dialer's reference to the Registration Server)
  754.  
  755.         document.setupPlugin.DialerHangup();
  756.  
  757.         // go to error screen
  758.  
  759.         document.setupPlugin.GetRegInfo(true);
  760.         setContentPage("error.htm");
  761.         parent.screen.location.replace("screen.htm");
  762.  
  763.         navigator.preference("security.warn_submit_insecure",    true);
  764.         navigator.preference("security.warn_entering_secure",    true);
  765.         navigator.preference("security.warn_leaving_secure",    true);
  766.         }
  767. }
  768.  
  769.  
  770.  
  771. function verifyIPaddress(address)
  772. {
  773.     var dotCount=0,dotIndex=0,net,validFlag=false;
  774.  
  775.     while(dotIndex>=0)    {
  776.         net="";
  777.         dotIndex=address.indexOf(".");
  778.         if (dotIndex>=0)    {
  779.             net=address.substring(0,dotIndex);
  780.             address=address.substring(dotIndex+1);
  781.             ++dotCount;
  782.             }
  783.         else    {
  784.             net=address;
  785.             if (net=="")    break;
  786.             }
  787.  
  788.         netValue=parseInt(net);
  789.         if (isNaN(netValue))    break;
  790.         if (netValue<0 || netValue>255)    break;
  791.  
  792.         if (dotCount==3 && dotIndex<0)    validFlag=true;
  793.         }    
  794.     return(validFlag);
  795. }
  796.  
  797.  
  798.  
  799. function verifyAreaCode(areaCode)
  800. {
  801.     var    validFlag=false;
  802.  
  803.     if (areaCode.length >= 3)    {
  804.         validFlag=true;
  805.         for (var x=0; x<areaCode.length; x++)    {
  806.             if ("0123456789".indexOf(areaCode.charAt(x)) <0)    {
  807.                 validFlag=false;
  808.                 break;
  809.                 }
  810.             }
  811.         }
  812.     return(validFlag);
  813. }
  814.  
  815.  
  816.  
  817. function verifyZipCode(zipCode)
  818. {
  819.     var    validFlag=false;
  820.  
  821.     if (zipCode.length >= 5)    {
  822.         validFlag=true;
  823.         for (var x=0; x<zipCode.length; x++)    {
  824.             if ("0123456789-".indexOf(zipCode.charAt(x)) <0)    {
  825.                 validFlag=false;
  826.                 break;
  827.                 }
  828.             }
  829.         }
  830.     return(validFlag);
  831. }
  832.  
  833.  
  834.  
  835. function verifyPhoneNumber(phoneNum)
  836. {
  837.     var    validFlag=false;
  838.  
  839.     if (phoneNum.length >= 7)    {
  840.         validFlag=true;
  841.         for (var x=0; x<phoneNum.length; x++)    {
  842.             if ("0123456789().,-+ ".indexOf(phoneNum.charAt(x)) <0)    {
  843.                 validFlag=false;
  844.                 break;
  845.                 }
  846.             }
  847.         }
  848.     return(validFlag);
  849. }
  850.  
  851.  
  852.  
  853. // end hiding contents from old browsers  -->
  854.