Index: lib/style/common/templates/entryForm.js
===================================================================
--- lib/style/common/templates/entryForm.js	(nonexistent)
+++ lib/style/common/templates/entryForm.js	(revision 3473)
@@ -0,0 +1,1129 @@
+function addParagraph() {
+    var newParaWidget = document.createElement("textarea");
+    newParaWidget.setAttribute("rows", "6");
+    newParaWidget.className="longwidth";
+    newParaWidget.setAttribute("name", "methodPara");
+
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+    var TD = createTD("5","left");
+    var emptyTD = createTD("","right");
+    TD.appendChild(newParaWidget);
+    TR.appendChild(emptyTD);
+    TR.appendChild(TD);
+    var addParaButton = document.getElementById("addparabutton1");
+    var parent = addParaButton.parentNode;
+    parent.insertBefore(TR, addParaButton);
+}
+
+function addMethod() {
+    var index = incrementCount('methodCount');
+    var methodButton = document.getElementById("addmethodbutton");
+    var parent = methodButton.parentNode;
+    
+    parent.insertBefore(createHRRow(), methodButton);
+    parent.insertBefore(addMethodTitle(), methodButton);
+    parent.insertBefore(addMethodDescription(index), methodButton);
+    parent.insertBefore(addMethodButton(index), methodButton);
+}
+
+function  addMethodButton(index) {
+    var TR = document.createElement("tr");
+    var buttonId = 'addparabutton' + index;
+    TR.className='sectbody';
+    TR.setAttribute("id", buttonId);
+    var labelTD = createTD("","right");
+    var TD = createTD("5","left");
+    var button = document.createElement("input");
+    button.setAttribute("type", "button"); 
+    button.setAttribute("value", "Add Paragraph to Method Description"); 
+    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+        button.attachEvent("onclick", new Function("addParagraph("+ index + ", '" + buttonId + "')"));
+    } else {
+        button.setAttribute("onclick", "addParagraph("+ index +", '" + buttonId + "')"); 
+    }
+    TD.appendChild(button);
+    TR.appendChild(labelTD);
+    TR.appendChild(TD);
+    return TR;
+}
+
+function  addMethodTitle() {
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+    var labelTD = createTD("","right");
+    labelTD.appendChild(document.createTextNode("Method Title"));
+    var TD = createTD("5","left");
+    var textField = document.createElement("input");
+    textField.setAttribute("type", "text"); 
+    textField.setAttribute("name", "methodTitle"); 
+    textField.className="longwidth";
+    TD.appendChild(textField);
+    TR.appendChild(labelTD);
+    TR.appendChild(TD);
+    return TR;
+}
+
+function  addMethodDescription(index) {
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+    var labelTD = createTD("","right");
+    labelTD.setAttribute("vAlign","top");
+    labelTD.appendChild(document.createTextNode("Method Description"));
+    var TD = createTD("5","left");
+    var textArea = document.createElement("textarea");
+    textArea.setAttribute("name", "methodPara"+index);
+    textArea.setAttribute("rows", 6); 
+    textArea.className="longwidth";
+    TD.appendChild(textArea);
+    TR.appendChild(labelTD);
+    TR.appendChild(TD);
+    return TR;
+}
+
+function createTextField(name, size, value) {
+    var newField = document.createElement("input");
+    newField.setAttribute("type", "text"); 
+    newField.setAttribute("name", name); 
+    newField.setAttribute("size", size); 
+    newField.value = value; 
+    return newField;
+}
+
+function createTextRow(count, varName, labelText, value) {
+    var textField = createTextField(varName + count, "30", value);
+    var row = createRow(count, textField, labelText);
+    return row;
+}
+
+function createRow(count, elem, labelText) {
+    var textTD = createTD("5");
+    textTD.appendChild(elem);
+
+    var labelTD = createTD("","right");
+
+    var labelSpan = document.createElement("span");
+    labelSpan.className = 'label';
+
+    var label = document.createTextNode(labelText);
+    labelSpan.appendChild(label);
+    labelTD.appendChild(labelSpan);
+
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+    TR.appendChild(labelTD);
+    TR.appendChild(textTD);
+
+    return TR;
+}
+
+function createHRRow() {
+    var hrCell = createTD("6");
+    var hr = document.createElement("hr");
+    hr.setAttribute("width", "85%");
+    hrCell.appendChild(hr);
+
+    var hrTR = document.createElement("tr");
+    hrTR.className = 'sectbody';
+    hrTR.appendChild(hrCell);
+
+    return hrTR;
+}
+
+function createHiddenInput(name, value) {
+    var elem = document.createElement("input");
+    elem.setAttribute("type", "hidden");
+    elem.setAttribute("name", name);
+    elem.setAttribute("value", value);
+    return elem
+}
+
+function sortInputTags() {
+    sortTagWithAttributeName("aoFirstName", "addAssociatedParty");
+    sortTagWithAttributeName("aoLastName", "addAssociatedParty");
+    sortTagWithAttributeName("aoRole", "addAssociatedParty", "select");
+    
+    sortTagWithAttributeName("taxonName", "addTaxon");
+    sortTagWithAttributeName("taxonRank", "addTaxon");
+    
+    sortTagWithAttributeName("keyword", "addKeyword");
+    sortTagWithAttributeName("keywordType", "addKeyword");
+    sortTagWithAttributeName("keywordTh", "addKeyword");
+}
+
+
+function sortTagWithAttributeName(tag, afterTag, parentTag) {
+    var elem = document.getElementById(afterTag);
+   
+    elem = elem.nextSibling.nextSibling;
+    while (elem.nodeName == "TR") {
+    var nodes = elem.getElementsByTagName("input");
+        for(var i = 0; i < nodes.length; i++) {
+            var node = nodes.item(i); 
+            if (node.getAttribute("name")==tag) {
+                    var parent = node.parentNode;
+                    var clone = node.cloneNode(true);
+                    parent.removeChild(node);
+                    parent.appendChild(clone);
+            }
+        }
+        if (parentTag != null) {
+            var nodes = elem.getElementsByTagName(parentTag);
+            for(var i = 0; i < nodes.length; i++) {
+                var node = nodes.item(i); 
+                if (node.getAttribute("name")==tag) {
+                        var parent = node.parentNode;
+                        var clone = node.cloneNode(true);
+                        clone.value = node.value;
+                        parent.removeChild(node);
+                        parent.appendChild(clone);
+                }
+            }
+        }
+        elem = elem.nextSibling;
+    }
+}
+
+function incrementCount(_count) {
+    var countField = document.getElementById(_count);
+    var count = countField.getAttribute("value");
+    count++;
+    countField.setAttribute("value", count);
+    return count;
+}
+
+function decrementCount(_count) {
+    var countField = document.getElementById(_count);
+    var count = countField.getAttribute("value");
+    count--;
+    countField.setAttribute("value", count);
+    return count;
+}
+
+function createImageLink(imgSrc, imgAlt, imgOnClick, cursor) {
+    var link = document.createElement("a");
+    var img = document.createElement("img");
+    img.setAttribute("src", imgSrc);
+    img.setAttribute("alt", imgAlt);
+    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+        link.style.setAttribute("cursor", cursor);
+        img.attachEvent("onclick", new Function(imgOnClick));
+    } else {
+        link.setAttribute("style", "cursor:"+cursor);
+        img.setAttribute("onClick", imgOnClick);
+    }
+    img.setAttribute("border", "0");
+    link.appendChild(img);        
+    return link;
+}
+
+
+function createTD(colSpan, align, cursor) {
+    var td = document.createElement("td");
+    if (colSpan != "")
+        td.setAttribute("colSpan", colSpan);
+    td.setAttribute("align", align);
+    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+        td.style.setAttribute("cursor", cursor);
+    } else {
+        td.setAttribute("style", "cursor:"+cursor);
+    }
+    return td;
+}
+
+
+function cleanTextNodes(startTagId, endTagId) {
+    var startTag = document.getElementById(startTagId);
+
+    var bro = startTag.nextSibling;       
+
+    while(bro) {
+        if (bro.nodeName == "#text") {
+            var temp = bro.nextSibling;
+            bro.parentNode.removeChild(bro);
+            bro = temp;
+        } else {
+            var id = bro.getAttribute("id");
+            if (id == endTagId) {
+              return;
+            }
+            bro = bro.nextSibling;
+        }
+    }
+
+}
+
+function delRow(evt) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        if (elem) {
+            try {
+                var table = elem.parentNode.parentNode.parentNode.parentNode;
+                var row = elem.parentNode.parentNode.parentNode;
+
+                table.removeChild(row);
+            }
+            catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}
+
+function moveUpRow(evt) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        if (elem) {
+            try {
+                var table = elem.parentNode.parentNode.parentNode.parentNode;
+                var row = elem.parentNode.parentNode.parentNode;
+                
+                var bro = row.previousSibling;
+                if (bro != null && bro.previousSibling.nodeName =="TR") {
+                    clone = row.cloneNode(true);
+                    table.insertBefore(clone, bro);
+                    table.removeChild(row);
+                }
+            }
+            catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}
+
+function moveDownRow(evt, lastTR) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        if (elem) {
+            try {
+                var table = elem.parentNode.parentNode.parentNode.parentNode;
+                var row = elem.parentNode.parentNode.parentNode;
+                
+                var _test = row.nextSibling;
+                if (_test.getAttribute("id") == lastTR) {
+                    return;
+                }
+                var bro = row.nextSibling.nextSibling;
+                if (bro != null && bro.nodeName =="TR") {
+                    clone = row.cloneNode(true);
+                    table.insertBefore(clone, bro);
+                    table.removeChild(row);
+                }
+            }
+            catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}
+
+function addAssociatedParty() {
+    var AOLN   = document.getElementById("AONameLast");
+    var AOFN   = document.getElementById("AONameFirst");
+    var AORole = document.getElementById("AORole");
+
+    if (AOLN.value != "") {
+        var aoCount = incrementCount("aoCount");
+        
+        try {
+            var aoRow = createAORow(aoCount, AOLN.value, AOFN.value, AORole.options[AORole.selectedIndex].text);
+        } catch(e) {
+            var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+            alert("Error:\n" + msg);
+            return;
+        }
+
+        var aoRowMarker = document.getElementById("addaorow");
+        var parent = aoRowMarker.parentNode;
+        
+        var aoHR = document.getElementById("aoHRRow");
+        if (aoHR == null) {
+            var aoHRRow = createHRRow();
+            aoHRRow.setAttribute("id", "aoHRRow");
+            parent.insertBefore(aoHRRow, aoRowMarker);
+        }
+        
+        parent.insertBefore(aoRow, aoRowMarker);
+    
+        AOFN.value = "";
+        AOLN.value = "";
+        AORole.selectedIndex = 0;
+    } else {
+        alert("Enter the last name of the associated party");
+    }
+}
+
+function createAORow(aoCount, AOLN, AOFN, AORole){    
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+    var labelTD = createTD("5","left", "pointer");
+    
+    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+        labelTD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN  + "\",\""
+                         + AOLN  + "\",\"" + AORole + "\")"));
+    } else {
+        labelTD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN  + "\",\""
+                         + AOLN  + "\",\"" + AORole + "\")");
+    }
+
+    var text   = AOFN + " " + AOLN + " (Role: " + AORole + ")";
+    var label = document.createTextNode(text);
+
+    labelTD.appendChild(label);
+    labelTD.appendChild(createHiddenInput("aoFirstName", AOFN));
+    labelTD.appendChild(createHiddenInput("aoLastName", AOLN));
+    labelTD.appendChild(createHiddenInput("aoRole", AORole));
+    
+    var imgTD = createTD("","right");
+    
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/previous.gif",
+                                      "Move Up","moveUpRow(event)","pointer"));
+    imgTD.appendChild(document.createTextNode(" "));
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/next.gif",
+                                      "Move Down", "moveDownRow(event, \"addaorow\")",
+                                      "pointer"));
+    imgTD.appendChild(document.createTextNode(" "));
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/delete.gif",
+                                      "Delete", "delRow(event)",
+                                      "pointer"));
+
+    TR.appendChild(imgTD);
+    TR.appendChild(labelTD);
+    
+    return TR;
+}
+
+function aoEditRow(evt, num,  AOFN ,  AOLN ,  AORole) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        if (elem && elem.nodeName == "TD") {
+            try {
+                var table = elem.parentNode;
+                if (num == 0) {
+                    table.removeChild(elem);
+                    var TD = createTD("5","left", "pointer");
+                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+                        TD.attachEvent("onclick", new Function("aoEditRow(event, 1, \"" + AOFN  + "\",\""
+                                                    + AOLN  + "\",\"" + AORole + "\")"));
+                    } else {
+                        TD.setAttribute("onClick","aoEditRow(event, 1, \"" + AOFN  + "\",\""
+                                             + AOLN  + "\",\"" + AORole + "\")");
+                    }                   
+                    TD.appendChild(createTextField("aoFirstName", 15, AOFN));
+                    TD.appendChild(document.createTextNode(" "));
+                    TD.appendChild(createTextField("aoLastName", 15, AOLN));
+                    TD.appendChild(document.createTextNode(" Role: "));
+                    TD.appendChild(createAORoleTypeSelect("aoRole", AORole));
+                    table.appendChild(TD);
+                } else {
+                    var child = elem.childNodes;
+                    AOFN = child.item(0).value;
+                    AOLN = child.item(2).value;
+                    var _AORole = child.item(4);
+                    AORole = _AORole.options[_AORole.selectedIndex].text;
+                    table.removeChild(elem);
+
+                    var TD = createTD("5","left", "pointer");
+                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+                        TD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN  + "\",\""
+                                                    + AOLN  + "\",\"" + AORole + "\")"));
+                    } else {
+                        TD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN  + "\",\""
+                                             + AOLN  + "\",\"" + AORole + "\")");
+                    }
+                    var text   = AOFN + " " + AOLN + " (Role: " + AORole + ")";
+                    var label = document.createTextNode(text);
+                    TD.appendChild(label);
+                    TD.appendChild(createHiddenInput("aoFirstName", AOFN));
+                    TD.appendChild(createHiddenInput("aoLastName", AOLN));
+                    TD.appendChild(createHiddenInput("aoRole", AORole));
+                    table.appendChild(TD);
+                }
+            } catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}
+
+function createAORoleTypeSelect(name, value) {
+    var newField = document.createElement("select");
+    newField.setAttribute("name", name);
+    var option1 = document.createElement("option");
+    var text1 = document.createTextNode("Co-owner");
+    option1.appendChild(text1);
+    newField.appendChild(option1);
+    var option2 = document.createElement("option");
+    var text2 = document.createTextNode("Custodian/Steward");
+    option2.appendChild(text2);
+    newField.appendChild(option2);
+    var option3 = document.createElement("option");
+    var text3 = document.createTextNode("Metadata Provider");
+    option3.appendChild(text3);
+    newField.appendChild(option3)
+    var option4 = document.createElement("option");
+    var text4 = document.createTextNode("User");
+    option4.appendChild(text4);
+    newField.appendChild(option4);
+        
+    if (value == "Co-owner") {
+        newField.selectedIndex = 0;
+    } else if (value == "Custodian/Steward") {
+        newField.selectedIndex = 1;
+    } else if (value == "Metadata Provider") {
+        newField.selectedIndex = 2;
+    } else if (value == "User") {
+        newField.selectedIndex = 3;
+    }
+
+    return newField;
+}
+
+function addTaxon() {   
+    var taxonRank   = document.getElementById("taxonRank");
+    var taxonName   = document.getElementById("taxonName");
+
+    if (taxonRank.value !="" && taxonName.value != "") {
+        var taxonCount = incrementCount("taxaCount");
+        var row = createTaxonRow(taxonCount, taxonRank.value, taxonName.value);
+        var taxonRowMarker = document.getElementById("addtaxarow");
+        var parent = taxonRowMarker.parentNode;
+        
+        var taxonHR = document.getElementById("taxonHRRow");
+        if (taxonHR == null) {
+            var taxonHRRow = createHRRow();
+            taxonHRRow.setAttribute("id", "taxonHRRow");
+            parent.insertBefore(taxonHRRow, taxonRowMarker);
+        }
+        
+        parent.insertBefore(row, taxonRowMarker);
+
+        taxonRank.value = "";
+        taxonName.value = "";
+    } else {
+        alert("Enter complete taxonomic information");
+    }
+}
+
+function createTaxonRow(taxonCount, taxonRank, taxonName){    
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+
+    var labelTD = createTD("5","left", "pointer");
+    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+        labelTD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
+                         + "\",\"" + taxonRank  + "\")"));
+    } else {
+        labelTD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
+                         + "\",\"" + taxonRank  + "\")");
+    }
+
+    var text = "Rank: " + taxonRank + ", Name: " + taxonName;
+    var label = document.createTextNode(text);
+
+    labelTD.appendChild(label);
+    labelTD.appendChild(createHiddenInput("taxonName", taxonName));
+    labelTD.appendChild(createHiddenInput("taxonRank", taxonRank));
+    
+    var imgTD = createTD("","right");
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/previous.gif",
+                                      "Move Up", "moveUpRow(event)",
+                                      "pointer"));
+    imgTD.appendChild(document.createTextNode(" "));
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/next.gif",
+                                      "Move Down", "moveDownRow(event, 'addtaxarow')",
+                                      "pointer"));
+    imgTD.appendChild(document.createTextNode(" "));
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/delete.gif",
+                                      "Delete", "delRow(event)",
+                                      "pointer"));
+
+    TR.appendChild(imgTD);
+    TR.appendChild(labelTD);
+    
+    return TR;
+}
+
+function taxonEditRow(evt, num,  taxonName ,  taxonRank) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        if (elem && elem.nodeName == "TD") {
+            try {
+                var table = elem.parentNode;
+                if (num == 0) {
+                    table.removeChild(elem);
+                    var TD = createTD("5","left", "pointer");
+                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+                        TD.attachEvent("onclick",new Function("taxonEditRow(event, 1, \"" + taxonName
+                                       + "\",\"" + taxonRank  + "\")"));
+                    } else {
+                        TD.setAttribute("onClick","taxonEditRow(event, 1, \"" + taxonName
+                                        + "\",\"" + taxonRank  + "\")");
+                    }
+          
+                    TD.appendChild(document.createTextNode("Rank: "));
+                    TD.appendChild(createTextField("taxonName", 15, taxonName));
+                    TD.appendChild(document.createTextNode(" Name: "));
+                    TD.appendChild(createTextField("taxonRank", 15, taxonRank));
+                    table.appendChild(TD);
+                } else {
+                    var child = elem.childNodes;
+                    taxonName = child.item(1).value;
+                    taxonRank = child.item(3).value;
+                    table.removeChild(elem);
+
+                    var TD = createTD("5","left", "pointer");
+                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+                        TD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
+                                       + "\",\"" + taxonRank  + "\")"));
+                    } else {
+                        TD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
+                                        + "\",\"" + taxonRank  + "\")");
+                    }                        
+                    var text = "Rank: " + taxonName + ", Name: " + taxonRank;
+                    var label = document.createTextNode(text);
+                    TD.appendChild(label);
+                    TD.appendChild(createHiddenInput("taxonName", taxonName));
+                    TD.appendChild(createHiddenInput("taxonRank", taxonRank));
+                    table.appendChild(TD);
+                }
+            } catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}
+
+function addKeyword() {
+    var keyword   = document.getElementById("keyword");
+    var keywordType   = document.getElementById("keywordType");
+    var keywordTh = document.getElementById("keywordTh");
+
+    if (keyword.value !="") {
+        var keyCount = incrementCount("keyCount");
+        var keyRow = createKeywordRow(keyCount, keyword.value, 
+                                      keywordType.options[keywordType.selectedIndex].text, 
+                                      keywordTh.options[keywordTh.selectedIndex].text);
+        var keyRowMarker = document.getElementById("addkeyrow");
+        var parent = keyRowMarker.parentNode;
+        
+        var keyHR = document.getElementById("keywordHRRow");
+        if (keyHR == null) {
+            var keyHRRow = createHRRow();
+            keyHRRow.setAttribute("id", "keywordHRRow");
+            parent.insertBefore(keyHRRow, keyRowMarker);
+        }
+        
+        parent.insertBefore(keyRow, keyRowMarker);
+    
+        keyword.value = "";
+        keywordType.selectedIndex = 0;
+        keywordTh.selectedIndex = 0;
+    } else {
+        alert("Enter keyword");
+    }
+}
+
+function createKeywordRow(keyCount, keyword, keywordType, keywordTh){    
+    var TR = document.createElement("tr");
+    TR.className='sectbody';
+
+    var labelTD = createTD("5","left", "pointer");
+    
+    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+        labelTD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
+            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
+    } else {
+        labelTD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
+            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
+    }
+              
+    var text   = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
+    var label = document.createTextNode(text);
+
+    labelTD.appendChild(label);
+    labelTD.appendChild(createHiddenInput("keyword", keyword));
+    labelTD.appendChild(createHiddenInput("keywordType", keywordType));
+    labelTD.appendChild(createHiddenInput("keywordTh", keywordTh));
+    
+    var imgTD = createTD("","right");
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/previous.gif",
+                                      "Move Up", "moveUpRow(event)",
+                                      "pointer"));
+    imgTD.appendChild(document.createTextNode(" "));
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/next.gif",
+                                      "Move Down", "moveDownRow(event, 'addkeyrow')",
+                                      "pointer"));
+    imgTD.appendChild(document.createTextNode(" "));
+    imgTD.appendChild(createImageLink("http://ebm.nceas.ucsb.edu:80/knb/style/images/delete.gif",
+                                      "Delete", "delRow(event)",
+                                      "pointer"));
+
+    TR.appendChild(imgTD);
+    TR.appendChild(labelTD);
+    
+    return TR;
+}
+
+function keywordEditRow(evt, num,  keyword,  keywordType, keywordTh) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        if (elem && elem.nodeName == "TD") {
+            try {
+                var table = elem.parentNode;
+                if (num == 0) {
+                    table.removeChild(elem);
+                    var TD = createTD("5","left", "pointer");
+                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+                        TD.attachEvent("onclick", new Function("keywordEditRow(event, 1, \"" + keyword
+                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
+                    } else {
+                        TD.setAttribute("onClick","keywordEditRow(event, 1, \"" + keyword
+                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
+                    }
+                
+                    TD.appendChild(createTextField("keyword", 15, keyword));
+                    TD.appendChild(document.createTextNode(" Type: "));
+                    TD.appendChild(createKeyTypeSelect("keywordType", keywordType));
+                    TD.appendChild(document.createTextNode(" Thesaurus: "));
+                    TD.appendChild(createKeyThSelect("keywordTh", keywordTh));
+                    table.appendChild(TD);
+                } else {
+                    var child = elem.childNodes;
+                    keyword = child.item(0).value;
+                    var _keywordType = child.item(2);
+                    keywordType = _keywordType.options[_keywordType.selectedIndex].text;
+                    var _keywordTh = child.item(4);
+                    keywordTh = _keywordTh.options[_keywordTh.selectedIndex].text;
+                    table.removeChild(elem);
+
+                    var TD = createTD("5","left", "pointer");
+                    if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all) {
+                        TD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
+                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
+                    } else {
+                        TD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
+                        + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
+                    }
+                
+                    var text   = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
+                    var label = document.createTextNode(text);
+                    TD.appendChild(label);
+                    TD.appendChild(createHiddenInput("keyword", keyword));
+                    TD.appendChild(createHiddenInput("keywordType", keywordType));
+                    TD.appendChild(createHiddenInput("keywordTh", keywordTh));
+                    table.appendChild(TD);
+                }
+            } catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}
+
+function createKeywordThesaurusRow(name) {        
+    var keyRowTemplate = document.getElementById("keyThRow");
+    var newField =  keyRowTemplate.cloneNode(true);
+    var nodes = newField.getElementsByTagName("input");
+    nodes.item(0).setAttribute("name", name);
+    nodes.item(1).setAttribute("name", name);
+    return newField;
+}
+
+function createKeyThSelect(name, value) {
+    var newField = document.createElement("select");
+    newField.setAttribute("name", name);
+    var option1 = document.createElement("option");
+    var text1 = document.createTextNode("None");
+    option1.appendChild(text1);
+    newField.appendChild(option1);
+    var option2 = document.createElement("option");
+    var text2 = document.createTextNode("GCMD");
+    option2.appendChild(text2);
+    newField.appendChild(option2);
+
+    if (value == "None") {
+        newField.selectedIndex = 0;
+    } else if (value == "GCMD") {
+        newField.selectedIndex = 1;
+    }
+    return newField;
+}
+
+function createKeyTypeSelect(name, value) {
+    var newField = document.createElement("select");
+    newField.setAttribute("name", name);
+    var option1 = document.createElement("option");
+    var text1 = document.createTextNode("None");
+    option1.appendChild(text1);
+    newField.appendChild(option1);
+    var option2 = document.createElement("option");
+    var text2 = document.createTextNode("Theme");
+    option2.appendChild(text2);
+    newField.appendChild(option2);
+    var option3 = document.createElement("option");
+    var text3 = document.createTextNode("Place");
+    option3.appendChild(text3);
+    newField.appendChild(option3)
+    var option4 = document.createElement("option");
+    var text4 = document.createTextNode("Stratum");
+    option4.appendChild(text4);
+    newField.appendChild(option4);
+    var option5 = document.createElement("option");
+    var text5 = document.createTextNode("Temporal");
+    option5.appendChild(text5);
+    newField.appendChild(option5);
+    var option6 = document.createElement("option");
+    var text6 = document.createTextNode("Taxonomic");
+    option6.appendChild(text6);
+    newField.appendChild(option6);        
+    if (value == "None") {
+        newField.selectedIndex = 0;
+    } else if (value == "Theme") {
+        newField.selectedIndex = 1;
+    } else if (value == "Place") {
+        newField.selectedIndex = 2;
+    } else if (value == "Stratum") {
+        newField.selectedIndex = 3;
+    }else if (value == "Temporal") {
+        newField.selectedIndex = 4;
+    } else if (value == "Taxonomic") {
+        newField.selectedIndex = 5;
+    }
+    return newField;
+}
+
+var basicInfoBit = 1;
+var submitterBit = 1;
+var dsoBit = 1;
+var apBit = 1;
+var abstractBit = 1;
+var keywordBit = 1;
+var temporalBit = 1;
+var spatialBit = 1;
+var taxonomicBit = 1;
+var methodBit = 1;
+var dscBit = 1;
+var distBit = 1;
+var uploadBit = 1;
+
+function swap(evt, _node, nodeBit) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        
+        // hack so that this works on safari...
+        if (elem.nodeName != 'A') {
+            elem = elem.parentNode;
+        }
+        elem.removeChild(elem.firstChild);
+        var node = document.getElementById(_node);
+        if (nodeBit) {
+            elem.appendChild(document.createTextNode("Show"));
+            node.className="hide";
+            return 0;
+        } else {
+            elem.appendChild(document.createTextNode("Hide"));
+            node.className="tables";
+            return 1;
+        }
+    }        
+}
+
+function handleOther(enable, node) {
+    var textBox = document.getElementById(node);
+    if (enable) {
+        textBox.removeAttribute("disabled");   
+    } else {
+        textBox.value="";
+        textBox.disabled = "true";   
+    }
+}
+
+function copyContact() {
+    var checkBox = document.getElementById("copyCheckBox");
+    if (checkBox.checked == true)
+    {
+        var cnf = document.getElementById("contactNameFirst");
+        var onf = document.getElementById("origNameFirst");
+        cnf.value = onf.value;
+        cnf.disabled = "true";
+
+        var cnl = document.getElementById("contactNameLast");
+        var onl = document.getElementById("origNameLast");
+        cnl.value = onl.value;
+        cnl.disabled = "true";
+
+        var cno = document.getElementById("contactNameOrg");
+        var ono = document.getElementById("origNameOrg");
+        cno.value = ono.value;
+        cno.disabled = "true";
+
+        var ce = document.getElementById("contactEmail");
+        var oe = document.getElementById("origEmail");
+        ce.value = oe.value;
+        ce.disabled = "true";
+
+        var cp = document.getElementById("contactPhone");
+        var op = document.getElementById("origPhone");
+        cp.value = op.value;
+        cp.disabled = "true";
+
+        var cf = document.getElementById("contactFAX");
+        var of = document.getElementById("origFAX");
+        cf.value = of.value;
+        cf.disabled = "true";
+
+        var cd = document.getElementById("contactDelivery");
+        var od = document.getElementById("origDelivery");
+        cd.value = od.value;
+        cd.disabled = "true";
+
+        var cc = document.getElementById("contactCity");
+        var oc = document.getElementById("origCity");
+        cc.value = oc.value;
+        cc.disabled = "true";
+
+        var cs = document.getElementById("contactState");
+        var os = document.getElementById("origState");
+        cs.options[os.selectedIndex].selected = true;
+        cs.disabled = "true";           
+
+        var cso = document.getElementById("contactStateOther");
+        var oso = document.getElementById("origStateOther");
+        cso.value = oso.value;
+        cso.disabled = "true";
+
+        var cz = document.getElementById("contactZip");
+        var oz = document.getElementById("origZip");
+        cz.value = oz.value;
+        cz.disabled = "true";
+
+        var cC = document.getElementById("contactCountry");
+        var oC = document.getElementById("origCountry");
+        cC.value = oC.value;
+        cC.disabled = "true";
+    } else {
+        var cnf = document.getElementById("contactNameFirst");
+        cnf.value = "";
+        cnf.removeAttribute("disabled");
+
+        var cnl = document.getElementById("contactNameLast");
+        cnl.value = "";
+        cnl.removeAttribute("disabled");
+
+        var cno = document.getElementById("contactNameOrg");
+        cno.value = "";
+        cno.removeAttribute("disabled");
+
+        var ce = document.getElementById("contactEmail");
+        ce.value = "";
+        ce.removeAttribute("disabled");
+
+        var cp = document.getElementById("contactPhone");
+        cp.value = "";
+        cp.removeAttribute("disabled");
+
+        var cf = document.getElementById("contactFAX");
+        cf.value = "";
+        cf.removeAttribute("disabled");
+
+        var cd = document.getElementById("contactDelivery");
+        cd.value = "";
+        cd.removeAttribute("disabled");
+
+        var cc = document.getElementById("contactCity");
+        cc.value = "";
+        cc.removeAttribute("disabled");
+
+        var cs = document.getElementById("contactState");
+              cs.options[0].selected = true;
+        cs.removeAttribute("disabled");
+
+        var cso = document.getElementById("contactStateOther");
+        cso.value = "";
+        cso.removeAttribute("disabled");
+
+        var cz = document.getElementById("contactZip");
+        cz.value = "";
+        cz.removeAttribute("disabled");
+
+        var cC = document.getElementById("contactCountry");
+        cC.value = "";
+        cC.removeAttribute("disabled");
+    }
+}
+
+// include source for Multiple file uploader:
+// http://the-stickman.com/web-development/javascript/
+
+function MultiSelector(list_target, max) {
+
+    this.list_target = list_target;
+    this.count = 0;
+    this.id = 0;
+    var fcount =  document.getElementById("fileCount");
+    if (fcount.value > 0) {
+        this.id = fcount.value;
+    }
+
+    if (max) {
+        this.max = max;
+    } else {
+      this.max = -1;
+    };
+
+    /**
+     * Add a new file input element
+     */
+    this.addElement = function( element ) {
+
+        // Make sure it's a file input element
+        if (element.tagName == 'INPUT' && element.type == 'file' ) {
+            // Element name -- what number am I?
+            element.name = 'file_' + this.id++;
+
+            // Add reference to this object
+            element.multi_selector = this;
+
+            // What to do when a file is selected
+            element.onchange = function() {
+            // Increment file counter
+            var fileCount = incrementCount("fileCount");
+                // Clean up file text
+                var comment_element = document.getElementById( 'file_comment' );
+                if (comment_element) {
+                    comment_element.parentNode.removeChild(comment_element);
+                }
+
+                // New file input
+                var new_element = document.createElement( 'input' );
+                new_element.type = 'file';
+
+                // Add new element
+                this.parentNode.insertBefore( new_element, this );
+
+                // Apply 'update' to element
+                this.multi_selector.addElement( new_element );
+
+                // Update list
+                this.multi_selector.addListRow( this );
+
+                // Hide this: we can't use display:none because Safari doesn't like it
+                this.style.position = 'absolute';
+                this.style.left = '-1000px';
+            };
+
+            // If we've reached maximum number, disable input element
+            if (this.max != -1 && this.count >= this.max ) {
+                element.disabled = true;
+            };
+            
+            // File element counter
+            this.count++;
+
+            // Most recent element
+            this.current_element = element;
+
+        } else {
+            // This can only be applied to file input elements!
+            alert( 'Error: not a file input element' );
+        };
+    };
+
+    /**
+     * Add a new row to the list of files
+     */
+    this.addListRow = function( element ) {
+        // Row div
+        var new_row = document.createElement( 'div' );
+
+        // Delete button
+        var new_row_button = document.createElement( 'input' );
+        new_row_button.type = 'button';
+        new_row_button.value = 'Delete';
+
+        // References
+        new_row.element = element;
+
+        // Delete function
+        new_row_button.onclick= function() {
+            // Remove element from form
+            this.parentNode.element.parentNode.removeChild( this.parentNode.element );
+
+            // Remove this row from the list
+            this.parentNode.parentNode.removeChild( this.parentNode );
+            // Decrement counter
+            this.parentNode.element.multi_selector.count--;
+
+            // Re-enable input element (if it's disabled)
+            this.parentNode.element.multi_selector.current_element.disabled = false;
+
+            // Appease Safari
+            //    without it Safari wants to reload the browser window
+            //    which nixes your already queued uploads
+            return false;
+        };
+
+        // Set row value
+        new_row.innerHTML = element.value + " ";
+  
+        // Add button
+        new_row.appendChild( new_row_button );
+
+        // Add it to the list
+        this.list_target.appendChild( new_row );
+    };
+
+};
+
+function deleteFile(evt, file) {
+    evt = (evt) ? evt : ((window.event) ? window.event : null);
+    if (evt) {
+        // equalize W3C/IE models to get event target reference
+        var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
+        var element = document.getElementById("file_element");
+        if (elem) {
+            try {
+                // Add a new hidden form element to delete exisiting files
+                var delete_existing = document.createElement( 'input' );
+                delete_existing.type = "hidden";
+                delete_existing.name = "deletefile"; // HTML array
+                delete_existing.value = file.name;
+                element.parentNode.appendChild( delete_existing );
+
+                // Remove this row from the list
+                elem.parentNode.parentNode.removeChild( elem.parentNode );
+            } catch(e) {
+                var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
+                alert("Error:\n" + msg);
+                return;
+            }
+        }
+    }
+}

Property changes on: lib/style/common/templates/entryForm.js
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: lib/style/common/templates/entryForm.tmpl
===================================================================
--- lib/style/common/templates/entryForm.tmpl	(revision 3472)
+++ lib/style/common/templates/entryForm.tmpl	(revision 3473)
@@ -1,1165 +1,6 @@
 [% INCLUDE "genericHeader.tmpl" %]
 
-  <script language="JavaScript" type="text/javascript">
-
-    function addParagraph() {
-        var newParaWidget=document.createElement("textarea");
-        newParaWidget.setAttribute("rows", "6");
-        newParaWidget.className="longwidth";
-        newParaWidget.setAttribute("name", "methodPara");
-
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-        var TD = createTD("5","left");
-        var emptyTD = createTD("","right");
-        TD.appendChild(newParaWidget);
-        TR.appendChild(emptyTD);
-        TR.appendChild(TD);
-        var addParaButton = document.getElementById("addparabutton1");
-        var parent = addParaButton.parentNode;
-        parent.insertBefore(TR, addParaButton);
-    }
-
-    function addMethod(){
-        var index = incrementCount('methodCount');
-        var methodButton = document.getElementById("addmethodbutton");
-        var parent = methodButton.parentNode;
-        
-        parent.insertBefore(createHRRow(), methodButton);
-        parent.insertBefore(addMethodTitle(), methodButton);
-        parent.insertBefore(addMethodDescription(index), methodButton);
-        parent.insertBefore(addMethodButton(index), methodButton);
-    }
-
-    function  addMethodButton(index){
-        var TR = document.createElement("tr");
-        var buttonId = 'addparabutton' + index;
-        TR.className='sectbody';
-        TR.setAttribute("id", buttonId);
-        var labelTD = createTD("","right");
-        var TD = createTD("5","left");
-        var button=document.createElement("input");
-        button.setAttribute("type", "button"); 
-        button.setAttribute("value", "Add Paragraph to Method Description"); 
-        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-            button.attachEvent("onclick", new Function("addParagraph("+ index + ", '" + buttonId + "')"));
-        } else {
-            button.setAttribute("onclick", "addParagraph("+ index +", '" + buttonId + "')"); 
-        }
-        TD.appendChild(button);
-        TR.appendChild(labelTD);
-        TR.appendChild(TD);
-        return TR;
-    }
-    
-    function  addMethodTitle(){
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-        var labelTD = createTD("","right");
-        labelTD.appendChild(document.createTextNode("Method Title"));
-        var TD = createTD("5","left");
-        var textField=document.createElement("input");
-        textField.setAttribute("type", "text"); 
-        textField.setAttribute("name", "methodTitle"); 
-        textField.className="longwidth";
-        TD.appendChild(textField);
-        TR.appendChild(labelTD);
-        TR.appendChild(TD);
-        return TR;
-    }
-
-    function  addMethodDescription(index){
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-        var labelTD = createTD("","right");
-        labelTD.setAttribute("vAlign","top");
-        labelTD.appendChild(document.createTextNode("Method Description"));
-        var TD = createTD("5","left");
-        var textArea=document.createElement("textarea");
-        textArea.setAttribute("name", "methodPara"+index);
-        textArea.setAttribute("rows", 6); 
-        textArea.className="longwidth";
-        TD.appendChild(textArea);
-        TR.appendChild(labelTD);
-        TR.appendChild(TD);
-        return TR;
-    }
-    
-    function createTextField(name, size, value) {
-        var newField=document.createElement("input");
-        newField.setAttribute("type", "text"); 
-        newField.setAttribute("name", name); 
-        newField.setAttribute("size", size); 
-        newField.value = value; 
-        return newField;
-    }
-
-    function createTextRow(count, varName, labelText, value) {
-        var textField=createTextField(varName + count, "30", value);
-	var row = createRow(count, textField, labelText);
-	return row;
-    }
-
-    function createRow(count, elem, labelText){
-        var textTD = createTD("5");
-        textTD.appendChild(elem);
-
-        var labelTD = createTD("","right");
-
-        var labelSpan = document.createElement("span");
-        labelSpan.className = 'label';
-
-        var label = document.createTextNode(labelText);
-        labelSpan.appendChild(label);
-        labelTD.appendChild(labelSpan);
-
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-        TR.appendChild(labelTD);
-        TR.appendChild(textTD);
-
-       return TR;
-    }
-
-    function createHRRow() {
-        var hrCell = createTD("6");
-	var hr = document.createElement("hr");
-	hr.setAttribute("width", "85%");
-        hrCell.appendChild(hr);
-
-        var hrTR = document.createElement("tr");
-        hrTR.className = 'sectbody';
-        hrTR.appendChild(hrCell);
-
-        return hrTR;
-    }
-
-    function createHiddenInput(name, value){
-        var elem = document.createElement("input");
-        elem.setAttribute("type", "hidden");
-        elem.setAttribute("name", name);
-        elem.setAttribute("value", value);
-        return elem
-    }
-
-    function sortInputTags(){
-        sortTagWithAttributeName("aoFirstName", "addAssociatedParty");
-        sortTagWithAttributeName("aoLastName", "addAssociatedParty");
-        sortTagWithAttributeName("aoRole", "addAssociatedParty", "select");
-        
-        sortTagWithAttributeName("taxonName", "addTaxon");
-        sortTagWithAttributeName("taxonRank", "addTaxon");
-        
-        sortTagWithAttributeName("keyword", "addKeyword");
-        sortTagWithAttributeName("keywordType", "addKeyword");
-        sortTagWithAttributeName("keywordTh", "addKeyword");
-
-    }
-    
-
-    function sortTagWithAttributeName(tag, afterTag, parentTag){
-       var elem = document.getElementById(afterTag);
-       
-       elem=elem.nextSibling.nextSibling;
-        while(elem.nodeName == "TR"){
-            var nodes = elem.getElementsByTagName("input");
-            for(var i=0; i < nodes.length; i++){
-                var node = nodes.item(i); 
-                if(node.getAttribute("name")==tag){
-                        var parent = node.parentNode;
-                        var clone = node.cloneNode(true);
-                        parent.removeChild(node);
-                        parent.appendChild(clone);
-                }
-            }
-            if(parentTag != null){
-            var nodes = elem.getElementsByTagName(parentTag);
-            for(var i=0; i < nodes.length; i++){
-                var node = nodes.item(i); 
-                if(node.getAttribute("name")==tag){
-                        var parent = node.parentNode;
-                        var clone = node.cloneNode(true);
-                        clone.value = node.value;
-                        parent.removeChild(node);
-                        parent.appendChild(clone);
-                }
-            }
-            }
-            elem=elem.nextSibling;
-        }
-    }
-    
-    function incrementCount(_count){
-        var countField = document.getElementById(_count);
-        var count = countField.getAttribute("value");
-        count++;
-        countField.setAttribute("value", count);
-        return count;
-    }
-    
-    function decrementCount(_count){
-        var countField = document.getElementById(_count);
-        var count = countField.getAttribute("value");
-        count--;
-        countField.setAttribute("value", count);
-        return count;
-    }
-    
-    function createImageLink(imgSrc, imgAlt, imgOnClick, cursor){
-        var link = document.createElement("a");
-        var img = document.createElement("img");
-        img.setAttribute("src", imgSrc);
-        img.setAttribute("alt", imgAlt);
-        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-            link.style.setAttribute("cursor", cursor);
-            img.attachEvent("onclick", new Function(imgOnClick));
-        } else {
-            link.setAttribute("style", "cursor:"+cursor);
-            img.setAttribute("onClick", imgOnClick);
-        }
-        img.setAttribute("border", "0");
-        link.appendChild(img);        
-        return link;
-    }
-    
-    
-    function createTD(colSpan, align, cursor){
-        var td = document.createElement("td");
-        if(colSpan != "")
-            td.setAttribute("colSpan", colSpan);
-        td.setAttribute("align", align);
-        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-            td.style.setAttribute("cursor", cursor);
-        } else {
-            td.setAttribute("style", "cursor:"+cursor);
-        }
-        return td;
-    }
-  
-  
-    function cleanTextNodes(startTagId, endTagId){
-        var startTag = document.getElementById(startTagId);
-
-        var bro = startTag.nextSibling;       
-
-        while(bro){
-            if(bro.nodeName == "#text"){
-                var temp = bro.nextSibling;
-                bro.parentNode.removeChild(bro);
-                bro = temp;
-            } else {
-                var id = bro.getAttribute("id");
-                if(id == endTagId){
-                  return;
-                }
-                bro = bro.nextSibling;
-            }
-        }
-
-    }
-  
-    function delRow(evt){
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           if (elem) {
-               try {
-                    var table = elem.parentNode.parentNode.parentNode.parentNode;
-                    var row = elem.parentNode.parentNode.parentNode;
-
-                    table.removeChild(row);
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-
-    function moveUpRow(evt){
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           if (elem) {
-               try {
-                    var table = elem.parentNode.parentNode.parentNode.parentNode;
-                    var row = elem.parentNode.parentNode.parentNode;
-                    
-                    var bro = row.previousSibling;
-                    if(bro != null && bro.previousSibling.nodeName =="TR"){
-                        clone = row.cloneNode(true);
-                        table.insertBefore(clone, bro);
-                        table.removeChild(row);
-                    }
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-
-    function moveDownRow(evt, lastTR){
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           if (elem) {
-               try {
-                    var table = elem.parentNode.parentNode.parentNode.parentNode;
-                    var row = elem.parentNode.parentNode.parentNode;
-                    
-                    var _test = row.nextSibling;
-                    if(_test.getAttribute("id") == lastTR){
-                            return;
-                    }
-                    var bro = row.nextSibling.nextSibling;
-                    if(bro != null && bro.nodeName =="TR"){
-                        clone = row.cloneNode(true);
-                        table.insertBefore(clone, bro);
-                        table.removeChild(row);
-                    }
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-  
-    function addAssociatedParty() {
-    	var AOLN   = document.getElementById("AONameLast");
-	var AOFN   = document.getElementById("AONameFirst");
-	var AORole = document.getElementById("AORole");
-
-        if(AOLN.value != ""){
-            
-            var aoCount = incrementCount("aoCount");
-            
-        try{
-            var aoRow = createAORow(aoCount, AOLN.value, AOFN.value, AORole.options[AORole.selectedIndex].text);
-        }    catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-
-             var aoRowMarker = document.getElementById("addaorow");
-            var parent = aoRowMarker.parentNode;
-            
-            var aoHR = document.getElementById("aoHRRow");
-            if(aoHR == null) {
-              var aoHRRow = createHRRow();
-              aoHRRow.setAttribute("id", "aoHRRow");
-              parent.insertBefore(aoHRRow, aoRowMarker);
-            }
-            
-            parent.insertBefore(aoRow, aoRowMarker);
-        
-            AOFN.value = "";
-            AOLN.value = "";
-            AORole.selectedIndex = 0;
-        } else {
-            alert("Enter the last name of the associated party");
-        }
-    }
-    
-    function createAORow(aoCount, AOLN, AOFN, AORole){    
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-        var labelTD = createTD("5","left", "pointer");
-        
-        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-            labelTD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN  + "\",\""
-                             + AOLN  + "\",\"" + AORole + "\")"));
-        } else {
-            labelTD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN  + "\",\""
-                             + AOLN  + "\",\"" + AORole + "\")");
-        }
-
-        
-        var text   = AOFN + " " + AOLN + " (Role: " + AORole + ")";
-        var label = document.createTextNode(text);
-
-        labelTD.appendChild(label);
-        labelTD.appendChild(createHiddenInput("aoFirstName", AOFN));
-        labelTD.appendChild(createHiddenInput("aoLastName", AOLN));
-        labelTD.appendChild(createHiddenInput("aoRole", AORole));
-        
-        var imgTD = createTD("","right");
-        
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/previous.gif",
-                                          "Move Up","moveUpRow(event)","pointer"));
-      	imgTD.appendChild(document.createTextNode(" "));
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/next.gif",
-                                          "Move Down", "moveDownRow(event, \"addaorow\")",
-                                          "pointer"));
-      	imgTD.appendChild(document.createTextNode(" "));
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/delete.gif",
-                                          "Delete", "delRow(event)",
-                                          "pointer"));
-    
-        TR.appendChild(imgTD);
-        TR.appendChild(labelTD);
-        
-        return TR;
-    }
-
-    function aoEditRow(evt, num,  AOFN ,  AOLN ,  AORole){
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           if (elem && elem.nodeName == "TD") {
-               try {
-                    var table = elem.parentNode;
-                    if(num == 0){
-                        table.removeChild(elem);
-                        var TD = createTD("5","left", "pointer");
-                        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-                            TD.attachEvent("onclick", new Function("aoEditRow(event, 1, \"" + AOFN  + "\",\""
-                                                        + AOLN  + "\",\"" + AORole + "\")"));
-                        } else {
-                            TD.setAttribute("onClick","aoEditRow(event, 1, \"" + AOFN  + "\",\""
-                                                 + AOLN  + "\",\"" + AORole + "\")");
-                        }                   
-                        TD.appendChild(createTextField("aoFirstName", 15, AOFN));
-                        TD.appendChild(document.createTextNode(" "));
-                        TD.appendChild(createTextField("aoLastName", 15, AOLN));
-                        TD.appendChild(document.createTextNode(" Role: "));
-                        TD.appendChild(createAORoleTypeSelect("aoRole", AORole));
-                        table.appendChild(TD);
-                    } else {
-                        var child = elem.childNodes;
-                        AOFN = child.item(0).value;
-                        AOLN = child.item(2).value;
-                        var _AORole = child.item(4);
-                        AORole = _AORole.options[_AORole.selectedIndex].text;
-                        table.removeChild(elem);
-    
-                        var TD = createTD("5","left", "pointer");
-                        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-                            TD.attachEvent("onclick", new Function("aoEditRow(event, 0, \"" + AOFN  + "\",\""
-                                                        + AOLN  + "\",\"" + AORole + "\")"));
-                        } else {
-                            TD.setAttribute("onClick","aoEditRow(event, 0, \"" + AOFN  + "\",\""
-                                                 + AOLN  + "\",\"" + AORole + "\")");
-                        }
-                        var text   = AOFN + " " + AOLN + " (Role: " + AORole + ")";
-                        var label = document.createTextNode(text);
-                        TD.appendChild(label);
-                        TD.appendChild(createHiddenInput("aoFirstName", AOFN));
-                        TD.appendChild(createHiddenInput("aoLastName", AOLN));
-                        TD.appendChild(createHiddenInput("aoRole", AORole));
-                        table.appendChild(TD);
-                    }
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-
-    function createAORoleTypeSelect(name, value) {
-        var newField=document.createElement("select");
-        newField.setAttribute("name", name);
-	var option1=document.createElement("option");
-	var text1=document.createTextNode("Co-owner");
-	//var text1=document.createTextNode("Principal Investigator");
-	option1.appendChild(text1);
-	newField.appendChild(option1);
-	var option2=document.createElement("option");
-	var text2=document.createTextNode("Custodian/Steward");
-	option2.appendChild(text2);
-	newField.appendChild(option2);
-	var option3=document.createElement("option");
-	var text3=document.createTextNode("Metadata Provider");
-	option3.appendChild(text3);
-	newField.appendChild(option3)
-	var option4=document.createElement("option");
-	var text4=document.createTextNode("User");
-	option4.appendChild(text4);
-	newField.appendChild(option4);
-        
-        if(value == "Co-owner"){
-            newField.selectedIndex=0;
-        } else if(value == "Custodian/Steward"){
-            newField.selectedIndex=1;
-        } else if(value == "Metadata Provider"){
-            newField.selectedIndex=2;
-        } else if(value == "User"){
-            newField.selectedIndex=3;
-        }
-
-	return newField;
-    }
-
-
-
-   function addTaxon() {   
-      	var taxonRank   = document.getElementById("taxonRank");
-	var taxonName   = document.getElementById("taxonName");
-
-        if(taxonRank.value !="" && taxonName.value != ""){
-            
-            var taxonCount = incrementCount("taxaCount");
-
-            var row = createTaxonRow(taxonCount, taxonRank.value, taxonName.value);
-            var taxonRowMarker = document.getElementById("addtaxarow");
-            var parent = taxonRowMarker.parentNode;
-            
-            var taxonHR = document.getElementById("taxonHRRow");
-            if(taxonHR == null) {
-              var taxonHRRow = createHRRow();
-              taxonHRRow.setAttribute("id", "taxonHRRow");
-              parent.insertBefore(taxonHRRow, taxonRowMarker);
-            }
-            
-            parent.insertBefore(row, taxonRowMarker);
-        
-            taxonRank.value = "";
-            taxonName.value = "";
-        } else {
-            alert("Enter complete taxonomic information");
-        }
-    }
-
-    function createTaxonRow(taxonCount, taxonRank, taxonName){    
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-
-        var labelTD = createTD("5","left", "pointer");
-        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-            labelTD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
-                             + "\",\"" + taxonRank  + "\")"));
-        } else {
-            labelTD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
-                             + "\",\"" + taxonRank  + "\")");
-        }
-
-        
-        var text = "Rank: " + taxonRank + ", Name: " + taxonName;
-        var label = document.createTextNode(text);
-
-        labelTD.appendChild(label);
-        labelTD.appendChild(createHiddenInput("taxonName", taxonName));
-        labelTD.appendChild(createHiddenInput("taxonRank", taxonRank));
-        
-        var imgTD = createTD("","right");
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/previous.gif",
-                                          "Move Up", "moveUpRow(event)",
-                                          "pointer"));
-      	imgTD.appendChild(document.createTextNode(" "));
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/next.gif",
-                                          "Move Down", "moveDownRow(event, 'addtaxarow')",
-                                          "pointer"));
-      	imgTD.appendChild(document.createTextNode(" "));
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/delete.gif",
-                                          "Delete", "delRow(event)",
-                                          "pointer"));
-    
-        TR.appendChild(imgTD);
-        TR.appendChild(labelTD);
-        
-        return TR;
-    }
-
-
-    function taxonEditRow(evt, num,  taxonName ,  taxonRank){
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           if (elem && elem.nodeName == "TD") {
-               try {
-                    var table = elem.parentNode;
-                    if(num == 0){
-                        table.removeChild(elem);
-                        var TD = createTD("5","left", "pointer");
-                        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-                            TD.attachEvent("onclick",new Function("taxonEditRow(event, 1, \"" + taxonName
-                                 + "\",\"" + taxonRank  + "\")"));
-                        } else {
-                            TD.setAttribute("onClick","taxonEditRow(event, 1, \"" + taxonName
-                                 + "\",\"" + taxonRank  + "\")");
-                        }
-                  
-                        TD.appendChild(document.createTextNode("Rank: "));
-                        TD.appendChild(createTextField("taxonName", 15, taxonName));
-                        TD.appendChild(document.createTextNode(" Name: "));
-                        TD.appendChild(createTextField("taxonRank", 15, taxonRank));
-                        table.appendChild(TD);
-                    } else {
-                        var child = elem.childNodes;
-                        taxonName = child.item(1).value;
-                        taxonRank = child.item(3).value;
-                        table.removeChild(elem);
-    
-                        var TD = createTD("5","left", "pointer");
-                        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-                            TD.attachEvent("onclick",new Function("taxonEditRow(event, 0, \"" + taxonName
-                                 + "\",\"" + taxonRank  + "\")"));
-                        } else {
-                            TD.setAttribute("onClick","taxonEditRow(event, 0, \"" + taxonName
-                                 + "\",\"" + taxonRank  + "\")");
-                        }                        
-                        var text = "Rank: " + taxonName + ", Name: " + taxonRank;
-                        var label = document.createTextNode(text);
-                        TD.appendChild(label);
-                        TD.appendChild(createHiddenInput("taxonName", taxonName));
-                        TD.appendChild(createHiddenInput("taxonRank", taxonRank));
-                        table.appendChild(TD);
-                    }
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-    
-    function addKeyword() {
-    	var keyword   = document.getElementById("keyword");
-	var keywordType   = document.getElementById("keywordType");
-	var keywordTh = document.getElementById("keywordTh");
-
-        if(keyword.value !=""){
-            var keyCount = incrementCount("keyCount");
-
-            var keyRow = createKeywordRow(keyCount, keyword.value, keywordType.options[keywordType.selectedIndex].text, keywordTh.options[keywordTh.selectedIndex].text);
-            var keyRowMarker = document.getElementById("addkeyrow");
-            var parent = keyRowMarker.parentNode;
-            
-            var keyHR = document.getElementById("keywordHRRow");
-            if(keyHR == null) {
-              var keyHRRow = createHRRow();
-              keyHRRow.setAttribute("id", "keywordHRRow");
-              parent.insertBefore(keyHRRow, keyRowMarker);
-            }
-            
-            parent.insertBefore(keyRow, keyRowMarker);
-        
-            keyword.value = "";
-            keywordType.selectedIndex = 0;
-            keywordTh.selectedIndex = 0;
-        } else {
-            alert("Enter keyword");
-        }
-    }
-
-
-    function createKeywordRow(keyCount, keyword, keywordType, keywordTh){    
-        var TR = document.createElement("tr");
-        TR.className='sectbody';
-
-        var labelTD = createTD("5","left", "pointer");
-        
-        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-            labelTD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
-                + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
-        } else {
-            labelTD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
-                + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
-        }
-                  
-        var text   = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
-        var label = document.createTextNode(text);
-
-        labelTD.appendChild(label);
-        labelTD.appendChild(createHiddenInput("keyword", keyword));
-        labelTD.appendChild(createHiddenInput("keywordType", keywordType));
-        labelTD.appendChild(createHiddenInput("keywordTh", keywordTh));
-        
-        var imgTD = createTD("","right");
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/previous.gif",
-                                          "Move Up", "moveUpRow(event)",
-                                          "pointer"));
-      	imgTD.appendChild(document.createTextNode(" "));
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/next.gif",
-                                          "Move Down", "moveDownRow(event, 'addkeyrow')",
-                                          "pointer"));
-      	imgTD.appendChild(document.createTextNode(" "));
-        imgTD.appendChild(createImageLink("@systemidserver@@html-path@/style/images/delete.gif",
-                                          "Delete", "delRow(event)",
-                                          "pointer"));
-    
-        TR.appendChild(imgTD);
-        TR.appendChild(labelTD);
-        
-        return TR;
-    }
-
-    function keywordEditRow(evt, num,  keyword,  keywordType, keywordTh){
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           if (elem && elem.nodeName == "TD") {
-               try {
-                    var table = elem.parentNode;
-                    if(num == 0){
-                        table.removeChild(elem);
-                        var TD = createTD("5","left", "pointer");
-                        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-                            TD.attachEvent("onclick", new Function("keywordEditRow(event, 1, \"" + keyword
-                            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
-                        } else {
-                            TD.setAttribute("onClick","keywordEditRow(event, 1, \"" + keyword
-                            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
-                        }
-                    
-                        TD.appendChild(createTextField("keyword", 15, keyword));
-                        TD.appendChild(document.createTextNode(" Type: "));
-                        TD.appendChild(createKeyTypeSelect("keywordType", keywordType));
-                        TD.appendChild(document.createTextNode(" Thesaurus: "));
-                        TD.appendChild(createKeyThSelect("keywordTh", keywordTh));
-                        table.appendChild(TD);
-                    } else {
-                        var child = elem.childNodes;
-                        keyword = child.item(0).value;
-                        var _keywordType = child.item(2);
-                        keywordType = _keywordType.options[_keywordType.selectedIndex].text;
-                        var _keywordTh = child.item(4);
-                        keywordTh = _keywordTh.options[_keywordTh.selectedIndex].text;
-                        table.removeChild(elem);
-    
-                        var TD = createTD("5","left", "pointer");
-                        if (navigator.userAgent.toLowerCase().indexOf('msie')!= -1 && document.all){
-                            TD.attachEvent("onclick", new Function("keywordEditRow(event, 0, \"" + keyword
-                            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")"));
-                        } else {
-                            TD.setAttribute("onClick","keywordEditRow(event, 0, \"" + keyword
-                            + "\",\"" + keywordType + "\",\"" + keywordTh  + "\")");
-                        }
-                    
-                        var text   = keyword + " (Type: " + keywordType + ", Thesaurus: " + keywordTh + ")";
-                        var label = document.createTextNode(text);
-                        TD.appendChild(label);
-                        TD.appendChild(createHiddenInput("keyword", keyword));
-                        TD.appendChild(createHiddenInput("keywordType", keywordType));
-                        TD.appendChild(createHiddenInput("keywordTh", keywordTh));
-                        table.appendChild(TD);
-                    }
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-    
-    function createKeywordThesaurusRow(name) {        
-        var keyRowTemplate = document.getElementById("keyThRow");
-        var newField =  keyRowTemplate.cloneNode(true);
-	var nodes = newField.getElementsByTagName("input");
-	nodes.item(0).setAttribute("name", name);
-	nodes.item(1).setAttribute("name", name);
-	return newField;
-    }
-
-    function createKeyThSelect(name, value) {
-        var newField=document.createElement("select");
-        newField.setAttribute("name", name);
-	var option1=document.createElement("option");
-	var text1=document.createTextNode("None");
-	option1.appendChild(text1);
-	newField.appendChild(option1);
-	var option2=document.createElement("option");
-	var text2=document.createTextNode("GCMD");
-	option2.appendChild(text2);
-	newField.appendChild(option2);
-
-        if(value == "None"){
-            newField.selectedIndex=0;
-        } else if(value == "GCMD"){
-            newField.selectedIndex=1;
-        }
-	return newField;
-    }
-
-    function createKeyTypeSelect(name, value) {
-        var newField=document.createElement("select");
-        newField.setAttribute("name", name);
-	var option1=document.createElement("option");
-	var text1=document.createTextNode("None");
-	option1.appendChild(text1);
-	newField.appendChild(option1);
-	var option2=document.createElement("option");
-	var text2=document.createTextNode("Theme");
-	option2.appendChild(text2);
-	newField.appendChild(option2);
-	var option3=document.createElement("option");
-	var text3=document.createTextNode("Place");
-	option3.appendChild(text3);
-	newField.appendChild(option3)
-	var option4=document.createElement("option");
-	var text4=document.createTextNode("Stratum");
-	option4.appendChild(text4);
-	newField.appendChild(option4);
-	var option5=document.createElement("option");
-	var text5=document.createTextNode("Temporal");
-	option5.appendChild(text5);
-	newField.appendChild(option5);
-	var option6=document.createElement("option");
-	var text6=document.createTextNode("Taxonomic");
-	option6.appendChild(text6);
-	newField.appendChild(option6);        
-        if(value == "None"){
-            newField.selectedIndex=0;
-        } else if(value == "Theme"){
-            newField.selectedIndex=1;
-        } else if(value == "Place"){
-            newField.selectedIndex=2;
-        } else if(value == "Stratum"){
-            newField.selectedIndex=3;
-        }else if(value == "Temporal"){
-            newField.selectedIndex=4;
-        } else if(value == "Taxonomic"){
-            newField.selectedIndex=5;
-        }
-	return newField;
-    }
-    
-    var basicInfoBit = 1;
-	var submitterBit = 1;
-    var dsoBit = 1;
-    var apBit = 1;
-    var abstractBit = 1;
-    var keywordBit = 1;
-    var temporalBit = 1;
-    var spatialBit = 1;
-    var taxonomicBit = 1;
-    var methodBit = 1;
-    var dscBit = 1;
-    var distBit = 1;
-    var uploadBit = 1;
-    
-    function swap(evt, _node, nodeBit){
-        evt = (evt) ? evt : ((window.event) ? window.event : null);
-        if(evt) {
-            var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-            
-            // hack so that this works on safari...
-            if(elem.nodeName != 'A'){
-                elem=elem.parentNode;
-            }
-            elem.removeChild(elem.firstChild);
-            var node = document.getElementById(_node);
-            if(nodeBit){
-                elem.appendChild(document.createTextNode("Show"));
-                node.className="hide";
-                return 0;
-            } else {
-                elem.appendChild(document.createTextNode("Hide"));
-                node.className="tables";
-                return 1;
-            }
-        }        
-    }
-
-
-    function handleOther(enable, node){
-        var textBox = document.getElementById(node);
-        if(enable){
-       	   textBox.removeAttribute("disabled");   
-        } else {
-           textBox.value="";
-      	   textBox.disabled = "true";   
-        }
-    }
-    function copyContact(){
-        var checkBox = document.getElementById("copyCheckBox");
-        if(checkBox.checked == true)
-	{
-	   var cnf=document.getElementById("contactNameFirst");
-	   var onf=document.getElementById("origNameFirst");
-	   cnf.value = onf.value;
-	   cnf.disabled = "true";
-
-	   var cnl=document.getElementById("contactNameLast");
-	   var onl=document.getElementById("origNameLast");
-	   cnl.value = onl.value;
-	   cnl.disabled = "true";
-
-	   var cno=document.getElementById("contactNameOrg");
-	   var ono=document.getElementById("origNameOrg");
-	   cno.value = ono.value;
-	   cno.disabled = "true";
-
-	   var ce=document.getElementById("contactEmail");
-	   var oe=document.getElementById("origEmail");
-	   ce.value = oe.value;
-	   ce.disabled = "true";
-
-	   var cp=document.getElementById("contactPhone");
-	   var op=document.getElementById("origPhone");
-	   cp.value = op.value;
-	   cp.disabled = "true";
-
-	   var cf=document.getElementById("contactFAX");
-	   var of=document.getElementById("origFAX");
-	   cf.value = of.value;
-	   cf.disabled = "true";
-
-	   var cd=document.getElementById("contactDelivery");
-	   var od=document.getElementById("origDelivery");
-	   cd.value = od.value;
-	   cd.disabled = "true";
-
-	   var cc=document.getElementById("contactCity");
-	   var oc=document.getElementById("origCity");
-	   cc.value = oc.value;
-	   cc.disabled = "true";
-
-	   var cs=document.getElementById("contactState");
-	   var os=document.getElementById("origState");
-	   cs.options[os.selectedIndex].selected=true;
-	   cs.disabled = "true";           
-
-	   var cso=document.getElementById("contactStateOther");
-	   var oso=document.getElementById("origStateOther");
-	   cso.value = oso.value;
-	   cso.disabled = "true";
-
-	   var cz=document.getElementById("contactZip");
-	   var oz=document.getElementById("origZip");
-	   cz.value = oz.value;
-	   cz.disabled = "true";
-
-	   var cC=document.getElementById("contactCountry");
-	   var oC=document.getElementById("origCountry");
-	   cC.value = oC.value;
-	   cC.disabled = "true";
-
-	} else {
-	   var cnf=document.getElementById("contactNameFirst");
-	   cnf.value = "";
-	   cnf.removeAttribute("disabled");
-
-	   var cnl=document.getElementById("contactNameLast");
-	   cnl.value = "";
-	   cnl.removeAttribute("disabled");
-
-	   var cno=document.getElementById("contactNameOrg");
-	   cno.value = "";
-	   cno.removeAttribute("disabled");
-
-	   var ce=document.getElementById("contactEmail");
-	   ce.value = "";
-	   ce.removeAttribute("disabled");
-
-	   var cp=document.getElementById("contactPhone");
-	   cp.value = "";
-	   cp.removeAttribute("disabled");
-
-	   var cf=document.getElementById("contactFAX");
-	   cf.value = "";
-	   cf.removeAttribute("disabled");
-
-	   var cd=document.getElementById("contactDelivery");
-	   cd.value = "";
-	   cd.removeAttribute("disabled");
-
-	   var cc=document.getElementById("contactCity");
-	   cc.value = "";
-	   cc.removeAttribute("disabled");
-
-	   var cs=document.getElementById("contactState");
-           cs.options[0].selected = true;
-	   cs.removeAttribute("disabled");
-
-	   var cso=document.getElementById("contactStateOther");
-	   cso.value = "";
-	   cso.removeAttribute("disabled");
-
-	   var cz=document.getElementById("contactZip");
-	   cz.value = "";
-	   cz.removeAttribute("disabled");
-
-	   var cC=document.getElementById("contactCountry");
-	   cC.value = "";
-	   cC.removeAttribute("disabled");
-	}
-    }
-
-  // include source for Multiple file uploader:
-  // http://the-stickman.com/web-development/javascript/
-
-  function MultiSelector( list_target, max ){
-
-    this.list_target = list_target;
-    this.count = 0;
-    this.id = 0;
-    var fcount =  document.getElementById("fileCount");
-    if (fcount.value > 0) {
-        this.id = fcount.value;
-    }
-    
-    if( max ){
-      this.max = max;
-    } else {
-      this.max = -1;
-    };
-
-    /**
-     * Add a new file input element
-     */
-    this.addElement = function( element ){
-
-      // Make sure it's a file input element
-      if( element.tagName == 'INPUT' && element.type == 'file' ){
-        // Element name -- what number am I?
-        element.name = 'file_' + this.id++;
-
-        // Add reference to this object
-        element.multi_selector = this;
-
-        // What to do when a file is selected
-        element.onchange = function(){
-          // Increment file counter
-          var fileCount = incrementCount("fileCount");
-
-          // Clean up file text
-          var comment_element = document.getElementById( 'file_comment' );
-          if (comment_element){
-            comment_element.parentNode.removeChild(comment_element);
-          }
-
-          // New file input
-          var new_element = document.createElement( 'input' );
-          new_element.type = 'file';
-
-          // Add new element
-          this.parentNode.insertBefore( new_element, this );
-
-          // Apply 'update' to element
-          this.multi_selector.addElement( new_element );
-
-          // Update list
-          this.multi_selector.addListRow( this );
-
-          // Hide this: we can't use display:none because Safari doesn't like it
-          this.style.position = 'absolute';
-          this.style.left = '-1000px';
-
-        };
-
-        // If we've reached maximum number, disable input element
-        if( this.max != -1 && this.count >= this.max ){
-          element.disabled = true;
-        };
-        // File element counter
-        this.count++;
-
-        // Most recent element
-        this.current_element = element;
-
-      } else {
-        // This can only be applied to file input elements!
-        alert( 'Error: not a file input element' );
-      };
-
-    };
-
-    /**
-     * Add a new row to the list of files
-     */
-    this.addListRow = function( element ){
-
-      // Row div
-      var new_row = document.createElement( 'div' );
-
-      // Delete button
-      var new_row_button = document.createElement( 'input' );
-      new_row_button.type = 'button';
-      new_row_button.value = 'Delete';
-
-      // References
-      new_row.element = element;
-
-      // Delete function
-      new_row_button.onclick= function(){
-        // Remove element from form
-        this.parentNode.element.parentNode.removeChild( this.parentNode.element );
-
-        // Remove this row from the list
-        this.parentNode.parentNode.removeChild( this.parentNode );
-        // Decrement counter
-        this.parentNode.element.multi_selector.count--;
-
-        // Re-enable input element (if it's disabled)
-        this.parentNode.element.multi_selector.current_element.disabled = false;
-
-        // Appease Safari
-        //    without it Safari wants to reload the browser window
-        //    which nixes your already queued uploads
-        return false;
-      };
-
-      // Set row value
-      new_row.innerHTML = element.value + " ";
-      
-      // Add button
-      new_row.appendChild( new_row_button );
-
-      // Add it to the list
-      this.list_target.appendChild( new_row );
-
-    };
-
-  };
-
-  function deleteFile(evt, file) {
-         evt = (evt) ? evt : ((window.event) ? window.event : null);
-         if (evt) {
-           // equalize W3C/IE models to get event target reference
-           var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
-           var element = document.getElementById("file_element");
-           if (elem) {
-               try {
-                 // Add a new hidden form element to delete exisiting files
-                 // FIXME: this needs to find the matching file element, so if our node
-                 // has 'test.txt' as the filename, find the input hidden value="test.txt"
-                 //element.parentNode.removeChild( element );
-
-                 var delete_input = document.createElement( 'input' );
-                 delete_input.type = 'hidden';
-                 delete_input.value = file;
-                 elem.appendChild( delete_input );
-                 
-                 // Remove this row from the list
-                 elem.parentNode.parentNode.removeChild( elem.parentNode );
-
-                 // Decrement counter
-                 elem.parentNode.element.multi_selector.count--;
-
-                 // Re-enable input element (if it's disabled)
-                 elem.parentNode.element.multi_selector.current_element.disabled = false;
-                 }
-               catch(e) {
-                   var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
-                   alert("Error:\n" + msg);
-                   return;
-               }
-           }
-         }
-    }
-
+  <script language="JavaScript" type="text/javascript" src="@systemidserver@@style-common-path@/templates/entryForm.js">
   </script>
 
       [% IF form != 're_entry' %]	
@@ -1745,23 +586,24 @@
     <tr class="sectbody"><td class="topbottom" align="center" colspan="6"><span class="label">COORDINATES</span></td></tr>
         
      
-[% IF showSiteList == 'true' %]
+  [% IF showSiteList == 'true' %]
     <tr class="sectbody"><td align="left" valign="top" colspan="6">
         <input class="label" type="CHECKBOX" name="useSiteCoord" [%useSiteCoord%]>
         <span class="regtext">Use [% lsite %] coordinates. (This indicates that the data were
         collected at the [% lsite %]. If you check this box, you don't need
         to fill in the lat./long. fields below).</span>
-        </td></tr>
-[% END %]
+        </td>
+    </tr>
+  [% END %]
     
     <tr class="sectbody">
-        <td width="190"></td><td width="100" align="left"><span class="label">Degrees</span></td>
-	<td width="110" align="left"><span class="label">Minutes</span></td>
-	<td width="70" align="left"><span class="label">Seconds</span></td>
-        <td width="200"></td><td width="90"</td></tr>
-		    
+      <td width="190"></td><td width="100" align="left"><span class="label">Degrees</span></td>
+	    <td width="110" align="left"><span class="label">Minutes</span></td>
+	    <td width="70" align="left"><span class="label">Seconds</span></td>
+      <td width="200"></td><td width="90"</td>
+   </tr>
       
-     <tr class="sectbody">
+   <tr class="sectbody">
      <td class="rightCol">
       [% IF spatialRequired == 'true' %]
         <span class="label">*Latitude</span>
@@ -1774,29 +616,19 @@
       <td>  <input type="TEXT" name="latSec1" value="[%latSec1%]" size="2" maxlength="2"></td>
       
       <td Align="left" colspan="2"> 
-    
-<!--    <select name="hemisphLat1">
-	    [% IF form == 're_entry' && hemisphLat1 != ""%]
-	    	<option selected>[%hemisphLat1%]</option>
-	    [% END %]
-            <option>N</option>
-            <option>S</option>
-          </select>   -->
-	  
 	    [% IF form == 're_entry' && hemisphLat1 == "N"%]
-	  <input type="radio"  name="hemisphLat1" value="N" CHECKED><span class="regtext">North&nbsp;&nbsp;</span>
-	[%ELSE%]
-	  <input type="radio"  name="hemisphLat1" value="N"><span class="regtext">North&nbsp;&nbsp;</span>
-	[%END%]
+	      <input type="radio"  name="hemisphLat1" value="N" CHECKED><span class="regtext">North&nbsp;&nbsp;</span>
+	    [%ELSE%]
+	      <input type="radio"  name="hemisphLat1" value="N"><span class="regtext">North&nbsp;&nbsp;</span>
+	    [%END%]
 	    [% IF form == 're_entry' && hemisphLat1 == "S"%]
-	  <input type="radio"  name="hemisphLat1" value="S" CHECKED><span class="regtext">South&nbsp;&nbsp;</span>
-	  [%ELSE%]
-	  <input type="radio"  name="hemisphLat1" value="S"><span class="regtext">South&nbsp;&nbsp;</span>
-	[%END%]
+	      <input type="radio"  name="hemisphLat1" value="S" CHECKED><span class="regtext">South&nbsp;&nbsp;</span>
+	    [%ELSE%]
+	      <input type="radio"  name="hemisphLat1" value="S"><span class="regtext">South&nbsp;&nbsp;</span>
+	    [%END%]
+	    </td>
+    </tr>
 
-	  </td></tr>
-      
-           
     <tr class="sectbody">
       <td class="rightCol"> 
       [% IF spatialRequired == 'true' %]
@@ -1811,60 +643,42 @@
       
       
       <td align="left" colspan="2"> 
-          
-<!--     <select name="hemisphLong1">
-	    [% IF form == 're_entry' && hemisphLong1 != ""%]
-	    	<option selected>[%hemisphLong1%]</option>
-	    [% END %]
-            <option>W</option>
-            <option>E</option>
-          </select>   -->
-	  
-	  
-	    [% IF form == 're_entry' && hemisphLong1 == "W"%]
-	  <input type="radio"  name="hemisphLong1" value="W" CHECKED><span class="regtext">West&nbsp;&nbsp;</span>
-	[%ELSE%]
-	  <input type="radio"  name="hemisphLong1" value="W"><span class="regtext">West&nbsp;&nbsp;</span>
-	[%END%]
-	    [% IF form == 're_entry' && hemisphLong1 == "E"%]
-	  <input type="radio"  name="hemisphLong1" value="E" CHECKED><span class="regtext">East&nbsp;&nbsp;</span>
+    [% IF form == 're_entry' && hemisphLong1 == "W"%]        
+	    <input type="radio"  name="hemisphLong1" value="W" CHECKED><span class="regtext">West&nbsp;&nbsp;</span>
 	  [%ELSE%]
-	  <input type="radio"  name="hemisphLong1" value="E"><span class="regtext">East&nbsp;&nbsp;</span>
+	    <input type="radio"  name="hemisphLong1" value="W"><span class="regtext">West&nbsp;&nbsp;</span>
 	  [%END%]
-	  </td></tr>
+	  [% IF form == 're_entry' && hemisphLong1 == "E"%]
+	    <input type="radio"  name="hemisphLong1" value="E" CHECKED><span class="regtext">East&nbsp;&nbsp;</span>
+	  [%ELSE%]
+	    <input type="radio"  name="hemisphLong1" value="E"><span class="regtext">East&nbsp;&nbsp;</span>
+	  [%END%]
+	    </td>
+    </tr>
       
       
-      <tr class="sectbody"><td><td colspan="4" align="left"><span class="regtext">If only this first lat/long pair is entered, this indicates a point location. If both lat/long pairs are entered, then this first pair represents the northwest corner of a bounding box.</span>
+    <tr class="sectbody"><td><td colspan="4" align="left"><span class="regtext">If only this first lat/long pair is entered, this indicates a point location. If both lat/long pairs are entered, then this first pair represents the northwest corner of a bounding box.</span>
       </td><td></td></tr>
       
-      <tr class="sectbody"> 
+    <tr class="sectbody"> 
       <td class="rightCol"><span class="label">Latitude</span></td>
 	<td ><input type="TEXT" name="latDeg2" value="[%latDeg2%]" size="3" maxlength="3"></td>
-        <td><input type="TEXT" name="latMin2" value="[%latMin2%]" size="2" maxlength="2"></td>
-        <td><input type="TEXT" name="latSec2" value="[%latSec2%]" size="2" maxlength="2"></td>
+      <td><input type="TEXT" name="latMin2" value="[%latMin2%]" size="2" maxlength="2"></td>
+      <td><input type="TEXT" name="latSec2" value="[%latSec2%]" size="2" maxlength="2"></td>
         
-	<td align="left" colspan="2"> 
-          
-<!--      <select name="hemisphLat2">
-	    [% IF form == 're_entry' && hemisphLat2 != ""%]
-	    	<option selected>[%hemisphLat2%]</option>
-            [% END %]
-	    <option>N</option>
-            <option>S</option>
-          </select> -->
-	  
+	    <td align="left" colspan="2"> 
 	    [% IF form == 're_entry' && hemisphLat2 == "N"%]
-	  <input type="radio"  name="hemisphLat2" value="N" CHECKED><span class="regtext">North&nbsp;&nbsp;</span>
-	[%ELSE%]
-	  <input type="radio"  name="hemisphLat2" value="N"><span class="regtext">North&nbsp;&nbsp;</span>
-	[%END%]
+	      <input type="radio"  name="hemisphLat2" value="N" CHECKED><span class="regtext">North&nbsp;&nbsp;</span>
+	    [%ELSE%]
+	      <input type="radio"  name="hemisphLat2" value="N"><span class="regtext">North&nbsp;&nbsp;</span>
+	    [%END%]
 	    [% IF form == 're_entry' && hemisphLat2 == "S"%]
-	  <input type="radio"  name="hemisphLat2" value="S" CHECKED><span class="regtext">South&nbsp;&nbsp;</span>
-	  [%ELSE%]
-	  <input type="radio"  name="hemisphLat2" value="S"><span class="regtext">South&nbsp;&nbsp;</span>
-	  [%END%]
-	  
-	  </td></tr>
+	      <input type="radio"  name="hemisphLat2" value="S" CHECKED><span class="regtext">South&nbsp;&nbsp;</span>
+	    [%ELSE%]
+	      <input type="radio"  name="hemisphLat2" value="S"><span class="regtext">South&nbsp;&nbsp;</span>
+	    [%END%]
+	    </td>
+    </tr>
     
     <tr class="sectbody"><td class="rightCol"><span class="label">Longitude</span></td>
        <td> <input type="TEXT" name="longDeg2" value="[%longDeg2%]" size="3" maxlength="3"></td>
@@ -1872,31 +686,24 @@
        <td> <input type="TEXT" name="longSec2" value="[%longSec2%]" size="2" maxlength="2"></td>
        <td align="left" colspan="2">
        
-<!--      <select name="hemisphLong2">
-            [% IF form == 're_entry' && hemisphLong2 != ""%]
-	    	<option selected>[%hemisphLong2%]</option>
-	    [% END %]
-            <option>W</option>
-            <option>E</option>
-          </select> -->
-	  
 	    [% IF form == 're_entry' && hemisphLong2 == "W"%]
-	  <input type="radio"  name="hemisphLong2" value="W" CHECKED><span class="regtext">West&nbsp;&nbsp;</span>
-	[%ELSE%]
-	  <input type="radio"  name="hemisphLong2" value="W"><span class="regtext">West&nbsp;&nbsp;</span>
-	[%END%]
+	      <input type="radio"  name="hemisphLong2" value="W" CHECKED><span class="regtext">West&nbsp;&nbsp;</span>
+	    [%ELSE%]
+	      <input type="radio"  name="hemisphLong2" value="W"><span class="regtext">West&nbsp;&nbsp;</span>
+	    [%END%]
 	    [% IF form == 're_entry' && hemisphLong2 == "E"%]
-	  <input type="radio"  name="hemisphLong2" value="E" CHECKED><span class="regtext">East&nbsp;&nbsp;</span>
-	  [%ELSE%]
-	  <input type="radio"  name="hemisphLong2" value="E"><span class="regtext">East&nbsp;&nbsp;</span>
-	  [%END%]
-	  
-	  </td></tr>
-  <tr class="sectbody"><td></td>
+	      <input type="radio"  name="hemisphLong2" value="E" CHECKED><span class="regtext">East&nbsp;&nbsp;</span>
+	    [%ELSE%]
+	      <input type="radio"  name="hemisphLong2" value="E"><span class="regtext">East&nbsp;&nbsp;</span>
+	    [%END%]
+	    </td>
+    </tr>
+    <tr class="sectbody"><td></td>
        <td align="left" colspan="4"><span class="regtext">
         If entered, this lat/long pair represents the southeast corner of a bounding box.</span>
-      </td><td></td></tr>
-    </table>    
+      </td><td></td>
+    </tr>
+  </table>    
    [% END %]
 
    [% IF hasTaxonomic == 'true' %]
@@ -2210,19 +1017,6 @@
   <tr class="sectbody"><td class="rightCol"><span class="label">*Usage Rights</span></td>
       <td colspan="5" align="left">
       
-      
-      
-<!--      <select name="useConstraints">
-	    [% IF form == 're_entry' %]	
-	        <option selected>[%useConstraints%]</option>
-	    [% ELSE %]
-                <option>Select restrictions here.</option>
-	    [% END %]
-            <option>No restrictions</option>
-            <option>Obtain permission from data set owner(s)</option>
-            <option>Other</option>
-          </select>  -->
-	  
           [% IF form == 're_entry' && useConstraints == "no restrictions" %]		  
 	    <input type="radio"  name="useConstraints" onClick="handleOther(0, 'otherUC')" value="no restrictions" CHECKED><span class="regtext">No restrictions&nbsp;&nbsp;</span>
           [%ELSE%]
@@ -2301,7 +1095,7 @@
     [% cnt = 0 %]
     [% WHILE cnt < upCount %]
         [% SET fileName = "uploadname_${cnt}" %]
-        [% IF fileName %]<div>[% $fileName %] <input type="button" value="Delete" onclick="deleteFile(event, [%fileName%]);"</div>[% END %]
+        [% IF fileName %]<div>[% $fileName %] <input type="button" value="Delete" onclick="deleteFile(event, [%fileName%]);"/></div>[% END %]
         [% cnt = cnt + 1 %]
     [% END %]
     [% END %]</div></td>
Index: src/perl/register-dataset.cgi
===================================================================
--- src/perl/register-dataset.cgi	(revision 3472)
+++ src/perl/register-dataset.cgi	(revision 3473)
@@ -177,6 +177,9 @@
     $nceas_db_password = $config->nceas_db_password();
 }
 my $debug = $config->debug();
+if ($FORM::debug) {
+    $debug = $FORM::debug;
+}
 my $lat = $config->get('lat');
 my $lon = $config->get('lon');
 
@@ -196,7 +199,8 @@
 my $ttConfig = {
              INCLUDE_PATH => $templatesdir, 
              INTERPOLATE  => 0,                    
-             POST_CHOMP   => 1,                   
+             POST_CHOMP   => 1,
+             #DEBUG        => 'all',
              };
 
 # create an instance of the template processor
@@ -226,9 +230,8 @@
 if (!hasContent($metacatUrl)) {
     debug("Registry: No Metacat.");
     print "Content-type: text/html\n\n";
-    $$templateVars{'message'} = 'Error: Metacat is not initialized! Make sure' . 
+    'Registry Error: Metacat is not initialized! Make sure' .
         ' MetacatUrl is set correctly in ' .  $FORM::cfg . '.cfg';
-    $template->process( $loginFormTemplate, $templateVars);
     exit(0);
 }
 
@@ -573,6 +576,14 @@
 } else {
     $$templateVars{'docid'} = $docid;
     $$templateVars{'cfg'} = $FORM::cfg;
+    # delete the remaining file objects from disk
+    for (my $fileNum = 0; $fileNum <= $FORM::upCount; $fileNum++) {
+        my $fn = 'uploadname_' . $fileNum;
+        if (hasContent(param($fn))) {
+            deleteFile(param($fn));
+        }
+    }
+    
 }
 
 #if (! $error) {
@@ -750,11 +761,11 @@
 	#}
     }
 
-    if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9][0-9][0-9][0-9]/)){
+    if (hasContent($FORM::beginningYear) && !($FORM::beginningYear =~ /[0-9]{4}/)){
 	push(@invalidParams, "Invalid year of start date specified.")
     }
 
-    if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9][0-9][0-9][0-9]/)){
+    if (hasContent($FORM::endingYear) && !($FORM::endingYear =~ /[0-9]{4}/)){
 	push(@invalidParams, "Invalid year of stop date specified.")
     }
     
@@ -1141,6 +1152,21 @@
     return ($outputName, $digest);
 }
 
+sub deleteFile {
+    my $input = shift;
+    my $fileName = $tmpdir . "/" . $input;
+
+    if (-e $fileName) {
+        unlink $fileName or
+            debug("Registry: failed to delete file $fileName.");
+    } else {
+        debug("Registry: unable to find file $fileName");
+    }
+    if (!-e $fileName) {
+        debug("Registry: successfully deleted $fileName");
+    }
+}
+
 sub uploadData {
     my $data = shift;
     my $docid = shift;
@@ -1240,7 +1266,7 @@
     foreach my $origName (param()) {
         my $origNum = $origName;
         $origNum =~ s/origNamelast//; # get the index of the parameter 0 to 10
-        if ( $origNum =~ /^([0-9])$/) {
+        if ( $origNum =~ /^([0-9]+)$/) {
             # do not generate EML for empty originator fields
             if (hasContent(param("origNamefirst" . $origNum))) {
                 my $first = normalize(param("origNamefirst" . $origNum));
@@ -1355,7 +1381,7 @@
     foreach my $kwName (param()) {
         my $kwNum = $kwName;
         $kwNum =~ s/keyword//; # get the index of the parameter 0, ..., 10
-        if ( $kwNum =~ /^([0-9])$/ ){
+        if ( $kwNum =~ /^([0-9]+)$/ ){
             # don't generate xml for empty keyword fields
             # don't generate taxonomic keyword fields, those go in taxonomic coverage
             if (hasContent(param($kwName))) {
@@ -1538,8 +1564,7 @@
 
     if (hasContent($FORM::origDeliveryContact) ||
         hasContent($FORM::origCityContact) ||
-        (hasContent($FORM::origStateContact) &&
-        ($FORM::origStateContact !~ "Select state here.")) ||
+        hasContent($FORM::origStateContact)  ||
         hasContent($FORM::origStateOtherContact) ||
         hasContent($FORM::origZIPContact) ||
         hasContent($FORM::origCountryContact)) {
@@ -1552,7 +1577,7 @@
             $cont .= "<city>".normalize($FORM::origCityContact)."</city>\n";
         }
         if (hasContent($FORM::origStateContact) &&
-            ($FORM::origStateContact !~ "Select state here.")) {
+            ($FORM::origStateContact !=~ /select state/i)) {
             $cont .= "<administrativeArea>".normalize($FORM::origStateContact);
             $cont .= "</administrativeArea>\n";
         } elsif (hasContent($FORM::origStateOtherContact)) {
@@ -1740,7 +1765,7 @@
             my $taxIndex = $trn;
             $taxIndex =~ s/taxonRankName//; # get the index of the parameter 0, ..., 10
             my $trv = "taxonRankValue".$taxIndex;
-            if ( $taxIndex =~ /[0-9]/ ){
+            if ( $taxIndex =~ /[0-9]+/ ){
                 if (hasContent(param($trn)) && hasContent(param($trv))) {
                     if (! $foundFirstTaxon) {
                         $cov .= "<taxonomicCoverage>\n";
@@ -3654,7 +3679,6 @@
     	}
     }
 
-
     $$templateVars{'providerGivenName'} = normalizeCD($FORM::providerGivenName);
     $$templateVars{'providerSurName'} = normalizeCD($FORM::providerSurName);
     if($FORM::site eq "Select your station here."){
@@ -3670,12 +3694,11 @@
     $$templateVars{'origNamefirst0'} = normalizeCD($FORM::origNamefirst0);
     $$templateVars{'origNamelast0'} = normalizeCD($FORM::origNamelast0);
     $$templateVars{'origNameOrg'} = normalizeCD($FORM::origNameOrg);
-    # $$templateVars{'origRole0'} = $FORM::origRole0;
     $$templateVars{'origDelivery'} = normalizeCD($FORM::origDelivery);
     $$templateVars{'origCity'} = normalizeCD($FORM::origCity);
-    if($FORM::origState eq "Select State Here."){
+    if ($FORM::origState =~ /select state/i) {
         $$templateVars{'origState'} = "";
-    }else{
+    } else {
         $$templateVars{'origState'} = $FORM::origState;
     }
     $$templateVars{'origStateOther'} = normalizeCD($FORM::origStateOther);
@@ -3686,12 +3709,13 @@
     $$templateVars{'origEmail'} = normalizeCD($FORM::origEmail);
     $$templateVars{'useOrigAddress'} = normalizeCD($FORM::useOrigAddress);
     if($FORM::useOrigAddress eq "on"){
+      
         $$templateVars{'origNamefirstContact'} = normalizeCD($FORM::origNamefirst0);
         $$templateVars{'origNamelastContact'} = normalizeCD($FORM::origNamelast0);
         $$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrg);
         $$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDelivery); 
         $$templateVars{'origCityContact'} = normalizeCD($FORM::origCity);
-        if($FORM::origState eq "Select State Here."){
+        if($FORM::origState =~ /select state/i){
         $$templateVars{'origStateContact'} = "";
         }else{
         $$templateVars{'origStateContact'} = $FORM::origState;
@@ -3708,7 +3732,7 @@
         $$templateVars{'origNameOrgContact'} = normalizeCD($FORM::origNameOrgContact);
         $$templateVars{'origDeliveryContact'} = normalizeCD($FORM::origDeliveryContact); 
         $$templateVars{'origCityContact'} = normalizeCD($FORM::origCityContact);
-        if($FORM::origStateContact eq "Select State Here."){
+        if($FORM::origStateContact =~ /select state/i){
         $$templateVars{'origStateContact'} = "";
         }else{
         $$templateVars{'origStateContact'} = $FORM::origStateContact;
@@ -3735,7 +3759,7 @@
             $$templateVars{"origNamelast".$aoCount} = normalizeCD($aoLNArray->[$i]);
             $$templateVars{"origRole".$aoCount} = normalizeCD($aoRoleArray->[$i]);
             $aoCount++;
-	}    
+        }    
     }
 
     $$templateVars{'aoCount'} = $aoCount;
@@ -3811,17 +3835,22 @@
 
     $$templateVars{'taxaCount'} = $taxonCount-1;
     $$templateVars{'taxaAuth'} = normalizeCD($FORM::taxaAuth);
-
+    my $deleteCount = 0;
     for (my $upNum = 0; $upNum <= $FORM::upCount; $upNum++) {
         my $upn = "upload_$upNum";
         if (hasContent(param($upn))) {
-            debug("Registry: processing existing file: $upn");
-            $$templateVars{"upload_$upNum"} = param("upload_$upNum");
-            $$templateVars{"uploadname_$upNum"} = param("uploadname_$upNum");
-            $$templateVars{"uploadtype_$upNum"} = param("uploadtype_$upNum");
+            if (grep {$_ eq ("uploadname_$upNum")} @FORM::deletefile) {
+                deleteFile(param("uploadname_$upNum"));
+                $deleteCount++;
+            } else {
+                debug("Registry: processing existing file: $upn");
+                $$templateVars{"upload_$upNum"} = param("upload_$upNum");
+                $$templateVars{"uploadname_$upNum"} = param("uploadname_$upNum");
+                $$templateVars{"uploadtype_$upNum"} = param("uploadtype_$upNum");
+            }
         }
     }
-
+    
     my $uploadCount = 0;
     for (my $fileNum = 0; $fileNum <= $FORM::fileCount; $fileNum++) {
         my $fn = 'file_' . $fileNum;
@@ -3839,7 +3868,8 @@
             $uploadCount++;
         }
     }
-    $$templateVars{'upCount'} = $uploadCount + $FORM::upCount;
+    # total uploads are: new uploads - deleted files + original uploads
+    $$templateVars{'upCount'} = $uploadCount - $deleteCount + $FORM::upCount;
     $$templateVars{'methodTitle'} = normalizeCD($FORM::methodTitle);
  
     my @tempMethodPara;
@@ -3934,7 +3964,6 @@
     $$templateVars{'origNamefirst0'} = $FORM::origNamefirst0;
     $$templateVars{'origNamelast0'} = $FORM::origNamelast0;
     $$templateVars{'origNameOrg'} = $FORM::origNameOrg;
- #   $$templateVars{'origRole0'} = $FORM::origRole0;
     $$templateVars{'origDelivery'} = $FORM::origDelivery;
     $$templateVars{'origCity'} = $FORM::origCity;
     $$templateVars{'origState'} = $FORM::origState;
@@ -3969,7 +3998,7 @@
 	    $origNameIndex =~ s/origNamefirst//; # get the index of the parameter 0, ..., 10
 	    my $origNamelast = "origNamelast".$origNameIndex;
 	    my $origRole = "origRole".$origNameIndex;
-	    if ( $origNameIndex =~ /[0-9]/  && $origNameIndex > 0){
+	    if ( $origNameIndex =~ /[0-9]+/  && $origNameIndex > 0){
 		if (hasContent(param($origName)) && hasContent(param($origNamelast)) && hasContent(param($origRole))) {
 		    debug("Registry processing keyword: $origName = ".param($origName)." $origNamelast = ".param($origNamelast)." $origRole = ".param($origRole));
 		    $$templateVars{$origName} = normalizeCD(param($origName));
@@ -3988,7 +4017,7 @@
 	    $keyIndex =~ s/keyword//; # get the index of the parameter 0, ..., 10
 	    my $keyType = "kwType".$keyIndex;
 	    my $keyTh = "kwTh".$keyIndex;
-	    if ( $keyIndex =~ /[0-9]/ ){
+	    if ( $keyIndex =~ /[0-9]+/ ){
 		if (hasContent(param($kyd)) && hasContent(param($keyType)) && hasContent(param($keyTh))) {
 		    debug("Registry processing keyword: $kyd = ".param($kyd)." $keyType = ".param($keyType)." $keyTh = ".param($keyTh));
 		    $$templateVars{$kyd} = param($kyd); 
@@ -4040,7 +4069,7 @@
             my $taxIndex = $trn;
             $taxIndex =~ s/taxonRankName//; # get the index of the parameter 0, ..., 10
             my $trv = "taxonRankValue".$taxIndex;
-            if ( $taxIndex =~ /[0-9]/ ){
+            if ( $taxIndex =~ /[0-9]+/ ){
                 if (hasContent(param($trn)) && hasContent(param($trv))) {
                     debug("Registry processing taxon: $trn = ".param($trn)." $trv = ".param($trv));
                     $$templateVars{$trn} = param($trn);
@@ -4073,7 +4102,7 @@
         if ($upload =~ /upload_/) {
             my $fileIndex = $upload;
             $fileIndex =~ s/upload_//;
-            if ( $fileIndex =~ /[0-9]/ ) {
+            if ( $fileIndex =~ /[0-9]+/ ) {
                 if (hasContent(param($upload))) {
                     debug("Registry: returning filename: " . param($upload));
                     $$templateVars{"upload_$fileIndex"} = param($upload);
