Index: other-projects/computer-says-no/trunk/src/computer_says_no.user.js
===================================================================
--- other-projects/computer-says-no/trunk/src/computer_says_no.user.js	(revision 25845)
+++ other-projects/computer-says-no/trunk/src/computer_says_no.user.js	(revision 25845)
@@ -0,0 +1,3049 @@
+// ==UserScript==
+// @name           Computer Says No
+// @namespace      org.greenstone.csn
+// @include        http://*
+// ==/UserScript==
+
+
+
+var csnInitialized = false;
+
+var inspectorActive = false;
+var inspectorDragging = false;
+var inspectorIgnoreSingleClick = false;
+
+var inspectorSelectedElems = [];
+
+var csnFoldOrExpand = "fold";
+var csnMode = null;
+var csnFirstnameMode = "full";
+var csnPunctMode     = "with-spaces";
+var csnMergeMode     = "interactive";
+var csnDeleteMode    = "interactive";
+
+
+var csnOnTop = false;
+
+var seaweedActivated = false;
+
+var zRange = {};
+
+
+var ELEMENT_NODE                =  1;
+var ATTRIBUTE_NODE              =  2;
+var TEXT_NODE                   =  3;
+var CDATA_SECTION_NODE          =  4;
+var ENTITY_REFERENCE_NODE       =  5;
+var ENTITY_NODE                 =  6;
+var PROCESSING_INSTRUCTION_NODE =  7;
+var COMMENT_NODE                =  8;
+var DOCUMENT_NODE               =  9;
+var DOCUMENT_TYPE_NODE          = 10;
+var DOCUMENT_FRAGMENT_NODE      = 11;
+var NOTATION_NODE               = 12;
+
+function trim(str)
+{
+    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
+}
+
+function whiteSpaceIndent(count) 
+{
+    var spaces_cache = [ "", " ", "  ", "   ", "    ", "     ", "      " ];
+    if (count < spaces_cache.length) {
+	return spaces_cache[count];
+    }
+
+    var spaces = "";
+
+    for (var i=0; i<count; i++) {
+	spaces += " ";
+	spaces_cache[i] = spaces;
+    }
+    
+    return spaces;
+}
+
+function traverseDOM(node,depth) 
+{
+    if (depth==null) {
+	depth = 0;
+    }
+
+    if (node.nodeType == TEXT_NODE) {
+	var text = node.nodeValue;
+	if (!text.match(/^\s*$/)) {
+	    // only print if not whitespace
+	    var indent = whiteSpaceIndent(depth);
+	    console.log(indent + node.nodeValue);
+	}
+    }
+    else if (node.nodeType == ELEMENT_NODE) {
+	var indent = whiteSpaceIndent(depth);
+	console.log(indent + "<"+node.nodeName.toLowerCase()+">");
+	for(var i=0; i<node.childNodes.length; i++) {
+	    traverseDOM(node.childNodes[i],depth+1);
+	}
+	console.log(indent + "</"+node.nodeName.toLowerCase()+">");
+    }
+    else {
+	alert("Unexpectedly got : " + node.nodeType + "for : " + nodeType);
+    }
+}
+
+
+
+function getChildText(node) 
+{
+    var text = "";
+
+    if (node.nodeType == TEXT_NODE) {
+	text = node.nodeValue;
+	if (text.match(/^\s*$/)) {
+	    text = "";
+	}
+    }
+    else if (node.nodeType == ELEMENT_NODE) {	
+
+	if (node.nodeName.toLowerCase() == "input")  {
+	    text = node.value;
+	    if (text.match(/^\s*$/)) {
+		text = "";
+	    }
+	}
+	else {
+	    for(var i=0; i<node.childNodes.length; i++) {
+		text += getChildText(node.childNodes[i]);
+	    }
+	}
+    }
+    else {
+	alert("getChildText(): Unexpectedly got : " + node.nodeType + "for : " + nodeType);
+    }
+
+    text = trim(text);
+
+    return text;
+}
+
+function getChildHyperlinks(node,links) 
+{
+    if (node.nodeType == ELEMENT_NODE) {
+	if (node.nodeName.toLowerCase() == "a") {
+	    links[links.length] = node;
+	}
+	else {
+	    for(var i=0; i<node.childNodes.length; i++) {
+		var childNode = node.childNodes[i];
+		getChildHyperlinks(childNode,links);
+	    }
+	}
+    }
+}
+
+
+function getFirstChildHyperlink(node)
+{
+    var link = null;
+
+    var links = new Array();
+    getChildHyperlinks(node,links);
+
+    if (links.length>0) {
+	//hyperlink found
+	link = links[0];
+    }
+
+    return link;
+}
+
+
+
+function elementPartOfCsn(elem)
+{
+    // ignore any elements that are within the CSN area
+
+
+    while (true) {
+	if ((elem==null) || (elem.nodeName.toLowerCase()=="body")) {
+	    break;
+	}
+
+	if (elem.nodeType != ELEMENT_NODE) {
+	    // ignore events caused by clicking on the scroll bar, etc.
+	    break;
+	}
+
+	//console.log("elem = " + elem);
+
+	var elemId = elem.getAttribute("id");
+
+	if ((elemId != null) && (elemId=="ComputerSaysNo")) {
+	    return true;
+	}
+
+	var parent = elem.parentNode;
+
+	if (parent==null) {
+	    break;
+	}
+
+	elem = parent;
+    }
+
+    return false;
+}
+
+
+
+function elementPartOfPreLookup(elem)
+{
+    // ignore any elements that are within the CSN area
+
+
+    while (true) {
+	if ((elem==null) || (elem.nodeName.toLowerCase()=="body")) {
+	    break;
+	}
+
+	if (elem.nodeType != ELEMENT_NODE) {
+	    // ignore events caused by clicking on the scroll bar, etc.
+	    break;
+	}
+
+	//console.log("elem = " + elem);
+
+	var elemId = elem.getAttribute("id");
+
+	if ((elemId != null) && (elemId=="preLookup")) {
+	    return true;
+	}
+
+	var parent = elem.parentNode;
+
+	if (parent==null) {
+	    break;
+	}
+
+	elem = parent;
+    }
+
+    return false;
+}
+
+
+
+function appendIfUniq(elem)
+{
+    var appendElem = true;
+    for (var i=0; i<inspectorSelectedElems.length; i++) {
+	if (inspectorSelectedElems[i] == elem) {
+	    appendElem = false;
+	    break;
+	}
+    }
+    if (appendElem) {
+	inspectorSelectedElems[inspectorSelectedElems.length] = elem;
+    }
+
+}
+
+
+function getElemParents(elem,inclusive) 
+{
+    // setting inclusive to true means 'elem' is also put in the array of parents
+    // default is to exclude it
+    var parents = new Array();
+
+    while (true) {
+	if ((elem==null) || (elem.nodeName.toLowerCase()=="body")) {
+	    break;
+	}
+
+	if ((inclusive!=null) && (inclusive)) {
+	    parents[parents.length] = elem;
+	}
+
+	var parent = elem.parentNode;
+
+	if (parent==null) {
+	    break;
+	}
+
+	if ((inclusive==null) || (!inclusive)) {
+	    parents[parents.length] = parent;
+	}
+
+	elem = parent;
+    }
+
+    return parents;
+}
+
+function calcSharedElemParent(startElem,endElem) 
+{
+    if (startElem==null) { return null; };
+
+    // This case shouldn't arise anymore
+    if (endElem==null) { return startElem.parentNode; }
+
+    var startParents = getElemParents(startElem);
+    var endParents = getElemParents(endElem);
+
+    var sharedParent = null;
+
+    for (var s=0; s<startParents.length; s++) {
+	var currStartParent = startParents[s];
+	for (var e=0; e<endParents.length; e++) {
+	    var currEndParent = endParents[e];
+	    if (currEndParent==currStartParent) {
+		console.log("Got match at level: " + s + "=<"+startParents[s].nodeName+"> (start) " 
+			    + e + "=<" +endParents[e].nodeName + "> (end)");
+		sharedParent = currEndParent;
+		break;
+	    }
+	}
+	if (sharedParent != null) {
+	    break;
+	}
+    }
+
+    return sharedParent;
+}
+
+function getSiblingPosition(sharedSiblings,elem)
+{
+    var elemParents = getElemParents(elem,true);
+
+    var siblingPos = -1;
+
+    for (var sb=0; sb<sharedSiblings.length; sb++) {
+	var currSibling = sharedSiblings[sb];
+	for (var el=0; el<elemParents.length; el++) {
+	    var currElemParent = elemParents[el];
+	    if (currElemParent==currSibling) {
+		siblingPos = sb;
+		break;
+	    }
+	}
+	if (siblingPos>0) {
+	    break;
+	}
+    }
+
+    return siblingPos;
+}
+
+
+var rangedElemsHistory_ = new Array();
+var sharedParentElemHistory_ = new Array();
+
+
+function calcRangedElems(sharedParent,startElem,endElem) 
+{
+    var rangedElems = new Array();
+    
+    // if get to here, then there is a non-trivial range to work out
+    var sharedSiblings = sharedParent.childNodes;
+
+    var startSiblingPos = getSiblingPosition(sharedSiblings,startElem);
+    var endSiblingPos   = getSiblingPosition(sharedSiblings,endElem);
+
+    for (var sb=startSiblingPos; sb<=endSiblingPos; sb++) {
+	rangedElems[rangedElems.length] = sharedSiblings[sb];
+    }
+
+
+    return rangedElems;
+}
+
+function zIndexRange()
+{
+    var minZ=null;
+    var maxZ=null;
+
+    var elems = document.getElementsByTagName("*");
+
+    for (var e = 0; e < elems.length; e++) {
+	var z = elems[e].style.zIndex;
+	if (z) {
+	    if (minZ!=null) {
+		if (z < minZ) { minZ = z; }
+	    }
+	    else {
+		minZ = z;
+	    }
+
+	    if (maxZ!=null) {
+		if (z > maxZ) { maxZ = z; }	    
+	    }
+	    else {
+		maxZ = z;
+	    }
+	}
+
+    }
+
+    return { minZ: minZ, maxZ: maxZ };
+}
+
+
+
+function csnInit()
+{
+    //alert("The Inspector");
+
+    if (csnInitialized) return;
+    if (window!=window.top) return; // child iFrame 
+
+    csnInitialized = true;
+
+    var csnCheck = document.getElementById('ComputerSaysNo');
+    if (csnCheck!=null) return;
+
+
+    var body = document.body;
+
+    zRange = zIndexRange();
+    var minZ = zRange['minZ'];
+    var maxZ = zRange['maxZ'];
+
+    var inspectBaseZindex = (minZ==null) ? -1 : "inherit" ;
+    var inspectHighlightZindex = (maxZ==null) ? 1000 : parseInt(maxZ)+1000;
+
+    //console.log("base zindex: " + inspectBaseZindex);
+    //console.log("highlight zindex: " + inspectHighlightZindex);
+
+    // wrap original body content in a div tag so any 
+    // absolute position the document uses will be relatative
+    // to its new position (once the CSN toolbar added in)
+
+    var orig_child_len = body.childNodes.length;
+
+    var beyondToolbarDiv = document.createElement('div');
+    var beyondToolbarDivStyle = "position: relative; left: 0px; top: 0px;";
+    beyondToolbarDiv.setAttribute('style',beyondToolbarDivStyle);
+    body.insertBefore(beyondToolbarDiv,body.firstChild);
+
+    for (var i=0; i<orig_child_len; i++) {
+	// always position '1' as we then remove the item
+	var childNode = body.childNodes[1];
+	body.removeChild(childNode);
+	beyondToolbarDiv.appendChild(childNode);
+    }
+
+
+    // Build up and add in the CSN Tool Bar
+
+    var csnDivStyle = "position: relative; left: 0px; top: 0px;";
+    csnDivStyle += " width: 100%;";
+
+    var csnDiv = document.createElement('div');
+    csnDiv.setAttribute('id','ComputerSaysNo');
+    csnDiv.setAttribute('style',csnDivStyle);
+
+    // Table for Logo
+    var csnBgImage = 'background="' + csnImage + '"';
+    var csmBgImage = 'background="' + csmImage + '"';
+    var csyBgImage = 'background="' + csyImage + '"';
+
+    var bgImageStyle = 'style="background-position: center; background-repeat: no-repeat;" ';
+
+    var csnTdImage = '<td width="33%" ' + bgImageStyle + csnBgImage + ' style="background-repeat: no-repeat;"></td>';
+    var csmTdImage = '<td width="33%" ' + bgImageStyle + csmBgImage + ' style="background-repeat: no-repeat;"></td>';
+    var csyTdImage = '<td width="33%" ' + bgImageStyle + csyBgImage + ' style="background-repeat: no-repeat;"></td>';
+
+    var csnLogo = '<table bgcolor="black" width="100%" height="27"><tr>' + csnTdImage + csmTdImage + csyTdImage + '</tr></table>';
+
+    // Table for actions
+    var csnContent = '<tr style="color: white;">';
+
+    var tick = '<span style="visibility: hidden;">&#10003;&nbsp;</span>';
+
+    var accentFoldOptions = '<ul id="accentFoldOptions" class="csnOption" style="display: none;">'
+    accentFoldOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    accentFoldOptions +=    '  <li><p id="accentFoldCancel" class="csnOption" href="#">Cancel</p></li>';
+    accentFoldOptions +=    '</ul>';
+
+    var punctFoldOptions = '<ul id="punctFoldOptions" class="csnOption" style="display: none;">'
+    punctFoldOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    punctFoldOptions +=    '  <li><p id="punctFoldCancel" class="csnOption" href="#">Cancel</p></li>';
+    punctFoldOptions +=    '</ul>';
+
+    var firstnameFoldOptions = '<ul id="firstnameFoldOptions" class="csnOption" style="display: none;">'
+    firstnameFoldOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    firstnameFoldOptions +=    '  <li><p id="firstnameFullFoldButton" class="csnOption">'   +tick+'Firstname</p></li>';
+    firstnameFoldOptions +=    '  <li><p id="firstnameInitialFoldButton" class="csnOption">'+tick+'Only initial</p></li>';
+    firstnameFoldOptions +=    '  <li><p id="firstnameFoldCancel" class="csnOption">Cancel</p></li>';
+    firstnameFoldOptions +=    '</ul>';
+
+    var NAOptions = '<ul id="NAOptions" class="csnOption" style="display: none;">'
+    NAOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    NAOptions +=    '  <li><p id="NACancel" class="csnOption" href="#">Cancel</p></li>';
+    NAOptions +=    '</ul>';
+
+    var editOptions = '<ul id="editOptions" class="csnOption" style="display: none;">'
+    editOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    //editOptions +=    '  <li><p id="editInteractiveButton" class="csnOption">'     +tick+'Interacitve click/drag</p></li>';
+    editOptions +=    '  <li><p id="editPreviousButton" class="csnOptionDisabled">Previous region</p></li>';
+    editOptions +=    '  <li><p id="editCancel" class="csnOption" href="#">Cancel</p></li>';
+    editOptions +=    '</ul>';
+
+    var sortOptions = '<ul id="sortOptions" class="csnOption" style="display: none;">'
+    sortOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    //sortOptions +=    '  <li><p id="sortInteractiveButton" class="csnOption">'     +tick+'Interacitve click/drag</p></li>';
+    sortOptions +=    '  <li><p id="sortPreviousButton" class="csnOptionDisabled">Previous region</p></li>';
+    sortOptions +=    '  <li><p id="sortCancel" class="csnOption" href="#">Cancel</p></li>';
+    sortOptions +=    '</ul>';
+
+    var mergeOptions = '<ul id="mergeOptions" class="csnOption" style="display: none;">'
+    mergeOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    //mergeOptions +=    '  <li><p id="mergeInteractiveButton" class="csnOption">'     +tick+'Interacitve click/drag</p></li>';
+    mergeOptions +=    '  <li><p id="mergePreviousButton" class="csnOptionDisabled">Previous region</p></li>';
+    mergeOptions +=    '  <li><p id="mergeCancel" class="csnOption" href="#">Cancel</p></li>';
+    mergeOptions +=    '</ul>';
+
+    var deleteOptions = '<ul id="deleteOptions" class="csnOption" style="display: none;">'
+    deleteOptions +=    '  <li><p class="csnOptionText"><i>[Click/drag region]</i></p></li>';
+    deleteOptions +=    '  <li><p id="deletePreviousButton" class="csnOptionDisabled">Previous region</p></li>';
+    deleteOptions +=    '  <li><p id="deleteCancel" class="csnOption" href="#">Cancel</p></li>';
+    deleteOptions +=    '</ul>';
+
+
+    var csnContentStyle = "border: 2px inset white; background-color: rgb(25,25,25);";
+    //var csnContentStyle = "background-color: rgb(20,20,20);";
+
+    csnContent += '<td valign="top"><table width="100%" style="'+csnContentStyle+'"><tr>';
+    csnContent += '<td width="85" valign="top"><p id="accentFoldButton"    class="csnAction csnActionHighlight" href="#">Accent ...</p>'+accentFoldOptions+'</td>';
+    csnContent += '<td width="85" valign="top"><p id="punctFoldButton"     class="csnAction csnActionHighlight" href="#">Punctuation ...</p>'+punctFoldOptions+'</td>';
+    csnContent += '<td width="85" valign="top"><p id="firstnameFoldButton" class="csnAction csnActionHighlight" href="#">Firstname ...</p>'+firstnameFoldOptions+'</td>';
+    csnContent += '<td width="85" valign="top"><p id="NAButton"           class="csnAction csnActionHighlight" href="#">Name Authority ...</p>'+NAOptions+'</td>';
+    csnContent += '</tr></table></td>';
+
+
+    csnContent += '<td valign="top"><table width="100%" style="'+csnContentStyle+'"><tr>';
+    csnContent += '<td width="70" valign="top"><p id="editButton"          class="csnAction csnActionHighlight" href="#">Edit ...</p>'+editOptions+'</td>';
+    csnContent += '<td width="70" valign="top"><p id="sortButton"          class="csnAction csnActionHighlight" href="#">Sort same ...</p>'+sortOptions+'</td>';
+    csnContent += '<td width="70" valign="top"><p id="mergeButton"         class="csnAction csnActionHighlight" href="#">Merge ...</p>'+mergeOptions+'</td>';
+
+    // Delete and Undo
+    csnContent += '<td width="40" valign="top"><p id="deleteButton" class="csnAction csnActionHighlight">Delete ...</p>'+deleteOptions+'</td>';
+    csnContent += '<td width="40" valign="top"><p id="undoButton" class="csnAction csnActionHighlight">Undo</p></td>';
+
+
+    csnContent += '</tr></table></td>';
+
+
+
+
+
+    // Fold or Expand radio buttons
+    csnContent += '<td valign="top" width="220">';
+    csnContent += '<table width="100%" style="'+csnContentStyle+'"><tr>';
+    csnContent += '  <td><p class="csnAction">Fold:</p></td>';
+    csnContent += '  <td><input id="foldRadioButton" type="radio" name="csnFoldOrExpand" value="fold" checked></td>';
+    csnContent += '  <td><p class="csnAction">Expand:</p></td>';
+    csnContent += '  <td><input id="expandRadioButton" type="radio" name="csnFoldOrExpand" value="expand"></td>';
+    csnContent += '</tr></table>';
+    csnContent += '</td>';
+
+    //csnContent += '<td width="15%" valign="top"><p id="CsnOnTopButton"      class="csnAction" href="#">Toolbar on top</p></td>';
+    csnContent += '</tr>';
+
+    var csnDisplay = '<style>';
+    csnDisplay += 'p.csnAction,span.csnAction { text-decoration: none; color: white; ';
+    csnDisplay += ' margin: 2px; border: 0px; padding: 1px; ';
+    csnDisplay += ' font-family: arial; font-size: 11pt;  font-weight: bold; }';
+    csnDisplay += 'p.csnActionHighlight:hover { color: green;  }';
+    csnDisplay += 'p.csnOption,p.csnOptionText { text-decoration: none; color: white; ';
+    csnDisplay += ' margin: 2px; border: 0px; padding: 1px; ';
+    csnDisplay += ' font-family: arial; font-size: 10pt; }';
+    csnDisplay += 'p.csnOption:hover { color: green;  }';
+    csnDisplay += 'ul.csnOption { list-style-type: square; line-height: 100%; margin: 0px 0px 0px 20px; padding: 0px 0px 2px 0px;}';
+    csnDisplay += 'p.csnOptionDisabled { text-decoration: none; color: gray; ';
+    csnDisplay += ' margin: 2px; border: 0px; padding: 1px; ';
+    csnDisplay += ' font-family: arial; font-size: 10pt; }';
+    csnDisplay += 'h3.csnPreLookup { background-color: black; color: white; ';
+    csnDisplay += '  padding: 4px; }';
+    csnDisplay += 'p.csnPreLookup { background-color: white; color: black; ';
+    csnDisplay += '  padding: 2px 4px 2px 4px; } ';
+    csnDisplay += '</style>';
+
+    csnDisplay += '<table bgcolor="black" width="100%">' + csnContent + '</table>';
+
+    var csnCode = '<script type="text/javascript">'+multiSearch + continueMultiSearch + resizeFrame+'</script>';
+
+   // alert("setting multiSearch");
+
+    //csnDiv.innerHTML = csnLogo + csnDisplay + csnCode;
+    //body.insertBefore(csnDiv,body.firstChild);
+
+
+    csnDiv.innerHTML = csnLogo + csnDisplay ;
+    body.insertBefore(csnDiv,body.firstChild);
+
+    var csnScript = document.createElement('script');
+    csnScript.setAttribute('type',    'text/javascript');
+    csnScript.setAttribute('charset', 'UTF-8');
+    csnScript.innerHTML = multiSearch + continueMultiSearch + resizeFrame;
+    document.getElementsByTagName('head')[0].appendChild(csnScript);
+
+
+    var accentFoldButton = document.getElementById("accentFoldButton");
+    var accentFoldCancel = document.getElementById("accentFoldCancel");
+    accentFoldButton.addEventListener('click', activateAccentFold, true);
+    accentFoldCancel.addEventListener('click', cancelModeOption, true);
+
+    var punctFoldButton      = document.getElementById("punctFoldButton");
+    var punctFoldCancel      = document.getElementById("punctFoldCancel");
+    punctFoldButton.addEventListener('click', activatePunctFold, true);
+    punctFoldCancel.addEventListener('click', cancelModeOption, true);
+
+    var firstnameFoldButton         = document.getElementById("firstnameFoldButton");
+    var firstnameFullFoldButton     = document.getElementById("firstnameFullFoldButton");
+    var firstnameInitialFoldButton  = document.getElementById("firstnameInitialFoldButton");
+    var firstnameFoldCancel         = document.getElementById("firstnameFoldCancel");
+    firstnameFoldButton.addEventListener('click', activateFirstnameFold, true);
+    firstnameFullFoldButton.addEventListener('click', activateFirstnameFullFold, true);
+    firstnameInitialFoldButton.addEventListener('click', activateFirstnameInitialFold, true);
+    firstnameFoldCancel.addEventListener('click', cancelModeOption, true);
+    firstnameFullFoldButton.firstChild.style.visibility = "visible";
+    firstnameFullFoldButton.firstChild.style.color = "green";
+
+    var NAButton              = document.getElementById("NAButton");
+    var NACancel              = document.getElementById("NACancel");
+    NAButton.addEventListener('click', activateNA, true);
+    NACancel.addEventListener('click', cancelModeOption, true);
+
+    var editButton             = document.getElementById("editButton");
+    var editCancel             = document.getElementById("editCancel");
+    editButton.addEventListener('click', activateEdit, true);
+    editCancel.addEventListener('click', cancelModeOption, true);
+
+    var sortButton             = document.getElementById("sortButton");
+    var sortCancel             = document.getElementById("sortCancel");
+    sortButton.addEventListener('click', activateSort, true);
+    sortCancel.addEventListener('click', cancelModeOption, true);
+
+    var mergeButton            = document.getElementById("mergeButton");
+    var mergeCancel            = document.getElementById("mergeCancel");
+    mergeButton.addEventListener('click', activateMerge, true);
+    mergeCancel.addEventListener('click', cancelModeOption, true);
+
+    var deleteButton            = document.getElementById("deleteButton");
+    var deleteCancel            = document.getElementById("deleteCancel");
+    deleteButton.addEventListener('click', activateDelete, true);
+    deleteCancel.addEventListener('click', cancelModeOption, true);
+
+    var undoButton            = document.getElementById("undoButton");
+    undoButton.addEventListener('click', performUndo, true);
+
+
+    var foldRadioButton     = document.getElementById("foldRadioButton");
+    var expandRadioButton   = document.getElementById("expandRadioButton");
+    foldRadioButton.addEventListener('click', setFoldMode, true);
+    expandRadioButton.addEventListener('click', setExpandMode, true);
+
+    //var CsnOnTopButton       = document.getElementById("CsnOnTopButton");
+    //CsnOnTopButton.addEventListener('click', putCsnToolbarOnTop, true);
+
+    // ------------
+    // 4 div for rect-outline, for inspection highlighting
+    // ------------
+    var csnInspectDiv = document.createElement('div');
+    csnInspectDiv.setAttribute('id','InspectDiv');
+
+    var csnOffScreenStyle = 'position: fixed; left: 0px; top: 0px;';
+    csnOffScreenStyle += ' visibility: visible;';
+
+    var inspectBoxStyle = "width: 2px; height: 2px;";
+    inspectBoxStyle += "z-index: " + inspectHighlightZindex + "; ";
+    inspectBoxStyle += "background-color: rgba(0,128,0,1.0);";
+    inspectBoxStyle += "position: absolute;";
+
+    var inspectBoxAttr = ' style="'+inspectBoxStyle+'"';
+
+    var csnInspectRect = '<div style="'+csnOffScreenStyle+'">\n';
+    csnInspectRect += '  <div id="inspectBoxL" '+inspectBoxAttr+'></div>\n';
+    csnInspectRect += '  <div id="inspectBoxR" '+inspectBoxAttr+'></div>\n';
+    csnInspectRect += '  <div id="inspectBoxT" '+inspectBoxAttr+'></div>\n';
+    csnInspectRect += '  <div id="inspectBoxB" '+inspectBoxAttr+'></div>\n';
+
+    var csnPreLookupStyle = "background-color: white; color: black;";
+    csnPreLookupStyle += " border: 2px solid black;";
+    csnPreLookupStyle += " min-width: 600px;";
+    csnPreLookupStyle += " z-index: " + inspectHighlightZindex + "; ";
+    csnPreLookupStyle += " position: absolute;";
+    csnPreLookupStyle += " visibility: hidden;";
+
+    csnInspectRect += '  <div id="preLookup" class="csnPreLookup" style="'+csnPreLookupStyle+'">\n';
+    //csnInspectRect += '    dasf fad adsffdsa sfda\n';
+    csnInspectRect += '  </div>\n';
+
+    csnInspectRect += '</div>\n';
+
+    csnInspectDiv.innerHTML = csnInspectRect;
+
+
+    body.insertBefore(csnInspectDiv,body.firstChild);
+
+    var preLookupDiv = document.getElementById("preLookup");
+    //preLookupDiv.addEventListener("mouseout",hidePreLookup,true);
+
+}
+
+
+
+var existingTimeoutId = null;
+
+
+function showPreLookup(ev)
+{
+    //console.log("*** supressing show prelookup");
+    //return;
+
+    var targetElem = ev.target;
+    if (elementPartOfPreLookup(targetElem)) {
+	// no need to go any further
+	return;
+    }
+
+    // get mouse cursor
+    var mx = ev.pageX - window.pageXOffset; 
+    var my = ev.pageY - window.pageYOffset;
+    
+
+    var author_pack = generateAuthorPack(targetElem);
+    var author_name = author_pack.name;
+
+
+    var fullMessage = "";
+    if (csnMode == "NA") {
+	var NAmessage ='<h3 class="csnPreLookup">Name Authority Lookup</h3>';
+	NAmessage += '<p id="prelookupNACount" class="csnPreLookup">Number of occurrences of &quot;'
+	    +author_name+'&quot;:\n';
+	NAmessage += '<div id="prelookupNAList">Pending ...</div>\n';
+
+	fullMessage += NAmessage;
+    }
+
+    // Crowd Sourcing
+    var CSmessage = '<h3 class="csnPreLookup">Crowdsourcing Lookup</h3>';
+    CSmessage += '<p id="prelookupCSCount" class="csnPreLookup">Number of remappings of &quot;'
+	+author_name+'&quot;:\n';
+    CSmessage += '<div id="prelookupCSList">Pending ...</div>\n';
+
+    fullMessage += CSmessage;
+
+    var preLookupDiv = document.getElementById("preLookup");
+    preLookupDiv.style.left = (mx-30) + "px";
+    preLookupDiv.style.top = (my-30) + "px";
+    preLookupDiv.innerHTML = fullMessage;
+
+    if (csnMode == "NA") {
+	var naTargetElem = ev.target;
+	var naElemClone = naTargetElem.cloneNode(true);
+
+	async_named_authority_srw(naElemClone,count_named_authority_canonical);
+    }
+
+    var csTargetElem = ev.target;
+    var csElemClone = csTargetElem.cloneNode(true);
+    
+    async_crowdsource_greenstone(csElemClone,count_crowdsource_canonical);
+
+    // ensure rect-box is visibile
+    preLookupDiv.style.visibility = "visible";
+
+}
+
+
+function hidePreLookup(ev)
+{
+    var preLookupDiv = document.getElementById("preLookup");
+    preLookupDiv.style.visibility = "hidden";
+    
+    //console.log("Mouse out inhidPreLookup");
+
+    if (existingTimeoutId!=null) {
+	clearTimeout(existingTimeoutId);
+    }
+
+    existingTimeoutId = null;
+}
+
+
+function csnDeHighlight(ev)
+{
+    if (!inspectorActive) return false;
+
+    var targetElem = ev.target;
+
+    // check to see if in preLookup popup
+    //var targetElemId = targetElem.getAttribute("id");
+    //if ((targetElemId) && (targetElemId == "preLookup")) {
+
+    if (elementPartOfPreLookup(targetElem)) {
+	//console.log("Mouse out in DeHighlight: part of CSN, hiding");
+
+	if (existingTimeoutId!=null) {
+	    clearTimeout(existingTimeoutId);
+	}
+	// hide preLookup if no new mouse-over event *within* the
+	// div tag occurs in the next 200 ms
+	existingTimeoutId = setTimeout(hidePreLookup, 200, ev); 
+	
+	return false;
+    }
+    
+    ev.preventDefault();
+    ev.stopPropagation();
+
+    var elems;
+    if (inspectorDragging) {
+	var selected_elems_len = inspectorSelectedElems.length;
+	if (selected_elems_len>1) {
+	    // Remove this elem
+	    var targetElem = ev.target;
+	    for (var i=0; i<selected_elems_len; i++) {
+		if (inspectorSelectedElems[i] == targetElem) {
+		    // remove element from array
+		    inspectorSelectedElems.splice(i,1);
+		    break;
+		}
+	    }
+	}
+    }
+}
+
+function csnHighlight(ev)
+{
+    if (!inspectorActive) {
+	// look to see if on-hover pre-lookup should be displayed
+	return false;
+    }
+
+
+    ev.preventDefault();
+    ev.stopPropagation();
+
+    var targetElem = ev.target;
+    if (elementPartOfCsn(targetElem)) {
+	// consume this event if part of the CSN toolbar
+	// and hide any PreLookup popup is present or on timer
+
+	hidePreLookup(ev);
+	return false;
+    }
+
+    // Consider showing preLookup (if remain still for 2 further seconds)
+    var preLookupDiv = document.getElementById("preLookup");
+    if (preLookupDiv.style.visibility == "hidden") {
+	if (existingTimeoutId!=null) {
+	    clearTimeout(existingTimeoutId);
+	}
+	
+	existingTimeoutId = setTimeout(showPreLookup, 2000, ev); 
+    }
+    else {
+	// pop-up currently visible
+	if (elementPartOfPreLookup(targetElem)) {
+	    // a hide event might be in the works, but it we've nearly
+	    // instantaneously got a new mouse-in event that's in the
+	    // same pop-up div tag, so cancel the hide event
+
+	    if (existingTimeoutId!=null) {
+		clearTimeout(existingTimeoutId);
+		existingTimeoutId = null;
+	    }
+	}
+	return false;
+    }
+
+    var elems;
+    if (inspectorDragging) {
+	// append this elem
+
+	appendIfUniq(targetElem);
+
+	elems = inspectorSelectedElems;
+    }
+    else {
+	elems = [ ev.target ];
+    }
+
+    // work out union off all rects
+    var union_rect_xl;
+    var union_rect_xr;
+    var union_rect_yt;
+    var union_rect_yb;
+
+    for (var i=0; i<elems.length; i++) {
+	var elem = elems[i];
+	var rect = elem.getBoundingClientRect();
+
+	var rect_xl = rect.left;
+	var rect_xr = rect.right;
+	var rect_yt = rect.top;
+	var rect_yb = rect.bottom;
+
+	var rect_width = rect_xr - rect_xl +1;
+	var rect_height = rect_yb - rect_yt +1;
+
+	if ((rect_width<=3) || (rect_height<=3)) {
+	    continue;
+	}
+	
+	if ((union_rect_xl==null) || (rect_xl<union_rect_xl)) {
+	    union_rect_xl = rect_xl;
+	}
+	if ((union_rect_xr==null) || (rect_xr>union_rect_xr)) {
+	    union_rect_xr = rect_xr;
+	}
+
+	if ((union_rect_yt==null) || (rect_yt<union_rect_yt)) {
+	    union_rect_yt = rect_yt;
+	}
+	if ((union_rect_yb==null) || (rect_yb>union_rect_yb)) {
+	    union_rect_yb = rect_yb;
+	}
+    }
+
+    var rect_pp = "(" + rect_xl + "," + rect_yt + ") ";
+    rect_pp += rect_width + " x " + rect_height;
+    //console.log("Mouseover event:" + rect_pp);
+    
+    if (!csnInitialized) {
+	console.log("... but Computer Says No not initialized");
+	return true;
+    }
+
+    // Make sure we've got a valid rect
+    if ((union_rect_xl==null) || (union_rect_xr==null) 
+	|| (union_rect_yt==null) || (union_rect_yb==null)) {
+	return true;
+    }
+
+    // Adjust values to ensure they fall out side where mouse
+    // focus is
+
+    union_rect_xl -= 2;
+    union_rect_xr += 1;
+    union_rect_yt -= 2;
+    union_rect_yb += 1;
+
+    var union_rect_width  = union_rect_xr - union_rect_xl +2;
+    var union_rect_height = union_rect_yb - union_rect_yt +2;
+
+
+    var inspectboxL = document.getElementById("inspectBoxL");
+    inspectboxL.style.left = union_rect_xl + "px";
+    inspectboxL.style.top = union_rect_yt + "px";
+    inspectboxL.style.width = "2px";
+    inspectboxL.style.height = union_rect_height + "px";
+    
+    var inspectboxR = document.getElementById("inspectBoxR");
+    inspectboxR.style.left = union_rect_xr + "px";
+    inspectboxR.style.top = union_rect_yt + "px";
+    inspectboxR.style.width = "2px";
+    inspectboxR.style.height = union_rect_height + "px";
+    
+    var inspectboxT = document.getElementById("inspectBoxT");
+    inspectboxT.style.left = union_rect_xl + "px";
+    inspectboxT.style.top = union_rect_yt + "px";
+    inspectboxT.style.width = union_rect_width + "px";
+    inspectboxT.style.height = "2px";
+    
+    var inspectboxB = document.getElementById("inspectBoxB");
+    inspectboxB.style.left = union_rect_xl + "px";
+    inspectboxB.style.top = union_rect_yb + "px";
+    inspectboxB.style.width = union_rect_width + "px";
+    inspectboxB.style.height = "2px";
+	
+    // ensure rect-box is visibile
+    inspectboxL.style.visibility = "visible";
+    inspectboxR.style.visibility = "visible";
+    inspectboxT.style.visibility = "visible";
+    inspectboxB.style.visibility = "visible";
+
+    return true;
+}
+
+
+function csnStartDragging(ev)
+{
+    var targetElem = ev.target;
+
+    if (elementPartOfCsn(targetElem)) {
+	// allow this event to propagate
+    	return false;
+    }
+
+    if (inspectorActive) {
+	ev.preventDefault();
+	ev.stopPropagation();
+
+	if (!inspectorDragging) {
+	    inspectorDragging = true;
+	    inspectorSelectedElems = [ev.target];
+	}
+	else {
+	    // append this elem
+	    // can this situation actually occur?
+	    inspectorSelectedElems[inspectorSelectedElems.length] = ev.target;
+	}
+
+	return true;
+    }
+    else {
+	return false;
+    }
+}
+
+function csnStopDragging(ev)
+{
+    var targetElem = ev.target;
+    if (elementPartOfCsn(targetElem)) {
+	// allow this event to propagate
+	return false;
+    }
+    
+    //if (inspectorActive) {
+    if ((inspectorActive) && (inspectorDragging)) {
+	ev.preventDefault();
+	ev.stopPropagation();
+		
+	appendIfUniq(ev.target);
+
+	var ise_len = inspectorSelectedElems.length;
+	var startElem = inspectorSelectedElems[0];
+	var endElem   = (ise_len==1) ? startElem : inspectorSelectedElems[1];
+	var sharedParentElem = calcSharedElemParent(startElem,endElem);
+
+	if (sharedParentElem!=null) {
+
+	    var rangedElems = calcRangedElems(sharedParentElem,startElem,endElem);
+	    if (rangedElemsHistory_.length==0) {
+		// first time, establish as the base
+		sharedParentElemHistory_[0] = sharedParentElem;
+		rangedElemsHistory_[0] = rangedElems;
+	    }
+
+	    if (rangedElems.length>0) {
+		// turn from grayed out deactive -> active
+		var editPreviousButton     = document.getElementById("editPreviousButton");
+		editPreviousButton.className = "csnOption";
+		editPreviousButton.addEventListener('click', performPreviousRangedElemsAction, true);
+		
+		var sortPreviousButton     = document.getElementById("sortPreviousButton");
+		sortPreviousButton.className = "csnOption";
+		sortPreviousButton.addEventListener('click', performPreviousRangedElemsAction, true);
+		
+		var mergePreviousButton    = document.getElementById("mergePreviousButton");
+		mergePreviousButton.className = "csnOption";
+		mergePreviousButton.addEventListener('click', performPreviousRangedElemsAction, true);
+
+		var deletePreviousButton    = document.getElementById("deletePreviousButton");
+		deletePreviousButton.className = "csnOption";
+		deletePreviousButton.addEventListener('click', performPreviousRangedElemsAction, true);
+	    }
+
+	    performModeAction(sharedParentElem,rangedElems);
+	}
+	else {
+	    alert("Invalid Selection");
+	}
+
+
+
+	var inspectboxL = document.getElementById("inspectBoxL");
+	var inspectboxR = document.getElementById("inspectBoxR");
+	var inspectboxT = document.getElementById("inspectBoxT");
+	var inspectboxB = document.getElementById("inspectBoxB");
+
+	inspectboxL.style.visibility = "hidden";
+	inspectboxR.style.visibility = "hidden";
+	inspectboxT.style.visibility = "hidden";
+	inspectboxB.style.visibility = "hidden";
+
+	inspectorActive = false;
+	inspectorDragging = false;
+	inspectorIgnoreSingleClick = true;
+
+	cancelModeOption();
+
+	return true;
+    }
+    else {
+	return false;
+    }
+}
+
+function csnSingleClick(ev)
+{
+    var targetElem = ev.target;
+    if (elementPartOfCsn(targetElem)) {
+	// allow this event to propagate
+	return false;
+    }
+
+    if (inspectorIgnoreSingleClick) {
+	// Stop any further events from happening, such as a click through
+	// on a hyperlink
+	ev.preventDefault();
+	ev.stopPropagation();
+
+	inspectorActive = false;
+	inspectorDragging = false;
+	inspectorIgnoreSingleClick = false;
+
+	return true;
+    }
+    else {
+	return false;
+    }
+}
+
+
+
+function csnKeyPress(ev)
+{
+    var targetElem = ev.target;
+
+    //console.log("*** in csnKeyPress");
+
+    if (ev.ctrlKey) {
+
+	var keyChar = ev.charCode;
+	var keyStr = String.fromCharCode(keyChar);
+
+	if (keyStr.toLowerCase() == "s") {
+	    ev.preventDefault();
+	    ev.stopPropagation();
+
+	    save_live_doc_html();
+	    
+	    return true;
+	}
+    }
+
+    // get to here, return false so event can propagate
+    return false;
+
+}
+
+
+
+function performModeAction(sharedParentElem,rangedElems)
+{
+    if (csnFoldOrExpand == "fold") {
+	if (csnMode == "merge") {
+	    mergeAuthors(sharedParentElem,rangedElems);
+	}
+	else if (csnMode == "delete") {
+	    deleteAuthors(sharedParentElem,rangedElems);
+	}
+	else if (csnMode == "edit") {
+	    editAuthors(sharedParentElem,rangedElems);
+	}
+	else if (csnMode == "NA") {
+	    naCanonicalAuthors(sharedParentElem,rangedElems);
+	}
+	else {
+	    analyzeAuthors(sharedParentElem,rangedElems);
+	}
+    }
+    else {
+	if (csnMode == "NA") {
+	    naAliasesAuthors(sharedParentElem,rangedElems);
+	}
+	
+    }
+}
+
+function performPreviousRangedElemsAction()
+{
+    var sharedParentElem = sharedParentElemHistory_[sharedParentElemHistory_.length-1];
+    var rangedElems = rangedElemsHistory_[rangedElemsHistory_.length-1];
+
+    //console.log("ranged elems length: " + rangedElems.length);
+    //console.log("shared parent elem: " + sharedParentElem);
+
+    performModeAction(sharedParentElem,rangedElems);
+
+    inspectorActive = false;
+    inspectorDragging = false;
+
+    cancelModeOption();
+
+    return true;
+}
+
+
+function _activateGeneral(id) 
+{
+    var options = document.getElementById(id);
+    options.style.display = "block";
+}
+
+function _cancelGeneral(id)
+{
+    var options = document.getElementById(id);
+    options.style.display = "none";
+
+    var inspectboxL = document.getElementById("inspectBoxL");
+    var inspectboxR = document.getElementById("inspectBoxR");
+    var inspectboxT = document.getElementById("inspectBoxT");
+    var inspectboxB = document.getElementById("inspectBoxB");
+    
+    inspectboxL.style.visibility = "hidden";
+    inspectboxR.style.visibility = "hidden";
+    inspectboxT.style.visibility = "hidden";
+    inspectboxB.style.visibility = "hidden";
+
+    var preLookupDiv = document.getElementById("preLookup");
+    hidePreLookup(null,preLookupDiv);
+
+    inspectorIgnoreSingleClick = true;
+}
+
+function activateAccentFold()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+
+    inspectorActive = true;
+    csnMode = "accentFold";
+
+    _activateGeneral("accentFoldOptions");
+
+    return true;
+}
+
+function activatePunctFold()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+
+    inspectorActive = true;
+    csnMode = "punctFold";
+
+    _activateGeneral("punctFoldOptions");
+
+    return true;
+}
+
+function activateFirstnameFold()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+
+    inspectorActive = true;
+    csnMode = "firstnameFold";
+    // let csnFirstnameMode remain whatever it is currently selected as
+
+    _activateGeneral("firstnameFoldOptions");
+
+    return true;
+}
+
+function activateFirstnameFullFold()
+{
+    csnFirstnameMode = "full";
+
+    var firstnameFullFoldButton = document.getElementById("firstnameFullFoldButton");
+    firstnameFullFoldButton.firstChild.style.visibility = "visible";
+    firstnameFullFoldButton.firstChild.style.color = "green";
+    var firstnameInitialFoldButton = document.getElementById("firstnameInitialFoldButton");
+    firstnameInitialFoldButton.firstChild.style.visibility = "hidden";
+    firstnameInitialFoldButton.firstChild.style.color = "white";
+
+    return activateFirstnameFold();
+}
+
+function activateFirstnameInitialFold()
+{
+    csnFirstnameMode = "initial";
+
+    var firstnameFullFoldButton = document.getElementById("firstnameFullFoldButton");
+    firstnameFullFoldButton.firstChild.style.visibility = "hidden";
+    firstnameFullFoldButton.firstChild.style.color = "white";
+    var firstnameInitialFoldButton = document.getElementById("firstnameInitialFoldButton");
+    firstnameInitialFoldButton.firstChild.style.visibility = "visible";
+    firstnameInitialFoldButton.firstChild.style.color = "green";
+
+    return activateFirstnameFold();
+}
+
+
+function activateNA()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+
+    inspectorActive = true;
+    csnMode = "NA";
+
+    _activateGeneral("NAOptions");
+
+    return true;
+}
+
+
+function activateEdit()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+
+    inspectorActive = true;
+    csnMode = "edit";
+    // let csnEditMode remain whatever it is currently selected as
+
+    _activateGeneral("editOptions");
+
+    if (!seaweedActivated) {
+	init_seaweed();
+	seaweedActivated = true;
+    }
+
+    return true;
+}
+
+function activateInteractiveEdit()
+{
+
+    csnEditMode = "interactive";
+
+    var editInteractiveButton = document.getElementById("editInteractiveButton");
+    editInteractiveButton.firstChild.style.visibility = "visible";
+    editInteractiveButton.firstChild.style.color = "green";
+    var editPreviousFoldButton = document.getElementById("editPreviousButton");
+    editPreviousFoldButton.firstChild.style.visibility = "hidden";
+    editPreviousFoldButton.firstChild.style.color = "white";
+
+    return activateEdit();
+}
+
+function activatePreviousEdit()
+{
+
+    csnEditMode = "previous";
+
+    var editInteractiveButton = document.getElementById("editInteractiveButton");
+    editInteractiveButton.firstChild.style.visibility = "hidden";
+    editInteractiveButton.firstChild.style.color = "white";
+    var editPreviousFoldButton = document.getElementById("editPreviousButton");
+    editPreviousFoldButton.firstChild.style.visibility = "visible";
+    editPreviousFoldButton.firstChild.style.color = "green";
+
+    return activateEdit();
+}
+
+
+
+function activateSort()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+    inspectorActive = true;
+    csnMode = "sort";
+
+    _activateGeneral("sortOptions");
+
+    return true;
+}
+
+function activateInteractiveSort()
+{
+    csnSortMode = "interactive";
+
+    var sortInteractiveButton = document.getElementById("sortInteractiveButton");
+    sortInteractiveButton.firstChild.style.visibility = "visible";
+    sortInteractiveButton.firstChild.style.color = "green";
+    var sortPreviousFoldButton = document.getElementById("sortPreviousButton");
+    sortPreviousFoldButton.firstChild.style.visibility = "hidden";
+    sortPreviousFoldButton.firstChild.style.color = "white";
+
+    return activateSort();
+}
+
+function activatePreviousSort()
+{
+    csnSortMode = "previous";
+
+    var sortInteractiveButton = document.getElementById("sortInteractiveButton");
+    sortInteractiveButton.firstChild.style.visibility = "hidden";
+    sortInteractiveButton.firstChild.style.color = "white";
+    var sortPreviousFoldButton = document.getElementById("sortPreviousButton");
+    sortPreviousFoldButton.firstChild.style.visibility = "visible";
+    sortPreviousFoldButton.firstChild.style.color = "green";
+
+    return activateSort();
+
+}
+
+
+function activateMerge()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+    inspectorActive = true;
+    csnMode = "merge";
+
+    _activateGeneral("mergeOptions");
+
+    return true;
+}
+
+
+function activateInteractiveMerge()
+{
+    csnMergeMode = "interactive";
+
+    var mergeInteractiveButton = document.getElementById("mergeInteractiveButton");
+    mergeInteractiveButton.firstChild.style.visibility = "visible";
+    mergeInteractiveButton.firstChild.style.color = "green";
+    var mergePreviousFoldButton = document.getElementById("mergePreviousButton");
+    mergePreviousFoldButton.firstChild.style.visibility = "hidden";
+    mergePreviousFoldButton.firstChild.style.color = "white";
+
+    return activateMerge();
+}
+
+function activatePreviousMerge()
+{
+
+    csnMergeMode = "previous";
+
+    var mergeInteractiveButton = document.getElementById("mergeInteractiveButton");
+    mergeInteractiveButton.firstChild.style.visibility = "hidden";
+    mergeInteractiveButton.firstChild.style.color = "white";
+    var mergePreviousFoldButton = document.getElementById("mergePreviousButton");
+    mergePreviousFoldButton.firstChild.style.visibility = "visible";
+    mergePreviousFoldButton.firstChild.style.color = "green";
+
+    return activateMerge();
+}
+
+
+function activateDelete()
+{
+    if (csnMode !=null) { cancelModeOption(); }
+    inspectorActive = true;
+    csnMode = "delete";
+
+    _activateGeneral("deleteOptions");
+
+    return true;
+}
+
+function activatePreviousDelete()
+{
+    csnDeleteMode = "previous";
+
+    var deleteInteractiveButton = document.getElementById("deleteInteractiveButton");
+    deleteInteractiveButton.firstChild.style.visibility = "hidden";
+    deleteInteractiveButton.firstChild.style.color = "white";
+    var deletePreviousFoldButton = document.getElementById("deletePreviousButton");
+    deletePreviousFoldButton.firstChild.style.visibility = "visible";
+    deletePreviousFoldButton.firstChild.style.color = "green";
+
+    return activateDelete();
+}
+
+function cancelModeOption()
+{
+    inspectorActive = false;
+
+    _cancelGeneral(csnMode + "Options");
+
+    csnMode = null;
+
+    return true;
+}
+
+
+function performUndo()
+{
+    alert("Not implemented yet");
+
+    return true;
+}
+
+
+
+function setFoldMode()
+{
+    csnFoldOrExpand = "fold";
+}
+
+function setExpandMode()
+{
+    csnFoldOrExpand = "expand";
+}
+
+
+function putCsnToolbarOnTop()
+{
+    var toolbar = document.getElementById("ComputerSaysNo");
+
+
+    if (!csnOnTop) {
+	var maxZ = zRange['maxZ'];
+	var toolbarZindex = (maxZ==null) ? 1000 :parseInt(maxZ);
+
+	toolbar.style.zIndex = toolbarZindex;
+	var toolbarActionButton = document.getElementById("CsnOnTopButton");
+	toolbarActionButton.innerHTML = "Toolbar underneath";
+	csnOnTop = true;
+    }
+    else {
+	toolbar.style.zIndex = "inherit";
+	var toolbarActionButton = document.getElementById("CsnOnTopButton");
+	toolbarActionButton.innerHTML = "Toolbar on top";
+	csnOnTop = false;
+    }
+
+    return true;
+}
+
+
+
+             //------------------------------------------//
+
+
+// Manipulate Lists of author names
+
+function generateAuthorPack(elem)
+{	
+    var elem_text  = getChildText(elem);
+
+    var author_name = elem_text;
+    author_name = author_name.replace(/^(.*)\(\d+\)?(.*)$/,"$1$2");
+    console.log("processing author: " + author_name);
+
+    var author_pack = { "name": author_name,				
+			"elem": elem };
+
+    // Dig out author count if there
+    var author_count = elem_text;
+    if (author_count.match(/^.*\((\d+)\).*$/)) {
+	author_count = author_count.replace(/^.*\((\d+)\).*$/,"$1");
+	//console.log("author count: " + author_count);
+	author_pack.count = author_count;
+    }
+
+    // Dig our key hyperlink if there
+    var author_link = getFirstChildHyperlink(elem);
+    if (author_link != null) {
+	var author_link_href  = author_link.href;
+
+	author_pack.link = author_link;
+	author_pack.href = author_link_href;
+    }
+
+    return author_pack;
+}
+
+
+function generateAuthorMap(rangedElems)
+{
+    console.log("generateAuthorMap");
+
+    var author_map = new Object();
+
+    //console.log("ranged len " + rangedElems.length);
+
+    for (var i=0; i<rangedElems.length; i++) {
+	var currElem = rangedElems[i];
+	//console.log("curr Elem" + currElem.nodeName);
+	
+	var author_pack = generateAuthorPack(currElem);
+
+	if ("link" in author_pack) {
+	    var author_name = author_pack.name;
+	    author_pack.folded_name = calcFoldedName(author_name);
+
+	    // enter pack as new entry in 'author_map' if new, or merge with alias list if not
+	    if (author_name in author_map) {
+		// treat as alias
+		//console.log("adding it as an alias for the existing " + author_name);
+
+		var fi_pack = author_map[author_name];
+		var alias = fi_pack.alias;
+		alias[alias.length] = author_pack;
+	    }
+	    else {
+		author_pack.alias = new Array();
+		author_map[author_name] = author_pack;
+	    }
+	}
+    }
+
+    return author_map;
+}
+
+function generateAuthorKeys(author_map)
+{
+
+    var author_keys = new Array();
+
+    for (var key in author_map) {
+	author_keys[author_keys.length] = key;
+    }
+
+    return author_keys;
+}
+
+function collapseAuthorMap(author_keys,author_map)
+{
+    // look for any folded names that are the same, and collapse them into one entry
+
+    for (var fi=0; fi<author_keys.length; fi++) {
+	var fi_key = author_keys[fi];
+
+	var fi_pack = author_map[fi_key];
+
+	// skip item has if already been merged with earlier name
+	if (!fi_pack) { continue; }
+
+	var fi_folded_name  = fi_pack.folded_name;
+	//console.log("fi folded name:" + fi_folded_name)
+	for (var mi=fi+1; mi<author_keys.length; mi++) {
+	    var mi_key = author_keys[mi];
+	    var mi_pack = author_map[mi_key];
+
+	    // skip if already been merged with an earlier name
+	    if (!mi_pack) { continue; }
+
+	    var mi_folded_name = mi_pack.folded_name;
+	    if (fi_folded_name == mi_folded_name) {
+		//console.log(mi_key + " matches " + fi_key);
+		var fi_alias_array = author_map[fi_key].alias;
+		fi_alias_array[fi_alias_array.length] = mi_pack;
+
+		// and concatenate any existing alias values we know of already
+		for (var ai=0; ai<mi_pack.alias.length; ai++) {
+		    fi_alias_array[fi_alias_array.length] = mi_pack.alias[ai];
+		}
+
+		delete author_map[mi_key];
+	    }	    
+	}
+    }
+
+    
+    var collapsed_author_keys = generateAuthorKeys(author_map);
+
+    return collapsed_author_keys;
+}
+
+function protectedInsertBefore(sharedParentElem,insertBefore,elem)
+{
+    if (insertBefore!=null) {
+	sharedParentElem.insertBefore(elem,insertBefore);
+    }
+    else {
+	sharedParentElem.appendChild(elem);
+    }
+}
+
+
+function explainTooltipFolding(author_pack)
+{
+    var elem = author_pack.elem;
+
+    if (author_pack.name != author_pack.folded_name) {
+
+	var elemTitle = elem.getAttribute("title");
+	if (elemTitle==null) {
+	    elemTitle="Originally: ";
+	}
+	else {
+	    if (elemTitle.match(/Originally: /)) {
+		elemTitle += "-> ";
+	    }
+	    else {
+		elemTitle += "; Originally";
+	    }
+	}
+    
+	//console.log("*** save mapping currently supressed");
+	save_mapping(author_pack.name,author_pack.folded_name);
+
+	elemTitle += author_pack.name;
+	elem.setAttribute("title",elemTitle);
+    }
+}
+
+
+
+function analyzeAuthors(sharedParentElem, rangedElems)
+{
+    console.log("analyzeAuthors");
+
+    var author_map  = generateAuthorMap(rangedElems);
+    var author_keys = generateAuthorKeys(author_map);
+
+    var collapsed_author_keys = collapseAuthorMap(author_keys,author_map);
+
+    var oldEndElem = rangedElems[rangedElems.length-1];
+    var insertBefore = oldEndElem.nextSibling;
+
+    var newRangedElems = new Array();
+
+    // Take out the current elements
+    for (var oi=0; oi<rangedElems.length; oi++) {
+	sharedParentElem.removeChild(rangedElems[oi]);
+    }
+
+    // add them back in again in their new order
+
+    for (var fi=0; fi<collapsed_author_keys.length; fi++) {
+	var fi_key = collapsed_author_keys[fi];
+	var fi_pack = author_map[fi_key];
+
+	//console.log("fi = " + fi);
+
+	explainTooltipFolding(fi_pack);
+	var fi_anchor_link = fi_pack.link;
+	fi_anchor_link.innerHTML = fi_pack.folded_name;
+
+	var fi_elem = fi_pack["elem"];
+	protectedInsertBefore(sharedParentElem,insertBefore,fi_elem);
+
+	newRangedElems[newRangedElems.length] = fi_elem;
+
+	var alias = fi_pack.alias;
+
+	for (var ai=0; ai<alias.length; ai++) {	    
+	    //console.log("  ai = " + ai);
+
+	    var ai_pack = alias[ai];
+	    explainTooltipFolding(ai_pack);
+
+	    var ai_anchor_link = ai_pack.link;
+	    ai_anchor_link.innerHTML = ai_pack.folded_name;
+
+	    var ai_elem = ai_pack["elem"];
+	    protectedInsertBefore(sharedParentElem,insertBefore,ai_elem);
+
+	    newRangedElems[newRangedElems.length] = ai_elem;
+
+	}
+    }   
+
+    sharedParentElemHistory_[sharedParentElemHistory_.length] = sharedParentElem;
+    rangedElemsHistory_[rangedElemsHistory_.length] = newRangedElems;
+
+}
+
+
+function removeSeaweedEditable(elems)
+{
+    for (var i=0; i<elems.length; i++) {
+	if (elems[i].nodeType == ELEMENT_NODE) {
+	    var elem = elems[i];
+	    classAtt = elem.getAttribute("class");
+	    if (classAtt != null) {
+		if (classAtt.match(/editable/)) {
+		    classAtt = classAtt.replace(/\s*editable/,"");
+		    elem.setAttribute("class",classAtt);
+		}
+	    }
+	}
+    }
+}
+
+
+function addSeaweedEditable(elems)
+{
+
+    for (var i=0; i<elems.length; i++) {
+	if (elems[i].nodeType == ELEMENT_NODE) {
+	    var elem = elems[i];
+
+	    classAtt = elem.getAttribute("class");
+	    if (classAtt != null) {
+		if (!classAtt.match(/editable/)) {
+		    if (classAtt != "") {
+			classAtt = " ";
+		    }
+		    classAtt += "editable";
+		    elem.setAttribute("class",classAtt);
+		}
+	    }
+	    else {
+		elem.setAttribute("class","editable");
+	    }
+
+	    var innerHTML = elem.innerHTML;
+	    innerHTML += '&nbsp;<img style="border: 0px;" src="'+pencilImage+'">';
+	    elem.innerHTML = innerHTML;
+	}
+    }
+
+    
+}
+
+function editAuthors(sharedParentElem, rangedElems)
+{
+    addSeaweedEditable(rangedElems);
+}
+
+
+function naCanonicalAuthors(sharedParentElem, rangedElems)
+{
+
+    // Asynchronously apply na_alias to each entry
+    for (var i=0; i<rangedElems.length; i++) {
+	async_named_authority_srw(rangedElems[i],process_named_authority_canonical);
+    }
+}
+
+function mergeAuthors(sharedParentElem, rangedElems)
+{
+    console.log("mergeAuthors");
+
+    var author_map  = generateAuthorMap(rangedElems);
+    var author_keys = generateAuthorKeys(author_map);
+
+    var collapsed_author_keys = collapseAuthorMap(author_keys,author_map);
+
+    var oldEndElem = rangedElems[rangedElems.length-1];
+    var insertBefore = oldEndElem.nextSibling;
+
+    var curr_elem = rangedElems[0];
+    var curr_author_pack = generateAuthorPack(curr_elem);
+    var curr_author_name = curr_author_pack.name;
+
+    var next_elem = rangedElems[1];
+    var ne_pos = 1;
+
+    var newRangedElems = [ curr_elem ];
+    
+    while (next_elem!=null) {
+
+	var next_author_pack = generateAuthorPack(next_elem);
+	var next_author_name = next_author_pack.name;
+
+	// if same
+	if (curr_author_name == next_author_name) {
+	    // combine counts (if present), collate href, and then del item
+	    var orig_author_count = curr_author_pack.count;
+	    //var orig_author_link  = curr_author_pack.link;
+	    var orig_elem = curr_elem;
+
+	    var combined_count = parseInt(orig_author_count);
+	    var combined_hrefs = [ "'"+curr_author_pack.href+"'" ];
+
+	    //var combined_mappings = [ ];
+
+	    // continue consuming elems until it no longer matches curr_author_name
+	    while (next_elem!=null) {
+		var next_author_count = next_author_pack.count;
+
+		combined_count += parseInt(next_author_count);
+		combined_hrefs[combined_hrefs.length] = "'" + next_author_pack.href + "'";
+		//combined_mappings[combined_mappings.length] = next_author.orig_name;
+
+		console.log("title = " + next_elem.title);
+
+		if (next_elem.title != "") {
+		    orig_elem.title += " + " + next_elem.title;
+		}
+
+		sharedParentElem.removeChild(next_elem);
+
+		ne_pos++;
+		next_elem = rangedElems[ne_pos];
+
+		if (next_elem!=null) {
+		    next_author_pack = generateAuthorPack(next_elem);
+		    next_author_name = next_author_pack.name;
+		    
+		    if (next_author_name != curr_author_name) {
+			break;
+		    }
+		}
+	    }
+	    var href_array_str = "[" + combined_hrefs.join(",") + "]";
+
+	    //alert("Merging " + curr_author_name + " (" + combined_count + ")");
+
+	    var onclick_str = "return multiSearch("+href_array_str+")";
+	    var curr_author_link = curr_author_pack.link;
+	    curr_author_link.setAttribute("onclick",onclick_str);
+
+	    curr_author_link.href = "#";
+
+	    orig_inner_html = curr_elem.innerHTML;
+	    var count_re = new RegExp("\\("+orig_author_count+"\\)","g");
+	    //console.log("re: " + count_re);
+	    //console.log("inner html = " + orig_inner_html);
+
+	    orig_inner_html = orig_inner_html.replace(count_re,"("+combined_count+")");
+	    curr_elem.innerHTML = orig_inner_html;
+
+	    console.log("multiSearch("+href_array_str+")");
+	}
+
+	if (next_elem!=null) {
+
+	    curr_elem = next_elem;
+	    curr_author_pack = next_author_pack;
+	    curr_author_name = next_author_name;
+
+	    newRangedElems[newRangedElems.length] = curr_elem;
+	    
+	    ne_pos++;
+	    next_elem = rangedElems[ne_pos];
+	}
+    }
+
+    console.log("*** done merge");
+
+    sharedParentElemHistory_[sharedParentElemHistory_.length] = sharedParentElem;
+    rangedElemsHistory_[rangedElemsHistory_.length] = newRangedElems;
+
+}
+
+
+function deleteAuthors(sharedParentElem, rangedElems)
+{
+
+    // Take out the current elements
+    for (var oi=0; oi<rangedElems.length; oi++) {
+	sharedParentElem.removeChild(rangedElems[oi]);
+    }
+
+
+    sharedParentElemHistory_[sharedParentElemHistory_.length] = sharedParentElem;
+    rangedElemsHistory_[rangedElemsHistory_.length] = [];
+
+}
+
+
+             //------------------------------------------//
+
+function naAliasesAuthors(sharedParentElem, rangedElems)
+{
+
+    // Asynchronously apply na_alias to each entry
+    for (var i=0; i<rangedElems.length; i++) {
+	async_named_authority_srw(rangedElems[i],process_named_authority_aliases);
+    }
+}
+
+             //------------------------------------------//
+
+// Multi search
+
+function multiSearch(hrefs) 
+{
+    var windowHeight = window.innerHeight;
+    var windowWidth = window.innerWidth;
+
+    var new_html = '<table width="100%" ><tr id="trSearchFrame" valign="top">';
+
+    if (hrefs.length==0) {
+	alert("An error occured in merging: multiSearch called with no hrefs");
+    }
+
+
+    var num_frames = hrefs.length;
+    var equal_width = (100.0/num_frames) + "%";
+
+    for (var i=0; i<num_frames; i++) {
+
+	var tdId = "tdSearchFrame"+i;
+
+	var frame_html = '<td width="'+equal_width+'" id="'+tdId+'"></td>';
+
+
+	new_html += frame_html;
+    }
+
+    new_html += '</tr></table>';
+
+
+    document.body.innerHTML = new_html;
+
+    for (var i=0; i<num_frames; i++) {
+	var tdFrameElem = document.getElementById("tdSearchFrame"+i);
+	//tdFrameElem.height = windowHeight-20;
+	tdFrameElem.height = 200;
+    }
+
+
+    for (var i=0; i<num_frames; i++) {
+
+	var tdFrameElem = document.getElementById("tdSearchFrame"+i);
+
+	var frameElem = document.createElement("iframe");
+	//frameElem.setAttribute("src",hrefs[i]);
+	frameElem.setAttribute("width","98%");
+	frameElem.setAttribute("height","100%");
+	//frameElem.setAttribute("frameborder","0");
+	//frameElem.setAttribute("scrolling","no");
+	frameElem.setAttribute("id","searchFrame"+i);
+	frameElem.setAttribute("onload",'resizeFrame("searchFrame'+i+'")');
+
+	frameElem.style.overflowX = "scroll";
+	frameElem.style.overflowY = "hidden";
+
+	tdFrameElem.appendChild(frameElem);
+    }
+
+
+    setTimeout(continueMultiSearch, 2000, hrefs); // 2 sec delay
+
+    return false;
+}
+
+
+function continueMultiSearch(hrefs)
+{
+    // console.log("href count in contineu multi search= " + hrefs.length);
+
+    var num_frames = hrefs.length;
+
+    for (var i=0; i<num_frames; i++) {
+
+	var frameElem = document.getElementById("searchFrame"+i);
+
+	frameElem.setAttribute("src",hrefs[i]);
+    }
+
+    
+    return false;
+}
+
+    
+function resizeFrame(fid) {
+ 
+  // if (fid == "childframe") return;
+
+  f = parent.document.getElementById(fid);
+
+  if (f!=null) {
+
+    var new_height = f.contentWindow.document.body.scrollHeight;
+    new_height += 60; // allow for scroll bar at bottom?
+
+    f.style.height = new_height + "px";
+
+  }	
+
+}
+
+
+
+             //------------------------------------------//
+
+// Author Folding and other types of manipulation
+
+function calcFoldedName(author_name)
+{
+    // calculated folded name based on current mode
+    // note: in many cases this is the same string as the key
+
+    var folded_name;
+
+    if (csnMode == "accentFold") {
+	folded_name = accent_fold(author_name);
+    }
+    else if (csnMode == "punctFold") {
+	folded_name = punct_fold(author_name);
+    }
+    else if (csnMode == "firstnameFold") {
+	if (csnFirstnameMode == "full") {
+	    folded_name = firstname_fold(author_name);
+	}
+	else {
+	    folded_name = firstname_initial_fold(author_name);
+	}
+    }
+    else if (csnMode == "sort") {
+	// trial op: allows items to be sorted as is
+	trim(author_name);
+	author_name = author_name.replace(/\s+/g," ");
+	folded_name = author_name;
+    }
+    else if (csnMode == "merge") {
+	// trial op: allows items to be sorted as is
+	folded_name = author_name;
+    }
+    else {
+	alert("Unrecognized mode: " + csnMode);
+	folded_name = author_name;
+    }
+    
+    if (author_name != folded_name) {
+	console.log("Folded name mapping: " + author_name + "->" + folded_name);
+    }
+
+    return folded_name;
+}
+
+
+function accent_fold(search_string) 
+{
+    // tidy up any pre- or post- whitespace
+    search_string = trim(search_string);
+
+    // protect any string literals that are special RE characters
+    search_string = search_string.replace(/([|\(\)\[\{\}.+*?^$\\])/g,"\\$1");
+
+    // replace characters by their compositors
+    var accent_replacer = function(chr) {
+	if (chr.charCodeAt(0)>128) {
+	    for (var base_c in accented) {
+		var letter_re = new RegExp(accented[base_c],'gi');
+		if (letter_re.test(chr)) {
+		    // Got accented char
+		    // => downgrade to base character
+		    chr = base_c;
+		}
+		// otherwise, leave it alone
+	    }
+	}
+	return chr;
+    }
+
+    search_string = search_string.replace(/\S/g,accent_replacer);
+    search_string = search_string.replace(/\\([|\(\)\[\{\}.+*?^$\\])/g,"$1");
+
+    search_string = search_string.replace(/\s+/g," ");
+
+    return search_string;
+}
+
+
+function punct_fold(search_string) 
+{
+    search_string = trim(search_string);
+    search_string = search_string.replace(/\./g,"");
+
+    search_string = search_string.replace(/\s+/g," ");
+
+    return search_string;
+}
+
+
+function firstname_fold(search_string) 
+{
+    search_string = trim(search_string);
+
+    if (search_string.match(/^(.*\,\s*.).*$/)) {
+	search_string = search_string.replace(/^(.*\,\s*.[^\s]*).*$/,"$1");
+    }
+    else {
+	search_string = search_string.replace(/^(.[^\s]*).*\s+(.*)$/,"$1 $2");
+    }
+
+    search_string = search_string.replace(/\s+/g," ");
+
+    return search_string;
+}
+
+
+function firstname_initial_fold(search_string) 
+{
+    search_string = trim(search_string);
+
+    if (search_string.match(/^(.*\,\s*.).*$/)) {
+	search_string = search_string.replace(/^(.*\,\s*.).*$/,"$1");
+    }
+    else {
+	search_string = search_string.replace(/^(.).*\s+(.*)$/,"$1 $2");
+    }
+
+    search_string = search_string.replace(/\s+/g," ");
+
+    return search_string;
+}
+
+
+function process_named_authority_canonical(response,author_pack)
+{
+    //console.log("SRW response:\n" + response);
+
+    var parser = new DOMParser();
+    marc_xml_doc = parser.parseFromString(response,"text/xml");
+
+    var datafieldElems = marc_xml_doc.getElementsByTagName("mx:datafield");
+
+    var canonical_author_name = null;
+
+    for (var fi=0; fi<datafieldElems.length; fi++) {
+	var datafieldElem = datafieldElems[fi];
+	if (datafieldElem.getAttribute("tag")=="100") {
+	    console.log("got match on tag 100");
+
+	    var subfieldElems = datafieldElem.getElementsByTagName("mx:subfield");
+	    for (var si=0; si<subfieldElems.length; si++) {
+
+		var subfieldElem = subfieldElems[si];
+		if (subfieldElem.getAttribute("code")=="a") {
+		    canonical_author_name = getChildText(subfieldElem);
+		    console.log("*** canonical author = " + canonical_author_name);
+		}
+	    }
+	}
+    }
+
+    var author_name = author_pack.name;
+    var author_link = author_pack.link;
+
+
+    if ((canonical_author_name!=null) && (canonical_author_name!=author_name)) {
+	console.log("trying to set innerHTML with: " + canonical_author_name);
+	author_link.innerHTML = canonical_author_name;
+    }
+
+}
+
+
+function count_named_authority_canonical(response,author_pack)
+{
+    var parser = new DOMParser();
+    marc_xml_doc = parser.parseFromString(response,"text/xml");
+
+    var datafieldElems = marc_xml_doc.getElementsByTagName("mx:datafield");
+
+    var prelookupNames = new Array();
+    var prelookupAliases = new Array();
+
+    for (var fi=0; fi<datafieldElems.length; fi++) {
+	var datafieldElem = datafieldElems[fi];
+	if (datafieldElem.getAttribute("tag")=="100") {
+	    console.log("NA response: got match on tag 100");
+
+	    var subfieldElems = datafieldElem.getElementsByTagName("mx:subfield");
+	    for (var si=0; si<subfieldElems.length; si++) {
+
+		var subfieldElem = subfieldElems[si];
+		if (subfieldElem.getAttribute("code")=="a") {
+		    var canonical_author_name = getChildText(subfieldElem);
+		    prelookupNames[prelookupNames.length] = canonical_author_name;
+		    console.log("*** canonical author = " + canonical_author_name);
+		}
+	    }
+	}
+
+
+	if (datafieldElem.getAttribute("tag")=="400") {
+	    console.log("NA response: got match on tag 400");
+
+	    var subfieldElems = datafieldElem.getElementsByTagName("mx:subfield");
+	    for (var si=0; si<subfieldElems.length; si++) {
+
+		var subfieldElem = subfieldElems[si];
+		if (subfieldElem.getAttribute("code")=="a") {
+		    var canonical_author_name = getChildText(subfieldElem);
+		    prelookupNames[prelookupNames.length-1] += "<br>&nbsp;&nbsp; also: " + canonical_author_name;
+		    console.log("*** alias author = " + canonical_author_name);
+		}
+	    }
+	}
+
+    }
+
+    var prelookupNamesLen = prelookupNames.length;
+
+    var prelookupNACount= document.getElementById("prelookupNACount");
+    prelookupNACount.innerHTML += prelookupNamesLen;
+
+    var prelookupNAList = document.getElementById("prelookupNAList");
+    var newInnerHTML = '<p>&nbsp;' + prelookupNames.join("<br>") + '</p>';
+    prelookupNAList.innerHTML = newInnerHTML;
+}
+
+
+function process_named_authority_aliases(response,author_pack)
+{
+    var parser = new DOMParser();
+    marc_xml_doc = parser.parseFromString(response,"text/xml");
+
+    var datafieldElems = marc_xml_doc.getElementsByTagName("mx:datafield");
+
+    var author_name = author_pack.name;
+    var author_name_aliases = author_name;
+
+    for (var fi=0; fi<datafieldElems.length; fi++) {
+	var datafieldElem = datafieldElems[fi];
+	if ((datafieldElem.getAttribute("tag")=="100") || (datafieldElem.getAttribute("tag")=="400")) {
+
+	    var subfieldElems = datafieldElem.getElementsByTagName("mx:subfield");
+	    for (var si=0; si<subfieldElems.length; si++) {
+
+		var subfieldElem = subfieldElems[si];
+		if (subfieldElem.getAttribute("code")=="a") {
+		    var author_name_alias = getChildText(subfieldElem);
+
+		    if (author_name_alias != author_name) {
+			if (author_name_aliases != "") {
+			    author_name_aliases += " OR ";
+			}
+			author_name_aliases += author_name_alias;
+			console.log("*** alias author = " + author_name_alias);
+		    }
+		}
+	    }
+	}
+    }
+
+
+    var author_elem = author_pack.elem;
+
+    if (author_elem.nodeType==ELEMENT_NODE) {
+	if (author_elem.nodeName.toLowerCase()=="input") {
+	    author_elem.value=author_name_aliases;
+	}
+	else {
+	    author_elem.innerHTML = author_name_aliases;
+	}
+    }
+}
+
+function async_named_authority_srw(elem,process_function) 
+{
+    console.log("async name authority srw");
+
+    var url = "http://alcme.oclc.org/srw/search/lcnaf";
+
+    var author_pack = generateAuthorPack(elem);
+    var author_name = author_pack.name;
+
+    // tidy it up a bit
+    author_name = trim(author_name);
+    author_name = author_name.replace(/\s+/g," ");
+
+    var family_name;
+    var first_name;
+
+    if (author_name.match(/^.*\,\s*..*$/)) {
+	family_name = author_name.replace(/^(.*)\,\s*..*$/,"$1");
+	first_name  = author_name.replace(/^.*\,\s*(\S+).*$/,"$1");
+    }
+    else {
+	family_name = author_name.replace(/^\s*(\S+).*?(\S+)$/,"$2");
+	first_name  = author_name.replace(/^\s*(\S+).*?(\S+)$/,"$1");
+    }
+
+    // Looks like accent folding is needed to work nicely with OCLC search
+    // service
+    family_name = accent_fold(family_name);
+    first_name = accent_fold(first_name);
+
+    var query_cgi = 'query=local.FamilyName+%3D+"<FamilyName>"+and+local.FirstName+%3D+"<FirstName>"';
+    query_cgi = query_cgi.replace(/(<FamilyName>)/g,family_name);
+    query_cgi = query_cgi.replace(/(<FirstName>)/g,first_name);
+
+    var cgi_tail = "&version=1.1&operation=searchRetrieve&recordSchema=info%3Asrw%2Fschema%2F1%2Fmarcxml-v1.1&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys=";
+    
+    url += '?' + query_cgi + cgi_tail;
+
+    console.log("url = " + url);
+
+    GM_xmlhttpRequest( { method:  'GET',
+		         url:     url,
+		onload:  function (rsp) { process_function(rsp.responseText,author_pack); },
+		         onerror: function(rsp) { alert("Error retrieving name authority data:" + rsp.statusText); }
+		       } );
+}
+
+
+//----------------//
+
+
+
+function count_crowdsource_canonical(response,author_pack)
+{
+    console.log("Count crowd source");
+
+    var author_name = author_pack.name;
+
+    var holderDiv = document.createElement('div');
+    holderDiv.innerHTML = response.replace(/<script(.|\s)*?\/script>/g, '');
+
+    var tdArray = holderDiv.getElementsByTagName('td');
+
+    var csMap = new Object();
+    var currOrigName   = null;
+    var currFoldedName = null;
+
+    for (var i=0; i<tdArray.length; i++) {
+	var tdText = tdArray[i].innerHTML;
+	if (tdText.match(/^Original Name:/)) {
+	    currOrigName = tdText.replace(/^Original Name:\s+(.*)$/,"$1");
+	}
+	if (tdText.match(/^Folded Name:/)) {
+	    currFoldedName = tdText.replace(/^Folded Name:\s+(.*)$/,"$1");
+
+	    if (currOrigName != author_name) {
+		// Not interested in this one => skip
+		continue;
+	    }
+
+	    if (currOrigName in csMap) {
+		if (currFoldedName in csMap[currOrigName]) {
+		    csMap[currOrigName][currFoldedName]++;
+		    //console.log("Increasing mapping: " + currOrigName 
+		    //		+ " -> " + currFoldedName );
+		}
+		else {
+		    csMap[currOrigName][currFoldedName] = 1;
+		    // console.log("Creating another mapping for " + currOrigName 
+		    //		+ " (this time ->) " + currFoldedName );
+		}
+	    }
+	    else {
+		
+		//console.log("First ever mapping for: " + currOrigName 
+		//	    + " -> " + currFoldedName );
+		csMap[currOrigName] = new Object();
+		csMap[currOrigName][currFoldedName] = 1;
+	    }
+	}
+    }
+
+    var csMapKeys = new Array();
+    for (var key in csMap) {
+	csMapKeys[csMapKeys.length] = key;
+    }
+
+    var origNameLen = csMapKeys.length;
+
+    var prelookupCSCount= document.getElementById("prelookupCSCount");
+    var prelookupCSList = document.getElementById("prelookupCSList");
+
+    if (origNameLen == 1) {
+	var okey = csMapKeys[0];
+	var foldedKeys = new Array();
+
+	for (var fkey in csMap[okey]) {
+	    foldedKeys[foldedKeys.length]= fkey;
+	}
+
+	var foldedNameLen = foldedKeys.length;
+	
+	prelookupCSCount.innerHTML += foldedNameLen;
+
+	var newInnerHTML = '<p><table>';
+	for (var fkey in csMap[okey]) {
+	    newInnerHTML += "<tr><td>&nbsp;-> " + fkey + ":</td><td>&nbsp;freq(" + csMap[okey][fkey] + ")</td></tr>";
+	}
+	newInnerHTML += '</table></p>';
+
+	prelookupCSList.innerHTML = newInnerHTML;
+    }
+    else {
+	if (origNameLen == 0) {
+	    prelookupCSCount.innerHTML += 0;
+	    prelookupCSList.innerHTML = "no matches were found";
+	}
+	else {
+	    alert("Error: Did not expect to find more than one original name in crowdsource lookup.  Count: " + origNameLen);
+	}
+    }
+}
+
+
+function async_crowdsource_greenstone(elem,process_function) 
+{
+    console.log("Async crowdsource");
+
+    var url = "http://www.nzdl.org/custom/seaweed-gm/cgi-bin/library.cgi";
+
+    var data = "c="+crowdsourceNamespace+"&a=q&r=1&hs=1&fqf=GS&sf=&t=1&q=";
+
+    var author_pack = generateAuthorPack(elem);
+    var author_name = author_pack.name;
+
+    // tidy it up a bit
+    author_name = trim(author_name);
+    author_name = author_name.replace(/\s+/g," ");
+
+    data += author_name;
+
+    //var encoded_data = encodeURI(data);
+    var encoded_data = data;
+
+    url += "?" + encoded_data;
+
+    console.log("url = " + url);
+
+    GM_xmlhttpRequest( { method: 'GET',
+	                 url:     url,
+       onload: function (rsp) { process_function(rsp.responseText,author_pack); },
+       onerror:function(rsp) { alert("Error setting metadata"); }
+		       } );
+
+}
+
+
+
+
+//----------------//
+
+function name_unfold_re(search_string) {
+    // escape meta characters
+    search_string = search_string.replace(/\./g,"");
+    search_string = search_string.replace(/^\s/,"");
+    search_string = search_string.replace(/\s$/,"");
+
+    search_string = search_string.replace(/([|\(\)\[\{\}.+*?^$\\])/g,"\\$1");
+
+    // replace characters by their compositors
+    var accent_replacer = function(chr) {
+        return accented[chr.toLowerCase()] || chr;
+    }
+    search_string = search_string.replace(/\S/g,accent_replacer);
+
+    search_string = search_string.replace(/\s+/g,"\\s+");
+
+    return new RegExp(search_string,'g');
+}
+
+var accented = {
+    'a': '[Aa\xaa\xc0-\xc5\xe0-\xe5\u0100-\u0105\u01cd\u01ce\u0200-\u0203\u0226\u0227\u1d2c\u1d43\u1e00\u1e01\u1e9a\u1ea0-\u1ea3\u2090\u2100\u2101\u213b\u249c\u24b6\u24d0\u3371-\u3374\u3380-\u3384\u3388\u3389\u33a9-\u33af\u33c2\u33ca\u33df\u33ff\uff21\uff41]',
+    'b': '[Bb\u1d2e\u1d47\u1e02-\u1e07\u212c\u249d\u24b7\u24d1\u3374\u3385-\u3387\u33c3\u33c8\u33d4\u33dd\uff22\uff42]',
+    'c': '[Cc\xc7\xe7\u0106-\u010d\u1d9c\u2100\u2102\u2103\u2105\u2106\u212d\u216d\u217d\u249e\u24b8\u24d2\u3376\u3388\u3389\u339d\u33a0\u33a4\u33c4-\u33c7\uff23\uff43]',
+    'd': '[Dd\u010e\u010f\u01c4-\u01c6\u01f1-\u01f3\u1d30\u1d48\u1e0a-\u1e13\u2145\u2146\u216e\u217e\u249f\u24b9\u24d3\u32cf\u3372\u3377-\u3379\u3397\u33ad-\u33af\u33c5\u33c8\uff24\uff44]',
+    'e': '[Ee\xc8-\xcb\xe8-\xeb\u0112-\u011b\u0204-\u0207\u0228\u0229\u1d31\u1d49\u1e18-\u1e1b\u1eb8-\u1ebd\u2091\u2121\u212f\u2130\u2147\u24a0\u24ba\u24d4\u3250\u32cd\u32ce\uff25\uff45]',
+    'f': '[Ff\u1da0\u1e1e\u1e1f\u2109\u2131\u213b\u24a1\u24bb\u24d5\u338a-\u338c\u3399\ufb00-\ufb04\uff26\uff46]',
+    'g': '[Gg\u011c-\u0123\u01e6\u01e7\u01f4\u01f5\u1d33\u1d4d\u1e20\u1e21\u210a\u24a2\u24bc\u24d6\u32cc\u32cd\u3387\u338d-\u338f\u3393\u33ac\u33c6\u33c9\u33d2\u33ff\uff27\uff47]',
+    'h': '[Hh\u0124\u0125\u021e\u021f\u02b0\u1d34\u1e22-\u1e2b\u1e96\u210b-\u210e\u24a3\u24bd\u24d7\u32cc\u3371\u3390-\u3394\u33ca\u33cb\u33d7\uff28\uff48]',
+    'i': '[Ii\xcc-\xcf\xec-\xef\u0128-\u0130\u0132\u0133\u01cf\u01d0\u0208-\u020b\u1d35\u1d62\u1e2c\u1e2d\u1ec8-\u1ecb\u2071\u2110\u2111\u2139\u2148\u2160-\u2163\u2165-\u2168\u216a\u216b\u2170-\u2173\u2175-\u2178\u217a\u217b\u24a4\u24be\u24d8\u337a\u33cc\u33d5\ufb01\ufb03\uff29\uff49]',
+    'j': '[Jj\u0132-\u0135\u01c7-\u01cc\u01f0\u02b2\u1d36\u2149\u24a5\u24bf\u24d9\u2c7c\uff2a\uff4a]',
+    'k': '[Kk\u0136\u0137\u01e8\u01e9\u1d37\u1d4f\u1e30-\u1e35\u212a\u24a6\u24c0\u24da\u3384\u3385\u3389\u338f\u3391\u3398\u339e\u33a2\u33a6\u33aa\u33b8\u33be\u33c0\u33c6\u33cd-\u33cf\uff2b\uff4b]',
+    'l': '[Ll\u0139-\u0140\u01c7-\u01c9\u02e1\u1d38\u1e36\u1e37\u1e3a-\u1e3d\u2112\u2113\u2121\u216c\u217c\u24a7\u24c1\u24db\u32cf\u3388\u3389\u33d0-\u33d3\u33d5\u33d6\u33ff\ufb02\ufb04\uff2c\uff4c]',
+    'm': '[Mm\u1d39\u1d50\u1e3e-\u1e43\u2120\u2122\u2133\u216f\u217f\u24a8\u24c2\u24dc\u3377-\u3379\u3383\u3386\u338e\u3392\u3396\u3399-\u33a8\u33ab\u33b3\u33b7\u33b9\u33bd\u33bf\u33c1\u33c2\u33ce\u33d0\u33d4-\u33d6\u33d8\u33d9\u33de\u33df\uff2d\uff4d]',
+    'n': '[Nn\xd1\xf1\u0143-\u0149\u01ca-\u01cc\u01f8\u01f9\u1d3a\u1e44-\u1e4b\u207f\u2115\u2116\u24a9\u24c3\u24dd\u3381\u338b\u339a\u33b1\u33b5\u33bb\u33cc\u33d1\uff2e\uff4e]',
+    'o': '[Oo\xba\xd2-\xd6\xf2-\xf6\u014c-\u0151\u01a0\u01a1\u01d1\u01d2\u01ea\u01eb\u020c-\u020f\u022e\u022f\u1d3c\u1d52\u1ecc-\u1ecf\u2092\u2105\u2116\u2134\u24aa\u24c4\u24de\u3375\u33c7\u33d2\u33d6\uff2f\uff4f]',
+    'p': '[Pp\u1d3e\u1d56\u1e54-\u1e57\u2119\u24ab\u24c5\u24df\u3250\u3371\u3376\u3380\u338a\u33a9-\u33ac\u33b0\u33b4\u33ba\u33cb\u33d7-\u33da\uff30\uff50]',
+    'q': '[Qq\u211a\u24ac\u24c6\u24e0\u33c3\uff31\uff51]',
+    'r': '[Rr\u0154-\u0159\u0210-\u0213\u02b3\u1d3f\u1d63\u1e58-\u1e5b\u1e5e\u1e5f\u20a8\u211b-\u211d\u24ad\u24c7\u24e1\u32cd\u3374\u33ad-\u33af\u33da\u33db\uff32\uff52]',
+    's': '[Ss\u015a-\u0161\u017f\u0218\u0219\u02e2\u1e60-\u1e63\u20a8\u2101\u2120\u24ae\u24c8\u24e2\u33a7\u33a8\u33ae-\u33b3\u33db\u33dc\ufb06\uff33\uff53]',
+    't': '[Tt\u0162-\u0165\u021a\u021b\u1d40\u1d57\u1e6a-\u1e71\u1e97\u2121\u2122\u24af\u24c9\u24e3\u3250\u32cf\u3394\u33cf\ufb05\ufb06\uff34\uff54]',
+    'u': '[Uu\xd9-\xdc\xf9-\xfc\u0168-\u0173\u01af\u01b0\u01d3\u01d4\u0214-\u0217\u1d41\u1d58\u1d64\u1e72-\u1e77\u1ee4-\u1ee7\u2106\u24b0\u24ca\u24e4\u3373\u337a\uff35\uff55]',
+    'v': '[Vv\u1d5b\u1d65\u1e7c-\u1e7f\u2163-\u2167\u2173-\u2177\u24b1\u24cb\u24e5\u2c7d\u32ce\u3375\u33b4-\u33b9\u33dc\u33de\uff36\uff56]',
+    'w': '[Ww\u0174\u0175\u02b7\u1d42\u1e80-\u1e89\u1e98\u24b2\u24cc\u24e6\u33ba-\u33bf\u33dd\uff37\uff57]',
+    'x': '[Xx\u02e3\u1e8a-\u1e8d\u2093\u213b\u2168-\u216b\u2178-\u217b\u24b3\u24cd\u24e7\u33d3\uff38\uff58]',
+    'y': '[Yy\xdd\xfd\xff\u0176-\u0178\u0232\u0233\u02b8\u1e8e\u1e8f\u1e99\u1ef2-\u1ef9\u24b4\u24ce\u24e8\u33c9\uff39\uff59]',
+    'z': '[Zz\u0179-\u017e\u01f1-\u01f3\u1dbb\u1e90-\u1e95\u2124\u2128\u24b5\u24cf\u24e9\u3390-\u3394\uff3a\uff5a]'
+};
+
+
+
+             //------------------------------------------//
+
+// Static Images
+
+var csnImageLarge = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS4AAAAcCAYAAADfhVJRAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sBAgoeCYNOpdoAAAAZdEVYdENvbW1lbnQAQ3JlYXRl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QOr3++eX7ZvvZJ+5Td/dVWlq+o8mAwGSqjEYenpHCILITr/mE0lR3IGM9+0SAAAAAElFTkSuQmCC";
+
+// useful way to init string
+
+var abc = <>
+xxxxx
+    </>;
+
+
+document.body.addEventListener('mouseover',csnHighlight,true);
+document.body.addEventListener('mouseout',csnDeHighlight,true);
+
+document.body.addEventListener('mousedown',csnStartDragging,true);
+document.body.addEventListener('mouseup',csnStopDragging,true);
+document.body.addEventListener('click',csnSingleClick,true);
+
+//document.body.addEventListener('keydown',csnKeyPress,true);
+//document.body.addEventListener('keyup',csnKeyPress,true);
+document.body.addEventListener('keypress',csnKeyPress,true);
+
+/*
+var frames = document.getElementsByTagName("iframe");
+for (var i=0; i<frames.length; i++) {
+    var frame = frames[i];
+    frame.addEventListener('mouseover',csnHighlight,true);
+    frame.addEventListener('mouseout',csnDeHighlight,true);
+
+    frame.addEventListener('mousedown',csnStartDragging,true);
+    frame.addEventListener('mouseup',csnStopDragging,true);
+    frame.addEventListener('click',csnSingleClick,true);
+}
+*/
+
+document.addEventListener('load',csnInit,true);
+
+
+
+        //--------------------===========================--------------------//
+
+
+var usernameNamespace="jcdl2011";
+var crowdsourceNamespace="csn";
+
+function sw_clean(html)
+{
+  html = html.replace(/<div.*?sw-cursor.*?><\/div>/g,"");
+  html = html.replace(/<div.*?sw-protect.*?>.*?<\/div>/g,"");
+  html = html.replace(/<div.*?sw-protect.*?\/>/g,"");
+
+  return html;
+}
+
+function sw_edited()
+{
+   return (de.Changes.getChangedEditableSections().length>0);
+}
+
+
+var popupWidth = 100;
+var popupHeight = 20;
+
+function getScrollXY() 
+{
+    var scrOfX = 0, scrOfY = 0;
+    if( typeof( window.pageYOffset ) == 'number' ) {
+	//Netscape compliant
+	scrOfY = window.pageYOffset;
+	scrOfX = window.pageXOffset;
+    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
+	//DOM compliant
+	scrOfY = document.body.scrollTop;
+	scrOfX = document.body.scrollLeft;
+    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
+	//IE6 standards compliant mode
+	scrOfY = document.documentElement.scrollTop;
+	scrOfX = document.documentElement.scrollLeft;
+    }
+    return [ scrOfX, scrOfY ];
+}
+
+function set_popup_top(popUpDivVar,sy) 
+{
+    var window_height = window.innerHeight;
+
+    var popUpDiv = document.getElementById(popUpDivVar);
+    var popUpDiv_top=window_height/2-(popupHeight/2);
+    popUpDiv.style.top = (sy + popUpDiv_top) + 'px';
+}
+
+function set_popup_left(popUpDivVar,sx) 
+{
+    var window_width = window.innerWidth;
+
+    var popUpDiv = document.getElementById(popUpDivVar);
+    var window_left=window_width/2-(popupWidth/2);
+    popUpDiv.style.left = (sx + window_left) + 'px';
+}
+
+function show_popup(div_id) 
+{
+    var [ sx, sy ] = getScrollXY();
+
+    set_popup_top(div_id,sy);
+    set_popup_left(div_id,sx);
+
+    var el = document.getElementById(div_id);
+    el.style.display = 'block';
+}
+
+function hide_popup(div_id) 
+{
+    var el = document.getElementById(div_id);
+    el.style.display = 'none';
+}
+
+var starting_html = sw_clean(document.body.innerHTML);
+var live_html = null;
+
+
+
+function add_title_metadata(namespace,title,filename)
+{
+  if (title==null) {
+      title = document.title.replace(/ \[seaweed edited\]$/,"");
+  }
+
+  var url = "http://www.nzdl.org/custom/seaweed-gm/cgi-bin/metadata-server.pl";
+  var data = "a=set-import-metadata";
+  data += "&un=" + namespace;
+  data += "&pw=" + namespace;
+  data += "&c="  + namespace;
+
+  data += "&f=" + filename;
+  data += "&metaname=dc.Title&metavalue=" + title;
+  data += "&metamode=override";
+
+  var encoded_data = encodeURI(data);
+
+  url += "?" + encoded_data;
+
+  // alert("url = " + url);
+
+  // should change this to a GET
+  GM_xmlhttpRequest( { method: 'GET',
+	               url:     url,
+		       onerror: function(rsp) { alert("Error setting metadata"); }
+		       } );
+
+}
+
+
+
+function _save_doc_html(namespace,title,html,filename)
+{
+    if (!seaweedActivated) {
+	init_seaweed();
+	seaweedActivated = true;
+    }
+
+  var url = "http://www.nzdl.org/custom/seaweed-gm/cgi-bin/swio.pl";
+  var data = "cmd=store-file";
+  data += "&un=" + namespace;
+  data += "&pw=" + namespace;
+  data += "&c="  + namespace;
+  data += "&f="  + filename;
+
+  //alert("data = " + data);
+
+  var encoded_html = html;
+
+  encoded_html = encoded_html.replace(/&/g, "%26");
+  encoded_html = encoded_html.replace(/</g, "%3C");
+  encoded_html = encoded_html.replace(/>/g, "%3E");
+  encoded_html = encoded_html.replace(/\"/g,"%22");
+  encoded_html = encoded_html.replace(/\;/g,"%3B");
+  encoded_html = encoded_html.replace(/\+/g,"%2B");
+
+  data += "&html=" + encoded_html
+
+  var encoded_data = encodeURI(data);
+
+  //alert("encoded data = " + encoded_data);
+
+
+  var popup_div = document.getElementById("popUpDiv");
+  popup_div.innerHTML = "Saving ...";
+  show_popup('popUpDiv');
+
+  GM_xmlhttpRequest( { method: 'POST',
+	               url:     url,
+		       headers: {'Content-type':'application/x-www-form-urlencoded'},
+		       data:    encoded_data,
+	      onload:  function(rsp) { add_title_metadata(namespace,title,filename) ; save_done(rsp) },
+		       onerror: save_failed } );
+}
+
+
+
+function save_mapping(orig_name,new_name)
+{
+    var timestamp = new Date().getTime();
+    var filename = timestamp + ".html";
+    var title = timestamp + " Crowdsource Mapping";
+
+    var html = '<html>\n';
+    html += '  <head>\n';
+    html += '    <title>'+title+'</titile>\n';
+    html += '    <meta name="gs.OrigName" content="'+orig_name+'" />\n';
+    html += '    <meta name="gs.FoldedName" content="'+new_name+'" />\n';
+    html += '  </head>\n';
+    html += '  <body>\n';
+    html += '     <p>\n';
+    html += '     '+orig_name+'-&gt;'+new_name+'\n';
+    html += '     </p>\n';
+    html += '  </body>\n';
+    html += '</html>\n';
+
+    _save_doc_html(crowdsourceNamespace,title,html,filename);
+}
+
+
+function save_live_doc_html()
+{
+  live_html = sw_clean(document.body.innerHTML);
+ 
+  var location = new String(document.location);
+  var filename = location.replace(/^[a-z]+:\/\//,"");
+
+  if (filename.match(/\/$/)) {
+      filename += "index.html";
+  }
+
+  var title = document.title.replace(/ \[seaweed edited\]$/,"");
+  var head = "<head><title>" + title + "</title></head>";
+  var encoded_live_html = "<html>" + head + "<body>" + live_html + "</body></html>"; 
+
+  alert("encoded live html being sent");
+
+  _save_doc_html(usernameNamespace,title,encoded_live_html,filename);
+
+}
+
+
+
+function revert_to_orig_doc()
+{
+
+  GM_xmlhttpRequest( { method: 'GET',
+	      url:     document.location.toString(),
+	      onload:  revert_done,
+	      onerror: revert_failed } );
+}
+
+
+function revert_done(rsp)
+{
+  var status = rsp.status;
+  if (status == 200) {
+      var response = rsp.responseText;
+
+      //alert("response = " + response);
+
+      var inner_body =  response.match(/<body>(.*)<\/body>/i);
+      //alert("inner body = " + inner_body);
+
+      var response_body = response.replace(/^.*<body>(.*)<\/body>.*$/i,"$1");
+      
+      document.body.innerHTML = response_body;
+      
+      init_seaweed();  
+      starting_html = sw_clean(document.body.innerHTML);
+  }
+  else {
+    revert_failed(rsp);
+  }
+}
+
+
+
+function revert_failed(rsp)
+{
+  alert("Revert failed: Status = " + rsp.status + ";\n"+ rsp.statusText);
+  init_seaweed();  
+}
+
+
+
+function unload_precheck(event)
+{
+    var curr_html = sw_clean(document.body.innerHTML);
+
+  if (curr_html != starting_html) {
+//  if (sw_edited()) {	
+
+      event.returnValue = "The document has been edited.";
+      event.preventDefault();
+  }
+}
+
+
+
+function save_done(rsp)
+{
+  var status = rsp.status;
+  if (status == 200) {
+    var response = rsp.responseText;
+
+    if (response.match(/^Error:/i)) {
+        alert("Save failed for:\n\n  " + document.location + "\n\n" + response);
+    }
+    else {
+	if (live_html!=null) {
+	    starting_html = sw_clean(live_html);
+	}
+
+
+      //alert("popup" + hide_popup);
+
+      var popup_div = document.getElementById("popUpDiv");
+      popup_div.innerHTML = "Saving ... Done";
+      setTimeout(hide_popup,500,"popUpDiv");
+
+      if (live_html!=null) {
+	  de.Changes.clear();
+	  html_edited = false;
+	  document.title = document.title.replace(/ \[seaweed edited\]$/,"");
+      }
+    }
+  }
+  else {
+    save_failed(rsp);
+  }
+}
+
+function save_failed(rsp)
+{
+  alert("Save failed: Status = " + rsp.status + ";\n"+ rsp.statusText);
+}
+
+
+// -----------------------------------------------------
+
+
+function restore_live_doc_html()
+{
+  var location = new String(document.location);
+  var filename = location.replace(/^[a-z]+:\/\//,"");
+
+  var url = "http://www.nzdl.org/custom/seaweed-gm/cgi-bin/swio.pl?";
+  url += "cmd=restore-file";
+  url += "&un=" + usernameNamespace;
+  url += "&pw=" + usernameNamespace;
+  url += "&c="  + usernameNamespace;
+  url += "&f="  + filename;
+
+  GM_xmlhttpRequest( { method: 'GET',
+	               url:     url,
+		       onload:  load_done,
+		       onerror: load_failed } );
+
+}
+
+var html_edited = false;
+
+function init_seaweed()
+{
+    //alert("Init Seaweed, url = " + document.location);
+     de.init();
+     de.Changes.clear();
+
+     de.UndoMan.addObserver({
+       onBeforeExec : function() {
+	   if (!html_edited) {
+	       document.title += " [seaweed edited]";
+	   }
+	   html_edited = true;
+       }
+     });
+
+    var popup_div   = document.createElement("div");
+    popup_div.setAttribute("id","popUpDiv");
+    popup_div.setAttribute("class","sw-protect");
+
+    
+    popup_div.setAttribute("style",
+      "position:absolute; \
+       display:none; \
+       background-color:#363736; \
+       color: white; \
+       z-index: 9002;");
+
+    popup_div.style.width = popupWidth + "px";
+    popup_div.style.height = popupHeight + "px";
+
+    document.body.appendChild(popup_div);
+}
+
+function load_done(rsp)
+{
+  var status = rsp.status;
+  if (status == 200) {
+    var response = rsp.responseText;
+
+    if (response.match(/^Error:/i)) {
+        alert("Load failed for:\n\n  " + document.location + "\n\n" + response);
+    }
+    else {
+      if (response != "") {
+        document.body.innerHTML = response;
+      }
+     init_seaweed();  
+     starting_html = sw_clean(document.body.innerHTML);
+
+    }
+  }
+  else {
+    load_failed(rsp);
+  }
+}
+
+
+function load_failed(rsp)
+{
+  alert("Load failed: Status = " + rsp.status + ";\n"+ rsp.statusText);
+  init_seaweed();  
+}
+
+
+function loaded()
+{
+  restore_live_doc_html();
+}
+
+
+//window.addEventListener('beforeunload',unload_precheck,true);
+
+//window.addEventListener('load',init_seaweed,false);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(function(){var H,J;de={version:"0.0.1",m:[],collections:{},events:{},onready:(function(){var a0=[];function a1(){if(a0){for(var a2 in a0){a0[a2]()}a0=0}}if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);a1()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);a1()}});if(document.documentElement.doScroll&&window==window.top){(function(){if(!a0){return}try{document.documentElement.doScroll("left")}catch(a2){setTimeout(arguments.callee,0);return}a1()})()}A(window,"load",function(){a1();ad(window,"load",arguments.callee)})}}return function(a2){if(a0){a0.push(a2)}else{a2()}}})(),init:function(){if(!de.m){return}H=document.body;var a3=de.m;var a6;do{a6=false;for(var a4=0;a4<a3.length;a4++){var a5=a3[a4];if(!a5.depends){continue}for(var a2=0;a2<a5.depends.length;a2++){for(var a1=a4+1;a1<a3.length;a1++){if(a5.depends[a2]==a3[a1].name){var a0=a3;a3=a0.slice(0,a4).concat(a0.slice(a4+1,a1+1).concat([a5].concat(a0.slice(a1+1))));a6=true;break}}if(a6){break}}if(a6){break}}}while(a6);for(a4 in a3){if(a3[a4].init){a3[a4].init()}}delete de.m}};function L(a1,a2){var a0=Array.prototype.slice.call(arguments);a0.splice(0,2);de.m.push({name:a1,init:a2,depends:a0})}function D(a3,a1,a0){if(a0!==false){a0=true}for(var a2 in a1){if(a0||typeof a3[a2]=="undefined"){a3[a2]=a1[a2]}}return a3}function aZ(a3){var a0=a3.split(",");var a2={};for(var a1 in a0){a2[a0[a1]]=true}return a2}function N(a0){return document.createElement(a0)}var aU=function(){var a0=function(){this.length=0;this.head=null;this.tail=null};a0.prototype={add:function(a3){var a2={data:a3,next:null,prev:null};if(this.length==0){this.head=a2;this.tail=a2}else{this.tail.next=a2;a2.prev=this.tail;this.tail=a2}this.length++},remove:function(a2){var a3=this.head;while(a3){if(a3.data==a2){a1(this,a3);return true}a3=a3.next}return false},removeAtIndex:function(a2){if(a2>-1&&a2<this.length){var a4;if(a2<(this.length/2)){a4=this.head;for(var a3=0;a3<a2;a3++){a4=a4.next}}else{a4=this.tail;for(var a3=this.length-1;a3>a2;a3--){a4=a4.prev}}a1(this,a4);return a4.data}return null},pop:function(){return this.removeAtIndex(this.length-1)},chop:function(a5){var a4=this.tail,a3=this.length;while(a4&&a4!=a5){a4=a4.prev;a3--}if(!a4){return false}if(a4.next){var a2=a4.next;while(a2){a2.prev.next=null;a2.prev=null;a2=a2.next}this.tail=a4;this.length=a3}return true},clear:function(){while(this.head){var a2=this.head;this.head=a2.next;a2.prev=a2.next=null}this.tail=null;this.length=0},iterate:function(a3){var a4=this.head;while(a4){var a2=a3(a4.data);if(a2===false){break}a4=a4.next}}};a0.prototype.push=a0.prototype.add;function a1(a2,a3){if(a2.length==1){a2.clear();return}if(a3==a2.head){a2.head=a3.next;a2.head.prev=null;a3.next=null}else{if(a3==a2.tail){a2.tail=a3.prev;a2.tail.next=null;a3.prev=null}else{a3.prev.next=a3.next;a3.next.prev=a3.prev;a3.next=a3.prev=null}}a2.length--}return a0}();de.collections.DoublyLinkedList=aU;function h(a1){var a3=[],a2;D(a1,{fireEvent:function(a8){if(a3.length>0){var a7,a5,a4,a6=Array.prototype.slice.call(arguments);a6.shift();a2=[];for(a7 in a3){a5=a3[a7];if(typeof a5.ref["on"+a8]=="function"){a5.ref["on"+a8].apply(a5.context,a6)}}a4=a2;a2=0;for(a7 in a4){this.removeObserver(a4[a7])}}},addObserver:function(a5,a6,a4){if(a0(a5)!=-1){return}a5={ref:a5,context:a6||a5};if(a4){a3.unshift(a5)}else{a3.push(a5)}},removeObserver:function(a4){if(a2){a2.push(a4)}else{var a5=a0(a4);if(a5>=0){a3.splice(a5,1)}}}});function a0(a4){for(var a5=0;a5<a3.length;a5++){if(a3[a5].ref==a4){return a5}}return -1}}de.model=h;L("Platform",function(){var a0=N("p");a0.style.margin="0 0 0 0";a0.style.padding="0 0 0 0";a0.style.textAlign="";var a1=N("span");a1.innerHTML="X";a0.appendChild(a1);H.appendChild(a0);_localeDirection=a1.offsetLeft<(a0.offsetWidth-(a1.offsetLeft+a1.offsetWidth))?"ltr":"rtl";H.removeChild(a0)});var W,E,G,p,K,d={UNKNOWN:-1,FIREFOX:1,OPERA:2,IE:3,CHROME:4,SAFARI:6,KONQUEROR:8,NETSCAPE:9,WINDOWS:1,MAC:2,LINUX:3,GECKO:1,TRIDENT:2,WEBKIT:3,KHTML:4,PRESTO:5};(function(){var a4=[{string:navigator.userAgent,subString:"Chrome",id:4,versionSearch:"Chrome"},{string:navigator.vendor,subString:"Apple",id:6,versionSearch:"Version"},{prop:window.opera,id:2,versionSearch:"Opera"},{string:navigator.vendor,subString:"KDE",id:8,versionSearch:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",id:1,versionSearch:"Firefox"},{string:navigator.userAgent,subString:"Netscape",id:9,versionSearch:"Netscape"},{string:navigator.userAgent,subString:"MSIE",id:3,versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Mozilla",id:9,versionSearch:"Mozilla"}];var a2=[{string:navigator.platform,subString:"Win",id:1},{string:navigator.platform,subString:"Mac",id:2},{string:navigator.platform,subString:"Linux",id:3},];var a1=[{string:navigator.userAgent,subString:"MSIE",id:2,versionSearch:"MSIE"},{string:navigator.userAgent,subString:"WebKit",id:3,versionSearch:"WebKit"},{string:navigator.userAgent,subString:"KHTML",id:4,versionSearch:"KHTML"},{string:navigator.userAgent,subString:"Gecko",id:1,versionSearch:"rv"},{prop:window.opera,id:5,versionSearch:"Presto"},];function a0(a8){for(var a5 in a8){var a6=a8[a5].string,a7=a8[a5].prop;if(a6){if(a6.indexOf(a8[a5].subString)!=-1){return a8[a5]}}else{if(a7){return a8[a5]}}}return null}function a3(a7,a5){if(!a5){return null}var a6=a7.indexOf(a5);if(a6==-1){return null}return parseFloat(a7.substring(a6+a5.length+1))}W=a0(a2);W=W?W.id||-1:-1;E=a0(a4);G=-1;if(E){G=a3(navigator.userAgent,E.versionSearch)||a3(navigator.appVersion,E.versionSearch);E=E.id}else{E=-1}p=a0(a1);K=-1;if(p){K=a3(navigator.userAgent,p.versionSearch);p=p.id}else{p=-1}})();D(de,{Platform:d,os:W,browser:E,browserVersion:G,engine:p,engineVersion:K,localDirection:null});var aI=function(){alert("hit!!!")};(function(){var a3={},a2=new aU(),a1=null,a0=0;aI=function(a4,a5){a3[a4]=a5};de.UndoMan={maxHistoryCount:100,ExecFlag:{GROUP:1,UPDATE_SELECTION:2,DONT_STORE:4},registerAction:aI,execute:function(a5,bb){var ba=Array.prototype.slice.call(arguments);if(typeof a5!="number"){a5=2;bb=ba[0];ba.shift()}else{ba.splice(0,2)}if(a0){a5=4}if((a5&1)&&!a1){aj("Cannot group action to nothing")}if(!a3[bb]){aj('Unknown action called "'+bb+'"')}var bd,a7=a3[bb],bc=new av(bb,a5,de.selection.getRange(false),de.selection.getRange(true));if(bc.selBefore){var a9=de.doc.getEditProperties(bc.selBefore.startNode);if(a9&&a9.afRE){var a8=a9.afRE.test(bb.toLowerCase()+(bb=="Format"?ba[0].toLowerCase():""));if(a8!=a9.afInclusive){return}}}this.fireEvent("BeforeExec",bc);a0++;try{bd=a7.exec.apply(bc,ba)}finally{a0--}if(!(a5&4)){var a6=aP();if(!a6||a6.length==0){this.fireEvent("AfterExec",bc);if(bc.selBefore){de.selection.setSelection(bc.selBefore.startNode,bc.selBefore.startIndex,bc.selBefore.endNode,bc.selBefore.endIndex,true)}return bd}if(!a1){a2.clear()}else{if(a1.next){a2.chop(a1)}}bc.opList=a6;a2.push(bc);a1=a2.tail;if(a2.length>this.maxHistoryCount&&this.maxHistoryCount>-1&&!(a7.flags&1)){a2.removeAtIndex(0)}}if(a5&2){var a4=bc.selAfter;if(!a4){de.selection.clear()}else{de.selection.setSelection(a4.startNode,a4.startIndex,a4.endNode,a4.endIndex,true)}}else{delete bc.selBefore;if(bc.selAfter){delete bc.selAfter}}delete bc.selBeforeOrdered;this.fireEvent("AfterExec",bc);return bd},undo:function(){do{if(!a1){return}var a4=a1.data;this.fireEvent("BeforeUndo",a4);try{u(a4.opList);a1=a1.prev}catch(a6){this.clear();throw a6}if(a4.flags&2){var a5=a4.selBefore;if(!a5){de.selection.clear()}else{de.selection.setSelection(a5.startNode,a5.startIndex,a5.endNode,a5.endIndex,true)}}this.fireEvent("AfterUndo",a4)}while(a1&&(a4.flags&1))},redo:function(){var a4=true;while(1){if(a2.length==0||a1==a2.tail){return}var a7=a1?a1.next:a2.head;var a5=a7.data;if(!a4&&!(a5.flags&1)){return}a1=a7;this.fireEvent("BeforeRedo",a5);try{aW(a5.opList)}catch(a6){this.clear();throw a6}if(a5.selAfter){var a8=a5.selAfter;if(!a8){de.selection.clear()}else{de.selection.setSelection(a8.startNode,a8.startIndex,a8.endNode,a8.endIndex,true)}}a4=false;this.fireEvent("AfterRedo",a5)}},clear:function(){a2.clear();a1=null},hasUndo:function(){return a1!=null},hasRedo:function(){return a2.length>0&&a1!=a2.tail}};h(de.UndoMan)})();var av=function(){var a0=function(a2,a1,a4,a3){this.name=a2;this.flags=a1;this.selBefore=a4;this.selBeforeOrdered=a3};a0.prototype={getEditSection:function(){if(this.opList){for(var a2 in this.opList){var a4=this.opList[a2];for(var a3 in a4){if(ap(a4[a3])&&aK(H,a4[a3])){var a1=de.doc.getEditSectionContainer(a4[a3]);if(a1){return a1}}}}}}};return a0}();var ai=document.elementFromPoint?function(a0,a2){switch(p){case 1:case 2:return document.elementFromPoint(a0,a2);default:var a1=aR();return document.elementFromPoint(a0+a1.left,a2+a1.top)}}:function(a0,a3){var a2=null;a1(H);return a2;function a1(a4){if(a4.childNodes.length>0){var a6=a4.firstChild;while(a6){if(a1(a6)){return true}a6=a6.nextSibling}}if(a4.nodeType==1&&(a4.offsetLeft||a4.offsetLeft==0)){var a5=f(a4);if(a3>=a5.y&&a3<=(a5.y+a4.offsetHeight)&&a0>=a5.x&&a0<=(a5.x+a4.offsetWidth)){a2=a4;return true}}return false}};function al(a0){var a3=0,a2=0,a1=0;do{if(a0.offsetLeft||a0.offsetTop){if(a0==H){if(!a1){a3+=Math.abs(a0.offsetLeft);a2+=Math.abs(a0.offsetTop)}}else{a3+=a0.offsetLeft;a2+=a0.offsetTop}}a1|=(a0.style&&a0.style.position=="fixed")}while(a0=a0.offsetParent);if(!a1){var a4=aR();a3-=a4.left;a2-=a4.top;if(p==2){a3+=H.clientLeft;a2+=H.clientTop}}return{x:a3,y:a2}}var f=al;function aV(a2,a0){var a1=a0.nextSibling;if(!a1){a0.parentNode.appendChild(a2)}else{a0.parentNode.insertBefore(a2,a1)}return a2}function aX(a0,a3,a1){var a2=-1;var a4=a0.firstChild;while(++a2!=a1&&a4){a4=a4.nextSibling}if(a2==a1){if(a2==a0.childNodes.length){a0.appendChild(a3)}else{a0.insertBefore(a3,a4)}return a3}return null}function x(a1){var a0=0;ar(a1,true,function(a2){a0+=ah(a2)});return a0}function o(a1){var a2={};for(var a0 in a1){a2[a0]=a1[a0]}return a2}function I(a0,a7,a1,a2,a4){if(!a0){a0=aM(a7,[9,11])}var a3=aO(a7,a0,true,true);var a5=a3.length-1;(function a6(a9){var bb,a8,ba=false;if(a5>0){a5--;bb=a1?a3[a5].nextSibling:a3[a5].previousSibling;if(!a6(a3[a5])){return false}}else{if(a5==0){if(a1&&(!a2||a2.test(X(a9)))){a8=a4(a9);if(a8===false){return a8}ba=(a8===1)}if(!a1&&a9==a7){bb=null}else{bb=a1?a9.firstChild:a9.lastChild}}}if(!ba){while(bb){if(!a6(bb)){return false}bb=(a1)?bb.nextSibling:bb.previousSibling}}if(!a1&&(!a2||a2.test(X(a9)))){if(a4(a9)===false){return false}}return true})(a0)}function ar(a0,a3,a1,a2){I(a0,a3,a1,/^#text$/,a2)}function R(a0,a3,a1,a2){I(a0,a3,a1,null,a2)}function aK(a0,a1){a1=a1.parentNode;while(a1){if(a1==a0){return true}a1=a1.parentNode}return false}function aO(a5,a4,a0,a2){if(a5==a4){return(a0||a2)?[a5]:[]}var a1=a0?[a5]:[];var a3=a5.parentNode;while(a3&&a3!=a4){a1.push(a3);a3=a3.parentNode}if(a2&&a4&&a3==a4){a1.push(a4)}return a1}function j(a4,a1,a2,a0){var a3=null;while(a4){if(a2&&a2(a4)){if(a0){return a4}a3=a4}if(a4.parentNode==a1){break}a4=a4.parentNode}return a2?a3:a4}function w(a2,a1,a0){var a6=aO(a2,null,a0,true);var a5=aO(a1,null,a0,true);var a7=null;for(var a4 in a6){for(var a3 in a5){if(a6[a4]==a5[a3]){return a6[a4]}}}return null}function ag(a2,a0){var a1=null;I(null,a2,a0,null,function(a3){if(a3==a2){return true}a1=a3;return false});return a1}function aM(a2,a1){while(a2.parentNode){if(a1){for(var a0 in a1){if(a2.parentNode.nodeType==a1[a0]){return a2}}}a2=a2.parentNode}return a2}function l(a1){var a0=-1;while(a1){a0++;a1=a1.previousSibling}return a0}function aT(a4,a0){var a3="";var a6=0;var a5,a2;for(a2=0;a2<a4.length;a2++){a5=a4.charAt(a2);var a1=null;switch(a5){case'"':a1="&quot;";break;case"'":a1="&#39;";break;case"&":a1="&amp;";break;case"<":a1="&lt;";break;case">":a1="&gt;";break;default:if(a0&&a5=="\n"){a1="<br>"}else{if(M(a5)&&(a2==0||a2==(a4.length-1)||a4.charAt(a2-1)==" "||a4.charAt(a2+1)==" ")){a1="&nbsp;"}}}if(a1){if((a2-a6)>0){a3+=(a4.substring(a6,a2))}a3+=a1;a6=a2+1}}if((a2-a6)>0){a3+=(a4.substring(a6,a2))}return a3}function a(a1){var a0=N("span");a0.innerHTML=a1;return a0.firstChild.nodeValue}function ab(a0){while(a0){if(a0.nodeType==1){if(a0.style.display=="none"){return false}}a0=a0.parentNode}return true}function aD(a1,a0){while(a1&&a1.nodeType!=1){a1=a1.parentNode}if(!a1){return}if(window.getComputedStyle){return document.defaultView.getComputedStyle(a1,"").getPropertyValue(a0)}else{if(a1.currentStyle){return a1.currentStyle[t(a0)]}}}function ao(a1,a0){if(p==2){a1.style.setAttribute("cssText",a0)}else{a1.setAttribute("style",a0)}}function aJ(a1,a0,a2){if(p==2){a1.style.setAttribute(a0,a2)}else{a1.style[a0]=a2}}function aw(a0){return(p==2?a0.style.getAttribute("cssText"):a0.getAttribute("style"))||""}function r(a3){var a1=aw(a3);if(a1){a1=a1.split(";");for(var a2 in a1){var a0=a1[a2].indexOf(":");if(a0>0&&a0<(a1[a2].length-1)&&/\s*\S+\s*/.test(a1[a2].substr(a0))){return 1}}}}function e(a0){do{var a1=/([A-Z])/.exec(a0);if(a1){a0=a0.substr(0,a1.index)+"-"+a1[1].toLowerCase()+a0.substr(a1.index+1)}}while(a1);return a0}var k=function(){var a0=/^\s*rgb\s*\(\s*(\d+)\%?\s*\,\s*(\d+)\%?\s*\,\s*(\d+)\%?\s*\)\s*$/i,a1={maroon:[128,0,0],red:[255,0,0],orange:[255,165,0],yellow:[255,255,0],olive:[128,128,0],purple:[128,0,128],fuchsia:[255,0,255],white:[255,255,255],lime:[0,255,0],green:[0,128,0],navy:[0,0,128],blue:[0,0,255],aqua:[0,255,255],teal:[0,128,128],black:[0,0,0],silver:[12,12,12],gray:[128,128,128]};return function(a6){if(a6.charAt(0)=="#"){if(a6.length<7){a6+="000000"}return[parseInt(a6.substr(1,2),16),parseInt(a6.substr(3,2),16),parseInt(a6.substr(5,2),16)]}var a3=a0.exec(a6);if(a3){var a5=parseInt(a3[1]),a4=parseInt(a3[2]),a2=parseInt(a3[3]);if(a6.indexOf("%")>-1){if(a5>100){a5=100}a5=(255*a5)/100;if(a4>100){a4=100}a4=(255*a4)/100;if(a2>100){a2=100}a2=(255*a2)/100}else{if(a5>255){a5=255}if(a4>255){a4=255}if(a2>255){a2=255}}return[a5,a4,a2]}return a1[a6.toLowerCase()]||[255,255,255]}}();var ay=function(){var a1={bold:"700",normal:"400"};function a0(a2){return a1[a2.toLowerCase()]||a2}return function(a4,a3,a2){switch(a4){case"backgroundColor":case"borderColor":case"outlineColor":case"color":a3=k(a3);a2=k(a2);return a3[0]==a2[0]&&a3[1]==a2[1]&&a3[2]==a2[2];case"fontWeight":a3=a0(a3);a2=a0(a2);break}return a3==a2}}();function t(a0){do{var a1=a0.indexOf("-");if(a1>-1){a0=(a1==(a0.length-1))?a0.substr(0,a1):a0.substr(0,a1)+a0.charAt(a1+1).toUpperCase()+a0.substr(a1+2)}}while(a1>-1);return a0}function aG(a1){if(a1.outerHTML){return a1.outerHTML}else{var a0=N("span");a0.appendChild(a1.cloneNode(true));return a0.innerHTML}}function Z(){return !(E==3&&G<8)}function T(a2,a3){if(a2.nodeType==1||a2==H){var a1=au(a2);if(a1){var a4=a1.split(" ");for(var a0 in a4){if(a3.test(a4[a0])){return a4[a0]}}}}return null}function au(a0){return a0.className}function am(a1,a0){return E==3?a1.setAttribute("className",a0):a1.className=a0}function U(a2,a0){for(var a1 in a0){if(a0[a1]==a2){return parseInt(a1)}}return -1}function X(a0){return a0.nodeName.toLowerCase()}function ah(a1,a0){if(typeof a0=="undefined"){a0=null}return a1.nodeType==3?a1.nodeValue.length:a0}function ap(a0){return typeof Node=="object"?a0 instanceof Node:(typeof a0=="object"&&typeof a0.nodeType=="number"&&typeof a0.nodeName=="string")}D(de,{visitAllNodes:R,getCommonAncestor:w,getInnerText:function(a0){if(a0.nodeType==3){return a0.nodeValue}return a0.innerText||a0.textContent||""},parseHTMLString:a,insertAfter:aV,insertAt:aX,findClassName:T,getPositionInWindow:f,getOuterHTML:aG,getComputedStyle:aD});(function(){var a0=[];L("Changes",function(){de.Changes.clear();de.doc.addObserver({onSectionAdded:function(a1){a0.push({esNode:a1,initHTML:a1.innerHTML})}})},"Doc");de.Changes={getChangedEditableSections:function(){var a3=[],a8=/(<\s*\w+\s[^>]*?)(?:style|class|id|value)\s*=\s*(?:""|'')([^<]*?>)/i,a5=/(<\s*\w+\s[^>]*?)\s*(?:style|class|id|value)\s*(>|(?:[^=][^<]*?>))/i,a1=/<[^\/][^<>]*?\s[^<>]*>/,a4=/(?:[\t\n\r ]|&nbsp;)/g;ak(false);for(var a6 in a0){var a7=a0[a6];if(a2(a7.esNode.innerHTML)!=a2(a7.initHTML)||a7.dirty){a3.push(a7.esNode)}}ak(true);return a3;function a2(bd){bd=bd.replace(a4," ");var ba,bb,bc,a9="";for(bb=0;bb<(p==5?2:1);bb++){bc=bb==0?a8:a5;while(ba=bc.exec(bd)){bd=bd.substr(0,ba.index)+ba[1]+ba[2]+bd.substr(ba.index+ba[0].length)}}if(ba){while(ba=a1.exec(bd)){a9+=bd.substr(0,ba.index)+ba[0].replace(a4,"");bd=bd.substr(ba.index+ba[0].length)}a9+=bd}else{a9=bd}return de.spell.stripSpellWrapperHTML(a9)}},clear:function(a4){ak(false);if(a4){for(var a2 in a0){if(a0[a2].esNode==a4){a0[a2].initHTML=a4.innerHTML;a0[a2].dirty=false;break}}}else{a0=[];var a1=de.doc.getAllEditSections();for(var a2 in a1){var a3=a1[a2];a0.push({esNode:a3,initHTML:a3.innerHTML})}}ak(true)},dirty:function(a2){for(var a1 in a0){if(!a2||a0[a1].esNode==a2){a0[a1].dirty=true}}},reset:function(){de.UndoMan.clear();for(var a1 in a0){a0[a1].esNode.innerHTML=a0[a1].initHTML}this.clear()}}})();(function(){L("Clipboard",function(){switch(p){case 2:A(document,"keydown",bg);break;case 1:A(document,"keypress",bd);break;case 5:A(document,"keydown",a3);break;case 3:A(document,"copy",a4);A(document,"paste",a9);A(document,"keydown",bn);break}br=N("textarea");ao(br,"width:1px;height:1px;border-style:none");a6=N("div");am(a6,ax);ao(a6,"position:absolute;width:1px;height:1px;display:none;z-index:-500");a6.appendChild(br);H.appendChild(a6)},"events.Events");var bi,a2,a1,br,a6,bh,bb;function bl(bs){var bt="",bu;if(bs.nodeType==3&&aH(bs)){bt=bs.nodeValue.replace(/[\t\n\r]/g," ")}else{if(bs.nodeType==1){switch(X(bs)){case"br":bt+="\n";break;case"li":bt+="\n - ";break;default:if(aL(bs)){bt+="\n"}}bu=bs.firstChild;while(bu){bt+=bl(bu);bu=bu.nextSibling}if(aL(bs)){bt+="\n"}}}return bt}function a8(){var bs=de.selection.getHighlightedDOM();if(!bs){return null}a2=bs;bi=bl(a2);if(aL(a2)){bi=bi.replace(/^\n/,"").replace(/\n$/,"")}a1=false;return bi}function bk(){var bs=a8();if(bs){de.selection.remove()}return bs}function bc(bu){if(!de.cursor.exists()){return}de.selection.remove();var bv=de.cursor.getCurrentCursorDesc();var bs,bx;if(bi){if(!a1){bx=a2}else{if(bi==bu){bx=a2}else{if(bu){bs=bu}else{bx=a2}}}}else{bs=bu}if(bx){bx=null;bs=bi}if(bx||bs){var bt=bv.relIndex;if(bv.isRightOf){bt++}if(X(bv.domNode)=="br"){bt=1}var by=de.doc.getEditSectionContainer(bv.domNode);if(by){var bw=de.doc.getEditProperties(by);if(!bw.singleLine&&bx){}else{if(bs){if(!bw.singleLine&&/\n/.test(bs)){de.UndoMan.execute("InsertHTML",aT(bs,true),bv.domNode.parentNode,bv.domNode,bt)}else{de.UndoMan.execute("InsertText",bv.domNode,bs,bt)}}}}}}function bf(bt){var bs=window.clipboardData.setData("Text",bt);return bs===J||bs}function bm(){var bs=window.clipboardData.getData("Text");if(bs===""){if(!window.clipboardData.setData("Text",bs)){bs=null}}return bs}function bg(bt){bt=bt||window.event;if(!de.events.Keyboard.isAcceleratorDown(bt)){return}switch(bt.keyCode){case 67:case 88:var bs=bt.keyCode==67?a8():bk();if(bs){if(bf(bs)){a1=true}else{bq(bs)}}break;case 86:var bu=bm();if(bu){bc(bu)}else{be()}break}}function a5(){try{if(netscape.security.PrivilegeManager.enablePrivilege){netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")}else{return false}}catch(bs){return false}return true}function bp(bx){try{if(!a5()){return false}var bw=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);bw.data=bx;var bs=Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);if(!bs){return false}bs.addDataFlavor("text/unicode");bs.setTransferData("text/unicode",bw,copytext.length*2);var bu=Components.interfaces.nsIClipboard;var bt=Components.classes["@mozilla.org/widget/clipboard;1"].getService(bu);if(!bt){return false}bt.setData(bs,null,bu.kGlobalClipboard)}catch(bv){return false}}function a7(){try{if(!a5()){return null}var bu=Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);if(!bu){return null}var bs=Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);if(!bs){return null}bs.addDataFlavor("text/unicode");bu.getData(bs,bu.kGlobalClipboard);var bx={},bt={},bw="";bs.getTransferData("text/unicode",bx,bt);if(bx){bx=bx.value.QueryInterface(Components.interfaces.nsISupportsString)}if(bx){bw=bx.data.substring(0,bt.value/2)}return bw}catch(bv){return null}}function bd(bt){if(!de.events.Keyboard.isAcceleratorDown(bt)){return}switch(bt.which){case 99:case 120:var bs=bt.which==99?a8():bk();if(bs){if(bp(bs)){a1=true}else{bq(bs)}}break;case 118:var bu=a7();if(bu){bc(bu)}else{be()}break}}function a3(bt){if(!de.events.Keyboard.isAcceleratorDown(bt)){return}switch(bt.keyCode){case 67:var bs=a8();if(bs){bq(bs)}break;case 88:var bs=bk();if(bs){bq(bs)}break;case 86:be();break}}function a4(bt){var bs=a8();if(bs){bq(bs)}}function a9(bs){bc(bs.clipboardData.getData("Text"));bs.preventDefault()}function bn(bt){if(de.events.Keyboard.isAcceleratorDown(bt)&&bt.keyCode==88){var bs=bk();if(bs){bq(bs)}}}function bq(bs){ba(bs)}function be(){ba()}function ba(bt){bb=de.cursor.getCurrentCursorDesc();if(bh){clearTimeout(bh)}br.value=bt?bt:"";var bv=aR();a6.style.left=(bv.left==0?-50:bv.left+10)+"px";a6.style.top=(bv.top==0?-50:bv.top+10)+"px";a6.style.display="";try{br.focus();br.select()}catch(bu){}var bs=bt?a0:bj;bh=setTimeout(bs,0)}function bo(){a6.style.display="none"}function a0(){bh=null;bo();a1=true;window.focus()}function bj(){bh=null;bo();if(bb){var bs=de.cursor.getCurrentCursorDesc();if(!bs||bs.domNode!=bb.domNode||bs.relIndex!=bb.relIndex){de.cursor.setCursor(bb)}}bc(br.value);window.focus()}})();function aQ(bg,a8,a1){var bh=a1||N("p");var a7=j(w(bg,a8,true),H,aL,true)||H;while(bg.firstChild){bg=bg.firstChild}while(a8.lastChild){a8=a8.lastChild}if(a7!=H&&!n(bh,a7)){if(X(a7)=="ul"||X(a7)=="ol"){bg=j(bg,a7);a8=j(a8,a7);var a6=[];while(bg){if(X(bg)=="li"){a6.push(bg)}bg=bg==a8?null:bg.nextSibling}return a6}return[a7]}var ba,bd=[],a4=[],a0,a9;R(a7,bg,false,bc);if(bd.length>0){for(var be in bd){if(bd[be].parentNode){bd[be].parentNode.removeChild(bd[be]);a4.push(bd[be])}}}a0=ba;if(!a0){a0=a7.firstChild;while(a0.firstChild){a0=a0.firstChild}}ba=null;bd=[];R(a7,a8,true,bc);if(bd.length>0){for(var be in bd){if(bd[be].parentNode){bd[be].parentNode.removeChild(bd[be]);a4.push(bd[be])}}}a9=ba;if(!a9){a9=a7.lastChild;while(a9.lastChild){a9=a9.lastChild}}for(var be in a4){H.appendChild(a4[be])}if(!a9||!a0){return[]}a3(a0,a9,a7);bf(a0,a9,a7,bh);var a2=j(bg,a7);a8=j(a8,a7);var a5=[];do{var bb=a2;while(bb){if(aL(bb)){a5.push(bb);break}bb=bb.firstChild}a2=a2==a8?null:a2.nextSibling}while(a2);return a5;function bc(bj){if(bj==a7){return}var bk=bj,bi=null;while(bk!=a7){if(aL(bk)){bi=bk}if(bk.parentNode==a7&&de.doc.getProtectedNodeContainer(bk)==bk){bd.push(bk);bi=null}bk=bk.parentNode}if(bi){ba=bi;return false}}function a3(bl,bi,bj){var bk=bl,bm=false;while(bk&&!bm){R(bj,bk,true,function(bp){bk=null;bm|=bp==bi;if(bp==bj){return}if(aL(bp)){var bo=bp;while(bo.parentNode!=bj){if(bo.previousSibling){var br=bo.parentNode.cloneNode(false);while(bo.previousSibling){var bq=bo.previousSibling;Q(2,bq);Q(1,bq,br,0)}Q(1,br,bo.parentNode.parentNode,l(bo.parentNode))}if(bo.nextSibling){var br=bo.parentNode.cloneNode(false);while(bo.nextSibling){var bn=bo.nextSibling;Q(2,bn);Q(1,bn,br)}Q(1,br,bo.parentNode.parentNode,l(bo.parentNode)+1)}bo=bo.parentNode}bk=bo.nextSibling;R(bp,bp,true,function(bs){if(bs==bi){bm=true}return !bm});return false}return !bm})}}function bf(bl,bp,bj,bi){bl=j(bl,bj);bp=j(bp,bj);var bq=bl,bm=null;while(bq){var bo=bq,bn=false;while(bo){if(aL(bo)){bn=true;break}bo=bo.firstChild}if(bn){if(bm){bk(bm,bq);bm=null}}else{if(!bm){if(!(bq.nodeType==3&&!aH(bq))){bm=bq}}}bq=bq==bp?null:bq.nextSibling}if(bm){bk(bm,null)}function bk(bv,bs){var bt=bi.cloneNode(false),br=bv;Q(1,bt,bj,l(bv));while(br!=bs){var bu=br.nextSibling;Q(2,br);Q(1,br,bt);br=bu}}}}(function(){var bs,be,a4=460,bm,a3,bq,bn,a8,bp,bh,bk=aZ("img,table,input,select,button,textarea,object"),bg=aZ("img,table,input,select,button,textarea,object,br");L("Cursor",function(){bq=N("span");bn=document.createTextNode("");bq.appendChild(bn);a8=document.createTextNode("");be=N("div");am(be,ax+" sw-cursor");H.appendChild(be);var bv="";var bu=aD(be,"background-color");if(!bu||bu=="transparent"||bu=="auto"||bu=="rgba(0, 0, 0, 0)"){bv="background-color:black;"}bu=aD(be,"z-index");if(!bu||bu=="0"||bu=="auto"){}bv+="z-index:100";ao(be,"position:absolute; width:2px;visibility:hidden;"+bv);A(window,"resize",ba);A(document,"keystroke",bo);h(de.cursor);de.UndoMan.addObserver({onAfterExec:a5,onAfterUndo:a5,onAfterRedo:a5})},"UndoMan");de.cursor={PlacementFlag:{INSIDE:1,BEFORE:2,AFTER:4},setCursorColor:function(bu){be.style.backgroundColor=bu},doesNodeSupportCursor:function(bu){return !de.doc.isProtectedNode(bu)&&de.doc.isNodeEditable(bu)},setCursor:function(bu){if(bu&&!this.doesNodeSupportCursor(bu.domNode)){bu=null}bs=bu;a2(false);if(bs){be.style.left=(bs.docLeft+(bs.isRightOf?bs.width:0))+"px";be.style.top=bs.docTop+"px";be.style.height=bs.height+"px";a2(true)}a3=null;this.fireEvent("CursorChanged",this.getCurrentCursorDesc());return bs!=null},getCursorDescAtXY:a9,getCurrentCursorDesc:function(){return bs?o(bs):null},refreshCursor:function(){if(!bs){return}if(bp){return}bc(bs);be.style.left=(bs.docLeft+(bs.isRightOf?bs.width:0))+"px";be.style.top=bs.docTop+"px";be.style.height=bs.height+"px"},scrollToCursor:a5,exists:function(){return bs!=null},isCursorEle:function(bu){return bu==be},getNonCursorNodeAtXY:function(bu,bx){var bv=be.style.display;be.style.display="none";var bw=ai(bu,bx);be.style.display=bv;return bw},getNextCursorMovement:br,isOnSameLine:a6,createCursorDesc:function(bw,bu,by){var bv=bf(bw);if(bv==0||(bv!=1&&((by&&!(bv&4))||(!by&&!(bv&2))))){return null}var bx={domNode:bw,relIndex:bu,isRightOf:by,placement:bv};bc(bx);if(bv==1&&(bx.width==0||bx.height==0)){return null}return bx},getPlacementFlags:bf,getNearestCursorDesc:function(bv,bu,bA,bx){if(X(bv)=="br"){bA=true}var bw=de.cursor.createCursorDesc(bv,bu,bA);if(bw&&X(bv)=="br"){var by=br(bw,true),bz=br(bw,false);if((!by||!a6(by,bw))&&(!bz||!a6(bz,bw))){return bw}return(bx?by:bz)||bw}return bw||br({domNode:bv,isRightOf:bA,relIndex:bu,y:f(bv).y},bx)}};function bo(bA,bC){if(!bs||bA.ctrlKey||bA.metaKey||bA.altKey){return}var bE=false;switch(bC){case"Left":case"Right":bE=true;var bD=br(bs,bC=="Left");if(!bD){bD=bs}var bz=bs;if(!de.cursor.setCursor(bD)&&bz){de.cursor.setCursor(bz)}break;case"Up":case"Down":bE=true;var bB=bC=="Up";var bx=aR();var bu=a3?a3:(bs.docLeft-bx.left)+(bs.isRightOf?bs.width:0);var bv=by();var bw;if(bv){bw=bi(bu,bs.docTop-bx.top,bv,bs,bB);a7()}if(!bw){bw=bs}var bz=bs;if(!de.cursor.setCursor(bw)&&bz){de.cursor.setCursor(bz)}a3=bu;break}if(bE){a5();return false}return true;function by(){var bH=[];var bL=[];var bJ;R(H,bs.domNode,!bB,function(bP){bK(bP);var bO=bf(bP);if(bO==0){return true}var bQ,bN;if(bP.nodeType==3){bQ=f(bP.parentNode);bN=bP.parentNode.offsetHeight}else{if(X(bP)=="br"){bQ=bd(bP);bN=bQ.height}else{bQ=f(bP);bN=bP.offsetHeight}}if(!a6(bJ?bJ:bs,{y:bQ.y,height:bN})){if(bJ){return false}bJ={y:bQ.y,height:bN}}if(bO==1){bH.push({domNode:bP,placement:1})}else{if(bO&2){if(bB){bL.push(bP)}else{bH.push({domNode:bP,placement:2})}}if(bO&4){if(bB){bH.push({domNode:bP,placement:4})}else{bL.push(bP)}}}});if(!bJ){return null}bK(null);if(bB){bH.reverse()}var bM=0;for(var bG in bH){var bI=bH[bG];var bF=ah(bI.domNode,1);bI.startIndex=bM;bI.endIndex=bI.startIndex+(bF-1);bI.length=bF;bM+=bF}return{nodes:bH,totalLength:bM};function bK(bN){while(bL.length>0){if(!bN||!aK(bL[bL.length-1],bN)){bH.push({domNode:bL.pop(),placement:bB?2:4})}else{break}}}}}function ba(bu){de.cursor.refreshCursor()}function bj(bu){be.style.visibility=bu?"visible":"hidden"}function bl(){return be.style.visibility=="visible"}function a2(bu){if(typeof bu!="undefined"){a2.on=bu}if(a2.on){bj(!bl());bm=setTimeout(a2,a4,1)}else{if(bm){clearTimeout(bm);bm=null;bj(false)}}}function a5(){if(!bs){return}var bv=_getViewPortSize(),bx=0,bu=0;if((bs.y+bs.height)>=bv.height){bu=(bs.y+bs.height)-bv.height}else{if(bs.y<0){bu=bs.y}}var bw=bs.x+(bs.isRightOf?bs.width:0)+parseInt(be.style.width);if(bw>=bv.width){bx=bw-bv.width}else{if(bs.x<0){bx=bs.x}}if(bx||bu){window.scrollBy(bx,bu)}}function bf(bx){var bw=de.doc.getPackageContainer(bx);if(bw){var bv=0;if(bw==bx){bv=2|4}return bv}if(de.doc.isESPlaceHolder(bx,false)){return(de.doc.isESPlaceHolder(bx,true))?2:0}if(de.doc.isMNPlaceHolder(bx,false)){return(de.doc.isMNPlaceHolder(bx,true))?2:0}if(bx.nodeType==3){if(aH(bx)){return 1}return 0}var bu=0;if(de.cursor.usrGetPlacementFlags){bu=de.cursor.usrGetPlacementFlags(bx);if(bu===J){bu=0}else{return bu}}if(bk[X(bx)]){bu=2}if(bg[X(bx)]){bu|=4}return bu}function bb(bw,bv,bu){if(a6(bw,bv)){return bw.adx<bv.adx}else{if(bw.ady==bv.ady){return Math.abs((bw.y+(bw.height/2))-bu)<Math.abs((bv.y+(bv.height/2))-bu)}}return bw.ady<bv.ady}function a1(by,bw,bu,bz){if(a6(by,bw)){return Math.abs(by.x-bu)<Math.abs(bw.x-bu)}var bx=Math.min(Math.abs(by.y-bz),Math.abs((by.y+by.height)-bz));var bv=Math.min(Math.abs(bw.y-bz),Math.abs((bw.y+bw.height)-bz));if(bx==bv){return Math.abs((by.y+(by.height/2))-bz)<Math.abs((bw.y+(bw.height/2))-bz)}return bx<bv}function a6(bv,bu){return(bv.y>=bu.y&&bv.y<(bu.y+bu.height))||(bu.y>=bv.y&&bu.y<(bv.y+bv.height))}function a7(){if(bp){bp.parentNode.removeChild(bq);bp.parentNode.removeChild(a8);bp.nodeValue=bh;bp=null}}function bt(bu){if(bp==bu){return}if(bp){a7()}bp=bu;bh=bu.nodeValue;bu.parentNode.insertBefore(bq,bu);bu.parentNode.insertBefore(a8,bq)}function a0(bu){a8.nodeValue=bh.substr(0,bu);bn.nodeValue=bh.charAt(bu);bp.nodeValue=bh.substr(bu+1);return bq.offsetHeight!=0&&bq.offsetWidth!=0}function bd(bv){a7();bp={};bn.nodeValue=B;aV(bq,bv);var bu=f(bq);bu.height=bq.offsetHeight;bq.parentNode.removeChild(bq);bp=null;return bu}function bc(bw){if(!bw){return}if(X(bw.domNode)=="br"){var bv=bd(bw.domNode);bw.x=bv.x;bw.y=bv.y;bw.height=bv.height;bw.width=0}else{var bx;if(bw.placement==1){bt(bw.domNode);a0(bw.relIndex);bx=bq}else{bx=bw.domNode}var by=f(bx);bw.x=by.x;bw.y=by.y;bw.width=bx.offsetWidth;bw.height=bx.offsetHeight}var bu=aR();bw.docLeft=bu.left+bw.x;bw.docTop=bu.top+bw.y;a7()}function br(bD,bx){var bu=bD.domNode,bG=bD.relIndex,bI=bD.isRightOf,bz,bB,bw,bv=bf(bD.domNode),bA,bC,bF=false,bH;if(bv==1){if(bD.isRightOf==bx){var by=de.cursor.createCursorDesc(bD.domNode,bD.relIndex,!bD.isRightOf);if(by){return by}}}else{if(bD.isRightOf&&bv!=1){if(bx){while(bu.lastChild){bu=bu.lastChild}if(bu!=bD.domNode){bG=ah(bu,2)-1;bI=true}}}}R(H,bu,!bx,function(bN){var bL=bN==bu;if(!ab(bN)||de.doc.isProtectedNode(bN)){bA=bN;return true}if(!bF&&!bL){bF=aL(bN)}bv=bf(bN);if(bA){var bS=w(bN,bA,true);var bP=aO(bx?bN:bA,bS,false);if(bx){bP.reverse();if((bv&4)&&!aK(bN,bA)&&X(bN)!="br"){bP.push(bN)}}else{if(!aK(bA,bN)&&X(bA)!="br"&&!de.doc.isProtectedNode(bA)&&!(bA==bu&&bI)){bP.push(bA)}}for(var bO in bP){var bK=bP[bO];if(bf(bK)&4){if(bE(bK)){return false}bz=bK;bB=1;bw=true;return false}bF|=aL(bK)}}if(bv==0){if(!de.doc.isNodePackaged(bN)){var bM=0;if(aA(bN)){bM=1}else{if(aF(bN)){bM=2}}if(bM){de.UndoMan.execute(de.UndoMan.hasUndo()?1:0,"InsertHTML",aG(bM==1?de.doc.createESPlaceholder(bN):de.doc.createMNPlaceholder()),bN,bN.firstChild,0);if(!bE(bN.firstChild)){bz=bN.firstChild;bB=0;bw=false}return false}}}else{if(bv==1){bt(bN);var bR=bL?bG:(bx?ah(bN)-1:0),bQ;if(bL){bQ=bI}else{if(bH){if(bF){bH=null;bQ=bx}else{bQ=bH.isRightOf}}else{bQ=bx}}for(;(bx&&bR>=0)||(!bx&&bR<bh.length);bR+=bx?-1:1){if(!a0(bR)){if(bL){bQ=!bQ}bL=false;continue}var bJ=f(bq);bJ.height=bq.offsetHeight;if(bE(bq,bJ)){return false}if(bH){if(!a6(bJ,bH)){bz=bN;bB=bR;bw=!bQ;return false}}if(!bL||bu!=bD.domNode){bz=bN;bB=bR;bw=bQ;return false}bt(bN);bL=false;bH={domNode:bN,isRightOf:bQ,y:bJ.y,height:bJ.height};if(de.doc.isMNPlaceHolder(bN)||de.doc.isESPlaceHolder(bN)){prevDesc.isRightOf=false;break}}a7()}else{if(bv&2){if(!bL||(bx&&bN==bu&&bI)){if(!bE(bN)){bz=bN;bw=false;bB=0}return false}}else{if(X(bN)=="br"){if(!bL){if(bE(bN)){return false}if(bx){bC=bN;if(bE(bA,bH&&bH.domNode==bA?bH:null)){return false}}else{bC=bN}}}}}}bA=bN;if(!bx&&bL&&bD.isRightOf&&bv!=1){return 1}});a7();return bz?de.cursor.createCursorDesc(bz,bB,bw):null;function bE(bL,bJ){if(bC){var bK=bd(bC),bJ=bJ||(X(bL)=="br"?bd(bL):{y:f(bL).y,height:bL.offsetHeight});if(!a6(bK,bJ)){bz=bC;bB=1;bw=true;return true}bC=null}return false}}function a9(bw,bu,by){if(!by){by=ai(bw,bu)}if(by==be){be.style.display="none";by=ai(bw,bu);be.style.display=""}if(!by){return null}var bx=bz();var bv=bi(bw,bu,bx);a7();return bv;function bz(){var bB=[],bD=0,bA=aN();(function bC(bI){var bF=bf(bI),bH,bE;if(bI.nodeType==1){bH=bI}else{if(bI.nodeType==3&&bF!=0){bt(bI);a8.nodeValue="";bn.nodeValue=bh;bp.nodeValue="";bH=bq}}if(bH){bE=X(bH)=="br"?bd(bH):f(bH);if((bE.y+bH.offsetHeight)<=0){a7();return true}if(bE.y>bA.height){a7();return false}a7()}if(bF==1){bB.push({domNode:bI,startIndex:bD,endIndex:bD+ah(bI)-1,length:ah(bI),placement:1});bD+=ah(bI)}else{if(bF&2){bB.push({domNode:bI,startIndex:bD,endIndex:bD+1,length:1,placement:2,posInWnd:bE});bD++}}var bJ=bI.firstChild;var bG=true;while(bJ){if(!bC(bJ)){bG=false;break}bJ=bJ.nextSibling}if(bF&4){bB.push({domNode:bI,startIndex:bD,endIndex:bD+1,length:1,placement:4,posInWnd:bE});bD++}return bG})(by);return{nodes:bB,totalLength:bD}}}function bi(bJ,bH,bC,bz,bE){var bw={};if(bC.totalLength==0){return null}var bx=bD(0,0,2);if(!bx){return null}var bO=bD(bC.nodes.length-1,bC.nodes[bC.nodes.length-1].length-1,1);if(bx.domNode==bO.domNode&&bx.absIndex==bO.absIndex){return bF(bx)}var bK=[bx,bO];var by=null;by=bb(bx,bO,bH)?bx:bO;var bP,bQ;for(var bv=1;bv<=2;bv++){if(bv==1){if(bz){bA(bx,bu(bx.absIndex),bO,bu(bO.absIndex));bL();bH=by.y+(by.height/2);by.ady=Math.abs(by.y-bH);continue}else{if(!bG()){continue}}}else{var bR=bB();if(typeof bR=="boolean"){if(!bR){break}}else{break}}while(true){if(bQ.absIndex==(bP.absIndex-1)){break}var bM=bQ.absIndex+Math.floor((bP.absIndex-bQ.absIndex)/2);if(bM==bQ.absIndex){bM++}else{if(bM==bP.absIndex){bM--}}var bI=bu(bM);var bN=bD(bI,bM-bC.nodes[bI].startIndex,0);if(!bN){break}if(bv==1){bK.push(bN)}if(bb(bN,by,bH)){by=bN}if(bv==1){if(bH>=bN.y&&bH<=(bN.y+bN.height)){break}else{if(bN.y>bH){bP=bN}else{bQ=bN}}}else{if(a6(bN,by)){if(bJ>=bN.x&&bJ<=(bN.x+bN.width)){break}else{if(bN.x>bJ){bP=bN}else{bQ=bN}}}else{if(bN.y>bH){bP=bN}else{bQ=bN}}}}}return bF(by);function bu(bU){var bT=bC.nodes;if(bT.length==1){return 0}if(bU>=bT[0].startIndex&&bU<=bT[0].endIndex){return 0}if(bU>=bT[bT.length-1].startIndex&&bU<=bT[bT.length-1].endIndex){return bT.length-1}var bV=0;var bS=bT.length-1;var bX;while(true){var bW=bV+Math.floor((bS-bV)/2);if(bW==bV){bW++}else{if(bW==bS){bW--}}if(bU>=bT[bW].startIndex&&bU<=bT[bW].endIndex){bX=bW;break}else{if(bU<bT[bW].startIndex){bS=bW}else{bV=bW}}}return bX}function bD(b1,b5,bZ){var bT=bC.nodes,bY=bZ==0||bZ==1,b0=b5,bV=b1,bW=null,bX;do{if(!bY&&bZ==0){b1=bV;b5=b0+1;if(b5>bT[b1].endIndex){b1++;b5=0}}var bS=false;while(b1>=0&&b1<bT.length){bX=bT[b1];if(ab(bX.domNode)){if(bX.placement==1){bt(bX.domNode);while(b5>=0&&b5<bh.length){if(bZ==0&&((bQ.domNode==bX.domNode&&bQ.relIndex==b5)||(bP.domNode==bX.domNode&&bP.relIndex==b5))){bS=true;break}if(bw["_"+b1+"_"+b5]){b5+=(bY?-1:1);continue}if(!a0(b5)){bw["_"+b1+"_"+b5]=true;b5+=(bY?-1:1);continue}bW=bq;break}}else{if(bZ==0&&((bQ.domNode==bX.domNode&&bQ.placement==bX.placement)||(bP.domNode==bX.domNode&&bP.placement==bX.placement))){bS=true;break}bW=bX.domNode;break}}if(bW||bS){break}b1+=(bY?-1:1);b5=(bY&&b1>=0&&b1<bT.length)?(bT[b1].placement==1?bT[b1].length-1:1):0}if(bW){break}}while(bZ==0&&!(bY=!bY));if(!bW){return null}var b4,bU,b6;if(bX.posInWnd){b4=bX.posInWnd}if(X(bW)=="br"){b4=b4||bd(bW);b6=b4.height;bU=0}else{b4=b4||f(bW);bU=bW.offsetWidth;b6=bW.offsetHeight}var b7=Math.abs(b4.x-bJ),b3=Math.abs(b4.x+bU-bJ),b2;switch(bX.placement){case 2:b2=false;break;case 4:b2=true;break;default:b2=b3<b7}return{domNode:bX.domNode,relIndex:b5,absIndex:bX.startIndex+b5,placement:bX.placement,isRightOf:b2,x:b4.x,y:b4.y,adx:b2?b3:b7,ady:Math.min(Math.abs(b4.y-bH),Math.abs(b4.y+bW.offsetHeight-bH)),width:bU,height:b6}}function bG(){if(!((bH>=bx.y&&bH<=(bx.y+bx.height))||(bH>=bO.y&&bH<=(bO.y+bO.height)))&&bH>=bx.y&&bH<=(bO.y+bO.height)){bQ=bx;bP=bO;return true}return false}function bB(){if(bJ>=by.x&&bJ<(by.x+by.width)){return false}else{if(by.x>bJ){bP=by;bQ=null;for(i in bK){bN=bK[i];if(bN==by){continue}var bT;if(a6(bN,by)){bT=bN.x<by.x}else{bT=bN.y<by.y}if(bT&&(!bQ||a1(bN,bQ,by.x,by.y))&&bN.absIndex<bP.absIndex){bQ=bN}}if(!bQ){return by}}else{bQ=by;bP=null;var bU=false;for(i in bK){bN=bK[i];var bS;if(a6(bN,by)){bS=bN.x>by.x}else{bS=bN.y>by.y}if(bS&&(!bP||a1(bN,bP,(by.x+by.width),by.y))&&bN.absIndex>bQ.absIndex){bP=bN}}if(!bP){return by}}}return true}function bL(){by=bE?bx:bO;for(var bS in bK){var bT=bK[bS];if(a6(bT,bz)||(bE&&bT.y>bz.y)||(!bE&&bT.y<bz.y)){continue}if(bb(bT,by,bH)){by=bT}}}function bA(bX,bZ,bU,bW){var b0=[[bX,bZ,bU,bW]];while(b0.length>0){var bY=b0.pop();bX=bY[0];bZ=bY[1];bU=bY[2];bW=bY[3];var bS=bZ;while(bS<bC.nodes.length&&X(bC.nodes[bS].domNode)=="table"){bS++}if(bS==bC.nodes.length){continue}if(bS!=bZ){bX=bD(bS,0,2);bZ=bS;bK.push(bX)}bS=bW;while(bS>=0&&X(bC.nodes[bS].domNode)=="table"){bS--}if(bS==-1){continue}if(bS!=bW){bU=bD(bS,bC.nodes[bS].length-1,1);bW=bS;bK.push(bU)}if(bX.absIndex>=(bU.absIndex-1)||a6(bU,bX)){continue}var bV=bX.absIndex+Math.floor((bU.absIndex-bX.absIndex)/2);if(bV==bX.absIndex){bV++}else{if(bV==bU.absIndex){bV--}}var bT=bu(bV);bQ=bX;bP=bU;var b1=bD(bT,bV-bC.nodes[bT].startIndex,0);if(!b1){continue}bK.push(b1);b0.push([bX,bZ,b1,bT]);b0.push([b1,bT,bU,bW])}}function bF(bV){if(!bV){return null}if(X(bV.domNode)=="br"){var bU=br(bV,true);if(bU&&a6(bV,bU)){bV=bU;bV.isRightOf=true}else{var bT=br(bV,false);if(bT&&a6(bV,bT)){bV=bT;bV.isRightOf=false}}}else{if(de.doc.isMNPlaceHolder(bV.domNode)){bV.isRightOf=false}}bV.placement=bf(bV.domNode);var bS=aR();bV.docLeft=bS.left+bV.x;bV.docTop=bS.top+bV.y;return bV}}})();var ax="sw-protect",af="editable",V="sw-packaged";function aF(a0){if(v(a0)){return !ac(a0)}return false}function aA(a0){if(de.doc.isEditSection(a0)){return !ac(a0)}return false}function ac(a0){var a1=false;R(a0,a0,true,function(a4){if(a4==a0||de.doc.isProtectedNode(a4)){return}var a3=de.cursor.getPlacementFlags(a4);if(a3==1){if(aH(a4)&&ah(a4)>0){if(M(a4.nodeValue)){var a5=N("span"),a2=document.createTextNode(a4.nodeValue);a5.appendChild(a2);a4.nodeValue="";a4.parentNode.appendChild(a5);a1=a5.offsetHeight!=0&&a5.offsetWidth!=0;a4.parentNode.removeChild(a5);a4.nodeValue=a2.nodeValue}else{a1=true}}}else{if(a3){a1=true}}return !a1});return a1}var v=function(){var a0=aZ("li,dd,dt,p,td,th,h1,h2,h3,h4,h5,h6,pre,div");return function(a1){return a0[X(a1)]||a1==H}}();(function(){L("Doc",function(){h(de.doc);var a8=de.doc.getAllEditSections();c=false;for(var a7 in a8){m(a8[a7],true)}c=true;de.doc.addObserver({onSectionAdded:function(a9){c=false;m(a9,false);c=true}})});var a4={},a3="sw-mn-ph",a1="sw-es-ph",a5=new RegExp("^"+af+".*$"),a2=new RegExp("^"+af+"-?(.+)$"),a0=new RegExp("^"+ax+"$"),a6=new RegExp("^"+V+"$");de.doc={getEditSectionContainer:function(a7){return j(a7,null,this.isEditSection,true)},isEditSection:function(a7){if(a7&&a7.nodeType==1){return T(a7,a5)}return false},getAllEditSections:function(){var a7=[];R(H,H,true,function(a8){if(de.doc.isEditSection(a8)){a7.push(a8)}});return a7},isNodeEditable:function(a7){var a8=this.getEditSectionContainer(a7);return a8!=null&&a8!=a7},getProtectedNodeContainer:function(a7){return j(a7,null,function(a8){return a8.nodeType==1&&T(a8,a0)},true)},isProtectedNode:function(a7){return this.getProtectedNodeContainer(a7)!=null},getPackageContainer:function(a7){return j(a7,null,function(a8){return a8.nodeType==1&&T(a8,a6)},true)},isNodePackaged:function(a7){return this.getPackageContainer(a7)!=null},declarePropertySet:function(a8,be){be=o(be);if(typeof be.actionFilter=="string"){var a7=be.actionFilter;if(a7.charAt(0)!="!"){be.afInclusive=true;if(a7){a7+=","}a7+="inserthtml,inserttext,removedom,removetext"}else{a7=a7.substr(1);be.afInclusive=false}var bg=a7.toLowerCase().split(",");var bd="(";for(var bb in bg){bd+=((bb=="0")?"":"|");var a9=bg[bb];var bc=/^format\((.+)\)$/.exec(a9);if(bc){var bf=bc[1].split(",");for(var ba in bf){bd+=((ba=="0")?"":"|")+"format"+bf[ba]}}else{bd+=a9;if(a9.indexOf("format")==0){bd+=".+"}}}bd+=")";be.afRE=new RegExp("^"+bd+"$")}a4[a8]=be},declarePropertySets:function(a8){for(var a7 in a8){this.declarePropertySet(a7,a8[a7])}},getEditProperties:function(a8){if(!this.isEditSection(a8)){a8=this.getEditSectionContainer(a8)}if(a8){var a7=T(a8,a5);if(a7){var a9=a2.exec(a7);return a9?a4[a9[1]]||{}:{}}return{}}return null},createMNPlaceholder:function(){var a7=N("span");am(a7,a3);a7.innerHTML="&nbsp;";return a7},isMNPlaceHolder:function(a8,a7){switch(a8.nodeType){case 1:return au(a8)==a3;case 3:return !a7&&a8.parentNode&&au(a8.parentNode)==a3}return false},createESPlaceholder:function(a7){var a8=this.getEditProperties(a7).phMarkup||"&nbsp;";var a9=N("span");am(a9,a1);a9.innerHTML=a8;return a9},isESPlaceHolder:function(a9,a7){while(a9){if(a9.nodeType==1){var a8=au(a9);if(a8==a1){return true}}if(a7){break}a9=a9.parentNode}return false},registerEditSection:function(a7,a9){var a8=au(a7);am(a7,(a8?a8+" ":"")+af+(a9?"-"+a9:""));if(!ac(a7)){a7.appendChild(this.createESPlaceholder(a7))}this.fireEvent("SectionAdded",a7)},unregisterEditSection:function(a7){var a8=au(a7);if(a8){am(a7,a8.replace(new RegExp("^|s"+af+"S*$","g"),""))}this.fireEvent("SectionRemoved",a7)}}})();var an={"1":"Bad arguments"};function aj(a0){throw new Error(typeof a0=="number"?an[a0]:a0)}function A(a3,a0,a2){if(a3.setInterval&&a3!=window){a3=window}switch(a0){case"keystroke":a1(a3,"keydown",function(a5){var a4=de.events.Keyboard.getKeyIdentifier(a5,true);if(a4){return a2(a5,a4)}});a1(a3,"keypress",function(a5){var a4=de.events.Keyboard.getKeyIdentifier(a5,false);if(a4){return a2(a5,a4)}});break;case"mousedown":a1(a3,a0,function(a4){return de.events.Mouse.sniffMouseDownEvent(a4)?a2(a4):true});break;case"mouseup":a1(a3,a0,function(a4){return de.events.Mouse.sniffMouseUpEvent(a4)?a2(a4):true});break;case"mousemove":a1(a3,a0,function(a4){return de.events.Mouse.sniffMouseMoveEvent(a4)?a2(a4):true});break;default:a1(a3,a0,a2)}function a1(a6,a4,a5){if(!a2.evWrappers){a2.evWrappers={}}if(!a2.evWrappers[a4]){a2.evWrappers[a4]=[]}a2.evWrappers[a4].push([a6,a7]);if(a6.addEventListener){a6.addEventListener(a4,a7,false)}else{if(a6.attachEvent){a6.attachEvent("on"+a4,a7)}}function a7(a8){a8=a8||window.event;if(a5(a8)===false){return de.events.consume(a8)}}}}function ad(a4,a1,a3){if(a1=="keystroke"){ad(a4,"keydown",a3);ad(a4,"keypress",a3);return}if(a3.evWrappers&&a3.evWrappers[a1]){for(var a2 in a3.evWrappers[a1]){var a0=a3.evWrappers[a1][a2];if(a0[0]==a4){if(a3.evWrappers[a1].length==1){delete a3.evWrappers[a1]}else{a3.evWrappers[a1].splice(a2,1)}a3=a0[1];break}}}if(a4.removeEventListener){a4.removeEventListener(a1,a3,false)}else{if(a4.detachEvent){a4.detachEvent("on"+a1,a3)}}}D(de.events,{addHandler:A,removeHandler:ad,getXYInWindowFromEvent:function(a2){var a1=0,a0=0;if(a2.clientX||a2.clientX===0){a1=a2.clientX;a0=a2.clientY}else{if(a2.pageX!=null){var a3=aR();a1=a2.pageX-a3.left;a0=a2.pageY-a3.top}}return{x:a1,y:a0}},getEventTarget:function(a0){return a0.target||a0.srcElement||document},consume:function(a0){de.events.stopPropogation(a0);de.events.preventDefault(a0);return false},stopPropogation:function(a0){if(p==2){a0.cancelBubble=true}else{if(a0.stopPropagation){a0.stopPropagation()}}},preventDefault:function(a0){if(p==2){a0.returnValue=false}else{if(a0.preventDefault){a0.preventDefault()}}}});(function(){var a4="1",a2="2",a3,a0=false,a1={};L("events.Mouse",function(){if(E==3){a3={"1":a4,"2":a2}}else{a3={"0":a4,"2":a2}}a1[a4]=a1[a2]=false});de.events.Mouse={sniffMouseDownEvent:function(a7){var a6=a3[a7.button];if(a6){if(W==2&&a6==a4&&a7.ctrlKey){a6=RIGHT_CLICK}a1[a6]=true}if(a5(a7)){a0=this.isLeftDown();return false}return true},sniffMouseUpEvent:function(a7){var a6=a3[a7.button];if(a6){if(W==2&&a6==a4){this.clearDownStates()}else{a1[a6]=false}}a0=this.isLeftDown();return !a5(a7)},sniffMouseMoveEvent:function(a6){return !(this.isLeftDown()&&a0)},isLeftDown:function(){return a1[a4]},isRightDown:function(){return a1[a2]},clearDownStates:function(){a1[a4]=false;a1[a2]=false}};function a5(a8){var a7=de.events.getEventTarget(a8);if(a7==window||a7==document||a7==document.documentElement){if(p==5){return}var a9=de.events.getXYInWindowFromEvent(a8),a6=_getViewPortSize();if(a9.x>=a6.width){return 1}return a9.y>=a6.height}}})();var q={};function at(a0,a1,a2){a0=a0.toLowerCase();q[a0+"Eval"]=a1;q[a0+"Wrapper"]=a2}(function(){function a0(a1,a2){var a3=N("span");aJ(a3,a1,a2);return a3}(function(a1){for(var a2 in a1){at(a2,a1[a2][0],a1[a2][1])}})({bold:[function(a4){var a3=[];if(X(a4)=="b"||X(a4)=="strong"){a3.push({type:1})}var a2=a4.style.fontWeight;if(a2){var a1=a2=="bold";if(!a1){a2=parseInt(a2);a1=(!isNaN(a2)&&a2>=700)}if(a1){a3.push({type:3,match:"fontWeight"})}}return a3.length>0?{strip:a3,inline:N("strong"),value:true}:null},function(){return N("strong")}],italics:[function(a2){var a1=[];if(X(a2)=="i"||X(a2)=="em"){a1.push({type:1})}if(a2.style.fontStyle=="italic"){a1.push({type:3,match:"fontStyle"})}return a1.length>0?{strip:a1,inline:N("em"),value:true}:null},function(){return N("em")}],underline:[function(a2){var a1=[];if(X(a2)=="u"){a1.push({type:1})}if(a2.style.textDecoration=="underline"){a1.push({type:3,match:"textDecoration"})}return a1.length>0?{strip:a1,inline:a0("textDecoration","underline"),value:true}:null},function(){return a0("textDecoration","underline")}],strike:[function(a2){var a1=[];if(X(a2)=="strike"){a1.push({type:1})}if(a2.style.textDecoration=="line-through"){a1.push({type:3,match:"textDecoration"})}return a1.length>0?{strip:a1,inline:a0("textDecoration","line-through"),value:true}:null},function(){return a0("textDecoration","line-through")}],color:[function(a1){if(a1.style.color&&a1.style.color.length>0){return{strip:[{type:3,match:"color"}],inline:a0("color",a1.style.color),value:a1.style.color}}},function(a1){return a0("color",a1)}],backcolor:[function(a1){if(a1.style.backgroundColor&&a1.style.backgroundColor.length>0){return{strip:[{type:3,match:"backgroundColor"}],inline:a0("backgroundColor",a1.style.backgroundColor),value:a1.style.backgroundColor}}},function(a1){return a0("backgroundColor",a1)}],fontsize:[function(a1){if(X(a1)=="small"||X(a1)=="big"){var a2=X(a1)=="small"?"smaller":"larger";return{strip:[{type:1}],inline:a0("fontSize",a2),value:a2}}if(a1.style.fontSize&&a1.style.fontSize.length>0){return{strip:[{type:3,match:"fontSize"}],inline:a0("fontSize",a1.style.fontSize),value:a1.style.fontSize}}},function(a1){return a0("fontSize",a1)}],fontfamily:[function(a1){if(a1.style.fontFamily&&a1.style.fontFamily.length>0){return{strip:[{type:3,match:"fontFamily"}],inline:a0("fontFamily",a1.style.fontFamily),value:a1.style.fontFamily}}},function(a1){return a0("fontFamily",a1)}],link:[function(a1){if(X(a1)=="a"){return{strip:[{type:1}],inline:a1.cloneNode(false),value:{url:a1.href,title:a1.title}}}},function(a1){var a2=N("a");a2.href=a1.url;a2.title=a1.title;return a2}]})})();var az=function(){var a1=function(a3,a2){this.node=a3;this.pos=a2;this.children=[];this.isShared=false;this.parent=null};a1.prototype={visit:function(a3){if(a3(this)===false){return false}for(var a2 in this.children){if(!this.children[a2].visit(a3)){return false}}return true},disconnect:function(){this.visit(function(a2){if(!a2.isShared){a0(a2,false)}})},collapse:function(){var a8=w(this.getStartFragment().node,this.getEndFragment().node,false);var bb=this;while(bb.node!=a8){bb=bb.children[0]}this.disconnect();var bl=false,bi=this,a6=false;a9();var ba=a2(bb,true,a3(this.getStartFragment(),a8));for(var bg in ba){if(ba[bg].migrantRoots.length>0){var a4=ba[bg].migrationPoint.node;var bj=ba[bg].migrationPoint.children[0].pos;if(bk(ba[bg].migrationPoint.children[0].node)){bj++}for(var be=0;be<ba[bg].migrantRoots.length;be++){Q(1,ba[bg].migrantRoots[be],a4,bj+be)}var bf=false;if(v(a4)){R(a4,a4,true,function(bm){if(bm==a4){return}if(!(de.doc.isMNPlaceHolder(bm,false)&&(bm.nodeType==3?bm.parentNode.parentNode==a4:bm.parentNode==a4))&&de.cursor.getPlacementFlags(bm)){bf=true;return false}})}var bc=false;for(var bd=0;bd<a4.childNodes.length;bd++){var bh=a4.childNodes[bd];if(de.doc.isMNPlaceHolder(bh,true)||de.doc.isESPlaceHolder(bh,true)){if(bc||!v(a4)||bf){Q(2,bh)}bc=true}}}}return ba.length>0&&ba[0].migrantRoots.length>0?ba[0].migrantRoots[0]:null;function a2(bn,bs,bz){var bB={migrationPoint:bz,migrantRoots:[]};var by=[bB];for(var bw=bs?bn.getEndFragment():bn.getStartFragment();bw!=(bs?bn:bn.parent);bw=bw.parent){var bp,bq;if(bs){a6=false;for(var bv=bw.parent;bv!=bn;bv=bv.parent){if(bv.isShared&&a5(bv.node)){a6=true;break}}}if(!bs||bw.isShared){bp=bw.node;bq=bp.nextSibling;if(a5(bp)){bl=true;if(bs){a0(bw,true)}}if(!bs||a7(bp)){if(bp.firstChild){bp=bp.cloneNode(false)}else{Q(2,bp)}while(bB.migrationPoint!=bb&&!n(bp,bB.migrationPoint.node)){bB.migrationPoint=a3(bB.migrationPoint)}for(var bt=0;bt<by.length;bt++){for(var br in by[bt].migrantRoots){Q(1,by[bt].migrantRoots[br],bp)}by[bt].migrantRoots=[bp];if(bt<(by.length-1)){bp=bp.cloneNode(false)}}}else{if(!a5(bp)){bl=true;if(!bp.firstChild){a0(bw,true)}}}}else{if(!bw.parent.isShared){continue}var bx=bi;while(bx.children.length>0&&bx!=bw.parent){bx=bx.children[0]}if(bx==bw.parent){bq=null;if(!bx.insertedPH){if(bk(bx.children[0].node)){bq=bx.node.childNodes.length>(bx.children[0].pos+1)?bx.node.childNodes[bx.children[0].pos+1]:null}else{bq=bx.node.childNodes.length>bx.children[0].pos?bx.node.childNodes[bx.children[0].pos]:null}}}else{bq=bw.parent.node.firstChild}}if(bs&&!a7(bw.parent.node)&&!a5(bw.parent.node)){bl=true}else{if(!bs&&bw==bn){continue}}var bA=bw.getIndexInParent();if(bs){bw.parent.migrantIndex=0}while(bq&&(a6||!bl)){bp=bq;bq=bp.nextSibling;bA++;var bm;if(bs){var bo;if(bw.parent.migrants&&bw.parent.migrants.length>bw.parent.migrantIndex){bo=bw.parent.migrants[bw.parent.migrantIndex]}else{bo=aa(bp.parentNode,bp,0,bp,ah(bp,1));if(!bw.parent.migrants){bw.parent.migrants=[]}bw.parent.migrants.push(bo)}bw.parent.migrantIndex++;bm=a2(bo.children[0],false,by[by.length-1].migrationPoint)}else{bm=a2(bw.parent.children[bA],false,by[by.length-1].migrationPoint)}for(var bt in bm){if(bm[bt].migrantRoots.length==0){continue}var bu=false;for(var br in by){if(by[br].migrationPoint==bm[bt].migrationPoint){by[br].migrantRoots=by[br].migrantRoots.concat(bm[bt].migrantRoots);bu=true;break}}if(!bu){by.push(bm[bt])}}bB=by[by.length-1]}}return by}function a3(bm){do{bm=bm.parent}while(bm!=bb&&!(bk(bm.node)&&a5(bm.node)));return bm}function a5(bm){return S(bm)||X(bm)=="li"}function a7(bm){return bm.nodeType==3||ae(bm)}function bk(bm){return aK(H,bm)}function a9(){for(var bn=bi.getStartFragment();bn!=null;bn=bn.parent?bn.parent:null){var bm=bn.node;if(v(bm)||de.doc.isEditSection(bm)){if(bn.isShared){var bq=0;if(aA(bm)){bq=1}else{if(aF(bm)){bq=2}}if(bq){var bp=bq==1?de.doc.createESPlaceholder(bm):de.doc.createMNPlaceholder();Q(1,bp,bm);bn.insertedPH=1}}else{while(bm.firstChild){Q(2,bm.firstChild)}Q(1,de.doc.createMNPlaceholder(),bm);bn.insertedPH=1;while(!bn.isShared){if(bn.parent.isShared){Q(1,bn.node,bn.parent.node,bn.pos)}else{var bo=bn.parent.node;while(bo.firstChild){Q(2,bo.firstChild)}Q(1,bn.node,bo)}if(!bn.parent){break}bn=bn.parent}}break}}}},getStartFragment:function(){var a2=this;while(a2.children.length>0){a2=a2.children[0]}return a2},getEndFragment:function(){var a2=this;while(a2.children.length>0){a2=a2.children[a2.children.length-1]}return a2},getIndexInParent:function(){if(!this.parent){return null}var a2=0;while(this!=this.parent.children[a2]){a2++}return a2},wasStartSplit:function(){return this.getStartFragment().preSplitNode?true:false},wasEndSplit:function(){return this.getEndFragment().postSplitNode?true:false},getPreSplitNode:function(){var a2=this.getStartFragment();return a2.preSplitNode?a2.preSplitNode:null},getPostSplitNode:function(){var a2=this.getEndFragment();return a2.postSplitNode?a2.postSplitNode:null},getAdjustedNodeIndex:function(a4,a2){if(a4.nodeType==3&&a2>=ah(a4)){var a5=this.getStartFragment(),a3=this.getEndFragment();if(a5.wasStartSplit()){var a6=a5.getPreSplitNode();if(a4==a6){a2-=ah(a6);a4=a5.node}}if(a3.wasEndSplit()&&a4==a3.node&&a2>=ah(a4)){a2-=ah(a3.node);a4=a3.getPostSplitNode()}}return{node:a4,index:a2}},getOriginalNodeIndex:function(a4,a2){if(a4.nodeType==3){var a5=this.getStartFragment(),a3=this.getEndFragment();if(a4==a3.getPostSplitNode()){a2+=ah(a3.node);a4=a3.node}if(a5.wasStartSplit()&&a4==a5.node){var a6=a5.getPreSplitNode();a2+=ah(a6);a4=a6}}return{node:a4,index:a2}}};function a0(a2,a3){if(a3||(a2.parent&&a2.parent.isShared)){Q(2,a2.node)}}return a1}();function aa(bc,a0,bb,a8,a6){if(!bc){bc=w(a0,a8)}var a7=false;while(a0.firstChild){a0=bb==0?a0.firstChild:a0.lastChild;a7=true}if(a7&&bb>0){bb=ah(a0,1)}a7=false;while(a8.firstChild){a8=a6==0?a8.firstChild:a8.lastChild;a7=true}if(a7&&a6>0){a6=ah(a8,1)}if(de.doc.isMNPlaceHolder(a0)||de.doc.isESPlaceHolder(a0)){bb=0}if(de.doc.isMNPlaceHolder(a8)||de.doc.isESPlaceHolder(a8)){a6=ah(a8,1)}var a3=[];R(bc,a0,true,function(bf){a3.push(bf);return bf!=a8});var be=aO(a0,bc,false,true);be.reverse();a3=be.concat(a3);var a5;for(var a2 in a3){var a1=a3[a2],bd=0,a4=0;if((a1==a0||a1==a8)&&a1.nodeType==3){if(a1==a0&&bb>0&&bb<ah(a1)){bd=a1;a1=Q(3,a1,bb);if(a8==a0){a8=a1;a6-=ah(a0)}a0=a1}if(a1==a8&&a6>0&&a6<ah(a1)){a4=Q(3,a1,a6)}}var a9=new az(a1,l(a1));if(!a5){a5=a9}else{a9.parent=null;a5.visit(function(bf){if(bf.node==a9.node.parentNode){a9.parent=bf}return a9.parent==null});a9.parent.children.push(a9)}a9.isShared=!(bd||a4)&&((a1==a0&&bb==ah(a1,1))||(a1==a8&&a6==0));if(bd){a9.preSplitNode=bd}if(a4){a9.postSplitNode=a4}}ba(a5);return a5;function ba(bi){var bf=false;for(var bg in bi.children){var bh=bi.children[bg];ba(bh);bf|=bh.isShared}bi.isShared|=(bf||bi==a5||bi.node.childNodes.length!=bi.children.length)}}de.buildFragment=aa;var aY={},aB,c=true;function P(a3,a1,a0,a2){if(!a3){a3=P.genOp+1;do{a3++}while(aY[a3]);P.genOp=a3}aY[a3]={exec:a1,undo:a0,redo:a2};return a3}P.genOp=100;function Q(a3){var a1=aY[a3];var a2=Array.prototype.slice.call(arguments);a2.shift();a2.unshift({opCode:a3});var a0=a1.exec.apply(a1,a2);if(c){if(!aB){aB=[]}aB.push(a2[0])}return a0}function aP(){var a0=aB;aB=null;return a0}function u(a3){for(var a1=a3.length-1;a1>=0;a1--){var a2=a3[a1];var a0=aY[a2.opCode];a0.undo(a2)}}function aW(a3){for(var a1 in a3){var a2=a3[a1];var a0=aY[a2.opCode];a0.redo(a2)}}de.recordOperations=function(a0){c=a0};P(1,function(a3,a1,a2,a0){a3.newNode=a1;a3.parent=a2;if(a0||a0===0){a3.pos=a0}this.redo(a3)},function(a0){a0.parent.removeChild(a0.newNode)},function(a0){if(a0.pos||a0.pos===0){aX(a0.parent,a0.newNode,a0.pos)}else{a0.parent.appendChild(a0.newNode)}});P(2,function(a0,a1){a0.parent=a1.parentNode;a0.pos=l(a1);a0.target=a1;this.redo(a0)},function(a0){aX(a0.parent,a0.target,a0.pos)},function(a0){a0.parent.removeChild(a0.target)});P(3,function(a1,a2,a0){a1.target=a2;a1.index=a0;a1.rem=a2.splitText(a0);return a1.rem},function(a0){a0.target.nodeValue+=a0.rem.nodeValue;a0.rem.parentNode.removeChild(a0.rem);a0.rem.nodeValue=""},function(a1){var a0=a1.target.nodeValue;a1.rem.nodeValue=a0.substr(a1.index);a1.target.nodeValue=a0.substr(0,a1.index);aV(a1.rem,a1.target)});P(4,function(a2,a4,a5,a0){a2.target=a4;a2.index=a0;a2.len=a5.length;var a3=a4.nodeValue.substr(0,a0),a1=a4.nodeValue.substr(a0);a4.nodeValue=a3+a5+a1},function(a1){a1.text=a1.target.nodeValue.substr(a1.index,a1.len);var a2=a1.target.nodeValue.substr(0,a1.index),a0=a1.target.nodeValue.substr(a1.index+a1.len);a1.target.nodeValue=a2+a0;delete a1.len},function(a1){a1.len=a1.text.length;var a2=a1.target.nodeValue.substr(0,a1.index),a0=a1.target.nodeValue.substr(a1.index);a1.target.nodeValue=a2+a1.text+a0;delete a1.text});P(5,function(a3,a5,a0,a2){a3.target=a5;a3.index=a0;a3.text=a5.nodeValue.substr(a0,a2);var a4=a5.nodeValue.substr(0,a0),a1=a5.nodeValue.substr(a0+a2);a5.nodeValue=a4+a1},aY[4].redo,aY[4].undo);P(6,function(a2,a3,a0,a1){a2.target=a3;a2.css=a0;a2.newValue=a1;a2.oldValue=p==2?a2.target.style.getAttribute(a2.css):a2.target.style[a2.css];this.redo(a2)},function(a0){if(p==2){a0.target.style.setAttribute(a0.css,a0.oldValue)}else{a0.target.style[a0.css]=a0.oldValue}},function(a0){if(p==2){a0.target.style.setAttribute(a0.css,a0.newValue)}else{a0.target.style[a0.css]=a0.newValue}});P(7,function(a1,a2,a0){a1.target=a2;a1.newName=a0;a1.oldName=au(a2);this.redo(a1)},function(a0){am(a0.target,a0.oldName)},function(a0){am(a0.target,a0.newName)});P(9,function(a1,a2,a0){a1.row=a2;a1.index=a0>a2.cells.length?a2.cells.length:a0;if(a1.index<0){a1.index=0}return this.redo(a1)},function(a0){a0.row.deleteCell(a0.index)},function(a0){return a0.row.insertCell(a0.index)});P(8,function(a2,a1,a0){a2.table=a1;a2.index=a0>a1.rows.length?a1.rows.length:a0;if(a2.index<0){a2.index=0}return this.redo(a2)},function(a0){a0.table.deleteRow(a0.index)},function(a0){return a0.table.insertRow(a0.index)});P(10,function(a2,a1,a0){a2.table=a1;a2.index=a0>=a1.rows.length?a1.rows.length-1:a0;if(a2.index<0){a2.index=0}this.redo(a2)},function(a1){var a0=a1.table.insertRow(a1.index);while(a1.row.firstChild){var a2=a1.row.firstChild;a1.row.removeChild(a2);a0.appendChild(a2)}delete a1.row},function(a0){a0.row=a0.table.rows[a0.index];a0.table.deleteRow(a0.index)});P(11,function(a1,a2,a0){a1.row=a2;a1.index=a0>=a2.cells.length?a2.cells.length-1:a0;if(a1.index<0){a1.index=0}this.redo(a1)},function(a0){var a2=a0.row.insertCell(a0.index);while(a0.cell.firstChild){var a1=a0.cell.firstChild;a0.cell.removeChild(a1);a2.appendChild(a1)}delete a0.cell},function(a0){a0.cell=a0.row.cells[a0.index];a0.row.deleteCell(a0.index)});(function(){var a1={specialToCharCode:{8:"Backspace",9:"Tab",13:"Enter",27:"Escape",32:"Space"},keyCodeToId:{16:"Shift",17:"Control",18:"Alt",20:"CapsLock",224:"Meta",37:"Left",38:"Up",39:"Right",40:"Down",33:"PageUp",34:"PageDown",35:"End",36:"Home",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",44:"PrintScreen",145:"Scroll",19:"Pause",91:"Win",93:"Apps"},numpadToCharCode:{96:"0".charCodeAt(0),97:"1".charCodeAt(0),98:"2".charCodeAt(0),99:"3".charCodeAt(0),100:"4".charCodeAt(0),101:"5".charCodeAt(0),102:"6".charCodeAt(0),103:"7".charCodeAt(0),104:"8".charCodeAt(0),105:"9".charCodeAt(0),106:"*".charCodeAt(0),107:"+".charCodeAt(0),109:"-".charCodeAt(0),110:".".charCodeAt(0),111:"/".charCodeAt(0)},charCodeA:"A".charCodeAt(0),charCodeZ:"Z".charCodeAt(0),charCodea:"a".charCodeAt(0),charCodez:"z".charCodeAt(0),charCode0:"0".charCodeAt(0),charCode9:"9".charCodeAt(0),keyCodeFix:{},charCodeToKeyCode:{},ambiguousKeyPressCodes:{}};a1.idToKeyCode={};for(var a2 in a1.keyCodeToId){a1.idToKeyCode[a1.keyCodeToId[a2]]=parseInt(a2,10)}for(var a2 in a1.specialToCharCode){a1.idToKeyCode[a1.specialToCharCode[a2]]=parseInt(a2,10)}switch(p){case 2:a1.charCodeToKeyCode={13:13,27:27};break;case 1:a1.keyCodeFix={12:a3("NumLock")};break;case 3:if(d.engineVersion&&d.engineVersion<525.13){a1.charCodeToKeyCode={63289:a3("NumLock"),63276:a3("PageUp"),63277:a3("PageDown"),63275:a3("End"),63273:a3("Home"),63234:a3("Left"),63232:a3("Up"),63235:a3("Right"),63233:a3("Down"),63272:a3("Delete"),63302:a3("Insert"),63236:a3("F1"),63237:a3("F2"),63238:a3("F3"),63239:a3("F4"),63240:a3("F5"),63241:a3("F6"),63242:a3("F7"),63243:a3("F8"),63244:a3("F9"),63245:a3("F10"),63246:a3("F11"),63247:a3("F12"),63248:a3("PrintScreen"),3:a3("Enter"),12:a3("NumLock"),13:a3("Enter")}}else{a1.charCodeToKeyCode={13:13,27:27}}break;case 5:a1.ambiguousKeyPressCodes={35:51,36:52,44:188,45:109,46:190,91:219,93:221};a1.prestoSimulateInvOnShift={51:1,52:1};a1.prestoUseWhichCodes={33:1,34:1,40:1,39:1,38:1,37:1,123:1};break}a1.ambiguousKeyPressCodesInv={};for(var a2 in a1.ambiguousKeyPressCodes){a1.ambiguousKeyPressCodesInv[a1.ambiguousKeyPressCodes[a2]]=parseInt(a2,10)}de.events.Keyboard={getKeyIdentifier:function(bc,ba){var bg,bf,a8=false;switch(p){case 2:if(ba&&(a0(bc.keyCode)||bc.keyCode==8||bc.keyCode==9)){bg=bc.keyCode}if((!ba&&!bc.ctrlKey)||(ba&&bc.ctrlKey)){if(a1.charCodeToKeyCode[bc.keyCode]){bg=a1.charCodeToKeyCode[bc.keyCode]}else{bf=bc.keyCode}}break;case 1:if(ba){if(bc.keyCode>=16&&bc.keyCode<=18){bg=bc.keyCode}}else{bg=a1.keyCodeFix[bc.keyCode]||bc.keyCode;bf=bc.charCode}break;case 3:if(E==6){if(ba){if(K&&K<525.13){bg=a1.charCodeToKeyCode[bc.charCode]||bc.keyCode}else{bg=bc.keyCode}if(!a0(bg)&&!this.isAcceleratorDown(bc)){bg=0}}else{if(K&&K<525.13){if(a1.charCodeToKeyCode[bc.charCode]){bg=a1.charCodeToKeyCode[bc.charCode]}else{bf=bc.charCode}}else{if(a1.charCodeToKeyCode[bc.keyCode]){bg=a1.charCodeToKeyCode[bc.keyCode]}else{bf=bc.keyCode}}}}else{if(E==4){if(ba){if(a0(bc.keyCode)){bg=bc.keyCode}else{if(this.isAcceleratorDown(bc)){bf=bc.keyCode}}}else{if(bc.charCode&&!this.isAcceleratorDown(bc)){bf=bc.charCode}}}else{a8=true}}break;case 5:if(ba){if(a1.ambiguousKeyPressCodesInv[bc.keyCode]){var bd=a1.prestoSimulateInvOnShift[bc.keyCode];if((bc.shiftKey&&bd)||(!bc.shiftKey&&!bd)){bf=a1.ambiguousKeyPressCodesInv[bc.keyCode]}}else{if(a1.ambiguousKeyPressCodes[bc.keyCode]){bg=bc.keyCode}}}else{if(bc.which&&(a7(bc.which)||a1.prestoUseWhichCodes[bc.which])){bf=bc.which}else{if(a1.keyCodeToId[bc.keyCode]){bg=bc.keyCode}else{bf=bc.keyCode}}}break;case 4:a8=true;break;default:a8=true}if(a8&&ba){if(bc.keyIdentifier&&bc.keyIdentifier.length>0){var a9=/^U\+([\dA-Fa-f]+)$/.exec(bc.keyIdentifier);if(a9){var bb=parseInt(a9[1],16);var be=String.fromCharCode(bb);if(bc.shiftKey){return be.toUpperCase()}else{return be.toLowerCase()}}else{return bc.keyIdentifier}}else{bg=bc.keyCode||bc.which;bf=bc.charCode}}if(bg){if(!ba&&a1.ambiguousKeyPressCodes[bg]){return null}return a4(bg)}else{if(bf){return a6(bf)}}return null},isAcceleratorDown:function(a8){return W==2?a8.metaKey:a8.ctrlKey}};function a0(a8){return typeof a1.keyCodeToId[a8]=="string"||typeof a1.specialToCharCode[a8]=="string"}function a5(a8){return a7(a8)||a1.specialToCharCode[a8]||a1.numpadToCharCode[a8]||a0(a8)}function a7(a8){return(a8>=a1.charCodeA&&a8<=a1.charCodeZ)||(a8>=a1.charCodea&&a8<=a1.charCodez)||(a8>=a1.charCode0&&a8<=a1.charCode9)}function a6(a8){return a1.specialToCharCode[a8]||String.fromCharCode(a8)}function a4(a9){if(a5(a9)){var a8=a1.numpadToCharCode[a9];if(a8){return String.fromCharCode(a8)}return(a1.keyCodeToId[a9]||a1.specialToCharCode[a9]||String.fromCharCode(a9))}else{return null}}function a3(a8){return a1.idToKeyCode[a8]||a8.charCodeAt(0)}})();var ak;(function(){var bb=null,bg=null,a4=null,bq=null,bn=null,bl=null,a2=null,ba={high:"#3B4B5B",low:"#DFFFFF"},a9=false,bk=false,br=3,bf=aZ("button,input,select,textarea"),bm=aZ("br,button,img,iframe,map,object,select,textarea,applet"),a1=/^\W$/,bc,a0,a6;L("Selection",function(){h(de.selection);if(typeof H.onselectstart!="undefined"){H.onselectstart=function(){return de.events.consume(window.event)}}var bs=p==1?window:document;A(bs,"mousedown",a8);A(bs,"mouseup",a3);A(bs,"mousemove",be);A(bs,"dblclick",bp);A(document,"keydown",function(bu){if(de.events.Keyboard.isAcceleratorDown(bu)){if(bu.keyCode==65){return false}}});de.cursor.addObserver({onCursorChanged:function(bv){if(a9){return}if(bv){var bu=bd(bv.domNode,bh(bv));de.selection.setSelection(bu.node,bu.index,null,null,false)}else{de.selection.clear()}}});function bt(){de.selection.clear()}de.UndoMan.addObserver({onBeforeExec:bt,onBeforeUndo:bt,onBeforeRedo:bt});bc=N("div");am(bc,ax);bc.innerHTML='<input type="text" style="border-style:none">';ao(bc,"position:absolute;width:1px;height:1px;display:none;z-index:-500");a0=bc.firstChild;H.appendChild(bc)},"Cursor","UndoMan");function a8(bv){a6=0;var bu=de.events.getEventTarget(bv);var by=X(bu);if(bu&&bf[by]){if(by=="textarea"||(by=="input"&&bu.type=="text")){de.selection.clear();de.cursor.setCursor(null)}return}if(de.events.Mouse.isLeftDown()){if(de.doc.isProtectedNode(bu)){a6=1;return}var bs=de.events.getXYInWindowFromEvent(bv),bx=de.cursor.getCursorDescAtXY(bs.x,bs.y,bu);if(!bx){de.cursor.setCursor(null);return false}if(bv.shiftKey&&bb){a9=true;de.cursor.setCursor(bx);a9=false;var bt=bd(bx.domNode,bh(bx));a5(bb,bg,bt.node,bt.index,false)}else{de.cursor.setCursor(bx);if(!de.cursor.exists()&&!de.doc.isProtectedNode(bx.domNode)){var bt=bd(bx.domNode,bh(bx));a5(bt.node,bt.index,null,null,false)}}var bw=aR();bc.style.left=(bw.left==0?-50:bw.left+10)+"px";bc.style.top=(bw.top==0?-50:bw.top+10)+"px";bc.style.display="";a0.focus();a0.select();bc.style.display="none";return false}}function be(bw){if(de.events.Mouse.isLeftDown()&&bb&&!a6){bk=true;var bs=de.events.getXYInWindowFromEvent(bw),bv=de.cursor.getCurrentCursorDesc();if(bv&&bs.x>=(bv.x-br)&&bs.x<=(bv.x+bv.width+br)&&bs.y>=(bv.y-br)&&bs.y<=(bv.y+bv.height+br)){var bt=0;if(Math.abs(bs.x-bv.x)<Math.abs(bs.x-(bv.x+bv.width))){if(bv.isRightOf){bv.isRightOf=false;a9=true;de.cursor.setCursor(bv);a9=false;bt=1}}else{if(!bv.isRightOf){bv.isRightOf=true;a9=true;de.cursor.setCursor(bv);a9=false;bt=1}}if(bt){var bu=bd(bv.domNode,bh(bv));a5(bb,bg,bu.node,bu.index,false)}}else{bv=de.cursor.getCursorDescAtXY(bs.x,bs.y,de.events.getEventTarget(bw));if(bv&&!de.doc.isProtectedNode(bv.domNode)){var bu=bd(bv.domNode,bh(bv));a5(bb,bg,bu.node,bu.index)}}}}function a3(bs){if(bb&&bk){de.selection.fireEvent("SelectionChanged")}bk=false}function bp(bv){if(!de.doc.isProtectedNode(de.events.getEventTarget(bv))){de.selection.clear();var bs=de.events.getXYInWindowFromEvent(bv);var bu=de.cursor.getCursorDescAtXY(bs.x,bs.y,de.events.getEventTarget(bv));if(bu){var bt=de.selection.getWordRangeAt(bu.domNode,bu.relIndex);if(bt){a5(bt.startNode,bt.startIndex,bt.endNode,bt.endIndex)}}}return false}function bd(bt,bs){if(bn){return bn.getOriginalNodeIndex(bt,bs)}return{node:bt,index:bs}}function bi(bt,bs){if(bn){return bn.getAdjustedNodeIndex(bt,bs)}return{node:bt,index:bs}}ak=function(bs){if(bs&&bn){aW(a2)}else{if(!bs&&bn){u(a2)}}};function a7(){var bs=de.selection.getRange(true);try{var bu=de.cursor.getCurrentCursorDesc();bn=aa(w(bs.startNode,bs.endNode),bs.startNode,bs.startIndex,bs.endNode,bs.endIndex);bl=aP()||[];bn.visit(function(by){if(!by.isShared){var bx=by.node,bw=null;if(bx.nodeType==1){bw=bx}else{if(bx.nodeType==3&&by.parent.isShared&&aH(bx)){bw=N("span");bw.className="dehighlight-node";Q(1,bw,bx.parentNode,l(bx));Q(2,bx);Q(1,bx,bw)}}if(bw){Q(6,bw,"backgroundColor",ba.high);Q(6,bw,"color",ba.low)}}});a2=aP()||[];if(bu){var bt=bi(bu.domNode,bu.relIndex);if(bt.node!=bu.domNode||bt.index!=bu.relIndex){bu.domNode=bt.node;bu.relIndex=bt.index;a9=true;de.cursor.setCursor(bu);a9=false}}}catch(bv){settingHighlight=false;bb=a4=bn=null;a2=null;throw bv}}function bj(){if(bn){var bt=de.cursor.getCurrentCursorDesc();var bs=bt?bd(bt.domNode,bt.relIndex):null;u(a2);u(bl);a2=bl=bn=null;if(bs&&(bs.node!=bt.domNode||bs.index!=bt.relIndex)){bt.domNode=bs.node;bt.relIndex=bs.index;a9=true;de.cursor.setCursor(bt);a9=false}}}function a5(bt,bE,bB,by,bv){if(!bt){de.selection.clear(bv);return}if(bt==bB&&bE==by){bB=null}if(bt==bb&&bE==bg&&((!bB&&!a4)||(bB==a4&&by==bq))){return}bj();bb=bt;bg=bE;a4=bB;bq=by;if(a4){var bA=bo(),bz;while(bb){bz=de.doc.getProtectedNodeContainer(bb);if(bz){bb=(bA?bz.nextSibling:bz.previousSibling);if(bb){bg=bA?0:ah(bb,1)}}else{break}}while(a4){bz=de.doc.getProtectedNodeContainer(a4);if(bz){a4=(bA?bz.previousSibling:bz.nextSibling);if(a4){bq=bA?ah(a4,1):0}}else{break}}var bF=bb&&a4;if(bF){bF=false;var bw=[];R(w(bb,a4),bb,bA,function(bG){bz=de.doc.getProtectedNodeContainer(bG);if(bz){bw.push(bz)}if(bG==a4){bF=true;return false}})}if(!bF){de.selection.clear(bv);return}for(var bx in bw){var bD=bw[bx];if(bD.parentNode){bD.parentNode.removeChild(bD)}}for(var bx in bw){var bD=bw[bx];if(!bD.parentNode){H.appendChild(bD)}}a7()}if(bv!==false){var bs=null;if(de.selection.isRangeEditable()){var bu=a4?bi(a4,bq):bi(bb,bg);var bC=false;if(bu.node.nodeType==3&&bu.index>=ah(bu.node)){bC=true;bu.index--}bs=de.cursor.getNearestCursorDesc(bu.node,bu.index,bC,true)}a9=true;de.cursor.setCursor(bs);a9=false}if(!bk){de.selection.fireEvent("SelectionChanged")}}function bh(bt){var bs=bt.relIndex;if(bt.isRightOf&&bt.domNode.nodeType==3){bs++}return bs}function bo(){if(!a4){return true}if(bb==a4){return bg<bq}var bu=bi(bb,bg).node,bt=bi(a4,bq).node;var bs=false;R(H,bu,true,function(bv){bs=(bv==bt);return !bs});return bs}de.selection={setSelection:a5,clear:function(bs){bj();bb=a4=null;if(bs!==false){a9=true;de.cursor.setCursor(null);a9=false}if(!bk){de.selection.fireEvent("SelectionChanged")}},getRange:function(bu){if(!bb){return null}if(a4){var bs=bo();var bt=!bu||bs;range={inOrder:bu||(bs==bt),startNode:bt?bb:a4,startIndex:bt?bg:bq,endNode:bt?a4:bb,endIndex:bt?bq:bg}}else{range={startNode:bb,startIndex:bg}}return range},isRangeEditable:function(){if(bb){var bu=bi(bb,bg).node;var bt=a4?bi(a4,bq).node:bu;var bs=w(bu,bt,true);return(bu!=bt&&de.doc.isEditSection(bs))||de.doc.isNodeEditable(bs)}return false},getState:function(){if(bn){return"range"}if(bb){return"single"}return null},getActualNodeIndex:bi,getVirtualNodeIndex:bd,setHightlightCSS:function(){},remove:function(){var bs=this.getRange(true);if(bs&&bs.endNode){if(!this.isRangeEditable()){aj("Attempt to remove selection which contains uneditable content")}de.UndoMan.execute("RemoveDOM",bs.startNode,bs.startIndex,bs.endNode,bs.endIndex);return true}return false},getHighlightedDOM:function(){if(bn){u(a2);var bt=(function bs(bx){var bv=bx.node.cloneNode(false);for(var bu in bx.children){var bw=bs(bx.children[bu]);bv.appendChild(bw)}return bv})(bn);aW(a2);return bt}return null},selectAll:function(bs){if(!bs){var bt=de.cursor.getCurrentCursorDesc();if(bt){bs=de.doc.getEditSectionContainer(bt.domNode)}}if(bs){de.selection.setSelection(bs.firstChild,0,bs.lastChild,ah(bs.lastChild,1))}},selectES:function(bs,bv){var bu=bs;if(bv){while(bu.firstChild){bu=bu.firstChild}}else{while(bu.lastChild){bu=bu.lastChild}}var bt=de.cursor.getNearestCursorDesc(bu,bv?0:ah(bu,1),!bv,!bv);if(bt){de.cursor.setCursor(bt)}},getWordRangeAt:function(bw,bu){if(bw.nodeType==3){var bt={startNode:bw,startIndex:bu,endNode:bw,endIndex:bu};var bs=de.doc.isNodeEditable(bw);R(H,bw,false,function(by){if(by!=bw&&j(by,w(by,bw,true),bv,true)){return false}else{if(by.nodeType==3){for(var bx=by==bw?bu:ah(by)-1;bx>=0;bx--){var bz=by.nodeValue.charAt(bx);if(a1.test(bz)){return false}bt.startNode=by;bt.startIndex=bx}}}});R(H,bw,true,function(by){if(by!=bw&&(bv(by)||j(bw,w(by,bw,true),bv,true))){return false}if(by.nodeType==3){for(var bx=by==bw?bu:0;bx<ah(by);bx++){var bz=by.nodeValue.charAt(bx);if(a1.test(bz)){return false}bt.endNode=by;bt.endIndex=bx}}});bt.endIndex++;return bt}function bv(bx){return aL(bx)||bm[X(bx)]||(bs&&de.doc.isEditSection(bx))}},getEditState:function(bw){var bu={formatStates:{},inlineContainerType:null,textAlign:null,blockQuote:false};if(bn){u(a2);(function bv(bx){bs(bx.node)})(bn);aW(a2)}if(bb&&(bb.nodeType==3||ae(bb))){bs(bb.nodeType==3?bb.parentNode:bb)}return bu;function bt(bx){return X(bx)=="blockquote"}function bs(by){if(ae(by)){var bC=de.doc.getEditProperties(by)||{};for(var bB in bw){var bx=bw[bB].toLowerCase();if(!bu.formatStates[bx]||bu.formatStates[bx]!="mixed"){var bD=by,bz=false;while(bD!=H&&de.doc.isNodeEditable(bD)){var bE=q[bx+"Eval"](bD);if(bE){if(typeof bu.formatStates[bx]=="undefined"){bu.formatStates[bx]=bE.value}else{if(bu.formatStates[bx]!==bE.value){bu.formatStates[bx]="mixed"}}bz=true;break}bD=bD.parentNode}if(!bz){bu.formatStates[bx]=(bu.formatStates[bx]===null||typeof bu.formatStates[bx]=="undefined")?null:"mixed"}}}}if(by.nodeType==1){if(bu.textAlign!="mixed"){var bF=aD(by,"text-align");if(!bF){bF="start"}if(bF=="start"){bF=_localeDirection=="rtl"?"right":"left"}else{if(bF=="start"){bF=_localeDirection=="rtl"?"left":"right"}}if(!bu.textAlign){bu.textAlign=bF}else{if(bF!=bu.textAlign){bu.textAlign="mixed"}}}if(bu.inlineContainerType!="mixed"){var bG=aL(by)?by:j(by,H,aL,true);if(!de.doc.isNodeEditable(bG)){bG=null}var bA=bG?X(bG):"none";if(!bu.inlineContainerType){bu.inlineContainerType=bA}else{if(bA!=bu.inlineContainerType){bu.inlineContainerType="mixed"}}}if(!bu.blockQuote){var bH=bt(by)?by:j(by,H,bt,true);if(de.doc.isNodeEditable(bH)){bu.blockQuote=true}}}}}}})();L("Spell",function(){A(p==1?window:document,"mouseup",function(){var a1=de.selection.getRange();if(a1&&!a1.endNode){var a0=de.spell.getMarkedAncestor(a1.startNode);if(a0){de.selection.setSelection({startNode:a0,startIndex:0,endNode:a0,endIndex:1})}}})},"Selection");(function(){var a2="sw-spell-error",a1=/^sw-spell-error$/;de.spell={getWords:function(a3){if(!a3){a3=de.doc.getAllEditSections()}var a6=[],a4={};for(var a5 in a3){a0(a3[a5],function(a7){if(!a4[a7]){a6.push(a7);a4[a7]=1}})}return a6},markWords:function(a6,a3){if(!a3){a3=de.doc.getAllEditSections()}a6=aZ(typeof a6=="string"?a6.replace(/\s/g,","):a6.join(","));var a5=0;for(var a4 in a3){a0(a3[a4],function(ba,a8,bb,a7,a9){if(a6[ba]){var bc=de.UndoMan.execute(a5?1:0,"SpellMark",a8,bb,a7,a9+1);a5=1;return bc.children[bc.children.length-1].node}})}},clearAllMarks:function(a3){if(!a3){a3=de.doc.getAllEditSections()}var a5=[],a4;for(a4 in a3){R(a3[a4],a3[a4],true,function(a6){if(de.spell.isSpellErrorWrapper(a6)){a5.push(a6)}})}for(a4 in a5){de.UndoMan.execute(a4=="0"?0:1,"SpellUnmark",a5[a4])}return a5.length},ignoreError:function(a4,a3){de.UndoMan.execute(a3?a3:0,"SpellUnmark",a4)},correctError:function(a4,a3){de.UndoMan.execute("SpellCorrect",a4,a3)},getMarkedAncestor:function(a3){return this.isSpellErrorWrapper(a3)?a3:j(a3,this.isSpellErrorWrapper)},isSpellErrorWrapper:function(a3){return T(a3,a1)?true:false},stripSpellWrapperHTML:function(a3){var a4=/<span class\s*=\s*(?:"|')sw-spell-error(?:"|')\s*>([^<]+)<\/span>/i;while(match=a4.exec(a3)){a3=a3.substr(0,match.index)+match[1]+a3.substr(match.index+match[0].length)}return a3}};function a0(a6,bc){var a5=/^\W$/,ba=a6,a4,bb,a9,a7,a3;while(ba){R(a6,ba,true,function(be){if(ba==be){ba=0}else{if(be.nodeType==3&&be.parentNode.nodeType==1){if(a9&&be.previousSibling!=a9){if(a8()){return false}}var bf=be.nodeValue,bd;for(bd=0;bd<bf.length;bd++){var bg=bf.charAt(bd);if(a5.test(bg)){if(a8()){return false}}else{if(!a4){a4=be;bb=bd;a3=""}a3+=bg;a9=be;a7=bd}}}}})}a8();function a8(){if(a4&&a9&&!de.doc.isProtectedNode(a4)&&!de.doc.isNodePackaged(a4)){ba=bc(a3,a4,bb,a9,a7);a4=a9=0;return ba}a4=a9=0}}aI("SpellMark",{exec:function(a4,a8,a3,a6){var ba=aa(null,a4,a8,a3,a6),a9=N("span");am(a9,a2);Q(1,a9,ba.node,ba.children[0].pos);for(var a5=0;a5<ba.children.length;a5++){var a7=ba.children[a5].node;Q(2,a7);Q(1,a7,a9)}return ba}});aI("SpellUnmark",{exec:function(a3){while(a3.firstChild){var a4=a3.firstChild;Q(2,a4);Q(1,a4,a3.parentNode,l(a3))}Q(2,a3)}});aI("SpellCorrect",{exec:function(a4,a3){Q(1,document.createTextNode(a3),a4.parentNode,l(a4));Q(2,a4)}})})();de.Typing={};(function(){L("Typing",function(){A(document,"keystroke",a1);h(de.Typing)},"MVC");function a1(bb,bg){var a2={cancel:false};de.Typing.fireEvent("Typing",a2,bb,bg);if(a2.cancel){return}if(de.events.Keyboard.isAcceleratorDown(bb)){switch(bg.toLowerCase()){case"z":de.UndoMan.undo();return false;case"y":de.UndoMan.redo();return false}}if(!de.selection.isRangeEditable()||!de.cursor.exists()){return}var bi=de.doc.getEditSectionContainer(de.cursor.getCurrentCursorDesc().domNode);if(de.events.Keyboard.isAcceleratorDown(bb)){switch(bg.toLowerCase()){case"b":a0("bold");return false;case "s": save_live_doc_html(); return false; case "l": revert_to_orig_doc(); return false; case"i":a0("italics");return false;case"u":a0("underline");return false;case"a":de.selection.selectAll(bi);return false}}else{if(!bb.ctrlKey&&!bb.metaKey&&!bb.altKey){var a4=bg;if(a4){if(a4.length>1){switch(a4){case"Space":a4=" ";break;case"Tab":if(aL(bi)||bi==H){de.UndoMan.execute("Indent",!bb.shiftKey)}return false;case"Delete":case"Backspace":if(de.selection.remove()){return false}else{var a7=de.cursor.getCurrentCursorDesc(),bd,a5;if(a4=="Backspace"){if(a7.isRightOf&&(a7.placement==(4|2))){bd=o(a7);bd.isRightOf=false}else{bd=de.cursor.getNextCursorMovement(a7,true)}a5=a7}else{bd=a7;if(!a7.isRightOf&&(a7.placement==(4|2))){a5=o(a7);a5.isRightOf=true}else{a5=de.cursor.getNextCursorMovement(a7,false)}}if(bd&&a5){var bf=de.doc.isNodeEditable(a5.domNode);if(bf&&a5.domNode!=bd.domNode){bf&=de.doc.isNodeEditable(bd.domNode)}if(bf){var a3;if(bd.domNode.nodeType==3){a3=bd.relIndex;if(bd.isRightOf){a3++}}else{if(X(bd.domNode)=="br"){var ba=0;I(w(bd.domNode,a5.domNode),bd.domNode,true,null,function(bj){if(X(bj)=="br"){ba++}return bj!=a5.domNode});a3=ba>1?1:0}else{a3=bd.isRightOf?1:0}}var bc;if(a5.domNode.nodeType==3){bc=a5.relIndex;if(a5.isRightOf){bc++}}else{if(X(a5.domNode)=="br"){var ba=0;I(w(bd.domNode,a5.domNode),bd.domNode,true,null,function(bj){if(X(bj)=="br"&&!(bj==bd.domNode&&a3==1)){ba++}return bj!=a5.domNode});bc=ba>1?0:1}else{bc=a5.isRightOf?1:0}}var a8=de.selection.getVirtualNodeIndex(bd.domNode,a3),be=de.selection.getVirtualNodeIndex(a5.domNode,bc);if(a8.node==be.node&&a8.node.nodeType==3){de.UndoMan.execute("RemoveText",a8.node,a8.index,be.index-a8.index)}else{var a6=w(a8.node,be.node,true);if(de.doc.isEditSection(a6)||de.doc.isNodeEditable(a6)){de.UndoMan.execute("RemoveDOM",a8.node,a8.index,be.node,be.index)}}}}return false}case"Enter":de.selection.remove();var a7=de.cursor.getCurrentCursorDesc();var a9=a7.relIndex;if(a7.domNode.nodeType==3){a9+=(a7.isRightOf?1:0)}else{a9=a7.isRightOf?1:0}if(!de.doc.getEditProperties(bi).singleLine){if(bb.shiftKey){var bh="<br>";if(!(a7.domNode.nodeType==3&&a9<ah(a7.domNode))){bh+=aG(de.doc.createMNPlaceholder())}de.UndoMan.execute("InsertHTML",bh,a7.domNode.parentNode,a7.domNode,a9)}else{if(aL(bi)||bi==H){de.UndoMan.execute("SplitContainer",a7.domNode,a9)}}}return false;default:return true}}de.selection.remove();var a7=de.cursor.getCurrentCursorDesc();var a9=a7.relIndex;if(a7.domNode.nodeType==3&&a7.isRightOf){a9++}else{if(a7.domNode.nodeType==1){a9=a7.isRightOf?1:0}}de.UndoMan.execute("InsertText",a7.domNode,a4,a9);return false}}}}function a0(a2){return de.UndoMan.execute("Format",a2,!de.selection.getEditState([a2]).formatStates[a2])?true:false}})();(function(){var a0=aZ("dt,dd,caption,colgroup,col,thead,tfoot,tbody,legend,optgroup,option,area,frame");aI("TextAlign",{exec:function(a7,a3,a1){if(!a3){if(!this.selBefore){return}if(this.selBefore.endNode){a3=this.selBeforeOrdered.startNode;a1=this.selBeforeOrdered.endNode}else{a3=a1=this.selBefore.startNode}}var a5;var a2=w(a3,a1);for(var a6=0;a6<2;a6++){while(a2!=H&&!aL(a2)){a2=a2.parentNode}if(a2==H){break}if(X(a2)=="li"){a5=[a2];break}a2=a2.parentNode}if(!a5){a5=aQ(a3,a1)}for(var a4 in a5){R(a5[a4],a5[a4],true,function(a8){if(aL(a8)&&!a0[X(a8)]){Q(6,a8,"textAlign",a7)}})}this.selAfter=this.selBefore}})})();(function(){var a0=aZ("p,pre,h1,h2,h3,h4,h5,h6,li,address");aI("SplitContainer",{exec:function(a9,bd){var a3=j(a9.parentNode,H,aL,true)||H,bg,a4;if(!a0[X(a3)]){R(a3,a9,true,function(bi){if(aL(bi)){bg=bi}return bg==null});if(!bg||bg==a3){bg=a3;a4=1}else{if(bg==a9){bg=null}else{a4=0}}}else{bg=a3;a4=1}var a7;if(bg){a7=aa(a3,a9,bd,bg,a4);var bb=true;a7.visit(function(bi){if(!bi.isShared){bb=false}return bb});if(bb){a7=null}else{a7.disconnect()}}var a8,a2,a1;if(a0[X(a3)]){if(X(a3)!="li"&&a3!=H){var be=j(a3.parentNode,H,aL,true);if(be&&X(be)=="li"){a1=a3;a3=be}}a8=a3;a2=(a3.nodeName.charAt(0).toLowerCase()=="h"&&!a7)?N("p"):a3.cloneNode(false)}else{a2=N("p")}if(!a8){if(a7){var bf=a7.getStartFragment();if(a7.wasStartSplit()){a8=bf.getPreSplitNode()}else{if(bf.isShared){a8=bf.node}else{var bh=bf;while(!bh.isShared){bh=bh.parent}if(bh.node.firstChild){if(bh.children.length>0){if(bh.children[0].pos>0){a8=bh.node.childNodes[bh.children[0].pos-1]}else{Q(1,a2,bh.node,0);a8=null}}else{a8=bh.node.lastChild}}else{if(bh==a7){Q(1,a2,a3,0);a8=null}else{a8=bh.node}}}}}else{if(bd==0){Q(1,a2,a9.parentNode,l(a9));a8=null}else{a8=a9}}if(a8&&a8!=H&&!aL(a8)){while(a8!=H&&a8.parentNode!=H&&!aL(a8)&&!aL(a8.parentNode)){a8=a8.parentNode}}}if(a8){Q(1,a2,a8.parentNode,l(a8)+1)}if(a7){for(var ba in a7.children){var bc=a5(a7.children[ba]);if(bc){Q(1,bc,a2)}}}if(aF(a2)){Q(1,de.doc.createMNPlaceholder(),a2)}if(aF(a3)){Q(1,de.doc.createMNPlaceholder(),a3)}if(a1&&aF(a1)){Q(1,de.doc.createMNPlaceholder(),a1)}if(this.flags&2){var a6=de.cursor.getNearestCursorDesc(a2,0,false,false);if(a6){this.selAfter={startNode:a6.domNode,startIndex:a6.relIndex+(a6.domNode.nodeType==3&&a6.isRightOf?1:0)}}}function a5(bm){var bi;if(bm.isShared){var bl=true;bm.visit(function(bn){if(!bn.isShared){bl=false}return bl});if(bl){return null}bi=bm.node.cloneNode(false)}else{bi=bm.node;if(bi.parentNode&&bi.parentNode.nodeType!=11){Q(2,bi)}while(bi.firstChild){Q(2,bi.firstChild)}}for(var bj in bm.children){var bk=a5(bm.children[bj]);if(bk){Q(1,bk,bi)}}return bi}}})})();aI("RemoveText",{exec:function(a2,a5,a1){if(de.doc.isESPlaceHolder(a2,false)||de.doc.isMNPlaceHolder(a2,false)){if(this.flags&2){var a3=de.cursor.getCurrentCursorDesc();if(a3){this.selAfter={startNode:a3.domNode,startIndex:a3.relIndex+(a3.domNode.nodeType==3&&a3.isRightOf?1:0)}}}return}var a8,a7;if(a5==0){R(H,a2,false,function(ba){if(ba==a2){return}var a9=w(a2,ba);if(j(ba,a9,aL,true)){return false}if(ba.nodeType==3&&ah(ba)>0){if(M(ba.nodeValue.charAt(ah(ba)-1))){a8=a9;return false}}})}else{if(M(a2.nodeValue.charAt(a5-1))){a8=a2}}if((a5+a1)==ah(a2)){R(H,a2,true,function(ba){if(ba==a2){return}var a9=w(a2,ba);if(aL(ba)||j(a2,a9,aL,true)){return false}if(ah(ba,0)>0){if(M(ba.nodeValue.charAt(0))){a7=a9;return false}}})}else{if(M(a2.nodeValue.charAt(a5+a1))){a7=a2}}var a6=(a8&&a7&&a8!=a7)?w(a8,a7,true):a8||a7;if(a6){Y(a6)}Q(5,a2,a5,a1);if(a6){s(a6)}var a4,a0=de.doc.getEditSectionContainer(a2);if(a0&&aA(a0)){a4=de.doc.createESPlaceholder(a0)}else{a0=j(a2,H,aL,true)||H;if(aF(a0)){a4=de.doc.createMNPlaceholder()}}if(a4){Q(1,a4,a0)}if(this.flags&2){var a3=a4?de.cursor.createCursorDesc(a4,0,false):de.cursor.getNearestCursorDesc(a2,a5==0?0:a5-1,a5>0,false);if(a3){this.selAfter={startNode:a3.domNode,startIndex:a3.relIndex+(a3.domNode.nodeType==3&&a3.isRightOf?1:0)}}}if(ah(a2)==0){Q(2,a2)}}});aI("RemoveDOM",{exec:function(a0,a8,a5,a4){var a7=aa(w(a0,a5,false),a0,a8,a5,a4);Y(a7.node);var a1=a7.collapse();s(a7.node);if(this.flags&2){var a3;if(a1){a3=de.cursor.getNearestCursorDesc(a1,0,false,true)}else{var a6=a7.getStartFragment();while(a6.node!=H&&!aK(H,a6.node)){a6=a6.parent}var a2=a6.node;if(a6.children.length>0&&a2.childNodes.length>0&&a6.children[0].pos<=a2.childNodes.length){if(a6.children[0].pos==0){a3=de.cursor.getNearestCursorDesc(a2.firstChild,0,false,false)}else{var a9=a2.childNodes[a6.children[0].pos-1];a3=de.cursor.getNearestCursorDesc(a9,ah(a9,2)-1,true,false)}}else{a3=de.cursor.getNearestCursorDesc(a6.node,ah(a6.node,2)-1,true,true)}}if(a3){this.selAfter={startNode:a3.domNode,startIndex:a3.relIndex+(a3.domNode.nodeType==3&&a3.isRightOf?1:0)}}}}});aI("RemoveNode",{exec:function(a0){Q(2,a0)}});(function(){aI("ModifyTable",{exec:function(be,ba,bf){var bl=null,bi=[];R(w(ba,bf),ba,true,function(bm){if(!bl){bl=j(bm,H,function(bn){return(X(bn)=="table")},true)}bi.push(bm);return bm!=bf});if(bl){var bb={start:null,end:null};for(var bg=0;bg<bl.rows.length;bg++){var bk=bl.rows[bg];for(var bh=0;bh<bk.cells.length;bh++){var bj=bk.cells[bh];for(var bc in bi){if(bi[bc]==bj||aK(bj,bi[bc])){if(!bb.start){bb.start=[parseInt(bg),parseInt(bh),bj]}bb.end=[parseInt(bg),parseInt(bh),bj];break}}}}if(bb.start){be=be.toLowerCase().split("-");switch(be[0]){case"insert":if(be.length==4){var bd=parseInt(be[3]);if(isNaN(bd)){aj(1)}if(be[1]=="rows"){a0(bl,bb,be[2]=="before",bd)}else{if(be[1]=="cols"){a7(bl,bb,be[2]=="before",bd)}else{aj(1)}}}else{aj(1)}break;case"delete":if(be.length!=2){aj(1)}switch(be[1]){case"table":a3(bl);break;case"rows":a1(bl,bb);break;case"cols":a9(bl,bb);break;default:aj(1)}break;case"merge":break;case"split":break;default:aj(1)}}}}});function a8(bc,ba){var bb=Q(9,bc,ba);de.UndoMan.execute(4,"InsertHTML","<p>"+aG(de.doc.createMNPlaceholder())+"</p>",bb)}function a0(bj,bg,bb,bd){var be;if(bb){be=bg.start[0]}else{be=bg.end[0]+1;var bh=bg.end[2].getAttribute("rowspan");if(bh){be+=(parseInt(bh)-1)}}if(be>bj.rows.length){be=bj.rows.length}var bf=a5(bj);for(var bc=0;bc<bd;bc++){var bi=Q(8,bj,be);for(var ba=0;ba<bf;ba++){a8(bi,0)}}}function a6(bd,bb){var ba;if(bb){ba=Math.min(bd.start[1],bd.end[1])}else{var bf=bd.start[1],be=bd.end[1];var bc=bd.start[2].getAttribute("colspan");if(bc){bf+=(parseInt(bc)-1)}bc=bd.end[2].getAttribute("colspan");if(bc){be+=(parseInt(bc)-1)}ba=Math.max(bf,be)}return ba}function a5(ba){var bb=0;for(var bc=0;bc<ba.rows.length;bc++){bb=Math.max(bb,ba.rows[bc].cells.length)}return bb}function a7(bk,bh,bc,be){var bj=a6(bh,bc);if(!bc){bj++}for(var bd=0;bd<be;bd++){for(var bf=0;bf<bk.rows.length;bf++){var bm=bk.rows[bf];var ba=-1,bl=bj;for(var bg=0;bg<bm.cells.length;bg++){var bi=bm.cells[bg];ba++;var bb=bi.getAttribute("colspan");if(bb){ba+=(parseInt(bb)-1)}if(ba>=bj){bl=parseInt(bg);break}}a8(bm,bl)}}}function a3(ba){Q(2,ba)}function a1(bc,bb){if(bb.start[0]==0&&bb.end[0]>=(bc.rows.length-1)){a3(bc)}else{for(var ba=0;ba<=(bb.end[0]-bb.start[0]);ba++){Q(10,bc,bb.start[0])}}}function a9(bl,bj){var bd=a6(bj,true),bg=a6(bj,false),bf=a5(bl);if(bd==0&&bg>=(bf-1)){a3(bl)}else{for(var be=0;be<=(bg-bd);be++){for(var bh=0;bh<bl.rows.length;bh++){var bm=bl.rows[bh];var ba=-1,bb=bd;for(var bi=0;bi<bm.cells.length;bi++){var bk=bm.cells[bi];ba++;var bc=bk.getAttribute("colspan");if(bc){ba+=(parseInt(bc)-1)}if(ba>=bd){bb=parseInt(bi);break}}Q(11,bm,bb)}}}}function a4(bb,ba){}function a2(bd){for(var ba in bd){var bc=bd[ba];if(X(bc)=="td"||X(bc)=="th"){var bb=bc.getAttribute("colspan");if(bb){Q(_Operation.SET_ATTRIBUTE,bc,"colspan","")}var bb=bc.getAttribute("rowspan");if(bb){Q(_Operation.SET_ATTRIBUTE,bc,"rowspan","")}}}}})();(function(){var a0=aZ("p, div");aI("Itemize",{exec:function(a3,a4,a1){if(!a4){if(!this.selBefore){return}if(this.selBefore.endNode){a4=this.selBeforeOrdered.startNode;a1=this.selBeforeOrdered.endNode}else{a4=a1=this.selBefore.startNode}}(function a2(br,bk,bD,bA){var bi=j(w(br,bk,true),H,aL,true)||H,bJ,bo;var bE=br,bB=bk;while(bE.firstChild){bE=bE.firstChild}while(bB.lastChild){bB=bB.lastChild}if(y(bi)&&X(bi)!="td"&&X(bi)!="th"){var a5=[];R(bi,bi,true,function(bK){if(bK.nodeType==1&&(X(bK)=="td"||X(bK)=="th")){a5.push(bK);return(bK!=bB&&!aK(bK,bB))}return bK!=bB});var bn=true,bh=[];for(var bH in a5){var bv=bj(a5[bH],a5[bH]);if(bv){bn&=bv.allListEles;bh.push(bv.nrange)}else{bh.push(0)}}for(var bH in a5){if(bh[bH]){a2(a5[bH],a5[bH],bn,bh[bH])}}return}if(X(bi)=="ul"||X(bi)=="ol"){bi=bi.parentNode}var bx=bi;for(var a8=0;a8<2&&bx;a8++){if(X(bx)=="li"){if((bA&&bD)||(!bA&&((a3&&X(bx.parentNode)=="ul")||(!a3&&X(bx.parentNode)=="ol")))){bJ=[bx]}else{bo=[bx];bi=bx.parentNode}break}bx=j(bx.parentNode,H,aL,true)}if(!bA&&!bJ&&!bo){var bv=bj(br,bk);if(bv){bA=bv.nrange;if(bv.allListEles){bJ=bA}else{bo=bA}}else{return}}else{if(bA){if(bD){bJ=bA}else{bo=bA}}}if(bJ){for(var bH in bJ){var by=bJ[bH];var ba=X(by);if(ba=="li"){a9(by,true)}else{if(ba=="ul"||ba=="ol"){var bw=aK(by,br)?j(br,by):by.firstChild,bl=aK(by,bk)?j(bk,by):by.lastChild;while(bw){var bb=bw;bw=bw==bl?null:bw.nextSibling;if(X(bb)=="li"){a9(bb,true)}}}}}}else{var bu;for(var bH in bo){var by=bo[bH];var bg=by==bi?by:j(by,bi),ba=X(by);if(ba=="li"){if(bH=="0"){bu=a9(by,false)}else{var bp=by.parentNode;Q(2,by);Q(1,by,bu);var a7=bp.firstChild;while(a7&&X(a7)!="li"){a7=a7.nextSibling}if(!a7){Q(2,bp)}}}else{if(bH=="0"){bu=N(a3?"ul":"ol");if(ba=="ul"||ba=="ol"){var a6=false;var bq=by.firstChild;while(bq&&X(bq)!="li"){a6|=(bq==br);bq=bq.nextSibling}if(bq){a6|=aK(bq,br)}Q(1,bu,bg.parentNode,l(bg)+(a6?0:1))}else{Q(1,bu,bg.parentNode,l(bg)+1)}}if(ba=="ul"||ba=="ol"){var be=aK(by,br)?j(br,by):by.firstChild,bC=aK(by,bk)?j(bk,by):by.lastChild;while(be){var bs=X(be)=="li"?be:null;be=be==bC?null:be.nextSibling;if(bs){Q(2,bs);Q(1,bs,bu);if(bg!=by){var bm=bs.firstChild;while(bm){if(bm.nodeType!=1&&bm.nodeType!=3){continue}var bG=by.parentNode,bf=[];while(bG){bf.push(bG.cloneNode(false));bG=bG==bg?null:bG.parentNode}for(var bF=bf.length-1;bF>0;bF--){bf[bF].appendChild(bf[bF-1])}Q(1,bf[bf.length-1],bs,l(bm));Q(2,bm);Q(1,bm,bf[0]);bm=bf[bf.length-1].nextSibling}}}}var bt=true;be=by.firstChild;while(be){if(X(be)=="li"){bt=false;break}be=be.nextSibling}if(bt){Q(2,bg)}}else{var bz=N("li");Q(1,bz,bu);Q(2,bg);Q(1,bg,bz);if(a0[ba]){var bc=by.parentNode;Q(2,by);while(by.firstChild){var bI=by.firstChild;Q(2,bI);Q(1,bI,bc)}}}}}}function a9(bO,bT){var bL=bO.previousSibling,bP=false,bQ=false,bU=bO.parentNode,bK=false,bN=null;while(!bP&&bL){bP|=X(bL)=="li";bL=bL.previousSibling}bL=bO.nextSibling;while(!bQ&&bL){bQ|=X(bL)=="li";bL=bL.nextSibling}if(bP){bU=bd(bU,bO,!bT,true);bK=true}if(bT){if(X(bU.parentNode)!="li"){aQ(bO,bO)}while(bO.firstChild){var bS=bO.firstChild;Q(2,bS);Q(1,bS,bU.parentNode,l(bU))}Q(2,bO)}else{if(bK){if(bQ){var bM=bO.nextSibling;while(X(bM)!="li"){bM=bM.nextSibling}bd(bU,bM,true,true)}bN=bU}else{bN=bd(bU,bO,true,false)}}bL=bU.firstChild;while(bL&&X(bL)!="li"){bL=bL.nextSibling}if(!bL){var bR=bU;while(bR.parentNode.childNodes.length==1&&!de.doc.isEditSection(bR.parentNode)&&bR.parentNode!=H){bR=bR.parentNode}Q(2,bR)}return bN}function bd(bM,bP,bL,bN){var bK=bL?N(X(bM)=="ol"?"ul":"ol"):bM.cloneNode(false);if(bN){while(bP){var bO=bP;bP=bP.nextSibling;Q(2,bO);Q(1,bO,bK)}Q(1,bK,bM.parentNode,l(bM)+1)}else{while(bP){var bO=bP;bP=bP.previousSibling;Q(2,bO);Q(1,bO,bK,0)}Q(1,bK,bM.parentNode,l(bM))}return bK}function bj(bP,bK){var bL=aQ(bP,bK);if(bL.length==0){return null}var bO=true;for(var bN in bL){var bM=X(bL[bN]);if(bM=="li"){bM=X(bL[bN].parentNode)}if((a3&&bM!="ul")||(!a3&&bM!="ol")){bO=false;break}}return{allListEles:bO,nrange:bL}}})(a4,a1);this.selAfter=this.selBefore}})})();aI("InsertText",{exec:function(a1,a4,a0){a4=a(aT(a4));var a2;if(de.doc.isESPlaceHolder(a1,false)||de.doc.isMNPlaceHolder(a1,false)){a2=a1;while(!(de.doc.isESPlaceHolder(a2,true)||de.doc.isMNPlaceHolder(a2,true))){a2=a2.parentNode}a1=a2}if(a1.nodeType==3){Q(4,a1,a4,a0);if(this.flags&2){this.selAfter={startNode:a1,startIndex:a0+a4.length}}}else{var a3=document.createTextNode(a4);Q(1,a3,a1.parentNode,l(a1)+(a0==0?0:1));if(a2){Q(2,a2)}if(this.flags&2){this.selAfter={startNode:a3,startIndex:a0+ah(a3)}}}if(a4.indexOf(B)!=-1){s(a1.parentNode)}}});aI("InsertHTML",{exec:function(a6,a7,a9,a8){var a4=[];var a0=a7==H?N("div"):a7.cloneNode(false);a0.innerHTML=a6;var bb=a0.firstChild;while(bb){a4.push(bb);bb=bb.nextSibling}for(var a5=0;a5<a4.length;a5++){a0.removeChild(a4[a5]);a7.appendChild(a4[a5]);c=false;m(a4[a5],false);c=true;if(a4[a5].parentNode!=a7){a4.splice(a5,1);a5--}else{a7.removeChild(a4[a5])}}var a3;if(de.doc.isESPlaceHolder(a7,false)||de.doc.isMNPlaceHolder(a7,false)){a3=a7}else{if(a9&&(de.doc.isESPlaceHolder(a9,false)||de.doc.isMNPlaceHolder(a9,false))){a3=a9}}if(a3){while(a3.parentNode&&(de.doc.isESPlaceHolder(a3.parentNode,false)||de.doc.isMNPlaceHolder(a3.parentNode,false))){a3=a3.parentNode}targetNode=a3;a7=a3.parentNode;a9=a3}var ba;if(a9&&a9.nodeType==3&&a8>0&&a8<ah(a9)){var bc=Q(3,a9,a8);if(M(bc.nodeValue.charAt(0))||M(a9.nodeValue.charAt(a8-1))){ba=a9.parentNode;Y(ba)}}var a1;if(!a9){a1=null}else{if(a8==0){a1=a9.previousSibling}else{a1=a9}}for(var a5 in a4){if(!a1){Q(1,a4[a5],a7,a7.firstChild?l(a7.firstChild):null)}else{Q(1,a4[a5],a7,l(a1)+1)}a1=a4[a5]}if(ba){m(ba)}if(a9&&(de.doc.isMNPlaceHolder(a9)||de.doc.isESPlaceHolder(a9))){Q(2,a9)}if(this.flags&2){var a2=de.cursor.getNearestCursorDesc(a4[a4.length-1],ah(a4[a4.length-1],2)-1,true,X(a4[a4.length-1])!="br");if(a2){this.selAfter={startNode:a2.domNode,startIndex:a2.relIndex+(a2.domNode.nodeType==3&&a2.isRightOf?1:0)}}}}});(function(){var a1=20,a0=aZ("dt,dd,caption,colgroup,col,thead,tfoot,tbody,tr,td,th,legend,optgroup,option,area,frame");aI("Indent",{exec:function(ba,a5,a9){if(!a5){if(!this.selBefore){return}if(this.selBefore.endNode){a5=this.selBeforeOrdered.startNode;a9=this.selBeforeOrdered.endNode}else{a5=a9=this.selBefore.startNode}}var a6;var a7=w(a5,a9);for(var a3=0;a3<2;a3++){while(a7!=H&&!aL(a7)){a7=a7.parentNode}if(a7==H){break}if(X(a7)=="li"){a6=[a7];break}a7=a7.parentNode}if(!a6){a6=aQ(a5,a9)}for(var a8 in a6){if(!a0[X(a6[a8])]){var a4=a6[a8];var a2=(a4.style.marginLeft&&a4.style.marginLeft.toLowerCase()!="auto")?a4.style.marginLeft:null;if(!a2){a2=aD(a4,"margin-left")}a2=(a2&&a2.toLowerCase()!="auto")?a2:"0";var bc;if(a2.indexOf("%")!=-1){bc=a4.offsetLeft}else{bc=parseInt(a2)}var bb=bc+((ba?1:-1)*a1);if(bb<0){bb=0}if(bc!=bb){Q(6,a4,"marginLeft",bb+"px")}}}this.selAfter=this.selBefore}})})();aI("Format",{exec:function(bb,bd,a6){bb=bb.toLowerCase();if(typeof q[bb+"Wrapper"]=="undefined"){return}var a7=bd?false:true,a1=false,a9=true,a0;if(!a6){if(!this.selBefore){return}a6=o(this.selBeforeOrdered);a0=o(a6);a9=this.selBefore.inOrder}else{a0=o(a6)}if(!a0.endNode){var a5=null;if(bb=="link"){var a8=a0.startNode;while(a8&&de.doc.isNodeEditable(a8)){if(a8.nodeType==1&&X(a8)=="a"){a5={startNode:a8,startIndex:0,endNode:a8,endIndex:1};break}a8=a8.parentNode}}a0=a5?a5:de.selection.getWordRangeAt(a0.startNode,a0.startIndex>=ah(a0.startNode)?ah(a0.startNode)-1:a0.startIndex);if(!a0){return}a1=a9=true}var bc=ba(a0.startNode,a0.startIndex,a0.endNode,a0.endIndex,q[bb+"Wrapper"](bd||""),a7,q[bb+"Eval"]);if(this.flags&2){if(a1){var a3=bc.getAdjustedNodeIndex(a6.startNode,a6.startIndex);this.selAfter={startNode:a3.node,startIndex:a3.index}}else{var bf=bc.getStartFragment(),a2=bc.getEndFragment();var be=0,a4=ah(a2.node,1);this.selAfter={startNode:a9?bf.node:a2.node,startIndex:a9?be:a4,endNode:a9?a2.node:bf.node,endIndex:a9?a4:be}}}function ba(bx,bk,bq,bi,bn,br,bg){var bv=arguments.length>7,bj=bk==ah(bx,1),bl=bi==0;var bp=aa(w(bx,bq,false),bx,bk,bq,bi);var bm=bp.getStartFragment(),by=bp.getEndFragment(),bw=bp.node;if(bj){bh(bm)}if(bl){bh(by)}function bh(bz){do{bz.dontFormat=1;bz=bz.parent}while(bz&&bz.children.length==1)}bp.visit(function(bz){if(!bz.dontFormat){bs(bz.node)}});if(!bv){var bu=bw;while(bu){bs(bu);if(bu==H){break}bu=bu.parentNode}}if(!br){bx=bm.node;bq=by.node;var bo=aa(bw,bx,bj?ah(bx,1):0,bq,bl?0:ah(bq,1));if(bj){bh(bo.getStartFragment())}if(bl){bh(bo.getEndFragment())}(function bt(bE){var bD=[];for(var bA in bE.children){var bC=bE.children[bA];if(bz(bC)){bD.push(bC.node)}else{bB();bt(bC)}}bB();function bB(){if(bD.length>0){var bH=bn.cloneNode(false);Q(1,bH,bE.node,l(bD[0]));for(var bF in bD){var bG=bD[bF];Q(2,bG);Q(1,bG,bH)}bD=[]}}function bz(bI){if(bI.dontFormat){return false}var bG=true;R(bI.node,bI.node,true,function(bJ){bG=!aL(bJ);return bG});if(bG){var bH=true;(function bF(bL,bK){if(bL.dontFormat){bH=false;return}if(bK.firstChild){bH=bK.childNodes.length==bL.children.length;if(bH){for(var bJ=0;bJ<bK.childNodes.length;bJ++){bF(bL.children[bJ],bK.childNodes[bJ]);if(!bH){break}}}}else{bH=bL.children.length==0}})(bI,bI.node);return bH}return false}})(bo)}return bp;function bs(bA){if(bA.nodeType==1){var bB=false,bI=bg(bA);if(bI){for(var bE in bI.strip){switch(bI.strip[bE].type){case 1:bB=true;break;case 2:var bK=au(bA);if(bK){var bJ=bK.split(" ");for(var bC in bJ){if(bJ[bC]==bI.strip[bE].match){bJ.splice(bC,1);break}}bK=bK.length>0?bJ.join(" "):"";Q(7,bA,bK)}break;case 3:Q(6,bA,bI.strip[bE].match,"");break}if(bB){break}}var bF=bA.firstChild;while(bF.firstChild){bF=bF.firstChild}var bz=bA.lastChild;while(bz.lastChild){bz=bz.lastChild}if(!bB&&X(bA)=="span"){bB=!au(bA);if(!bB){bB=r(bA)}}if(bB){var bH=[];while(bA.firstChild){var bD=bA.firstChild;Q(2,bD);Q(1,bD,bA.parentNode,l(bH.length>0?bH[bH.length-1]:bA)+1);bH.push(bD)}if(bH.length>0){if(bA==bw){bw=bA.parentNode}Q(2,bA)}}if(!bv){var bG=false;bp.visit(function(bL){bG=(!bL.dontFormat&&bL.node==bF);return !bG});if(!bG){ba(bF,0,bm.node,bj?ah(bm.node,1):0,bI.inline,false,bg,true)}bG=false;bp.visit(function(bL){bG=(!bL.dontFormat&&bL.node==bz);return !bG});if(!bG){ba(by.node,bl?0:ah(by.node,1),bz,ah(bz,1),bI.inline,false,bg,true)}}}}}}}});(function(){aI("CreateTable",{exec:function(a1,a3,a4,a2,a6,a5){var a0="<table></table>"}})})();(function(){var a0=aZ("p,pre,h1,h2,h3,h4,h5,h6,address");aI("ChangeContainer",{exec:function(bb,a3,a9){if(!bb){bb="p"}bb=bb.toLowerCase();if(!a3){if(!this.selBefore){return}if(this.selBefore.endNode){a3=this.selBeforeOrdered.startNode;a9=this.selBeforeOrdered.endNode}else{a3=a9=this.selBefore.startNode}}var a4=aQ(a3,a9);for(var a8 in a4){var a2=a4[a8];if(X(a2)!=bb&&a0[X(a2)]){var a6=[],a7,bc=a2.parentNode,ba=l(a2);while(a7=a2.firstChild){a6.push(a7);Q(2,a7)}Q(2,a2);var a1=N(bb);Q(1,a1,bc,ba);for(var a5 in a6){Q(1,a6[a5],a1)}}}this.selAfter=this.selBefore}})})();aI("Blockquote",{exec:function(a2,a7){if(!a2){if(!this.selBefore){return}if(this.selBefore.endNode){a2=this.selBeforeOrdered.startNode;a7=this.selBeforeOrdered.endNode}else{a2=a7=this.selBefore.startNode}}var a9=null,a4=w(a2,a7,true);if(a0(a4)){a9=a4}else{R(a4,a2,true,function(ba){if(a0(ba)){a9=ba}return a9==null&&ba!=a7})}if(!a9){a9=j(a4,H,a0,true)||j(a2,a4,a0,true);if(!de.doc.isNodeEditable(a9)){a9=null}}if(a9){while(a9.firstChild){var a5=a9.firstChild;Q(2,a5);Q(1,a5,a9.parentNode,l(a9))}Q(2,a9)}else{var a3=aQ(a2,a7);var a8=N("blockquote");if(a3.length>0&&n(a8,a3[0].parentNode)){Q(1,a8,a3[0].parentNode,l(a3[0]));for(var a6 in a3){var a1=a3[a6];Q(2,a1);Q(1,a1,a8)}}}this.selAfter=this.selBefore;function a0(ba){return X(ba)=="blockquote"}}});var z={GB:"address,blockquote,center,del,div,h1,h2,h3,h4,h5,h6,hr,ins,isindex,noscript,p,pre",SI:"a,applet,basefont,bdo,br,font,iframe,img,map,area,object,param,q,script,span,sub,sup",PH:"abbr,acronym,cite,code,del,dfn,em,ins,kbd,samp,strong,var",F:"b,big,i,s,small,strike,tt,u",TE:"table,caption,colgroup,col,thead,tfoot,tbody,tr,td,th",NT:"table,textarea,tr,thead,tbody,tfoot,dl,ul,ol,menu,select,optgroup,option"};for(var aq in z){z[aq]=aZ(z[aq])}D(z,{B:D(aZ("dir,dl,fieldset,form,menu,noframes,ol,table,ul,dd,dt,frameset,li,tbody,td,tfoot,thead,th,tr"),z.GB),I:D(D(aZ("abbr,acronym,cite,code,dfn,em,kbd,samp,strong,var"),z.F),z.SI)});var F=function(){function a1(a5,a3){var a2=a3.split(","),a6=o(a5);for(var a4 in a2){delete a6[a2[a4]]}return a6}var a0=D(o(z.B),z.I);return{body:D(aZ("script,ins,del"),a0),address:D(aZ("p"),a0),blockquote:a0,centre:a0,del:a0,h1:z.I,h2:z.I,h3:z.I,h4:z.I,h5:z.I,h6:z.I,hr:{},ins:a0,isindex:{},noscript:a0,p:z.I,pre:a1(z.I,"img,object,applet,big,small,sub,sup,font,basefont"),dir:aZ("li"),dl:aZ("dd,dt"),dt:z.I,dd:a0,li:a0,menu:aZ("li"),ol:aZ("li"),ul:aZ("li"),table:aZ("caption,col,colgroup,thead,tfoot,tbody"),caption:z.I,colgroup:aZ("col"),col:{},thead:aZ("tr"),tfoot:aZ("tr"),tbody:aZ("tr"),tr:aZ("td,th"),td:a0,th:a0,form:a1(a0,"form"),button:a1(a0,"a,input,select,textarea,label,button,iframe,form,isindex,fieldset"),fieldset:D(aZ("legend"),a0),legend:z.I,input:{},label:a1(z.I,"label"),select:aZ("optgroup,option"),optgroup:aZ("option"),option:{},textarea:{},a:a1(z.I,"a"),applet:D(aZ("param"),a0),basefont:{},bdo:z.I,br:{},font:z.I,iframe:a0,img:{},map:D(aZ("area"),z.B),area:{},object:D(aZ("param"),a0),param:{},q:z.I,script:{},span:z.I,sub:z.I,sup:z.I,abbr:z.I,acroynm:z.I,cite:z.I,code:z.I,dfn:z.I,em:z.I,kbd:z.I,samp:z.I,strong:z.I,"var":z.I,b:z.I,big:z.I,i:z.I,s:z.I,small:z.I,strike:z.I,tt:z.I,u:z.I}}();function aC(a1,a0){if(a1.nodeType==1){return z[a0][X(a1)]?true:false}return false}function n(a2,a0){if(a2.nodeType==3){return true}var a1=F[X(a0)];if(a1){return a1[X(a2)]}return true}function aL(a0){return aC(a0,"B")}function S(a0){return aC(a0,"GB")}function ae(a0){return aC(a0,"I")}function g(a0){return aC(a0,"SI")}function O(a0){return aC(a0,"PH")}function aE(a0){return aC(a0,"F")}function y(a0){return aC(a0,"TE")}function M(a0){return/^[\t\n\r ]+$/.test(a0)}function aH(a0){return !aC(a0.parentNode,"NT")}var B=a("&nbsp;");D(de,{isBlock:aL});var b,C,aS,aR;(function(){var a3=1,a2,a1;L("viewport",function(){A(window,"resize",function(){a3=1})});de.getViewPortSize=_getViewPortSize=function(a4){if(a3||a4){a0()}return{width:a2,height:a1}};function a0(){if(E==3&&G<7){a2=document.documentElement.clientWidth;a1=document.documentElement.clientHeight}else{var a4=N("div");ao(a4,"position:fixed;top:0;left:0;width:100%;height:100%;border-style:none;margin:0");H.appendChild(a4);a2=a4.offsetWidth;a1=a4.offsetHeight;H.removeChild(a4)}a3=0}})();de.getDocumentScrollPos=aR=function(){var a1=0,a0=0;if(H.scrollLeft||H.scrollTop){a1=H.scrollLeft;a0=H.scrollTop}else{if(window.pageYOffset||window.pageXOffset){a1=window.pageXOffset;a0=window.pageYOffset}else{if(document.documentElement.scrollLeft||document.documentElement.scrollTop){a1=document.documentElement.scrollLeft;a0=document.documentElement.scrollTop}}}return{top:a0,left:a1}};function aN(){var a1=0,a0=0;if(window.innerWidth||window.innerHeight){a1=window.innerWidth;a0=window.innerHeight}else{if(document.documentElement.offsetWidth||document.documentElement.offsetWidth){a1=document.documentElement.offsetWidth;a0=document.documentElement.offsetHeight}else{if(H.offsetWidth||H.offsetWidth){a1=H.offsetWidth;a0=H.offsetWidth}}}return{width:a1,height:a0}}var m,s,Y;(function(){var a0=aZ("button,img,iframe,map,object"),a3=aZ("br,button,img,iframe,map,object,select,textarea,applet");Y=function(a5){ar(a5,a5,true,function(a6){if(aH(a6)&&a1(a6)=="normal"){a6.nodeValue=a6.nodeValue.replace(/[\t\n\r ]/g,B)}})};m=function(a8,bg){var bd;ar(a8,a8,true,function(bn){if(aH(bn)&&ah(bn)>0){bd=bn;return false}});if(!bd){return}var a7=a8;var bk=false;if(bg&&M(bd.nodeValue.charAt(0))){R(null,bd,false,function(bn){if(bn==bd){return}if(bn.nodeType==3){if(!aH(bn)){return false}a7=bn;if(!M(bn.nodeValue)){bk=true;return false}}else{if(!ae(bn)){return false}}})}var bi=aK(a8,a7),a5=0;while(a7){var be=a2(a7,a5,bk,a8,bi,false,false,bg);bk=false;bi=be.seenTargetNode;a7=be.resumeNode;a5=be.resumeIndex;if(be.startNode&&a1(be.startNode)!="pre"){if(a4(be.startNode,be.startIndex,be.endNode,be.endIndex)){if(be.startNode==be.endNode&&be.startIndex==(be.endIndex-1)){be.startNode=null}else{be.startIndex++}}if(be.startNode){var bc=aa(w(be.startNode,be.endNode,false),be.startNode,be.startIndex,be.endNode,be.endIndex);bc.disconnect();var a9=a7==a8;if(a7){var ba=bc.getStartFragment(),bm=bc.getEndFragment(),bj=false,bb=bc.wasStartSplit(),bh=bc.wasEndSplit();if(a7==be.startNode&&bb){if(a5>=ah(be.startNode)){var bl=ah(ba.node);if(a5<(ah(be.startNode)+bl)){a5=ah(be.startNode)-1}else{if(a7==be.endNode&&bh){a7=bm.getPostSplitNode();a5-=(ah(be.startNode)+bl)}else{assert(false)}}}bj=true}else{if(a7==be.endNode&&bh){var bl=ah(bm.node);if(a5>=bl){a7=bm.getPostSplitNode();a5-=bl;bj=true}else{a7=null}}}if(!bj){var bf;if(a7){bf=false;bc.visit(function(bn){if(!bn.isShared&&bn.node==a7){bf=true;return false}})}else{bf=true}if(bf){var a6=ba;while(!a6.isShared){a6=a6.parent}a7=a6.node;a5=a6==ba?ah(a7,1):0;if(a7.childNodes.length>0&&a6.children.length>0&&a6.children[0].pos>0){a7=a7.childNodes[a6.children[0].pos-1];a5=ah(a7,1)}}}if(a7&&a9){a8=a7}}}}}};s=function(bc){var a6=bc,bd=0;while(a6){var be=a2(a6,bd,false,bc,true,true,true,true);a6=be.resumeNode;bd=be.resumeIndex;if(be.startNode){var a8=a4(be.startNode,be.startIndex,be.endNode,be.endIndex);var bb=[];ar(w(be.startNode,be.endNode,false),be.startNode,true,function(bf){bb.push(bf);if(bf==be.endNode){return false}});for(var a9=0;a9<bb.length;a9++){var a7=bb[a9];for(var ba=(a9==0?be.startIndex:0);ba<(a9==(bb.length-1)?(be.endIndex+1):ah(a7));ba++){if(a7.nodeValue.charAt(ba)==B){if(!(!a8&&((a9==0&&ba==be.startIndex)||(a9==(bb.length-1)&&ba==be.endIndex)))){var a5;if(ba==0){a5=(a9>0)?bb[a9-1].nodeValue.charAt(ah(bb[a9-1])-1):null}else{a5=a7.nodeValue.charAt(ba-1)}if(!a5||!M(a5)){if(ba==(ah(a7)-1)){a5=(a9<(bb.length-1))?bb[a9+1].nodeValue.charAt(0):null}else{a5=a7.nodeValue.charAt(ba+1)}if(!a5||!M(a5)){a7.nodeValue=a7.nodeValue.substr(0,ba)+" "+a7.nodeValue.substr(ba+1)}}}}}}}}};function a2(bh,bc,be,bg,bi,a7,a6,bb){var bf=null,bj=bc,a5,bk,bd,ba,a8,a9;R(null,bh,true,function(bq){if(bi&&bq!=bg&&(!a5||!bb)&&!aK(bg,bq)){return false}bi|=(bq==bg);a9=a1(bq);if(a5){var bl=w(bq,a5,false);var bp=aO(a5,bl,false,false);var bm=false;for(var bn in bp){if(!(ae(bp[bn])&&!a3[X(bp[bn])])){bm=true;break}}if(bm||a9!=a8){bf=bq;bj=0;return false}}if(bq.nodeType==3){if(bq.parentNode.nodeType!=8){if(!aH(bq)){if(a5){bf=bq;bj=0;return false}}else{while(bj<ah(bq)){var bo=bq.nodeValue.charAt(bj);if(M(bo)||(a7&&bo==B)){if(!be){if(a5){bd=bq;ba=bj+1}else{a5=bq;a8=a9;bk=bj;bd=null}}}else{be=false;if(bd||(a5&&(a6||bk==0))){bf=bq;return false}else{a5=null}}bj++}}}else{be=false}}else{be=false;if(bq.nodeType!=8){if(a5&&!(ae(bq)&&!a3[X(bq)])){bf=bq;bj=0;return false}}}bj=0});if(a5&&!bd){bd=a5;ba=bk+1}return{seenTargetNode:bi,resumeNode:bf,resumeIndex:bj,startNode:a5,startIndex:bk,endNode:bd,endIndex:ba}}function a4(a8,bb,a5,ba){var a7=a1(a8);if(bb==0){var a9=false;R(null,a8,false,function(bg){if(bg==a8){return}var be=a6(bg,a8);if(!be&&a9){var bc=w(bg,a8,false);var bf=aO(bg,bc,false,false);for(var bd in bf){a9=false;if(!a6(bf[bd],a8)&&!a9){return false}}be=false;a9=true}return be});if(!a9){return false}}if(ba==ah(a5)){var a9=false;R(null,a5,true,function(bg){if(bg==a5){return}var be=a6(bg,a5);if(!be&&a9){var bc=w(bg,a5,false);var bf=aO(a5,bc,false,false);for(var bd in bf){a9=false;if(!a6(bf[bd],a5)&&!a9){return false}}a9=true;be=false}return be});if(!a9){return false}}return true;function a6(bc,bd){if(bc.nodeType==3){if(ah(bc)>0){a9=aH(bc);return false}}else{if(a0[X(bc)]){a9=!aK(bc,bd);return false}else{if(aL(bc)||X(bc)=="br"){return false}}}return true}}function a1(a6){var a5=aD(a6,"white-space");if(!a5){do{if(X(a6)=="pre"){a5="pre";break}a6=a6.parentNode}while(a6&&a6.nodeType==1);if(!a5){a5="normal"}}return a5}})()})();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+if (document.body.className) {
+  document.body.className += " editable";
+}
+else {
+  document.body.className = "editable";
+}
+*/
+
+
+csnInit();
