/*

    Copyright 2003-2007 Purdue University. 

    Developed by: Peter Turbek, Department of Mathematics, Computer Science, and Statistics, Purdue University Calumet.


    This file is part of CaluMath.

    CaluMath is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    CaluMath is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

//This file contains the names the user sees for all the objects they can create using the CaluMath Page Maker. These names are not the same as the names the CaluMath Page Maker and its associated program internally gives to them.//


CaluMath.PM.PerformForRemoval= function(){

   var tempobject= arguments[0];
   var childarray=tempobject.childarray;
   var childarraylength=childarray.length;
   var forremovalarray=tempobject.forremovalarray;
   var forremovalarraylength=forremovalarray.length;

   if(childarray != null && childarraylength>0){
      for (var i=0; i<childarraylength; i++){
         CaluMath.PM.PerformForRemoval(childarray[i]);
      };
   };
   
   if(forremovalarray != null && forremovalarraylength>0){
      for (var i=0; i<forremovalarraylength; i++){
         CaluMath.PM.PageMakerObjectArray=CaluMath.PM.PageMakerObjectArray.cm_removeelements(forremovalarray[i]);
         CaluMath.PM.PerformForRemoval(forremovalarray[i]);
      };
   };
   CaluMath.PM.PageMakerObjectArray=CaluMath.PM.PageMakerObjectArray.cm_removeelements(tempobject);
   CaluMath.PM.EveryObjectArray=CaluMath.PM.EveryObjectArray.cm_removeelements(tempobject);
};

CaluMath.PM.PopulateTableWithCurrentValues=function(){
   var defaultobject=CM_TopWindow.CaluMath.Html.Eval("CaluMath.PM.PageMaker"+arguments[0]+"Default"); 
   var tempobject=arguments[1];
   var tempobjectsettings = tempobject.settings;
   if(tempobject.settings != null){
      var tempobjectsettingslength = tempobjectsettings.length;

      for(var i=0; i<tempobjectsettingslength; i++){
         if(defaultobject.options != null && defaultobject.options[tempobjectsettings[i][0]] != null && defaultobject.options[tempobjectsettings[i][0]] .type=="input"){
              defaultobject.options[tempobjectsettings[i][0]].input.value=tempobjectsettings[i][1].cm_unescapequotes().cm_unescapebackslashes();
         }
         else if(defaultobject.required != null && defaultobject.required[tempobjectsettings[i][0]] != null && defaultobject.required[tempobjectsettings[i][0]] .type=="input"){
              if(defaultobject.options[tempobjectsettings[i][0]].input.getAttribute("type") != "file"){
                defaultobject.required[tempobjectsettings[i][0]].input.value=tempobjectsettings[i][1].cm_unescapequotes().cm_unescapebackslashes();
              };
         }
         else if(defaultobject.options != null && defaultobject.options[tempobjectsettings[i][0]] != null && defaultobject.options[tempobjectsettings[i][0]].type=="menu"){
            CaluMath.PM.MakeDefaultOption(defaultobject.options[tempobjectsettings[i][0]].menu,tempobjectsettings[i][1], "value");
         }
         else if(defaultobject.required != null && defaultobject.required[tempobjectsettings[i][0]] != null && defaultobject.required[tempobjectsettings[i][0]].type=="menu"){
            CaluMath.PM.MakeDefaultOption(defaultobject.required[tempobjectsettings[i][0]].menu,tempobjectsettings[i][1], "value");
         };
      }; 
   }
   else{
      var tempobjectoptionsarray = tempobject.cm_optionsarray;
      var tempobjectoptionsarraylength = tempobjectoptionsarray.length;

      for(var i=0; i<tempobjectoptionsarraylength; i++){
         if(defaultobject.options != null && defaultobject.options[tempobjectoptionsarray[i][0]] != null && defaultobject.options[tempobjectoptionsarray[i][0]] .type=="input"){
//            defaultobject.options[tempobjectoptionsarray[i][0]].input.value=tempobjectoptionsarray[i][1].cm_unescapebackslashes().cm_unescapesinglequotes().cm_unescapedoublequotes();
//            defaultobject.options[tempobjectoptionsarray[i][0]].input.value=tempobjectoptionsarray[i][1].cm_unescapequotes().cm_unescapebackslashes();
            defaultobject.options[tempobjectoptionsarray[i][0]].input.value=tempobjectoptionsarray[i][1].cm_unescapequotes().cm_unescapebackslashes().replace(/\/\,/g,",");
         }
         else if(defaultobject.options != null && defaultobject.options[tempobjectoptionsarray[i][0]] != null && defaultobject.options[tempobjectoptionsarray[i][0]].type=="menu"){
            CaluMath.PM.MakeDefaultOption(defaultobject.options[tempobjectoptionsarray[i][0]].menu,tempobjectoptionsarray[i][1], "value");
//            CaluMath.PM.MakeDefaultOption(defaultobject.options[tempobjectoptionsarray[i][0]].menu,tempobjectoptionsarray[i][1].cm_replacefromCharCode(), "value");
         }
      };
      var tempobjectrequiredarray = tempobject.cm_requiredarray;
      var tempobjectrequiredarraylength = tempobjectrequiredarray.length;

      for(var i=0; i<tempobjectrequiredarraylength; i++){
         if(defaultobject.required != null && defaultobject.required[tempobjectrequiredarray[i][0]] != null && defaultobject.required[tempobjectrequiredarray[i][0]] .type=="input"){
              if(defaultobject.required[tempobjectrequiredarray[i][0]].input.getAttribute("type") != "file"){
//                 defaultobject.required[tempobjectrequiredarray[i][0]].input.value=tempobjectrequiredarray[i][1].cm_unescapebackslashes().cm_unescapesinglequotes().cm_unescapedoublequotes();
                 defaultobject.required[tempobjectrequiredarray[i][0]].input.value=tempobjectrequiredarray[i][1].cm_unescapequotes().cm_unescapebackslashes();
              };
         }
         else if(defaultobject.required != null && defaultobject.required[tempobjectrequiredarray[i][0]] != null && defaultobject.required[tempobjectrequiredarray[i][0]].type=="menu"){
            CaluMath.PM.MakeDefaultOption(defaultobject.required[tempobjectrequiredarray[i][0]].menu,tempobjectrequiredarray[i][1], "value");
//            CaluMath.PM.MakeDefaultOption(defaultobject.required[tempobjectrequiredarray[i][0]].menu,tempobjectrequiredarray[i][1].cm_replacefromCharCode(), "value");
         }
      };
   }; 
};


CaluMath.PM.EndHelponclickfunction=function(){
   if(this.cm_object != null){
      this.cm_object.writetextstring1.cm_node[0].style.display="none";
      this.cm_object.helpbutton.style.display="";
      this.style.display="none";
   }
   else{
      //Comment: In this case it is newplot.
      CaluMath.PM.PageMakernewplotDefault.writetextstring1.cm_node[0].style.display="none";
      CaluMath.PM.PageMakernewplotDefault.helpbutton.style.display="";
      this.style.display="none";
   };
};

CaluMath.PM.Helponclickfunction=function(){
   if(this.cm_object != null){
      this.cm_object.writetextstring1.cm_node[0].style.display="";
      this.cm_object.endhelpbutton.style.display="";
      this.style.display="none";
   }
   else{
      //Comment: In this case it is newplot.
      CaluMath.PM.PageMakernewplotDefault.writetextstring1.cm_node[0].style.display="";
      CaluMath.PM.PageMakernewplotDefault.endhelpbutton.style.display="";
      this.style.display="none";
   };

};


CaluMath.PM.PopulateTableWithDefaultValues=function(){
//Comment: We restore the default values:
   var defaultobject=CM_TopWindow.CaluMath.Html.Eval("CaluMath.PM.PageMaker"+arguments[0]+"Default"); 
   var tempobject=arguments[1];
   var settingsnames= defaultobject.settingsnames;
   var settingsnameslength= settingsnames.length;

   for(var i=0; i<settingsnameslength; i++){ 
      if(defaultobject.options != null && defaultobject.options[settingsnames[i]] != null && defaultobject.options[settingsnames[i]].type=="input"){
        defaultobject.options[settingsnames[i]].input.value=defaultobject.options[settingsnames[i]].defaultvalue;
      }
      else if(defaultobject.options != null && defaultobject.options[settingsnames[i]] != null && defaultobject.options[settingsnames[i]].type=="menu"){
         CaluMath.PM.MakeDefaultOption(defaultobject.options[settingsnames[i]].menu,defaultobject.options[settingsnames[i]].defaultvalue, "value");
      }
      else if(defaultobject.required != null && defaultobject.required[settingsnames[i]] != null && defaultobject.required[settingsnames[i]].type=="input"){
        defaultobject.required[settingsnames[i]].input.value=defaultobject.required[settingsnames[i]].defaultvalue;
      }
      else if(defaultobject.required != null && defaultobject.required[settingsnames[i]] != null && defaultobject.required[settingsnames[i]].type=="menu"){
         CaluMath.PM.MakeDefaultOption(defaultobject.required[settingsnames[i]].menu,defaultobject.required[settingsnames[i]].defaultvalue, "value");
      };
   };
};


//Comment: For many objects created in (what is now) the CaluMath.PM.MATHBUTTON.onclick routine there are standard things that are done at the beginning in the creation of the tables that contain input boxes or dropdown menus. Some objects do not use this because they have subtle things that must be done, for example the dropdown menu in one part must be recreated depending on the what is selected in another dropdown menu. In these cases, the objects do not use CaluMath.PM.ObjectStandardBeginning. 

//Comment: The argument is the type of object to be created, for example "pointplot" or "highlight". It is a String. The second argument is what is the first argument that is passed to CaluMath.PM.MATHBUTTON.onclick when in CM_EditMode, which is the object that is being edited. So a typical call is CaluMath.PM.ObjectStandardBeginning("pointplot", arguments[0]). Note that if we are not in CM_EditMode, having the second argument of arguments[0] causes no problems. 

//Comment: CaluMath.PM.ObjectStandardBeginning does the following:
//   1) Creates the options and required tables for the object. 
//   2) If in CM_EditMode, it populates the tables with the current values (the values that were saved in the settings for that particular instance of the object). It also assigns all the old values for the object in case something like the name of the object changes. It then returns the object that is being edited. 
//   3) If not in CM_EditMode, it creates a new CaluMath.PM.PageMakerObject of the type given by arguments[0] and returns the newly created object.
//   4) If there is a cm_caswindow option, it does an onchange function that associates inserttargets from the window chosen as an option. 
CaluMath.PM.ObjectStandardBeginning=function(){
 

   var type=arguments[0];
   var editedtempobject=arguments[1];
   var defaultobject= eval("CaluMath.PM.PageMaker"+type+"Default");

   if(window.DoAgainActivated !="yes"){


   CaluMath.PM.CurrentDefault=defaultobject;
   if((type=="conditional" || type=="buttonaction" || type == "forloop" || type=="routine") && CM_TopWindow.CM_EditMode){
      var tempbeginstring= ('<hr style="height:5px" /><p style="font-size:20px; color:#990000">Below are the fields for the '+CaluMath.PM.PageMakerObjectLabelName(type)+'. </p>').cm_html("cm_insertin=displayleft");
      if(defaultobject.options != null && defaultobject.options.table != null && defaultobject.options.table.style != null &&    defaultobject.options.table.style.display=="block"){
         var oldoptionstable= defaultobject.options.table;
         var oldoptions= defaultobject.options;
         CaluMath.PM.MakeOptions(defaultobject, "options");
         if(defaultobject.options.table.rows.length >0){
            defaultobject.options.table.style.display="block";
         };
         defaultobject.options.table.predecessor=oldoptionstable;
         defaultobject.options.predecessor=oldoptions;
      }
      else{
         CaluMath.PM.MakeOptions(defaultobject, "options");
         if(defaultobject.options.table.rows.length >0){
            defaultobject.options.table.style.display="block";
         };
      };
      if(defaultobject.textstring == null){
        var tempwritestring= '<p style="font-size:20px; width:850px">Options (if any) are above, and can be ignored by beginning users. Required fields are below and must be filled in.</p>'.cm_html("cm_insertin=displayleft");
      }
      else{
         var tempwritestring= ('<p style="font-size:20px; margin-left:10px; width:850px">Options (if any) are above, and can be ignored by beginning users. Required fields are below and must be filled in.</p>').cm_html("cm_insertin=displayleft");
//         var tempwritestring1 =('<p style="display:none; margin-left:10px; width:850px">'+defaultobject.textstring.cm_replaceinequalitysymbols()+'</p>').cm_html("cm_insertin=displayleft");
         var tempwritestring1 =('<p style="display:none; margin-left:10px; width:850px">'+defaultobject.textstring.cm_replaceinequalitysymbols()+'</p>').cm_html("cm_insertin=displayleft");
         var helpbutton=document.createElement("input");
         helpbutton.setAttribute("type","button");
         helpbutton.setAttribute("value","Help for "+CaluMath.PM.PageMakerObjectLabelName(type));
         document.getElementById("displayleft").appendChild(helpbutton);
         var endhelpbutton=document.createElement("input");
         endhelpbutton.setAttribute("type","button");
         endhelpbutton.setAttribute("value","Hide Help for "+CaluMath.PM.PageMakerObjectLabelName(type));
         endhelpbutton.style.display="none";
         document.getElementById("displayleft").appendChild(endhelpbutton);
         endhelpbutton.onclick=CaluMath.PM.EndHelponclickfunction;
         helpbutton.onclick=CaluMath.PM.Helponclickfunction;
      };
      if(defaultobject.required != null && defaultobject.required.table != null && defaultobject.required.table.style != null &&    defaultobject.required.table.style.display=="block"){
         var oldrequiredtable= defaultobject.required.table;
         var oldrequired= defaultobject.required;

         CaluMath.PM.MakeOptions(defaultobject, "required");

         defaultobject.required.table.style.display="block";
         defaultobject.required.table.predecessor=oldrequiredtable;
         defaultobject.required.predecessor=oldrequired;
      }
      else{
         CaluMath.PM.MakeOptions(defaultobject, "required");
         defaultobject.required.table.style.display="block";
      };
      var tempendstring= ('<p style="font-size:20px; color:#990000">Above are the fields for the '+CaluMath.PM.PageMakerObjectLabelName(type)+'. </p>').cm_html("cm_insertin=displayleft");
   }
   else if(defaultobject ==  CaluMath.PM.PageMakernewplotDefault){

                  CaluMath.PM.PageMakernewplotDefault.writetextstring.cm_node[0].style.display="";  
                  CaluMath.PM.PageMakernewplotDefault.endtextstring.cm_node[0].style.display="";
                  CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[0].style.display="";
                  CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[1].style.display="";
                  CaluMath.PM.PageMakernewplotDefault.helpbutton.style.display="";

                  CaluMath.PM.PageMakernewplotDefault.writetextstring1.cm_node[0].style.display="none";  
      CaluMath.PM.PageMakernewplotDefault.options.table.style.display="";
      CaluMath.PM.PageMakernewplotDefault.required.table.style.display="";
      for(var i=0; i<CaluMath.PM.PageMakernewplotDefault.optionsarray.length; i++){
         if(CaluMath.PM.PageMakernewplotDefault.optionsarray[i][1]=="menu"){
            CaluMath.PM.MakeDefaultOption(CaluMath.PM.PageMakernewplotDefault.options[CaluMath.PM.PageMakernewplotDefault.optionsarray[i][0]][CaluMath.PM.PageMakernewplotDefault.optionsarray[i][1]],CaluMath.PM.PageMakernewplotDefault.optionsarray[i][3],"value");
         }
         else{
            CaluMath.PM.PageMakernewplotDefault.options[CaluMath.PM.PageMakernewplotDefault.optionsarray[i][0]][CaluMath.PM.PageMakernewplotDefault.optionsarray[i][1]].value=CaluMath.PM.PageMakernewplotDefault.optionsarray[i][3];
         };
      };
      for(var i=0; i<CaluMath.PM.PageMakernewplotDefault.requiredarray.length; i++){
         if(CaluMath.PM.PageMakernewplotDefault.requiredarray[i][1]=="menu"){
            CaluMath.PM.MakeDefaultOption(CaluMath.PM.PageMakernewplotDefault.required[CaluMath.PM.PageMakernewplotDefault.requiredarray[i][0]][CaluMath.PM.PageMakernewplotDefault.requiredarray[i][1]],CaluMath.PM.PageMakernewplotDefault.requiredarray[i][3],"value");
         }
         else{
            CaluMath.PM.PageMakernewplotDefault.required[CaluMath.PM.PageMakernewplotDefault.requiredarray[i][0]][CaluMath.PM.PageMakernewplotDefault.requiredarray[i][1]].value=CaluMath.PM.PageMakernewplotDefault.requiredarray[i][3];
         };
      };


   }
   else{
        var tempbeginstring= ('<hr style="height:5px" /><p style="font-size:20px; color:#990000">Below are the fields for the '+CaluMath.PM.PageMakerObjectLabelName(type)+'. </p>').cm_html("cm_insertin=displayleft");

      CaluMath.PM.MakeOptions(defaultobject, "options");
      if(defaultobject.textstring == null){
        var tempwritestring= '<p style="font-size:20px; width:850px">Options (if any) are above, and can be ignored by beginning users. Required fields are below and must be filled in.</p>'.cm_html("cm_insertin=displayleft");
      }
      else{
         var tempwritestring= ('<p style="font-size:20px; margin-left:10px; width:850px">Options (if any) are above, and can be ignored by beginning users. Required fields are below and must be filled in.</p>').cm_html("cm_insertin=displayleft");
//         var tempwritestring1 =('<p style="display:none; margin-left:10px; width:850px">'+defaultobject.textstring.cm_replaceinequalitysymbols()+'</p>').cm_html("cm_insertin=displayleft");
         var tempwritestring1 =('<p style="display:none; margin-left:10px; width:850px">'+defaultobject.textstring.cm_replaceinequalitysymbols()+'</p>').cm_html("cm_insertin=displayleft");
         var helpbutton=document.createElement("input");
         helpbutton.setAttribute("type","button");
         helpbutton.setAttribute("value","Help for "+CaluMath.PM.PageMakerObjectLabelName(type));
         document.getElementById("displayleft").appendChild(helpbutton);
         var endhelpbutton=document.createElement("input");
         endhelpbutton.setAttribute("type","button");
         endhelpbutton.setAttribute("value","Hide Help for "+CaluMath.PM.PageMakerObjectLabelName(type));
         endhelpbutton.style.display="none";
         document.getElementById("displayleft").appendChild(endhelpbutton);
         endhelpbutton.onclick=CaluMath.PM.EndHelponclickfunction;
         helpbutton.onclick=CaluMath.PM.Helponclickfunction;
             
      };
      if(defaultobject !=  CaluMath.PM.PageMakernewplotDefault){
         CaluMath.PM.MakeOptions(defaultobject, "required");
      };


      if(defaultobject.options.table.rows.length >0){
         defaultobject.options.table.style.display="block";
      };
      defaultobject.required.table.style.display="block";
      var tempendstring= ('<p style="font-size:20px; color:#990000">Above are the fields for the '+CaluMath.PM.PageMakerObjectLabelName(type)+'. </p>').cm_html("cm_insertin=displayleft");

   };
        
   if(CM_TopWindow.CM_EditMode){
      CaluMath.PM.PopulateTableWithCurrentValues(type,editedtempobject);
      var tempreturn = editedtempobject;
      CaluMath.PM.AssignOldValues(editedtempobject);
   }
   else{
      var tempreturn = CaluMath.PM.PageMakerObject(type); 
   };

   if(!CM_TopWindow.CM_EditMode){
      if(defaultobject !=  CaluMath.PM.PageMakernewplotDefault  && defaultobject !=  CaluMath.PM.PageMakeriframecontainerDefault && defaultobject !=  CaluMath.PM.PageMakeriframeDefault){
         if(defaultobject.options != null && defaultobject.options.cm_caswindow != null && defaultobject.options.cm_caswindow.menu != null && defaultobject.options.cm_inserttarget != null && defaultobject.options.cm_inserttarget.menu != null){
            defaultobject.options.cm_caswindow.menu.onchange=function(){
               CaluMath.PM.UpdateIndividualOption(defaultobject, "options", ["cm_inserttarget", "menu", [["n/a", "n/a"]].concat(CaluMath.PM.PlotlistObject[defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value].namedobjectlist), "n/a", [["Insert Target","cm_help/cm_individual_help.html#cm_inserttarget"], "Place Object In Relation To This Target Object", "same"]]);
            };
            defaultobject.options.cm_caswindow.menu.onchange();
         };
      }
      else if(defaultobject !=  CaluMath.PM.PageMakernewplotDefault){
         if(defaultobject.options != null && defaultobject.options.cm_caswindow != null && defaultobject.options.cm_caswindow.menu != null && defaultobject.options.cm_inserttarget != null && defaultobject.options.cm_inserttarget.menu != null){
            defaultobject.options.cm_caswindow.menu.onchange=function(){
               CaluMath.PM.UpdateIndividualOption(defaultobject, "options", ["cm_inserttarget", "menu", [["n/a", "n/a"]].concat(CaluMath.PM.PlotlistObject[defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value].staticobjectlist), "n/a", [["Insert Target","cm_help/cm_individual_help.html#cm_inserttarget"], "Place Object In Relation To This Target Object", "same"]]);
            };
            defaultobject.options.cm_caswindow.menu.onchange();
         };
      };
   }
   else{
      if(defaultobject !=  CaluMath.PM.PageMakernewplotDefault  && defaultobject !=  CaluMath.PM.PageMakeriframecontainerDefault && defaultobject !=  CaluMath.PM.PageMakeriframeDefault){
         if(defaultobject.options != null && defaultobject.options.cm_caswindow != null && defaultobject.options.cm_caswindow.menu != null && defaultobject.options.cm_inserttarget != null && defaultobject.options.cm_inserttarget.menu != null){
            var tempcaswindow=CaluMath.PM.GetPageMakerObjectSetting(tempreturn, "cm_caswindow");
            var tempinserttarget=CaluMath.PM.GetPageMakerObjectSetting(tempreturn, "cm_inserttarget");
            defaultobject.options.cm_caswindow.menu.onchange=function(){
               CaluMath.PM.UpdateIndividualOption(defaultobject, "options", ["cm_inserttarget", "menu", [["n/a", "n/a"]].concat(CaluMath.PM.PlotlistObject[defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value].namedobjectlist), "n/a", [["Insert Target","cm_help/cm_individual_help.html#cm_inserttarget"], "Place Object In Relation To This Target Object", "same"]]);
               if(defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value==tempcaswindow){
                  CaluMath.PM.MakeDefaultOption(defaultobject.options.cm_inserttarget.menu, tempinserttarget,"value");
               };
            };
            defaultobject.options.cm_caswindow.menu.onchange();
         };
      }
      else if(defaultobject !=  CaluMath.PM.PageMakernewplotDefault){
         if(defaultobject.options != null && defaultobject.options.cm_caswindow != null && defaultobject.options.cm_caswindow.menu != null && defaultobject.options.cm_inserttarget != null && defaultobject.options.cm_inserttarget.menu != null){
            defaultobject.options.cm_caswindow.menu.onchange=function(){
               if(defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value !=editedtempobject.cm_getsetting("cm_caswindow")){
                  CaluMath.PM.UpdateIndividualOption(defaultobject, "options", ["cm_inserttarget", "menu", [["n/a", "n/a"]].concat(CaluMath.PM.PlotlistObject[defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value].namedobjectlist), "n/a", [["Insert Target","cm_help/cm_individual_help.html#cm_inserttarget"], "Place Object In Relation To This Target Object", "same"]]);
               }
               else{
                  CaluMath.PM.UpdateIndividualOption(defaultobject, "options", ["cm_inserttarget", "menu", [["n/a", "n/a"]].concat(CaluMath.PM.PlotlistObject[defaultobject.options.cm_caswindow.menu[defaultobject.options.cm_caswindow.menu.selectedIndex].value].namedobjectlist), editedtempobject.cm_getsetting("cm_inserttarget"), [["Insert Target","cm_help/cm_individual_help.html#cm_inserttarget"], "Place Object In Relation To This Target Object", "same"]]);
               }
            };
            defaultobject.options.cm_caswindow.menu.onchange();
         };
      };
   };



   if(defaultobject !=  CaluMath.PM.PageMakernewplotDefault){
      tempreturn.endtextstring=tempendstring;
      tempreturn.begintextstring=tempbeginstring; 
      tempreturn.writetextstring=tempwritestring;
      tempreturn.writetextstring1=tempwritestring1;
   };

   if(helpbutton != null && defaultobject !=  CaluMath.PM.PageMakernewplotDefault ){
      tempreturn.helpbutton=helpbutton;
      tempreturn.endhelpbutton=endhelpbutton;
      tempreturn.helpbutton.cm_object=tempreturn; 
      tempreturn.endhelpbutton.cm_object=tempreturn;
   };


   window.location.hash="#endofdocument"; 
   return tempreturn; 

   } //Comment: End of if(window.DoAgainActivated !="yes")
   else{
      tempreturn = CaluMath.PM.PageMakerObject(type); 
      window.DoAgainActivatedNewObject =tempreturn;
      return tempreturn;
   };
};


if(window.CM_TopWindow==window){
/*
(function(){
//tempCM_CoreLoadingTime=new Date()
//tempCM_CoreLoadingTime=tempCM_CoreLoadingTime.getTime();
*/
         CaluMath.PM.PageMakernewplotDefault.begintextstring= ('<hr style="height:5px" /><p style="font-size:20px; color:#990000;width:850px">Below are the fields for the '+CaluMath.PM.PageMakerObjectLabelName("newplot")+'. </p>').cm_html("cm_insertin=displayleft");
         CaluMath.PM.MakeOptions(CaluMath.PM.PageMakernewplotDefault, "options");
         CaluMath.PM.PageMakernewplotDefault.writetextstring= ('<p id="fornewplotparagraph" style="display:none; margin-left:10px; font-size:20px; width:850px">Options (if any) are above, and can be ignored by beginning users. Required fields are below and must be filled in.</p>').cm_html("cm_insertin=displayleft");
//         CaluMath.PM.PageMakernewplotDefault.writetextstring1 =('<p id="fornewplotparagraph1" style="display:none; margin-left:10px; width:850px">'+CaluMath.PM.PageMakernewplotDefault.textstring.cm_replaceinequalitysymbols()+'</p>').cm_html("cm_insertin=displayleft");
         CaluMath.PM.PageMakernewplotDefault.writetextstring1 =('<p id="fornewplotparagraph1" style="display:none; margin-left:10px; width:850px">'+CaluMath.PM.PageMakernewplotDefault.textstring.cm_replaceinequalitysymbols()+'</p>').cm_html("cm_insertin=displayleft");
         CaluMath.PM.PageMakernewplotDefault.helpbutton=document.createElement("input");
         CaluMath.PM.PageMakernewplotDefault.helpbutton.setAttribute("type","button");
         CaluMath.PM.PageMakernewplotDefault.helpbutton.setAttribute("value","Help for "+CaluMath.PM.PageMakerObjectLabelName("newplot"));
         document.getElementById("displayleft").appendChild(CaluMath.PM.PageMakernewplotDefault.helpbutton);
         CaluMath.PM.PageMakernewplotDefault.endhelpbutton=document.createElement("input");
         CaluMath.PM.PageMakernewplotDefault.endhelpbutton.setAttribute("type","button");
         CaluMath.PM.PageMakernewplotDefault.endhelpbutton.setAttribute("value","Hide Help for "+CaluMath.PM.PageMakerObjectLabelName("newplot"));
         CaluMath.PM.PageMakernewplotDefault.endhelpbutton.style.display="none";
         CaluMath.PM.PageMakernewplotDefault.helpbutton.style.display="none";
         document.getElementById("displayleft").appendChild(CaluMath.PM.PageMakernewplotDefault.endhelpbutton);
         CaluMath.PM.PageMakernewplotDefault.endhelpbutton.onclick=CaluMath.PM.EndHelponclickfunction;
         CaluMath.PM.PageMakernewplotDefault.helpbutton.onclick=CaluMath.PM.Helponclickfunction;

         CaluMath.Html.MemoryLeakArray.push(CaluMath.PM.PageMakernewplotDefault.endhelpbutton);
         CaluMath.Html.MemoryLeakArray.push(CaluMath.PM.PageMakernewplotDefault.helpbutton);


         CaluMath.PM.MakeOptions(CaluMath.PM.PageMakernewplotDefault, "required");
         CaluMath.PM.PageMakernewplotDefault.endtextstring=  ('<p style="font-size:20px; margin-left:10px; color:#990000">Above are the fields for the '+CaluMath.PM.PageMakerObjectLabelName("newplot")+'. </p>').cm_html("cm_insertin=displayleft");
                  CaluMath.PM.PageMakernewplotDefault.endtextstring.cm_node[0].style.display="none";
                  CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[0].style.display="none";
                  CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[1].style.display="none";
/*
//temp1CM_CoreLoadingTime=new Date()
//temp1CM_CoreLoadingTime=temp1CM_CoreLoadingTime.getTime();
//alert(temp1CM_CoreLoadingTime-tempCM_CoreLoadingTime);

})();
*/
}  //Comment: This completes the conditional window.CM_TopWindow==window and finishes the execution and definition of the unnamed function that creates the newplot tables.

//Comment: This creates the Cancel, Delete and Finish Buttons for objects created or edited by CaluMath.PM.MATHBUTTON.onclick. It also creates routines for these buttons. 

CaluMath.PM.MakeCancelDeleteAndFinishButtons=function(){
         //Comment: tempobject is the same value as tempobject in CaluMath.PM.MATHBUTTON.onclick. 
         //Comment: type is the type of CaluMath.PM.PageMakerDefault object, for example, "Function" for CaluMath.PM.PageMakerdefinedfunctionDefault.
         //Comment: selectedlabel is the same value as selectedlabel in CaluMath.PM.MATHBUTTON.onclick. 
         //Comment: buttonlabel is what will appear on the button label. For example "Fucntion" yields "Cancel Function" and "Delete Function". 
         var tempobject=arguments[0];
         var type=tempobject.type;
         var selectedlabel=CaluMath.PM.PageMakerObjectLabelName(tempobject);
         var buttonlabel=selectedlabel;
         //Comment: Note that we use the local variable name  defaultobject. For type="definedconstant" than this variable represents CaluMath.PM.PageMakerdefinedconstantDefault, for type "newplot" represents CaluMath.PM.PageMakernewplotDefault etc.
         var defaultobject= eval("CaluMath.PM.PageMaker"+type+"Default"); 



//Comment: This is the finish button
         var finishbuttonElement=document.createElement("input");
         finishbuttonElement.setAttribute("type","button");
         finishbuttonElement.setAttribute("value","Finish "+selectedlabel);
         CaluMath.PM.BUTTONCONTAINER.appendChild(finishbuttonElement);


//Comment: This is the redo button
         if( !CM_TopWindow.CM_EditMode && !( tempobject.type=="nameclickedpoint" || tempobject.type=="comparison" || tempobject.type=="buttonaction" || tempobject.type=="addtobuttonaction" || tempobject.type=="forloop" || tempobject.type=="addtoforloop" || tempobject.type=="conditional" || tempobject.type=="addtoconditional" || tempobject.type=="newwindow" || tempobject.type=="newwindow" || tempobject.type=="routine" || tempobject.type=="addtoroutine" || tempobject.type=="importpage") ){
         var doagainbuttonElement=document.createElement("input");
         doagainbuttonElement.setAttribute("type","button");
         doagainbuttonElement.setAttribute("value","Finish "+selectedlabel+" and Do Another "+selectedlabel);
         CaluMath.PM.BUTTONCONTAINER.appendChild(doagainbuttonElement);
         tempobject.doagainbuttonElement=doagainbuttonElement;

           doagainbuttonElement.onclick=function(){
               window.DoAgainActivated="yes";
               window.DoAgainActivatedOldObject=tempobject;
               finishbuttonElement.onclick();
               cm_alert("You have completed one "+selectedlabel+". You can do another now. If this object requires a name, remember to give the next "+selectedlabel+" a different name than the one you just created.");
               var tempredoobject=new Array();
               tempredoobject.value=type;
//               CaluMath.PM.MATHBUTTONFUNCTION(tempredoobject);
               CaluMath.PM.MATHBUTTONFUNCTION(type, "table");
               
               window.DoAgainActivatedNewObject.writetextstring=window.DoAgainActivatedOldObject.writetextstring; 
               window.DoAgainActivatedNewObject.writetextstring1=window.DoAgainActivatedOldObject.writetextstring1; 
               window.DoAgainActivatedNewObject.helpbutton=window.DoAgainActivatedOldObject.helpbutton; 
               window.DoAgainActivatedNewObject.endhelpbutton=window.DoAgainActivatedOldObject.endhelpbutton; 
               window.DoAgainActivatedNewObject.endtextstring=window.DoAgainActivatedOldObject.endtextstring; 
               window.DoAgainActivatedNewObject.begintextstring=window.DoAgainActivatedOldObject.begintextstring; 
               window.DoAgainActivatedNewObject.horizontalrule=window.DoAgainActivatedOldObject.horizontalrule; 
               window.DoAgainActivated="no";
               window.DoAgainActivatedOldObject=null;
               window.DoAgainActivatedNewObject=null;
               if(defaultobject != null && defaultobject.required != null && defaultobject.required.name != null && defaultobject.required.name.input != null && defaultobject.required.name.input.value != null){
                  defaultobject.required.name.input.value=defaultobject.required.name.input.value+"ADJUST";
               }
               else if(defaultobject != null && defaultobject.options != null && defaultobject.options.name != null && defaultobject.options.name.input != null && defaultobject.options.name.input.value != null){
                  defaultobject.options.name.input.value=defaultobject.options.name.input.value+"ADJUST";
               };
            };
         };



//Comment: This is the cancel button. In WriteMode it cancels whatever you did. In CM_EditMode, it cancels the changes you made. Basically it does this by not touching the CaluMath.PM.PageMakerObjectArray. 
         var cancelbuttonElement=document.createElement("input");
         cancelbuttonElement.setAttribute("type","button");
         if(!CM_TopWindow.CM_EditMode){
            cancelbuttonElement.setAttribute("value","Cancel "+buttonlabel);
         }
         else{
            cancelbuttonElement.setAttribute("value","Cancel Changes to "+buttonlabel);
         };
         CaluMath.PM.BUTTONCONTAINER.appendChild(cancelbuttonElement);

//Comment: This is the delete button. It only appears in CM_EditMode. It goes into CaluMath.PM.PageMakerObjectArray and deletes the object corresponding to the element being edited. from it. This has the effect of deleting the element being edited
        var deletebuttonElement=document.createElement("input");
        deletebuttonElement.setAttribute("type","button");
        deletebuttonElement.setAttribute("value","Delete "+buttonlabel);
        CaluMath.PM.BUTTONCONTAINER.appendChild(deletebuttonElement);

        if(!CM_TopWindow.CM_EditMode){
           deletebuttonElement.style.display="none";
        };
        if( window.DoAgainActivated !="yes"){
           var horizontalrule = document.createElement("hr");
           horizontalrule.style.height="5px";
           CaluMath.PM.BUTTONCONTAINER.appendChild(horizontalrule);
           tempobject.horizontalrule=horizontalrule;
        };
//Comment: This is the standard cancel button onclick function. It is labeleled standardonclick, so the true onclick function can call it and do any specialized things it needs to do. 
         cancelbuttonElement.standardonclick=function(){
            CaluMath.PM.CurrentDefault=null;
            if(defaultobject.required != null && defaultobject.required.table != null){
               defaultobject.required.table.style.display="none";
            };
            if(defaultobject.options != null && defaultobject.options.table != null){
               defaultobject.options.table.style.display="none";
            };

            if(tempobject.doagainbuttonElement != null && tempobject.doagainbuttonElement.parentNode != null){
               tempobject.doagainbuttonElement.onclick=null; 
               tempobject.doagainbuttonElement.parentNode.removeChild(tempobject.doagainbuttonElement);
               tempobject.doagainbuttonElement=null; 
            };

            finishbuttonElement.onclick=null;
            cancelbuttonElement.onclick=null;
            deletebuttonElement.onclick=null;
            finishbuttonElement.standardcleanup=null;
            finishbuttonElement.standardonclick=null;
            cancelbuttonElement.standardonclick=null;
            deletebuttonElement.standardonclick=null;

            finishbuttonElement.parentNode.removeChild(finishbuttonElement);
            cancelbuttonElement.parentNode.removeChild(cancelbuttonElement);
            deletebuttonElement.parentNode.removeChild(deletebuttonElement);
            tempobject.horizontalrule.parentNode.removeChild(tempobject.horizontalrule);
            if(tempobject.type != "newplot"){
               tempobject.writetextstring.remove();
               tempobject.endtextstring.remove();
               tempobject.begintextstring.remove();
               tempobject.writetextstring=null; 
               tempobject.endtextstring=null;
               tempobject.begintextstring=null;
               tempobject.horizontalrule=null;
               if(tempobject.helpbutton != null){
                  tempobject.writetextstring1.remove(); 
                  tempobject.writetextstring1=null; 
                  tempobject.helpbutton.onclick=null;
                  tempobject.endhelpbutton.onclick=null;
                  tempobject.helpbutton.cm_object=null;
                  tempobject.endhelpbutton.cm_object=null;
                  tempobject.helpbutton.parentNode.removeChild(tempobject.helpbutton);
                  tempobject.endhelpbutton.parentNode.removeChild(tempobject.endhelpbutton);
                  tempobject.helpbutton=null;
                  tempobject.endhelpbutton=null;
               };
            }
            else{
               CaluMath.PM.PageMakernewplotDefault.writetextstring.cm_node[0].style.display="none";  
               CaluMath.PM.PageMakernewplotDefault.writetextstring1.cm_node[0].style.display="none";  
               CaluMath.PM.PageMakernewplotDefault.endtextstring.cm_node[0].style.display="none";
               CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[0].style.display="none";
               CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[1].style.display="none";
               CaluMath.PM.PageMakernewplotDefault.helpbutton.style.display="none";
               CaluMath.PM.PageMakernewplotDefault.endhelpbutton.style.display="none";
            };

//            CaluMath.PM.DisplayPageControls();
//            window.scroll(0,-1000);
//            if(CM_TopWindow.CM_EditMode != true || tempobject.parent == null || (tempobject.parent.type != "buttonaction" &&  tempobject.parent.type != "forloop" && tempobject.parent.type != "conditional" && tempobject.parent.type != "routine" && tempobject.parent.type != "newwindow")){
//               CM_TopWindow.CM_EditMode=false;
//               CaluMath.PM.InsertionObjectAlerts(tempobject);
//            }

            if(CM_TopWindow.CaluMath.PM.InsertionArray.length >0){
               CaluMath.PM.InsertionObjectAlerts(tempobject);
            } 
            else{
               if(tempobject.parent != null && tempobject.parent.makecontrolsvisible != null){
                  //Comment: CaluMath.PM.EditIndividualEntries has to do with tempobject.parent.makecontrolsvisible. The only place where CaluMath.PM.EditIndividualEntries would be invoked is in the cm_pagemaker_mainfile.js, and each reference there has been commented out. Therefore this conditional should never evaluate to true or be executed. 
                  //Comment: The body of this conditional should never be executed. 

                  tempobject.parent.makecontrolsvisible();
                  CaluMath.PM.HidePageControls(); 


                  if(defaultobject.required != null && defaultobject.required.table != null){
                     defaultobject.required.table.style.display="none";
                     //Comment: When we are editing, we can have several conditional tables open at the same time. The last on is always given the name CaluMath.PM.PageMakerconditionalDefault, along with the property predecessor that points to the one that should have that name as the tables close.
                     if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required=CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.predecessor;
                     }
                     else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.predecessor;
                     }
                     else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.predecessor;
                     }
                     else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.predecessor;
                     };
                  };
                  if(defaultobject.options != null && defaultobject.options.table != null){
                     defaultobject.options.table.style.display="none";
                     //Comment: When we are editing, we can have several conditional tables open at the same time. The last on is always given the name CaluMath.PM.PageMakerconditionalDefault, along with the property predecessor that points to the one that should have that name as the tables close.
                     if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options =CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.predecessor;
                     }
                     else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.predecessor;
                     }
                     else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.predecessor;
                     }
                     else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                        CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.table.predecessor;
                        CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.predecessor;
                     };
                  };
               }
               else{

                 //Comment: This means we are in CM_EditMode and the object is a child of an object that was an element in CaluMath.PM.InsertionArray. Therefore, when we finish this object we will go up a level to the parent of the parent (if it exists). In this case we must make the controls of the parent object. 
                 //Comment: This should never be done since we disabled makecontrolsvisible. 
                 if(tempobject.parent != null && tempobject.parent.makecontrolsvisible != null){
                    tempobject.parent.makecontrolsvisible();
                    CaluMath.PM.HidePageControls(); 
                 }
                 else{
                    CM_TopWindow.CM_EditMode=false;
                    CaluMath.PM.DisplayPageControls();
                 };

               };
//               CaluMath.PM.DisplayPageControls();
               //Commented this out Nov. 5 2007. 
               //window.scroll(0,-1000);
            };
            tempobject.makecontrolsvisible=null;
         };

 //Comment: This is the standard delete button onclick function. It is labeleled standardonclick, so the true onclick function can call it and do any specialized things it needs to do. 
        deletebuttonElement.standardonclick=function(){
           CaluMath.PM.CurrentDefault=null;
           delete tempobject.cm_tempobject;
           if(defaultobject.required != null && defaultobject.required.table != null){
              defaultobject.required.table.style.display="none";
           };
           if(defaultobject.options != null && defaultobject.options.table != null){
              defaultobject.options.table.style.display="none";
           };
           CaluMath.PM.PerformForRemoval(tempobject);
           if(tempobject.doagainbuttonElement != null && tempobject.doagainbuttonElement.parentNode != null){
              tempobject.doagainbuttonElement.onclick=null;
              tempobject.doagainbuttonElement.parentNode.removeChild(tempobject.doagainbuttonElement);
              tempobject.doagainbuttonElement=null; 
           };

           finishbuttonElement.onclick=null;
           cancelbuttonElement.onclick=null;
           deletebuttonElement.onclick=null;
           finishbuttonElement.standardcleanup=null;
           finishbuttonElement.standardonclick=null;
           cancelbuttonElement.standardonclick=null;
           deletebuttonElement.standardonclick=null;

           finishbuttonElement.parentNode.removeChild(finishbuttonElement);
           cancelbuttonElement.parentNode.removeChild(cancelbuttonElement);
           deletebuttonElement.parentNode.removeChild(deletebuttonElement);
           tempobject.horizontalrule.parentNode.removeChild(tempobject.horizontalrule);
           CaluMath.PM.DeleteFromLists(tempobject);
           CaluMath.PM.EveryObjectArray=CaluMath.PM.EveryObjectArray.cm_removeelements(tempobject, "yes");
           CaluMath.PM.DeletionCheck(tempobject);

           if(tempobject.type != "newplot"){
              tempobject.writetextstring.remove();
              tempobject.endtextstring.remove();
              tempobject.begintextstring.remove();
              tempobject.writetextstring=null; 
              tempobject.endtextstring=null;
              tempobject.begintextstring=null;
              tempobject.horizontalrule=null;
              if(tempobject.helpbutton != null){
                 tempobject.writetextstring1.remove(); 
                 tempobject.writetextstring1=null; 
                 tempobject.helpbutton.cm_object=null;
                 tempobject.endhelpbutton.onclick=null;
                 tempobject.helpbutton.onclick=null;
                 tempobject.endhelpbutton.cm_object=null;
                 tempobject.helpbutton.parentNode.removeChild(tempobject.helpbutton);
                 tempobject.endhelpbutton.parentNode.removeChild(tempobject.endhelpbutton);
                 tempobject.helpbutton=null;
                 tempobject.endhelpbutton=null;
              };
           }
           else{
              CaluMath.PM.PageMakernewplotDefault.writetextstring.cm_node[0].style.display="none";  
              CaluMath.PM.PageMakernewplotDefault.writetextstring1.cm_node[0].style.display="none";  
              CaluMath.PM.PageMakernewplotDefault.endtextstring.cm_node[0].style.display="none";
              CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[0].style.display="none";
              CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[1].style.display="none";
              CaluMath.PM.PageMakernewplotDefault.helpbutton.style.display="none";
              CaluMath.PM.PageMakernewplotDefault.endhelpbutton.style.display="none";
           };
 
//           CaluMath.PM.DisplayPageControls();
//           window.scroll(0,-1000);

//           if(CM_TopWindow.CM_EditMode != true || tempobject.parent == null ||  (tempobject.parent.type != "buttonaction" && tempobject.parent.type != "conditional" && tempobject.parent.type != "routine")){
//              CM_TopWindow.CM_EditMode=false;
//              CaluMath.PM.InsertionObjectAlerts(tempobject);
//           }
           if(CM_TopWindow.CaluMath.PM.InsertionArray.length >0){
              CaluMath.PM.InsertionObjectAlerts(tempobject);
           } 
           else{
              if(tempobject.parent != null && tempobject.parent.makecontrolsvisible != null){
                 //Comment: CaluMath.PM.EditIndividualEntries has to do with tempobject.parent.makecontrolsvisible. The only place where CaluMath.PM.EditIndividualEntries would be invoked is in the cm_pagemaker_mainfile.js, and each reference there has been commented out. Therefore this conditional should never evaluate to true or be executed. 
                 //Comment: The body of this conditional should never be executed. 
                 tempobject.parent.makecontrolsvisible();
                 CaluMath.PM.HidePageControls();
                 if(defaultobject.required != null && defaultobject.required.table != null){
                    defaultobject.required.table.style.display="none";
                    //Comment: When we are editing, we can have several conditional tables open at the same time. The last on is always given the name CaluMath.PM.PageMakerconditionalDefault, along with the property predecessor that points to the one that should have that name as the tables close.
                    if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required=CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.predecessor;
                    }
                    else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.predecessor;
                    }
                    else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.predecessor;
                    }
                    else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.predecessor;
                    };
                 };
                 if(defaultobject.options != null && defaultobject.options.table != null){
                    defaultobject.options.table.style.display="none";
                    //Comment: When we are editing, we can have several conditional tables open at the same time. The last on is always given the name CaluMath.PM.PageMakerconditionalDefault, along with the property predecessor that points to the one that should have that name as the tables close.
                    if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options =CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.predecessor;
                    }
                    else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.predecessor;
                    }
                    else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.predecessor;
                    }
                    else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                       CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.table.predecessor;
                       CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.predecessor;
                    };
                 };
              }
              else{
                 //Comment: This means we are in CM_EditMode and the object is a child of an object that was an element in CaluMath.PM.InsertionArray. Therefore, when we finish this object we will go up a level to the parent of the parent (if it exists). In this case we must make the controls of the parent object. 
                 //Comment: This should never be done since we disabled makecontrolsvisible. 
                 if(tempobject.parent != null && tempobject.parent.makecontrolsvisible != null){
                    tempobject.parent.makecontrolsvisible();
                    CaluMath.PM.HidePageControls(); 
                 }
                 else{
                    CM_TopWindow.CM_EditMode=false;
                    CaluMath.PM.DisplayPageControls();
                 };
              };
              //CaluMath.PM.DisplayPageControls();
              //Commented this out Nov. 5 2007. 
              //window.scroll(0,-1000);
           };
           tempobject.makecontrolsvisible=null;
        };

 //Comment: These things are usually done at the end of the onclick routine for the finish button. It populates the option and required tables with the default values for them (removing the specialized choices for this particular object). It also removes the cm_tempobject that was created to hold the values for the required settings. It also removes the cancel, delete and finish buttons. 
        finishbuttonElement.standardcleanup=function(){
           if(window.DoAgainActivated !="yes"){

           CaluMath.PM.CurrentDefault=null;
           if(!CM_TopWindow.CM_EditMode){
           var tempstringforprogressbox='';
           if(CM_TopWindow.CaluMath.PM.InsertionArray.length >0){ 
              tempstringforprogressbox='You are in a '+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray[0].cm_object.type)+'';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="buttonaction"){
              tempstringforprogressbox='You are in a Button Action';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="addtobuttonaction"){
              tempstringforprogressbox='You are in a Button Action';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="forloop"){
              tempstringforprogressbox='You are in a For Loop';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="addtoforloop"){
              tempstringforprogressbox='You are in a For Loop';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="conditional"){
              tempstringforprogressbox='You are in a Conditional';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="addtoconditional"){
              tempstringforprogressbox='You are in a Conditional';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="newwindow"){
              tempstringforprogressbox='You are in a New Window';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="addtonewwindow"){
              tempstringforprogressbox='You are in a New Window';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="routine"){
              tempstringforprogressbox='You are in a routine';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else if(tempobject.type=="addtoroutine"){
              tempstringforprogressbox='You are in a routine';
              // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
              CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
           }
           else{
//Comment: I commented this scroll out on Nov. 5, 2007 in putting back the downalevel buttons. 
              //window.scroll(0,-1000);
           };

           if(CM_TopWindow.CaluMath.PM.InsertionArray.length >1){ 
              for(var i=1; i<CM_TopWindow.CaluMath.PM.InsertionArray.length; i++){
                 tempstringforprogressbox=tempstringforprogressbox+ ' that contains a '+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray[i].cm_object.type)+'';
              };
           };

           if(CM_TopWindow.CaluMath.PM.InsertionArray.length >0){
              if(tempobject.type=="buttonaction"){
                 tempstringforprogressbox=tempstringforprogressbox+ ' that contains a Button Action';
              }
              else if(tempobject.type=="newwindow"){
                 tempstringforprogressbox=tempstringforprogressbox+ ' that contains a New Window';
              }
              else if(tempobject.type=="forloop"){
                 tempstringforprogressbox=tempstringforprogressbox+ ' that contains a For Loop';
              }
              else if(tempobject.type=="routine"){
                 tempstringforprogressbox=tempstringforprogressbox+ ' that contains a Routine';
              };
           };
           if(tempstringforprogressbox.match(/\S/)){
              tempstringforprogressbox= tempstringforprogressbox+'.';
           };
           document.getElementById("progressbox").childNodes[0].data=tempstringforprogressbox; 
           };

            delete tempobject.cm_tempobject;

            if(defaultobject.required != null && defaultobject.required.table != null){
               defaultobject.required.table.style.display="none";
               //Comment: When we are editing, we can have several conditional tables open at the same time. The last on is always given the name CaluMath.PM.PageMakerconditionalDefault, along with the property predecessor that points to the one that should have that name as the tables close.
               if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required=CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.required.predecessor;
               }
               else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.required.predecessor;
               }
               else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.required.predecessor;
               }
               else if(defaultobject.required==CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required && defaultobject.required.table !=null && defaultobject.required.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.table=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.required.predecessor;
               };
            };
            if(defaultobject.options != null && defaultobject.options.table != null){
               defaultobject.options.table.style.display="none";
               //Comment: When we are editing, we can have several conditional tables open at the same time. The last on is always given the name CaluMath.PM.PageMakerconditionalDefault, along with the property predecessor that points to the one that should have that name as the tables close.
               if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options =CM_TopWindow.CaluMath.PM.PageMakerconditionalDefault.options.predecessor;
               }
               else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options=CM_TopWindow.CaluMath.PM.PageMakernewwindowDefault.options.predecessor;
               }
               else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options=CM_TopWindow.CaluMath.PM.PageMakerbuttonactionDefault.options.predecessor;
               }
               else if(defaultobject.options==CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options && defaultobject.options.table != null && defaultobject.options.table.predecessor != null){
                  CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.table =CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.table.predecessor;
                  CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options=CM_TopWindow.CaluMath.PM.PageMakerroutineDefault.options.predecessor;
               };
            };

            }; //Comment: End of if(window.DoAgainActivated !="yes")


  

            if(tempobject.doagainbuttonElement != null && tempobject.doagainbuttonElement.parentNode != null){
               tempobject.doagainbuttonElement.onclick=null;
               tempobject.doagainbuttonElement.parentNode.removeChild(tempobject.doagainbuttonElement);
               tempobject.doagainbuttonElement=null; 
            };
            finishbuttonElement.onclick=null;
            cancelbuttonElement.onclick=null;
            deletebuttonElement.onclick=null;
            finishbuttonElement.standardcleanup=null;
            finishbuttonElement.standardonclick=null;
            cancelbuttonElement.standardonclick=null;
            deletebuttonElement.standardonclick=null;


            finishbuttonElement.parentNode.removeChild(finishbuttonElement);
            cancelbuttonElement.parentNode.removeChild(cancelbuttonElement);
            deletebuttonElement.parentNode.removeChild(deletebuttonElement);
            if(window.DoAgainActivated !="yes"){
               tempobject.horizontalrule.parentNode.removeChild(tempobject.horizontalrule);
               if(tempobject.type != "newplot"){
                  tempobject.writetextstring.remove();
                  tempobject.endtextstring.remove();
                  tempobject.begintextstring.remove();
                  tempobject.writetextstring=null; 
                  tempobject.endtextstring=null;
                  tempobject.begintextstring=null;
                  tempobject.horizontalrule=null;
                  if(tempobject.helpbutton != null){
                     tempobject.writetextstring1.remove(); 
                     tempobject.writetextstring1=null; 
                     tempobject.helpbutton.onclick=null;
                     tempobject.endhelpbutton.onclick=null;
                     tempobject.helpbutton.cm_object=null;
                     tempobject.endhelpbutton.cm_object=null;
                     tempobject.helpbutton.parentNode.removeChild(tempobject.helpbutton);
                     tempobject.endhelpbutton.parentNode.removeChild(tempobject.endhelpbutton);
                     tempobject.helpbutton=null;
                     tempobject.endhelpbutton=null;
                  };
               }
               else{
                  CaluMath.PM.PageMakernewplotDefault.writetextstring.cm_node[0].style.display="none";  
                  CaluMath.PM.PageMakernewplotDefault.writetextstring1.cm_node[0].style.display="none";  
                  CaluMath.PM.PageMakernewplotDefault.endtextstring.cm_node[0].style.display="none";
                  CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[0].style.display="none";
                  CaluMath.PM.PageMakernewplotDefault.begintextstring.cm_node[1].style.display="none";
                  CaluMath.PM.PageMakernewplotDefault.helpbutton.style.display="none";
                  CaluMath.PM.PageMakernewplotDefault.endhelpbutton.style.display="none";
//                  tempobject.horizontalrule.parentNode.removeChild(tempobject.horizontalrule);
               };
               
             };
            //Comment: CaluMath.PM.PlotlistObject contains a special entry for the individual newplot. This entry contains all the lists for things plotted in the newplot. We cannot have these be destroyed and written again each time the newplot is edited. 
            if(tempobject.type != "newplot" && tempobject.type != "definedconstant" && tempobject.type != "variablename" && tempobject.type != "definedfunction" && tempobject.type != "splitfunction" && tempobject.type != "discretefunctionfrompointsarray"){
               eval("CaluMath.PM.AddToLists"+type)(tempobject);
            };


           if(window.DoAgainActivated !="yes"){



//Comment: THIS IS VERY IMPORTANT. AS WE DEVELOP NEW TYPES OF GRAPHS THAT SUPPORT BUTTONS (FOR EXAMPLE CIRCLES AND PARAMETRIC PLOTS), WE MUST ADD THEM HERE. IF WE CHANGE THE GRAPH OF ONE OF THESE AND A BUTTON DEPENDS ON IT, THEN WE WANT TO HAVE THE BUTTON UPDATE THE NEW NAME. SO FAR, WE ONLY HAVE THIS FOR FUNCTIONPLOT.
           if(CM_TopWindow.CM_EditMode){
              //Comment: This really means they changed the name. Then all occurrences of that name must be replaced. 
//              if(tempobject.oldname  != null && tempobject.oldname != tempobject.cm_getsetting("name")){
//                 CaluMath.PM.NewChangeName(tempobject);	
//              }
//              else{ 
              //Comment: The remaining means they had a graph and changed either the plot it is on, or changed the graph to a different graph (For example, H.f becomes H.g). Then any buttons etc associated with H.f must be changed to H.g. 
              //Comment: Note that definedfunction corresponds to functionplots. All other graphs correspond to graph. 

                 var tempnewplotlistforchildren= [];
                 for(var t=0; t<CaluMath.PM.PlotlistObject.newplotlist.length; t++){
                    tempnewplotlistforchildren=tempnewplotlistforchildren.concat(CaluMath.PM.ListChildren(CaluMath.PM.PlotlistObject.newplotlist[t][2]));
                 };
                 var tempdochangeplotorgraph=false;
                 if(tempobject.oldnewplot  != null && tempobject.oldnewplot != tempobject.cm_getsetting("newplot")){
                    tempdochangeplotorgraph="all";
                 }
                 else if(tempobject.type=="definedfunction"){
                    //For defined functions, we may have several functions with the same name, for example, in a buttonaction with conditional statements. In this case, if we change the name of one of the functions, we don't want it to change the names and references of all of them. This is also a problem if we happen to define two functions with the same name. When you try to define one to be different, it cyclically used to change the other, so they would all be changed and you would still have two functions named the same. 
                    if(tempobject.oldname  != null && tempobject.oldname != tempobject.cm_getsetting("name")){
                       donotchangeifmultiplesamenamesloop1:
                       for(var ii=0; ii< CaluMath.PM.PlotlistObject.definedfunctionlist.length; ii++){
                          if(CaluMath.PM.PlotlistObject.definedfunctionlist[ii][0] == tempobject.oldname && CaluMath.PM.PlotlistObject.definedfunctionlist[ii][2] !=tempobject){
                             var multiplefunctionnames="yes";
                             break donotchangeifmultiplesamenamesloop1;
                          }
                          else{
                             tempdochangeplotorgraph=true;
                          };
                       };
                    };
                 }
                 else if(tempobject.type=="variablename"){
                    if(tempobject.oldname  != null && tempobject.oldname != tempobject.cm_getsetting("name")){
                       donotchangeifmultiplesamenamesloop2:
                       for(var ii=0; ii< CaluMath.PM.PlotlistObject.variablenamelist.length; ii++){
                          if(CaluMath.PM.PlotlistObject.variablenamelist[ii][0] == tempobject.oldname && CaluMath.PM.PlotlistObject.variablenamelist[ii][2] !=tempobject){
                             var multiplefunctionnames="yes";
                             break donotchangeifmultiplesamenamesloop2;
                          };
                       };
                    };
                 }
                 else if(tempobject.oldgraph  != null && tempobject.type=="functionplot" && tempobject.oldgraph != tempobject.cm_getsetting("graph")){
                    tempdochangeplotorgraph=true;
                 }
                 else if(tempobject.oldgraph  != null && (tempobject.type=="button" || tempobject.type=="clickbutton") && tempobject.oldgraph != tempobject.cm_getsetting("graph")){
                    tempdochangeplotorgraph=true;
                 }


                 if(tempdochangeplotorgraph==true || tempdochangeplotorgraph=="all"){
                    CaluMath.PM.ChangePlotOrGraph(tempobject, tempnewplotlistforchildren);
                 };

              if(tempobject.type != "definedfunction" && tempobject.type != "variablename"){
                 if(tempobject.oldname  != null && tempobject.oldname != tempobject.cm_getsetting("name")){
                    CaluMath.PM.NewChangeName(tempobject);	
                 };
              }
              else{
                 if(multiplefunctionnames != "yes"){
                    CaluMath.PM.NewChangeName(tempobject);	
                 };
              };

           }; 

            //Comment: Once the item is finished, if it was an edit we will want to return to "normal" mode. However, if the item is the child of a button action, then it is reached by going through the button action first. Therefore if the parent of the object is a "buttonaction", then we want to remain in CM_EditMode. 

            CaluMath.PM.InsertionObjectAlerts(tempobject);

            }; //Comment: End of  if(window.DoAgainActivated !="yes")
            tempobject.makecontrolsvisible=null;
        };
        return [finishbuttonElement,cancelbuttonElement,deletebuttonElement];
};


CaluMath.PM.ListChildren= function(){ 
  var childarray= arguments[0].childarray;
  tempreturn = [arguments[0]];
  if(childarray !=null && childarray.length >0){
     for(var i=0; i< childarray.length; i++){
        tempreturn=tempreturn.concat(CaluMath.PM.ListChildren(childarray[i]));
     };
  };
  return tempreturn; 
};



//Comment: CaluMath.PM.InsertionObjectAlerts examines 

CaluMath.PM.InsertionObjectAlerts= function(){ 
   var tempobject=arguments[0];
//   if(CM_TopWindow.CM_EditMode != true || tempobject.parent == null || !(tempobject.parent.type == "buttonaction" || tempobject.parent.type == "forloop" || tempobject.parent.type == "conditional" || tempobject.parent.type == "dynamic" || tempobject.parent.type == "routine" || tempobject.parent.type == "newwindow" ) || tempobject.parent.makecontrolsvisible==null || (CM_TopWindow["CaluMath"]["PM"]["PageMaker"+tempobject.parent.type+"Default"].required != null && CM_TopWindow["CaluMath"]["PM"]["PageMaker"+tempobject.parent.type+"Default"].required.table != null && CM_TopWindow["CaluMath"]["PM"]["PageMaker"+tempobject.parent.type+"Default"].required.table.style.display == "none") ){
   if(CM_TopWindow.CM_EditMode != true){ 
      if(CM_TopWindow.CaluMath.PM.InsertionArray.length == 0){
         CaluMath.PM.DisplayPageControls();
      }
      else{
         CaluMath.PM.HidePageControls("visible");
      };
      CM_TopWindow.CM_EditMode=false;
   }
   else{
      CaluMath.PM.DisplayPageControls();

      //Comment: This means we are in CM_EditMode and the object is a child of an object that was an element in CaluMath.PM.InsertionArray. Therefore, when we finish this object we will go up a level to the parent of the parent (if it exists). In this case we must make the controls of the parent object. 
      //Comment: This should never be done since we disabled makecontrolsvisible. 
      if(tempobject.parent != null && tempobject.parent.makecontrolsvisible != null){
         tempobject.parent.makecontrolsvisible();
         CaluMath.PM.HidePageControls(); 
      }
      else{
         CM_TopWindow.CM_EditMode=false;
      };
   };
   if(CM_TopWindow.CaluMath.PM.InsertionArray.length !=0 && !CM_TopWindow.CM_EditMode){
      //Comment: If this is not the first time, then we pop up a confirm window saying, "You are in a blah1 that contains a blah2, etc that contains blahn. Continue with blahn?". 
      if(CM_TopWindow.CaluMath.PM.InsertionArray.lastobjectfirsttime() != true && tempobject.type !="dynamic" &&  !(CaluMath.PM.TopWindowInsertionArrayObjectPossibilities.cm_contains(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type) && CaluMath.PM.TopWindowInsertionArrayObjectPossibilities.cm_contains(tempobject.type))){
         var TopWindowCM_InsertionArray=CM_TopWindow.CaluMath.PM.InsertionArray;
         var TopWindowCM_InsertionArraylength=TopWindowCM_InsertionArray.length;
         var tempstring='You are in a '+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray[0].cm_object.type)+'';
         if(TopWindowCM_InsertionArraylength >1){
            for(var i=1; i<TopWindowCM_InsertionArraylength; i++){
               tempstring=tempstring+ ' that contains a '+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray[i].cm_object.type)+'';
            };
            var tempstringforprogressbox= tempstring+'.';
            var typeofobject= CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type);
//            tempstring=tempstring+'. Continue with the last '+CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type+'?';
            tempstring=tempstring+'. Continue with the last '+typeofobject+'? Click OK to continue adding objects to your '+typeofobject+' or click Cancel to finish your '+typeofobject+'.';
         }
         else{
            var tempstringforprogressbox= tempstring+'.';
            var typeofobject= CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type);
//            tempstring=tempstring+'. Continue with the '+CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type+'?';
            tempstring=tempstring+'. Continue with the '+typeofobject+'? Click OK to continue adding objects to your '+typeofobject+' or click Cancel to finish your '+typeofobject+'.';
         };
         if(confirm(tempstring)){
             document.getElementById("progressbox").childNodes[0].data=tempstringforprogressbox; 
//              return cm_alert("Add another item to your "+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type)+".");
              var tempstringforcasalert= "Add another item to your "+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type)+".";
         }
         else{
            if(CM_TopWindow.CaluMath.PM.InsertionArray.length ==1){
               //Comment: Screens that never get seen pop up if you are in the middle of doing other things. So we limit this to length=1. 
//               cm_alert("You have finished your "+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type)+".");
               var tempstringforcasalert="You have finished your "+CaluMath.PM.PageMakerObjectLabelName(CM_TopWindow.CaluMath.PM.InsertionArray.lastobject().type)+".";
               //Commented this out Nov. 5 2007. 
               //window.scroll(0,-1000);
            }
            CM_TopWindow.CaluMath.PM.InsertionArray.pop();
            if(CM_TopWindow.CaluMath.PM.InsertionArray.length != 0){
               document.getElementById("progressbox").childNodes[0].data=tempstringforprogressbox.slice(0,tempstringforprogressbox.lastIndexOf(" that contains a"))+".";
               CaluMath.PM.InsertionObjectAlerts(tempobject);
            }
            else{
               CaluMath.PM.DisplayPageControls();
               document.getElementById("progressbox").childNodes[0].data='';
            };
         };
         if(tempstringforcasalert != null){
            CaluMath.PM.tempcasalert= cm_alert(tempstringforcasalert);
         };
      }
      else if(tempobject.type !="dynamic"){ 
         //Comment: If it was the object's first time, then we set the lastobjectfirsttime to be false. 
         CaluMath.PM.InsertionArray.setlastobjectfirsttime(false);
      };
   }
   else{
      //Comment: I commented out this scroll on Nov. 5, 2007 because of downalevel button being added back in. 
      //window.scroll(0,-1000);
   };
};


CaluMath.PM.EditIndividualEntries = function(){ 
   var tempobject= arguments[0]; 
   var finishbuttonElement= arguments[1];
   var cancelbuttonElement= arguments[2];
   var deletebuttonElement= arguments[3];
   CaluMath.PM.AssignParents(tempobject);
   tempobject.makecontrolsvisible = function(){
      finishbuttonElement.style.display="inline";
      cancelbuttonElement.style.display="inline";
      deletebuttonElement.style.display="inline";
      CaluMath.PM.EditIndividualEntries(tempobject,finishbuttonElement, cancelbuttonElement, deletebuttonElement); 

   };
       
   var childarray= tempobject.childarray;
         
   var downalevelbutton=document.createElement("input");
   downalevelbutton.setAttribute("type","button");
   downalevelbutton.setAttribute("value","Edit The Individual Entries in the "+CaluMath.PM.PageMakerObjectLabelName(tempobject));
   document.getElementById("endofdocumentcontainer").parentNode.insertBefore(downalevelbutton,document.getElementById("endofdocumentcontainer")) 
//   finishbuttonElement.parentNode.insertBefore(downalevelbutton,finishbuttonElement) 
   tempobject.downalevelbutton=downalevelbutton; 

   var endeditbutton=document.createElement("input");
   endeditbutton.setAttribute("type","button");
   endeditbutton.setAttribute("value","End Editing Individual Objects");
   document.getElementById("endofdocumentcontainer").parentNode.insertBefore(endeditbutton,document.getElementById("endofdocumentcontainer")) 
   endeditbutton.style.display="none";

   var movebutton=document.createElement("input");
   movebutton.setAttribute("type","button");
   movebutton.setAttribute("value","Move Highlighted Object Up");
   document.getElementById("endofdocumentcontainer").parentNode.insertBefore(movebutton,document.getElementById("endofdocumentcontainer")) 
   movebutton.style.display="none";

   var recreatebutton=document.createElement("input");
   recreatebutton.setAttribute("type","button");
   recreatebutton.setAttribute("value","Edit Highlighted Object");
   document.getElementById("endofdocumentcontainer").parentNode.insertBefore(recreatebutton,document.getElementById("endofdocumentcontainer")) 
   recreatebutton.style.display="none";
 
   window.location.hash="#endofdocument"; 
      
   downalevelbutton.onclick=function(){
      var childlist= new Array(); 
      for(var i=0; i<childarray.length; i++){
//         childlist[i]=[childarray[i].type+' named '+childarray[i].cm_getsetting("name"), childarray.type, childarray[i]];
         childlist[i]=[CaluMath.PM.PageMakerObjectLabelName(childarray[i])+' named '+childarray[i].cm_getsetting("name"), childarray.type, childarray[i]];

      };
      var childdropdown=document.createElement("select");
      document.getElementById("endofdocumentcontainer").parentNode.insertBefore(childdropdown,document.getElementById("endofdocumentcontainer")) 
      CaluMath.PM.MakeSelectMenu(childdropdown, childlist);
      childdropdown.options.selectedIndex=0;
      
      downalevelbutton.parentNode.removeChild(downalevelbutton);
      recreatebutton.style.display="inline";
      movebutton.style.display="inline";
      endeditbutton.style.display="inline";

      finishbuttonElement.style.display="none";
      cancelbuttonElement.style.display="none";
      deletebuttonElement.style.display="none";
 

      movebutton.onclick=function(){ 
         var selectedIndex= childdropdown.options.selectedIndex;
         if(selectedIndex !=0){
            var tempobjecttomove= childarray[selectedIndex];
            if(tempobject.type == "conditional" && selectedIndex==1){
               alert("You are not allowed to move this item any higher. The comparison for the conditional must be the first element");
               return ;
            };
            childarray[selectedIndex]=childarray[selectedIndex-1];
            childarray[selectedIndex-1]=tempobjecttomove;
            recreatebutton.parentNode.removeChild(recreatebutton);
            childdropdown.parentNode.removeChild(childdropdown);
            movebutton.parentNode.removeChild(movebutton);
            endeditbutton.parentNode.removeChild(endeditbutton);
            CaluMath.PM.EditIndividualEntries(tempobject,finishbuttonElement, cancelbuttonElement, deletebuttonElement)[0].onclick(); 
            
         };
      };

      endeditbutton.onclick=function(){ 
         finishbuttonElement.style.display="inline";
         cancelbuttonElement.style.display="inline";
         deletebuttonElement.style.display="inline";
         CaluMath.PM.EditIndividualEntries(tempobject,finishbuttonElement, cancelbuttonElement, deletebuttonElement);

            recreatebutton.parentNode.removeChild(recreatebutton);
            childdropdown.parentNode.removeChild(childdropdown);
            movebutton.parentNode.removeChild(movebutton);
            endeditbutton.parentNode.removeChild(endeditbutton);
    
      };
     

      recreatebutton.onclick=function(){ 
         CaluMath.PM.ReCreateObject(tempobject.childarray[childdropdown.options.selectedIndex]);  
         finishbuttonElement.style.display="none";
         cancelbuttonElement.style.display="none";
         deletebuttonElement.style.display="none";
            recreatebutton.parentNode.removeChild(recreatebutton);
            childdropdown.parentNode.removeChild(childdropdown);
            movebutton.parentNode.removeChild(movebutton);
            endeditbutton.parentNode.removeChild(endeditbutton);

      };


   };
   return [downalevelbutton, recreatebutton];
};

CaluMath.PM.AlertNoNewPlotConstructedYet=function(){
   var selectedvalue=arguments[0];
   if(CaluMath.PM.PlotlistObject.newplotlist== null || CaluMath.PM.PlotlistObject.newplotlist.length==0){
      alert("You cannot do a "+CaluMath.PM.PageMakerObjectLabelName(selectedvalue)+" until you have constructed a set of axes.");
      if(CaluMath.PM.InsertionArray.length==0){
         CaluMath.PM.DisplayPageControls();
      };
      // CaluMath.PM.TABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
      CaluMath.PM.MENUSTABLEFORHTMLCASMATHOPTIONS.style.visibility="visible";
      return "stop";
   };
};

//Comment: Many graphical objects depend on a set of axes and a graph. For example, a highlight object constructs a highlight on a graph. Given a selection of a set of axes in a drop down menu, you want the graphs that can be highlighted in that set of axes to apperar. If a new set of axes is selected, you want the objects in that set of axes that can highlights appear. This function does that in a uniform way for all types of objects that depend on both a set of axes and the graphs inside that set of axes. 
CaluMath.PM.MakeChangeNewPlotMenuRoutine = function(){
   //Comment: The first argument is the object being constructed. The remaining arguments come from the default array entry, for example, a typical default array entry looks like this: ["graph", "menu", "updatablefunctionplotlist", "newplotlist", "This Updatable Graph"]. We pick out the second, third and fifth entries of this arry for the remaining arguments. 
var tempobject=arguments[0];
var tempCM_PageMakerDefault = tempobject.defaultobject();
var temptype=tempobject.type;
var requiredoroptional=arguments[1];
var temppropertyname=arguments[2];
var listname= arguments[3];
var labelinfo=arguments[4];
var multifunction=arguments[5];

if(tempCM_PageMakerDefault.required.newplot.menu.options.length==CaluMath.PM.PlotlistObject.newplotlist.length){
   var NewPlotList=CaluMath.PM.PlotlistObject.newplotlist;
}
else if(tempCM_PageMakerDefault.required.newplot.menu.options.length==CaluMath.PM.PlotlistObject.newplotlist.length+1){
   var NewPlotList=[["none","CM_ParentObject"]].concat(CaluMath.PM.PlotlistObject.newplotlist);
}

   if(multifunction !="yes"){

         if(CM_TopWindow.CM_EditMode){
            var plotformenu=CaluMath.PM.GetPageMakerObjectSetting(tempobject, "newplot");
            var pointformenu=CaluMath.PM.GetPageMakerObjectSetting(tempobject, temppropertyname);
if(CaluMath.PM.PlotlistObject[plotformenu][listname]==null ||CaluMath.PM.PlotlistObject[plotformenu][listname][0] ==null || CaluMath.PM.PlotlistObject[plotformenu][listname][0][0]==null){
//   alert(["There is a problem",CaluMath.PM.PlotlistObject[plotformenu][listname],CaluMath.PM.PlotlistObject[plotformenu][listname][0]]);
            //Comment: This is to avoid a problem with ActivateStretchRectangles that occurred when all rectangles were moved to another graph and an already constructed ActivateStretchRectangles referred to a  newplot with no rectangles. Upont editing the ActivateStretchRectangles this would cause a problem. 
            CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", ["List Not Available"],"List Not Available",  labelinfo]);
            CaluMath.PM.PopulateTableWithCurrentValues(temptype,arguments[0]);
   return ;
};
            CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[plotformenu][listname],CaluMath.PM.PlotlistObject[plotformenu][listname][0][0],  labelinfo]);
            CaluMath.PM.PopulateTableWithCurrentValues(temptype,arguments[0]);
         }
         else{
            var haverequiredobjectslist=false;
            haverequiredobjectslistloop:
            for(var j=0; j<NewPlotList.length; j++){ 
               if(CaluMath.PM.PlotlistObject[NewPlotList[j][1]][listname].length != 0){
                  CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[NewPlotList[j][1]][listname], CaluMath.PM.PlotlistObject[NewPlotList[j][1]][listname][0][0], labelinfo]);
                  haverequiredobjectslist=true;
                  var goodhaverequiredobjectsindex=j;
                  var goodoptionindex=goodhaverequiredobjectsindex;
                  break haverequiredobjectslistloop;
               };
            };
            if(haverequiredobjectslist ==false){
               var stophaverequiredobjects="yes";
            };

               //Comment: We then assign an onchange function that changes the list of functions to those associated with the chosen plot. 
               tempCM_PageMakerDefault.required["newplot"].menu.onchange=function(){
                  var tempchosenplotnew= tempCM_PageMakerDefault.required.newplot.menu[tempCM_PageMakerDefault.required.newplot.menu.selectedIndex].value;
                  if(CaluMath.PM.PlotlistObject[tempchosenplotnew][listname].length >0){
                     CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[tempchosenplotnew][listname] , CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][0][0], labelinfo]);
                  }
                  else{
                     tempCM_PageMakerDefault.required.newplot.menu.options[goodoptionindex].selected=true
                     CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[NewPlotList[goodhaverequiredobjectsindex][1]][listname], CaluMath.PM.PlotlistObject[NewPlotList[goodhaverequiredobjectsindex][1]][listname][0][0],  labelinfo]);
                  };
               };
         };
         
         if(CM_EditMode){
            tempCM_PageMakerDefault.required["newplot"].menu.onchange=function(){
               var tempchosenplotnew= tempCM_PageMakerDefault.required.newplot.menu[tempCM_PageMakerDefault.required.newplot.menu.selectedIndex].value;
               if(CaluMath.PM.PlotlistObject[tempchosenplotnew][listname].length >0 && tempchosenplotnew != tempobject.cm_getsetting("newplot") ){
                  CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[tempchosenplotnew][listname] , CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][0][0], labelinfo]);
               }
               else{
                   CaluMath.PM.MakeDefaultOption(tempCM_PageMakerDefault.required["newplot"].menu, tempobject.cm_getsetting("newplot"), "value"); 
                  CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[tempobject.cm_getsetting("newplot")][listname],tempobject.cm_getsetting(temppropertyname),  labelinfo]);
               };
            };
          };

         if(stophaverequiredobjects !="yes"){
            tempCM_PageMakerDefault.required["newplot"].menu.onchange();
         };
   }
   else{

         if(CM_TopWindow.CM_EditMode){
            var plotformenu=CaluMath.PM.GetPageMakerObjectSetting(tempobject, "newplot");
            var pointformenu=CaluMath.PM.GetPageMakerObjectSetting(tempobject, temppropertyname);
            CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[plotformenu][listname],CaluMath.PM.PlotlistObject[plotformenu][listname][0][0],  labelinfo]);
            CaluMath.PM.PopulateTableWithCurrentValues(temptype,arguments[0]);
         }
         else{
            var haverequiredobjectslist=false;
            haverequiredobjectslistloop:
            for(var j=0; j<NewPlotList.length; j++){
               if(CaluMath.PM.PlotlistObject[NewPlotList[j][1]][listname].length != 0){
                  CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[NewPlotList[j][1]][listname], CaluMath.PM.PlotlistObject[NewPlotList[j][1]][listname][0][0], labelinfo]);
                  haverequiredobjectslist=true;
                  var goodhaverequiredobjectsindex=j;
                  var goodoptionindex=goodhaverequiredobjectsindex;
                  break haverequiredobjectslistloop;
               };
            };

            if(haverequiredobjectslist ==false){
               var stophaverequiredobjects="yes";
            };

               //Comment: We then assign an onchange function that changes the list of functions to those associated with the chosen plot. 
               tempCM_PageMakerDefault.required["newplot"].menu.onchange=function(){
                  var tempchosenplotnew= tempCM_PageMakerDefault.required.newplot.menu[tempCM_PageMakerDefault.required.newplot.menu.selectedIndex].value;
                  if(CaluMath.PM.PlotlistObject[tempchosenplotnew][listname].length >0){
                     CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[tempchosenplotnew][listname] , CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][0][0], labelinfo]);
                  }
                  else{
                     tempCM_PageMakerDefault.required.newplot.menu.options[goodoptionindex].selected=true
                     CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[NewPlotList[goodhaverequiredobjectsindex][1]][listname], CaluMath.PM.PlotlistObject[NewPlotList[goodhaverequiredobjectsindex][1]][listname][0][0],  labelinfo]);
                  };
               tempCM_PageMakerDefault.required["graph"].menu.onchange = function(){
                    var tempchosenplotnew= tempCM_PageMakerDefault.required.newplot.menu[tempCM_PageMakerDefault.required.newplot.menu.selectedIndex].value;
                     var tempchosengraphnew= tempCM_PageMakerDefault.required.graph.menu.selectedIndex;
                  if(CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][tempchosengraphnew][2].type !="linearplot" && CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][tempchosengraphnew][2].type !="arcplot"){
                     tempCM_PageMakerDefault.required.cm_functionindex.input.value="n/a";
                     tempCM_PageMakerDefault.required.cm_functionindex.input.onchange=CaluMath.PM.ForceInputToBeNA;
                  }
                  else{
                     tempCM_PageMakerDefault.required.cm_functionindex.input.value="0";
                     tempCM_PageMakerDefault.required.cm_functionindex.input.onchange= null;
                  };
               };
               tempCM_PageMakerDefault.required["graph"].menu.onchange();
              };

         };
         
         if(CM_EditMode){
            tempCM_PageMakerDefault.required["newplot"].menu.onchange=function(){
               var tempchosenplotnew= tempCM_PageMakerDefault.required.newplot.menu[tempCM_PageMakerDefault.required.newplot.menu.selectedIndex].value;
               if(CaluMath.PM.PlotlistObject[tempchosenplotnew][listname].length >0 && tempchosenplotnew != tempobject.cm_getsetting("newplot") ){
                  CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[tempchosenplotnew][listname] , CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][0][0], labelinfo]);
               }
               else{
                   CaluMath.PM.MakeDefaultOption(tempCM_PageMakerDefault.required["newplot"].menu, tempobject.cm_getsetting("newplot"), "value"); 
                  CaluMath.PM.UpdateIndividualOption(tempCM_PageMakerDefault, requiredoroptional, [temppropertyname, "menu", CaluMath.PM.PlotlistObject[tempobject.cm_getsetting("newplot")][listname],tempobject.cm_getsetting(temppropertyname),  labelinfo]);
               };
               tempCM_PageMakerDefault.required["graph"].menu.onchange = function(){
                  var tempchosenplotnew= tempCM_PageMakerDefault.required.newplot.menu[tempCM_PageMakerDefault.required.newplot.menu.selectedIndex].value;
                  var tempchosengraphnew= tempCM_PageMakerDefault.required.graph.menu.selectedIndex;
                  if(CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][tempchosengraphnew][2].type !="linearplot" && CaluMath.PM.PlotlistObject[tempchosenplotnew][listname][tempchosengraphnew][2].type !="arcplot"){
                     tempCM_PageMakerDefault.required.cm_functionindex.input.value="n/a";
                     tempCM_PageMakerDefault.required.cm_functionindex.input.onchange=CaluMath.PM.ForceInputToBeNA;
                  }
                  else{
                     tempCM_PageMakerDefault.required.cm_functionindex.input.value=tempobject.cm_getsetting("cm_functionindex");
                     tempCM_PageMakerDefault.required.cm_functionindex.input.onchange= null;
                  };
               };
            };
          };

         if(stophaverequiredobjects !="yes"){
            tempCM_PageMakerDefault.required["newplot"].menu.onchange();
            tempCM_PageMakerDefault.required["graph"].menu.onchange();
         };
   };
   return stophaverequiredobjects;

};

CaluMath.PM.ForceInputToBeNA=function(){
   this.value="n/a";
};

