        var statusInfoIdsToDelete='';
        function deleteRow(anchor){
            // Get the ID of the row to delete
            var taskStatusInfoID = anchor.parentNode.parentNode.querySelector('#taskStatusInfoID').value;
            
            // Determine if this was a saved node
            if (taskStatusInfoID!=="-1"){
                // Determine if this is the first one to delete
                if (statusInfoIdsToDelete===''){
                    // Just add it
                    statusInfoIdsToDelete = statusInfoIdsToDelete + taskStatusInfoID;
                }
                else {
                    // Add it with a comma
                    statusInfoIdsToDelete = statusInfoIdsToDelete + ',' + taskStatusInfoID;
                }
            }
            
            // Delete the sortable row
            anchor.parentNode.parentNode.remove();
            
            // We have removed a row, so we can reset back to the original until it is saved. Show the button.
            div_show("loadSavedTrunk");
        }
        
        function copyRow(anchor){
            // Get the main LI row to copy.  Should be two levels back.
            var copyUIHelper = anchor.parentNode.parentNode.cloneNode(true);

            // Make visible and hide the elements that need to be
            copyUIHelper.querySelector('#deleteLI').style.display = "block";
            copyUIHelper.querySelector('#expandLI').style.display = "block";
            copyUIHelper.querySelector('#moveThisOne').style.display = "none";
            
            // Copy to the routing list
            $("#initialStatusRouting").append(copyUIHelper);
            
            // We have added a new row, so we can reset back to the original until it is saved.  Show the button.
            div_show("loadSavedTrunk");
        }
        
        function toggleProperties(anchor){
            // Determine if the text is a plus or minus
            if (anchor.text==="-"){
                // Close the hidden field
                anchor.parentNode.parentNode.querySelector('#expandableLI').style.display = 'none';
                anchor.style.cursor = 's-resize';
                anchor.title = "Show the properties of this status routing.";
                
                // Set the text to a plus
                anchor.text="+";
            }
            else {
                // Open up the hidden field
                anchor.parentNode.parentNode.querySelector('#expandableLI').style.display = 'block';
                anchor.style.cursor = 'vertical-text';
                anchor.title = "Hide the properties of this status routing.";
                
                // Set the text to a minus
                anchor.text="-";
            }
        }

        function expandTree(anchor, theNodeID){
            // Determine if the text is a plus or minus
            if (anchor.text==="-"){
                // Close the hidden field
                document.getElementById(theNodeID).style.display = 'none';
                
                // Change properties of this anchor for the new state
                anchor.style.cursor = 's-resize';
                anchor.title = "Show the branch off of this status routing node.";
                
                // Set the text to a plus
                anchor.text="+";
            }
            else {
                // Open up the hidden field
                document.getElementById(theNodeID).style.display = 'block';
                
                // Change properties of this anchor for the new state
                anchor.style.cursor = 'vertical-text';
                anchor.title = "Hide this branch off.";
                
                // Set the text to a minus
                anchor.text="-";
            }
        }
        
        function moveRouteAsNecessary(taskNumber, currentTaskStatusRoutingNodeID, completionFeedbackNotes, routeGoToInfotrings){
            // set the return variable 
            var returnValue = -1;
            
            // Setup the parameters to pass to PHP
            var params = {
                "sessionID"                      : sessionID,
                "taskNumber"                     : taskNumber,
                "currentTaskStatusRoutingNodeID" : currentTaskStatusRoutingNodeID,
                "direction"                      : routeGoToInfotrings[8],
                "completionFeedbackNotes"        : completionFeedbackNotes,
                "gotoStatusID"                   : routeGoToInfotrings[1],
                "gotoTaskStatusRoutingInfoID"    : routeGoToInfotrings[2],
                "gotoMainBranchID"               : routeGoToInfotrings[3],
                "gotoMergeToBranchID"            : routeGoToInfotrings[4]
            };

            // Create the string containing the PHP file to use
            var url = "php_only_scripts/jquery_only/move_route_onwards.php";

            // Setup AJAX for communication
            $.ajax({
                context : this,
                type    : "GET", 
                url     : url, 
                data    : params, 
                dataType: "text", 
                encode  : true,
                async   : false, 
                cache   : false
            })
            .done(function(data){
                // Split the string on the double colon
                var errorStrings=data.trim().split("::");

                // Check to see if there is a reason NOT to allow changing the route
                if (data.includes("ABORT MOVE ROUTE ONWARDS")){
                    // Give an alert popup of the problem
                    alert(errorStrings[2]);

                    // Log any errors to the console
                    console.log(data.trim());
                }
                else {
                    // Send back the status ID that we went to
                    returnValue = errorStrings[0];
                }
            })
            .fail(function(data){   
                // Give an alert popup of the problem
                alert("There was an error communicating with the server. The error was:" . data);

                // Log any errors to the console
                console.log(data);

                // Return a failed result
                returnValue = -1;
            });
            
            // return what we got
            return returnValue;
        }
        
        function PreMoveCheckRoutingState(taskNumber, currentTaskStatusRoutingNodeID, currentMainBranchID, direction, currentChosenStatusID=-1){
            // set the return variable 
            var returnMessage = '';

            // Setup the parameters to pass to PHP
            var params = {
                "sessionID"                      : sessionID,
                "taskNumber"                     : taskNumber,
                "currentTaskStatusRoutingNodeID" : currentTaskStatusRoutingNodeID,
                "currentMainBranchID"            : currentMainBranchID,
                "direction"                      : direction,
                "currentChosenStatusID"          : currentChosenStatusID
            };

            // Create the string containing the PHP file to use
            var url = "php_only_scripts/jquery_only/precheck_route_move.php";

            // Setup AJAX for communication
            $.ajax({
                context : this,
                type    : "GET", 
                url     : url, 
                data    : params, 
                dataType: "text", 
                encode  : true,
                async   : false, 
                cache   : false
            })
            .done(function(data){
                // Check to see if there is a reason NOT to allow checking the route
                if (data.includes("ABORT PRECHECK ROUTE MOVING")){
                    // Split the string on the double colon
                    var errorStrings=data.trim().split("::");

                    // Give an alert popup of the problem
                    alert(errorStrings[1]);

                    // Log any errors to the console
                    console.log(data.trim());
                }
                else {
                    // Send any message we get back from the database query
                    returnMessage = data.trim();
                }
            })
            .fail(function(data){   
                // Give an alert popup of the problem
                alert("There was an error communicating with the server. The error was:" . data);

                // Log any errors to the console
                console.log(data.trim());
            });
            
            // return what we got
            return returnMessage;
        }
        
        var routeGoToInfoStrings=null;
        function moveRouting(taskNumber, currentTaskStatusRoutingNodeID, currentMainBranchID, direction, dialogCallName, headerElemName, currentChosenStatusID=-1, elementNamePrefix='', openDialog=true){
            // Check first and foremost if the session is good
            if (checkForSessionChange(sessionID, true)){
                // First check to see if there is anything that should be communicated to the user before moving this task
                var result = PreMoveCheckRoutingState(taskNumber, currentTaskStatusRoutingNodeID, currentMainBranchID, direction, currentChosenStatusID);

                // Determine if there is something to work with
                if (result!=''){
                    // Determine if the strings are not null
                    if (routeGoToInfoStrings!==null && routeGoToInfoStrings!==undefined){
                        // Free up memory
                        routeGoToInfoStrings.length=0;
                    }
                    
                    // attempt to split the string on the double colon
                    routeGoToInfoStrings=result.trim().split("::");

                    // Determine if the strings are not null
                    if (routeGoToInfoStrings!==null && routeGoToInfoStrings!==undefined){
                        // Get the elements that can have their values changed
                        document.getElementById(elementNamePrefix+'routeTID').value=taskNumber;
                        document.getElementById(elementNamePrefix+'routeStatusID').value=routeGoToInfoStrings[1];
                        document.getElementById(elementNamePrefix+'routeCurrentTaskStatusRoutingNodeID').value=currentTaskStatusRoutingNodeID;
                        document.getElementById(elementNamePrefix+'routeNodeEstimatedTime').value=routeGoToInfoStrings[6] + ' Hrs';
                        document.getElementById(elementNamePrefix+'routeNodeActualTime').value=routeGoToInfoStrings[7] + ' Hrs';
                        document.getElementById(elementNamePrefix+'nextStatusNotes').value=routeGoToInfoStrings[5];
            
                        // Check to see if there is something the user needs to confirm or not
                        if (routeGoToInfoStrings[0]!=""){
                            // Change the header
                            document.getElementById(headerElemName).innerHTML=routeGoToInfoStrings[0];
                        }

                        // Get the div element holding the controls with values to save and make it visible
                        document.getElementById(elementNamePrefix+'RouteParamsDiv').style.display = "block";

                        // Determine if I should open this dialog yet
                        if (openDialog){
                            // Open the appropriate dialog
                            $( "#" + dialogCallName ).dialog( "open" );
                        }
                    }
                    else {
                        // Let the user know there was a problem getting the info required to move route along path
                        alert('There was a problem getting information about the routing. Cannot use the move routing functionality at this time.\n\nPlease contact system administrator in order to fix this problem.');
                    }
                }
            }
        }
        
        function modifyStatusInfoRoute(inUpdateTaskNumber, statusInfoElement, inExecutionOrder, isRoutingTemplate=0, routingTemplateName=null, isCurrentRouteNode=false, autoAppendedNotes=""){
            // set the return variable 
            var returnValue = false;

            // Check first and foremost if the session is good
            if (checkForSessionChange(sessionID, true)){
                // attempt to make the task number a number
                var updateTaskNumber = parseInt(inUpdateTaskNumber, 10);

                // Get the elements necessary 
                var taskStatusInfoIDElem = statusInfoElement.querySelector('#taskStatusInfoID');
                var taskStatusInfoMainBranchIDElem = statusInfoElement.querySelector('#taskStatusInfoMainBranchID');
                var taskStatusInfoMergedToBranchIDElem = statusInfoElement.querySelector('#taskStatusInfoMergedToBranchID');
                var infoStatusIDElem = statusInfoElement.querySelector('#infoStatusID');
                var statusInfoEstimatedTimeElem = statusInfoElement.querySelector('#statusInfoEstimatedTime');
                var statusInfoCompletionFactorElem = statusInfoElement.querySelector('#statusInfoCompletionFactor');
                var statusInfoNoteElem = statusInfoElement.querySelector('#statusInfoNote');
                var feedbackNoteElem = statusInfoElement.querySelector('#feedbackNote');
                
                // Get the element values necessary to update/delete/add to send to server
                var taskStatusInfoID = (taskStatusInfoIDElem==null)?null:taskStatusInfoIDElem.value;
                var taskStatusInfoMainBranchID = (taskStatusInfoMainBranchIDElem==null)?null:taskStatusInfoMainBranchIDElem.value;
                var taskStatusInfoMergedToBranchID = (taskStatusInfoMergedToBranchIDElem==null)?null:taskStatusInfoMergedToBranchIDElem.value;
                var infoStatusID = (infoStatusIDElem==null)?null:infoStatusIDElem.value;
                var statusInfoEstimatedTime = (statusInfoEstimatedTimeElem==null)?null:statusInfoEstimatedTimeElem.value;
                var statusInfoCompletionFactor = (statusInfoCompletionFactorElem==null)?null:statusInfoCompletionFactorElem.value;
                var statusInfoNote = (statusInfoNoteElem==null)?null:statusInfoNoteElem.value;
                var feedbackNote = (feedbackNoteElem==null)?null:feedbackNoteElem.value;

                // Ensure that we have the status info ID element and then get the current route node
                var addCurrentRouteNodeElem = (taskStatusInfoID==null)?null:document.getElementById('addCurrentRouteNode' + taskStatusInfoID);
                var addCurrentRouteNode = (addCurrentRouteNodeElem==null)?null:+ addCurrentRouteNodeElem.checked;
                
                // Get the values that cam in or are static
                var statusInfoActualTime = 0;
                var executionOrder = inExecutionOrder;
                
                // Determine if we are saving a template right now or not
                if (inUpdateTaskNumber<1){
                    // set the status info ID as 0
                    taskStatusInfoID = -1;
                }

                // Create the string containing the PHP file to use as initial
                var url = "php_only_scripts/jquery_only/update_initial_route_node.php";
                
                // Determine if this is for current routing node
                if (isCurrentRouteNode){
                    // Create the string containing the PHP file to use
                    url = "php_only_scripts/jquery_only/update_current_route_node.php";
                    
                    // Determine if the execution order is null
                    if (executionOrder===null){
                        // gleen the execution from the node value
                        executionOrder=statusInfoElement.querySelector('#executionOrder').value;
                    }
                }

                // Setup the parameters to pass to PHP
                var params = {
                    "sessionID"                      : sessionID,
                    "updateTaskNumber"               : updateTaskNumber,
                    "taskStatusInfoID"               : taskStatusInfoID,
                    "taskStatusInfoMainBranchID"     : taskStatusInfoMainBranchID,
                    "taskStatusInfoMergedToBranchID" : taskStatusInfoMergedToBranchID,
                    "infoStatusID"                   : infoStatusID,
                    "statusInfoEstimatedTime"        : statusInfoEstimatedTime,
                    "statusInfoActualTime"           : statusInfoActualTime,
                    "statusInfoCompletionFactor"     : statusInfoCompletionFactor,
                    "statusInfoNote"                 : statusInfoNote,
                    "feedbackNote"                   : feedbackNote,
                    "autoAppendedNotes"              : autoAppendedNotes,
                    "executionOrder"                 : executionOrder,
                    "addCurrentRouteNode"            : addCurrentRouteNode,
                    "isRoutingTemplate"              : isRoutingTemplate,
                    "routingTemplateName"            : routingTemplateName
                };

                // Setup AJAX for communication
                $.ajax({
                    context : this,
                    type    : "GET", 
                    url     : url, 
                    data    : params, 
                    dataType: "text", 
                    encode  : true,
                    async   : false, 
                    cache   : false
                })
                .done(function(data){
                    // Check to see if there is a reason NOT to allow updating the nodes
                    if (data.includes("ABORT UPDATE STATUS INFO NODE")){
                        // Split the string on the double colon
                        var errorStrings=data.trim().split("::");

                        // Give an alert popup of the problem
                        alert(errorStrings[1]);

                        // Log any errors to the console
                        console.log(data.trim());

                        // Return a failed result
                        returnValue = false;
                    }
                    else {
                        // If there is no error text, then we must have modified the node
                        returnValue = true;
                    }
                })
                .fail(function(data){   
                    // Give an alert popup of the problem
                    alert("There was an error communicating with the server. The error was:" . data);

                    // Log any errors to the console
                    console.log(data);

                    // Return a failed result
                    returnValue = false;
                });
            }
            
            // return what we got
            return returnValue;
        }
        
        function deleteOldStatusRouteNodes(){
            // set the return variable 
            var returnValue = false;

            // Check first and foremost if the session is good
            if (checkForSessionChange(sessionID, true)){
                // Setup the parameters to pass to PHP
                var params = {
                    "sessionID"                      : sessionID,
                    "statusInfoIdsToDelete"          : statusInfoIdsToDelete
                };

                // Create the string containing the PHP file to use
                var url = "php_only_scripts/jquery_only/delete_old_route_nodes.php";

                // Setup AJAX for communication
                $.ajax({
                    context : this,
                    type    : "GET", 
                    url     : url, 
                    data    : params, 
                    dataType: "text", 
                    encode  : true,
                    async   : false, 
                    cache   : false
                })
                .done(function(data){
                    // Check to see if there is a reason NOT to allow deleting the nodes
                    if (data.includes("ABORT DELETE STATUS INFO NODES")){
                        // Split the string on the double colon
                        var errorStrings=data.trim().split("::");

                        // Give an alert popup of the problem
                        alert(errorStrings[1]);

                        // Log any errors to the console
                        console.log(data.trim());

                        // Return a failed result
                        returnValue = false;
                    }
                    else {
                        // Clear out the, hopefully, now deleted nodes
                        statusInfoIdsToDelete='';
                        
                        // If there is no error text, then we must have modified the node
                        returnValue = true;
                    }
                })
                .fail(function(data){   
                    // Give an alert popup of the problem
                    alert("There was an error communicating with the server. The error was:" . data);

                    // Log any errors to the console
                    console.log(data);

                    // Return a failed result
                    returnValue = false;
                });
            }
            
            // return what we got
            return returnValue;
        }
        
        function deleteFullStatusRoute(idToDelete){
            // set the return variable 
            var returnValue = false;

            // Check first and foremost if the session is good
            if (checkForSessionChange(sessionID, true)){
                // Setup the parameters to pass to PHP
                var params = {
                    "sessionID"       : sessionID,
                    "idToDelete"      : idToDelete
                };

                // Create the string containing the PHP file to use
                var url = "php_only_scripts/jquery_only/delete_status_route.php";

                // Setup AJAX for communication
                $.ajax({
                    context : this,
                    type    : "GET", 
                    url     : url, 
                    data    : params, 
                    dataType: "text", 
                    encode  : true,
                    async   : false, 
                    cache   : false
                })
                .done(function(data){
                    // Check to see if there is a reason NOT to delete the route
                    if (data.includes("ABORT DELETE STATUS ROUTE")){
                        // Split the string on the double colon
                        var errorStrings=data.trim().split("::");

                        // Give an alert popup of the problem
                        alert(errorStrings[1]);

                        // Log any errors to the console
                        console.log(data.trim());

                        // Return a failed result
                        returnValue = false;
                    }
                    else {
                        // If there is no error text, then we must have modified the node
                        returnValue = true;
                    }
                })
                .fail(function(data){   
                    // Give an alert popup of the problem
                    alert("There was an error communicating with the server. The error was:" . data);

                    // Log any errors to the console
                    console.log(data);

                    // Return a failed result
                    returnValue = false;
                });
            }
            
            // return what we got
            return returnValue;
        }
        
        function updateTaskTemplateName(inUpdateTaskNumber, routingTemplateName){
            // set the return variable 
            var returnValue = false;

            // Check first and foremost if the session is good
            if (checkForSessionChange(sessionID, true)){
                // Setup the parameters to pass to PHP
                var params = {
                    "sessionID"             : sessionID,
                    "updateTaskNumber"      : inUpdateTaskNumber,
                    "routingTemplateName"   : routingTemplateName
                };

                // Create the string containing the PHP file to use
                var url = "php_only_scripts/jquery_only/update_task_routing_template_name.php";

                // Setup AJAX for communication
                $.ajax({
                    context : this,
                    type    : "GET", 
                    url     : url, 
                    data    : params, 
                    dataType: "text", 
                    encode  : true,
                    async   : false, 
                    cache   : false
                })
                .done(function(data){
                    // Check to see if there is a reason NOT to delete the route
                    if (data.includes("ABORT UPDATE TASK STATUS ROUTE")){
                        // Split the string on the double colon
                        var errorStrings=data.trim().split("::");

                        // Give an alert popup of the problem
                        alert(errorStrings[1]);

                        // Log any errors to the console
                        console.log(data.trim());

                        // Return a failed result
                        returnValue = false;
                    }
                    else {
                        // Get and then determine if we got the hidden element to clear the name of the template applied
                        var appliedTemplateNameElem = document.getElementById("appliedTemplateName");
                        if (appliedTemplateNameElem!=null && appliedTemplateNameElem != 'undefined'){
                            // Set the hidden value for the applied template name to be none
                            appliedTemplateNameElem.value="";
                        }
                        
                        // If there is no error text, then we must have modified the node
                        returnValue = true;
                    }
                })
                .fail(function(data){   
                    // Give an alert popup of the problem
                    alert("There was an error communicating with the server. The error was:" . data);

                    // Log any errors to the console
                    console.log(data);

                    // Return a failed result
                    returnValue = false;
                });
            }
            
            // return what we got
            return returnValue;
        }
        
        function populateRouting(taskID){
            // set the return variable 
            var returnValue = false;
            
            // Setup the parameters to pass to PHP
            var params = {
                "sessionID"   : sessionID,
                "taskID"      : taskID
            };

            // Create the string containing the PHP file to use
            var url = "php_only_scripts/jquery_only/get_initial_routing.php";

            // Setup AJAX for communication
            $.ajax({
                context : this,
                type    : "GET", 
                url     : url, 
                data    : params, 
                dataType: "text", 
                encode  : true,
                async   : false, 
                cache   : false
            })
            .done(function(data){
                // Check to see if there is a reason NOT to allow updating the nodes
                if (data.includes("ABORT GET ROUTING")){
                    // Split the string on the double colon
                    var errorStrings=data.trim().split("::");

                    // Give an alert popup of the problem
                    alert(errorStrings[1]);

                    // Log any errors to the console
                    console.log(data.trim());

                    // Return a failed result
                    returnValue = false;
                }
                else {
                    // Remove any extraneous bullets
                    $( "#initialStatusRouting" ).empty();

                    // get the routing elements this user has
                    var currentStatusesContainer = document.getElementById('initialStatusRouting');

                    // Add the nodes to the appropriate container
                    currentStatusesContainer.innerHTML = data.trim();

                    // Get and then determine if we got the hidden element to clear the name of the template applied
                    var appliedTemplateNameElem = document.getElementById("appliedTemplateName");
                    if (appliedTemplateNameElem!=null && appliedTemplateNameElem != 'undefined'){
                        // Set the hidden value for the applied template name to be none
                        appliedTemplateNameElem.value="";
                    }
                    
                    // Since we have set everything back to initial, then hide the refill button
                    div_hide("loadSavedTrunk");

                    // If there is no error text, then we must have modified the node
                    returnValue = true;
                }
            })
            .fail(function(data){   
                // Give an alert popup of the problem
                alert("There was an error communicating with the server. The error was:" . data);

                // Log any errors to the console
                console.log(data);

                // Return a failed result
                returnValue = false;
            });
            
            // return what we got
            return returnValue;
        }
        
        function populateRoutingTemplate(){
            // set the return variable 
            var returnValue = false;
            
            // First get the value of the radio button to see what I am doing
            var applyPreferencesRadioElem = document.getElementsByName("applyPreferencesRadio");

            // loop through the radio elements
            var checkedValue = "NONE";
            for(i = 0; i < applyPreferencesRadioElem.length; i++) {
                // Determine if this one is checked
                if(applyPreferencesRadioElem[i].checked){
                    // Set this as the one checked
                    checkedValue = applyPreferencesRadioElem[i].value;
                    
                    // exit for
                    break;
                }
            }
            
            // Ensure this is only being clicked in the correct state
            if (checkedValue=="TaskID" || checkedValue=="Template"){
                // Set the value to pass as default for now
                var templateTID = -1;
                
                // Determine which was clicked
                if (checkedValue==="TaskID"){
                    // Get the routing TID to select options
                    var routingTIDToCopyElem = document.getElementById("taskIDToCopyRoute");
                    
                    // Determine if we got the element
                    if (routingTIDToCopyElem!=null && routingTIDToCopyElem != 'undefined'){
                        // Get the value of the TID box
                        templateTID = routingTIDToCopyElem.value;

                        // Get and then determine if we got the hidden element to hold the name of the template applied
                        var appliedTemplateNameElem = document.getElementById("appliedTemplateName");
                        if (appliedTemplateNameElem!=null && appliedTemplateNameElem != 'undefined'){
                            // Set the hidden value for the applied template name to be this TID
                            appliedTemplateNameElem.value=routingTIDToCopyElem.value;
                        }
                    }
                }
                else {
                    // Get the routing template to select options
                    var routingTemplateToCopyElem = document.getElementById("routingTemplateToCopy");
                    
                    // Determine if we got the element
                    if (routingTemplateToCopyElem!=null && routingTemplateToCopyElem != 'undefined'){
                        // Get the value of the Template ID combo
                        templateTID = routingTemplateToCopyElem.value;

                        // Get and then determine if we got the hidden element to hold the name of the template applied
                        var appliedTemplateNameElem = document.getElementById("appliedTemplateName");
                        if (appliedTemplateNameElem!=null && appliedTemplateNameElem != 'undefined'){
                            // Set the hidden value for the applied template name to be the selected template
                            appliedTemplateNameElem.value=routingTemplateToCopyElem.options[routingTemplateToCopyElem.selectedIndex].text;
                        }
                    }
                }

                // Setup the parameters to pass to PHP
                var params = {
                    "sessionID"      : sessionID,
                    "templateTID"    : templateTID
                };

                // Create the string containing the PHP file to use
                var url = "php_only_scripts/jquery_only/get_routing_template.php";

                // Setup AJAX for communication
                $.ajax({
                    context : this,
                    type    : "GET", 
                    url     : url, 
                    data    : params, 
                    dataType: "text", 
                    encode  : true,
                    async   : false, 
                    cache   : false
                })
                .done(function(data){
                    // Check to see if there is a reason NOT to allow updating the nodes
                    if (data.includes("ABORT GET ROUTING")){
                        // Split the string on the double colon
                        var errorStrings=data.trim().split("::");

                        // Give an alert popup of the problem
                        alert(errorStrings[1]);

                        // Log any errors to the console
                        console.log(data.trim());

                        // Return a failed result
                        returnValue = false;
                    }
                    else {
                        // get the routing elements this user has
                        var currentStatusesContainer = document.getElementById('initialStatusRouting');

                        // Now get an array of the delete links
                        var currentDeleteLink = currentStatusesContainer.getElementsByClassName('deleteLI');

                        // Get the lenth in a variable
                        var amountOfElements=currentDeleteLink.length;

                        // Loop through the elements
                        for(var executionOrder=0; executionOrder < amountOfElements; executionOrder++){
                            // Click this anchor as though the user were in order to fire methods needed
                            currentDeleteLink[0].click();
                        }
                        
                        // Remove any extraneous bullets
                        $( "#initialStatusRouting" ).empty();

                        // Add the nodes to the appropriate container
                        currentStatusesContainer.innerHTML = data;

                        // Since we have set to a template, but not saved show the refill button
                        div_show("loadSavedTrunk");

                        // If there is no error text, then we must have modified the node
                        returnValue = true;
                    }
                })
                .fail(function(data){   
                    // Give an alert popup of the problem
                    alert("There was an error communicating with the server. The error was:" . data);

                    // Log any errors to the console
                    console.log(data);

                    // Return a failed result
                    returnValue = false;
                });
            }
            
            // return what we got
            return returnValue;
        }
        
        function populateTemplateControl(){
            // set the return variable 
            var returnValue = false;
            
            // Setup the parameters to pass to PHP
            var params = {
                "sessionID"   : sessionID
            };

            // Create the string containing the PHP file to use
            var url = "php_only_scripts/jquery_only/get_template_control.php";

            // Setup AJAX for communication
            $.ajax({
                context : this,
                type    : "GET", 
                url     : url, 
                data    : params, 
                dataType: "text", 
                encode  : true,
                async   : false, 
                cache   : false
            })
            .done(function(data){
                // Check to see if there is a reason NOT to allow updating the nodes
                if (data.trim() !== ""){
                    // Get the parent dive of the current template element (either text box or combo box)
                    var templateParent = document.getElementById('routeTemplateParent');
                    
                    // Set the inner HTML to be what is returned after the triple colon
                    templateParent.innerHTML=data.trim();

                    // If there is no error text, then we must have modified the node
                    returnValue = true;
                }
            })
            .fail(function(data){   
                // Log any errors to the console
                console.log(data);

                // Return a failed result
                returnValue = false;
            });
            
            // return what we got
            return returnValue;
        }
        
        function updateRoutingTemplate(setAsTIDRoutingTemplateName=false){
            var returnValue = true;
            
            // get the routing elements this user has
            var currentStatusesContainer = document.getElementById('initialStatusRouting');
            
            // Now get an array of the available statuses
            var currentStatuses = currentStatusesContainer.getElementsByClassName('ViableStatus');

            // Have to get the template name in order to save as a template
            var routingTemplateName = document.getElementById("routingTemplateName").value;

            // Get the template select list
            var routingTemplateList = document.getElementById("routingTemplateToCopy");
            
            // Set a value for the template as null to determine if it exists
            var currentTemplateValue=null;
            var currentTemplateName=null;
            
            // loop through the template select list to see if there is currently a template as named
            for(i=0; i<routingTemplateList.options.length;i++){
                // Determine if the text matches
                if (routingTemplateName.trim()==routingTemplateList.options[i].text.trim()){
                    // Set the current template value
                    currentTemplateValue=routingTemplateList.options[i].value;
                    
                    // Set the routing template name
                    currentTemplateName=routingTemplateList.options[i].text.trim();
                    
                    // break out of the loop
                    break;
                }
            }
            
            // Determine if the text matches
            if (routingTemplateName.trim()==currentTemplateName){
                // Delete this route to make new
                returnValue=deleteFullStatusRoute(currentTemplateValue);
            }
            
            // Determine if there is a name
            if (routingTemplateName.trim()!="" && returnValue==true){
                // Loop through the elements
                for(var executionOrder2=0; executionOrder2 < currentStatuses.length; executionOrder2++){
                    // Try to modify the element and then see if successful
                    if (modifyStatusInfoRoute(currentTemplateValue, currentStatuses[executionOrder2], (executionOrder2+1), 1, routingTemplateName.trim())===true){
                        // AND this with the current return value to see what the update result is
                        returnValue&=true; 
                    }
                    else {
                        // Set a return value of false for the entire method
                        returnValue=false; 
                    }
                }
                
                // Get and then determine if we got the hidden element to hold the name of the template applied
                var appliedTemplateNameElem = document.getElementById("appliedTemplateName");
                if (setAsTIDRoutingTemplateName && appliedTemplateNameElem!=null && appliedTemplateNameElem != 'undefined'){
                    // Set the hidden value for the applied template name to be this TID
                    appliedTemplateNameElem.value=routingTemplateName.trim();
                }
            }
            else {
                // Let the user know
                alert("Cannot save this as a template without a template name.\n\nCanceling template save...");
            }
        }
            
        function updateInitialRoutingElements(inUpdateTaskNumber){
            var returnValue = true;
            
            // init variables used throughout
            var initialStatusesContainer = null;
            var initialStatuses = null;

            // Delete ones that were saved, but now need to be deleted
            returnValue&=deleteOldStatusRouteNodes();

            // Determine if we are successful
            if (returnValue==true){
                // get the routing elements this user has
                initialStatusesContainer = document.getElementById('initialStatusRouting');

                // Now get an array of the available statuses
                initialStatuses = initialStatusesContainer.getElementsByClassName('ViableStatus');

                // Loop through the elements
                for(var executionOrder=0; executionOrder < initialStatuses.length; executionOrder++){
                    // Try to modify the element and then see if successful
                    if (modifyStatusInfoRoute(inUpdateTaskNumber, initialStatuses[executionOrder], (executionOrder+1))===true){
                        // AND this with the current return value to see what the update result is
                        returnValue&=true; 
                    }
                    else {
                        // Set a return value of false for the entire method
                        returnValue=false; 
                    }
                }
                
                // Determine if they are on the template radio 
                if (document.getElementById('isRoutingTemplate').checked){
                    // Update the template as one to have the template applied to the task if necessary
                    updateRoutingTemplate(true);
                }      
            }
        }
            
        function updateCurrentRoutingElements(inUpdateTaskNumber){
            var returnValue = true;
            
            // init variables used throughout
            var currentStatusesContainer = null;
            var currentStatuses = null;
            var currentBranchedStatusesContainer = null;
            var currentBranchedStatuses = null;

            // get the routing elements this user has
            currentStatusesContainer = document.getElementById('currentStatusRouting');

            // Now get an array of the available statuses
            currentStatuses = currentStatusesContainer.getElementsByClassName('ViableStatus');

            // Loop through the trunk elements
            for(var executionOrder=0; executionOrder < currentStatuses.length; executionOrder++){
                // Try to modify the element and then see if successful
                if (modifyStatusInfoRoute(inUpdateTaskNumber, currentStatuses[executionOrder], null, 0, null, true)===true){
                    // AND this with the current return value to see what the update result is
                    returnValue&=true; 
                }
                else {
                    // Set a return value of false for the entire method
                    returnValue=false; 
                }
            }
            
            // Determine if we were successful updating the trunk
            if (returnValue){
                // get the routing branching elements this user has
                currentBranchedStatusesContainer = document.getElementById('routingNodeBranches');

                // Now get an array of the available statuses
                currentBranchedStatuses = currentBranchedStatusesContainer.getElementsByClassName('ViableStatus');
                
                // Loop through the branch elements
                for(var executionOrder=0; executionOrder < currentBranchedStatuses.length; executionOrder++){
                    // Try to modify the element and then see if successful
                    if (modifyStatusInfoRoute(inUpdateTaskNumber, currentBranchedStatuses[executionOrder], null, 0, null, true)===true){
                        // AND this with the current return value to see what the update result is
                        returnValue&=true; 
                    }
                    else {
                        // Set a return value of false for the entire method
                        returnValue=false; 
                    }
                }
            }
        }
        
        function replaceCurrentWithInitial(inUpdateTaskNumber){
            // set the return variable 
            var returnValue = false;
            
            // Setup the parameters to pass to PHP
            var params = {
                "sessionID"   : sessionID, 
                "copyTaskID"  : inUpdateTaskNumber
            };

            // Create the string containing the PHP file to use
            var url = "php_only_scripts/jquery_only/copy_initial_to_current_routing.php";

            // Setup AJAX for communication
            $.ajax({
                context : this,
                type    : "GET", 
                url     : url, 
                data    : params, 
                dataType: "text", 
                encode  : true,
                async   : false, 
                cache   : false
            })
            .done(function(data){
                // Split the string on the double colon
                var errorStrings=data.trim().split("::");

                if (data.includes("ABORT COPY INITIAL TO CURRENT ROUTING")){
                    // Give an alert popup of the problem
                    alert(errorStrings[2]);

                    // Log any errors to the console
                    console.log(data.trim());

                    // Return a failed result
                    returnValue = false;
                }
                else if (data.includes("COPY INITIAL TO CURRENT ROUTING INFO")){
                    // Give an alert popup of the information to convey
                    alert(errorStrings[2]);

                    // Log any info to the console
                    console.log(data.trim());

                    // Return a failed result
                    returnValue = true;
                }
                else {
                    // If there is no error text, then we must have modified the node
                    returnValue = true;
                }
                
                // Determine if the error status is not negative one
                if (Number(errorStrings[0])!==-1){
                    // Change to the new status before forcing an update on the task
                    $("#status").val(errorStrings[0]);
                }
            })
            .fail(function(data){   
                // Log any errors to the console
                console.log(data);

                // Return a failed result
                returnValue = false;
            });
            
            // return what we got
            return returnValue;
        }
        
        function replaceInitialWithCurrent(inUpdateTaskNumber){
            // set the return variable 
            var returnValue = false;
            
            // Setup the parameters to pass to PHP
            var params = {
                "sessionID"   : sessionID, 
                "copyTaskID"  : inUpdateTaskNumber
            };

            // Create the string containing the PHP file to use
            var url = "php_only_scripts/jquery_only/copy_current_to_initial_routing.php";

            // Setup AJAX for communication
            $.ajax({
                context : this,
                type    : "GET", 
                url     : url, 
                data    : params, 
                dataType: "text", 
                encode  : true,
                async   : false, 
                cache   : false
            })
            .done(function(data){
                if (data.includes("ABORT COPY CURRENT TO INITIAL ROUTING")){
                    // Split the string on the double colon
                    var errorStrings=data.trim().split("::");

                    // Give an alert popup of the problem
                    alert(errorStrings[1]);

                    // Log any errors to the console
                    console.log(data.trim());

                    // Return a failed result
                    returnValue = false;
                }
                else {
                    // Refresh the page
                    location.reload();

                    // If there is no error text, then we must have modified the node
                    returnValue = true;
                }
            })
            .fail(function(data){   
                // Log any errors to the console
                console.log(data);

                // Return a failed result
                returnValue = false;
            });
            
            // return what we got
            return returnValue;
        }
