மீடியாவிக்கி:RefToolbarLegacy.js
var numforms = 0;
 var wikEdAutoUpdateUrl;
 var citeUserDateFormat;
 var refTagURL;
 var defaultRefTagURL = '//reftag.appspot.com/';
 var refToolDebug;
 
 String.prototype.trim = function() {
 	return this.replace(/^\s+|\s+$/g,&quot;&quot;);
 };
 
 function refbuttons() {
   if (mw.toolbar &amp;&amp; document.getElementById('toolbar') ) {
     var button = document.createElement('a');
     button.href = &quot;javascript:easyCiteMain()&quot;;
     button.title = &quot;Insert Citation&quot;;
     button.className = &quot;mw-toolbar-editbutton&quot;;
     var buttonimage = document.createElement('img');
     buttonimage.src = &quot;//upload.wikimedia.org/wikipedia/commons/e/ea/Button_easy_cite.png&quot;;
     buttonimage.alt = &quot;Insert Citation&quot;;
     button.appendChild(buttonimage);
     var toolbar = document.getElementById('toolbar');
     if (navigator.userAgent.indexOf('MSIE') == -1) {
       toolbar.appendChild(button);
       var citemain = document.createElement('div');
       citemain.style.display = 'none';
       citemain.style.margin = '0 0 6px';
       citemain.style.clear = 'both';
       citemain.style.height = 'auto';
       citemain.setAttribute('Id', 'citeselect');
       citemain.appendChild( addOption(&quot;citeWeb()&quot;, &quot;Web&quot;) );
       citemain.appendChild( addOption(&quot;citeNews()&quot;, &quot;News&quot;) );
       citemain.appendChild( addOption(&quot;citeBook()&quot;, &quot;Book&quot;) );
       citemain.appendChild( addOption(&quot;citeJournal()&quot;, &quot;Journal&quot;) );
       citemain.appendChild( addOption(&quot;citeNamedRef()&quot;, &quot;Named references&quot;) );
       citemain.appendChild( addOption(&quot;dispErrors()&quot;, &quot;Error check&quot;) );
       citemain.appendChild( addOption(&quot;showMore()&quot;, &quot;More&quot;) );
       citemain.appendChild( addOption(&quot;hideInitial()&quot;, &quot;Cancel&quot;) );
 
       var citemore = document.createElement('div');
       citemore.style.display = 'none';
       citemore.setAttribute('Id', 'citemore');
       citemore.appendChild( addOption(&quot;citeEncyclopedia()&quot;, &quot;Encyclopedia&quot;) );
       citemore.appendChild( addOption(&quot;citePressRelease()&quot;, &quot;Press release&quot;) );
       citemore.appendChild( addOption(&quot;citeMap()&quot;, &quot;Map&quot;) );
       citemore.appendChild( addOption(&quot;showRefSectionOptions()&quot;, &quot;Ref Section&quot;) );
       citemain.appendChild(citemore);
 
       $( citemain ).insertAfter( $( toolbar ) );
     }
     else {
       toolbar.appendChild(button);
       var citeselect = document.createElement('div');
       citeselect.id = 'citeselect';
       citeselect.style.display = &quot;none&quot;;
       citeselect.innerHTML = '&lt;input type=&quot;button&quot; value=&quot;Web&quot; onclick=&quot;citeWeb()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;News&quot; onclick=&quot;citeNews()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;Book&quot; onclick=&quot;citeBook()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;Journal&quot; onclick=&quot;citeJournal()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;Named references&quot; onclick=&quot;citeNamedRef()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;Error check&quot; onclick=&quot;dispErrors()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;More&quot; onclick=&quot;showMore()&quot; /&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;Cancel&quot; onclick=&quot;hideInitial()&quot; /&gt;'+
       '&lt;div id=&quot;citemore&quot; style=&quot;display:none&quot;&gt;\
       &lt;input type=&quot;button&quot; value=&quot;Encyclopedia&quot; onclick=&quot;citeEncyclopedia()&quot; /&gt;\
       &lt;input type=&quot;button&quot; value=&quot;Press release&quot; onclick=&quot;citePressRelease()&quot; /&gt;\
       &lt;input type=&quot;button&quot; value=&quot;Map&quot; onclick=&quot;citeMap()&quot; /&gt;\
       &lt;input type=&quot;button&quot; value=&quot;Ref Section&quot; onclick=&quot;showRefSectionOptions()&quot; /&gt;\
       &lt;/div&gt;';
       document.getElementById('editform').insertBefore(citeselect, document.getElementById('editform').firstChild ) ;
     }
     var reftoolformarea = document.createElement( 'span' );
     reftoolformarea.id = 'refToolFormArea';
     document.getElementById('citeselect').appendChild( reftoolformarea );
   }
   if (typeof EditTools == &quot;object&quot;) {
     var placeholder = document.getElementById(&quot;editpage-specialchars&quot;);
     EditTools.createEditTools (placeholder);
   }
 }
 
 function addOption(script, text) {
   var option = document.createElement('input');
   option.setAttribute('type', 'button');
   option.setAttribute('onclick', script);
   option.setAttribute(&quot;value&quot;, text);
   return option;
 }
 
 function hideInitial() {
   document.getElementById('citeselect').style.display = 'none';
   oldFormHide();
 }
 
 function oldFormHide() {
   //if (numforms != 0) {
   //  document.getElementById('citediv'+numforms).style.display = 'none';
   //}
   document.getElementById('refToolFormArea').innerHTML = '';
   if (document.getElementById('errorform') !== null) {
     document.getElementById('citeselect').removeChild(document.getElementById('errorform'));
   }
 }
 
 function easyCiteMain() {
   document.getElementById('citeselect').style.display = '';
   document.getElementById('citemore').style.display = 'none';
 }
 
 function showMore() {
 	document.getElementById('citemore').style.display = '';
 }
 
 var months = ['January', 'February', 'March', 'April', 'May', 'June',
   'July', 'August', 'September', 'October', 'November', 'December'];
 var citeGlobalDateFormat = &quot;&lt;date&gt; &lt;monthname&gt; &lt;year&gt;&quot;;
 function getTime() {
   var datestr = '';
   if (citeUserDateFormat) {
     datestr = citeUserDateFormat;
   } else {
     datestr = citeGlobalDateFormat;
   }
   var DT = new Date();
   var zmonth = '';
   var month = DT.getUTCMonth()+1;
   if (month &lt; 10) {
     zmonth = &quot;0&quot;+month.toString();
   } else {
     zmonth = month.toString();
   }
   month = month.toString();
   var zdate = '';
   var date = DT.getUTCDate();
   if (date &lt; 10) {
     zdate = &quot;0&quot;+date.toString();
   } else {
     zdate = date.toString();
   }
   date = date.toString();
   datestr = datestr.replace('&lt;date&gt;', date);
   datestr = datestr.replace('&lt;month&gt;', month);
   datestr = datestr.replace('&lt;zdate&gt;', zdate);
   datestr = datestr.replace('&lt;zmonth&gt;', zmonth);
   datestr = datestr.replace('&lt;monthname&gt;', months[DT.getUTCMonth()]);
   datestr = datestr.replace('&lt;year&gt;', DT.getUTCFullYear().toString());
   return (datestr);
 }
 
 function lastNameToRefname() {
   //Note: This only works if field 'refname' comes after field 'last', but it always does
   var lastName;
   var fields = document.getElementById('citediv'+numforms).getElementsByTagName('input');
   for (var i=0; i&lt;fields.length; i++) {
     if(fields[i].id == 'last') {
       lastName = fields[i].value;
     }
     else if(fields[i].id == 'refname') {
       fields[i].value = lastName.replace(/^\s*(.*?)\s*$/, &quot;$1&quot;);
       return;
     }
   }
 }
 
 function setAccessDateToday() {
   document.getElementById('accessdate').value = getTime();
 /*  var fields = document.getElementById('citediv'+numforms).getElementsByTagName('input');
   for (var i=0; i&lt;fields.length; i++) {
     if(fields[i].id == 'accessdate') {
       fields[i].value = getTime();
       return;
     }
   }
 */
 }
 
 function getLastName(authornum) {
   if (/\S/.test(document.getElementById('last'+authornum).value)) {
     return document.getElementById('last'+authornum).value;
   }
   else {
     var author = document.getElementById('author'+authornum).value;
     var match = /(\S+)\s*$/.exec(author);
     if (match) {
       return match[1];
     }
     else {
       return '';
     }
   }
 }
 
 function makeRefname() {
   var refname;
   if (document.getElementById('last1')) {
     refname = document.getElementById('last1').value + document.getElementById('last2').value;
   }
   else{
 	refname = document.getElementById('last').value;
   }
   if (/\S/.test(refname)) {
     var date = document.getElementById('date').value;
     var match = /[0-9]{4}/.exec(date);
     if (match) {
       refname += match[0];
     }
   }
   else {
     refname = document.getElementById('title').value;
   }
   document.getElementById('refname').value = refname;
 }
 
 function citeWeb() {
   citeNewsWeb(&quot;cite web&quot;);
 }
 function citeNews() {
   citeNewsWeb(&quot;cite news&quot;);
 }
 
 function citeNewsWeb(templatename) {
   oldFormHide();
   var template = templatename;
   var legend;
   if (template == &quot;cite web&quot;) {
     legend = &quot;Cite web source&quot;;
   } else {
     legend = &quot;Cite news source&quot;;
   }
   var newtime = getTime();
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;'+legend+'&lt;/legend&gt;'+
     '&lt;table cellspacing=&quot;5&quot;&gt;'+
     '&lt;input type=&quot;hidden&quot; value=&quot;'+template+'&quot; id=&quot;template&quot;&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;url&quot;&gt;&amp;nbsp;URL: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;image&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png&quot; tabindex=1 alt=&quot;Fetch&quot; title=&quot;' + ((template == 'cite news') ? 'For a New York Times article URL, fetch article data and fill in the fields. For other URLs, fetch the page title.' : 'Fetch the page title. Irrelevant parts often have to be removed manually afterwards.') + '&quot; onClick=&quot;pullURL(); return false;&quot; style=&quot;float:right&quot;&gt;&lt;span style=&quot;display: block;overflow: hidden;&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:97%&quot; id=&quot;url&quot;&gt;&lt;/span&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;title&quot;&gt;&amp;nbsp;Title: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;title&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;last&quot;&gt;&amp;nbsp;Last name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;last&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;first&quot;&gt;&amp;nbsp;First name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;first&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;coauthors&quot;&gt;&amp;nbsp;Coauthors: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;coauthors&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;date&quot;&gt;&amp;nbsp;Publication date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;date&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;work&quot;&gt;&amp;nbsp;' + ((template == 'cite news') ? 'Newspaper' : 'Work') + ': &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;work&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;publisher&quot;&gt;&amp;nbsp;Publisher: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;publisher&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;pages&quot;&gt;&amp;nbsp;Pages: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;pages&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;language&quot;&gt;&amp;nbsp;Language: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;language&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;accessdate&quot;&gt;&amp;nbsp;Access date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;accessdate&quot; value=&quot;'+ newtime +'&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;location&quot;&gt;&amp;nbsp;Location: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;location&quot;&gt;&lt;/td&gt;&lt;/tr&gt;';
   if (template == 'cite web') {
     form += '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;archiveurl&quot;&gt;&amp;nbsp;Archive URL: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;archiveurl&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;archivedate&quot;&gt;&amp;nbsp;Archive date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;archivedate&quot;&gt;&lt;/td&gt;&lt;/tr&gt;';
   }
   form += '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;refname&quot;&gt;&amp;nbsp;Reference name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:60%&quot; id=&quot;refname&quot;&gt;&lt;input type=&quot;button&quot; value=&quot;&lt;Last name&quot; onClick=&quot;lastNameToRefname()&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;/table&gt;'+
     ' &lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;addcites()&quot;&gt;'+
 	' &lt;input type=&quot;button&quot; value=&quot;Preview citation&quot; onClick=&quot;previewCitationDefault()&quot;&gt; \
 	&lt;img id=&quot;progress&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/5/59/RefToolbar_spinning_throbber.gif&quot; style=&quot;visibility: hidden&quot; /&gt;'+
     '&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;verbose&quot; id=&quot;verbose&quot; value=&quot;verbose&quot;&gt;&lt;label for=&quot;verbose&quot;&gt;Vertical form&lt;/label&gt;'+
     '&lt;span style=&quot;float:right&quot;&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:'+template.replace(/ /g, '_')+'&quot; target=&quot;_blank&quot;&gt;[Template documentation]&lt;/a&gt;&lt;/span&gt;'+
     '&lt;/fieldset&gt;&lt;span id=&quot;previewSpan&quot;&gt;&lt;/span&gt;&lt;/div&gt;';
    document.getElementById('refToolFormArea').innerHTML = form;
 }
 
 function citeBook() {
   oldFormHide();
   var template = &quot;cite book&quot;;
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;Cite book source&lt;/legend&gt;';
 
   form += '&lt;table cellspacing=&quot;5&quot; width=&quot;100%&quot;&gt; \
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;title&quot;&gt;Title: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td colspan=5&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;title&quot;&gt;&lt;/td&gt;&lt;/tr&gt;';
   for (var i=1;i&lt;=3;i++) {
     var i_str = i == 1 ? '': ' '+i;
     form += '&lt;tr&gt; \
 		&lt;td width=&quot;130&quot;&gt;&lt;label for=&quot;last'+i+'&quot;&gt;Author'+i_str+' last&amp;nbsp;name: &lt;/label&gt;&lt;/td&gt; \
 		&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;last'+i+'&quot;&gt;&lt;/td&gt; \
 		&lt;td&gt;&lt;label for=&quot;first'+i+'&quot;&gt;&amp;nbsp;first&amp;nbsp;name: &lt;/label&gt;&lt;/td&gt; \
 		&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;first'+i+'&quot;&gt;&lt;/td&gt; \
 		&lt;td&gt;&lt;label for=&quot;authorlink'+i+'&quot;&gt;&amp;nbsp;Authorlink: &lt;/label&gt;&lt;/td&gt; \
 		&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;authorlink'+i+'&quot;&gt; \
 		&lt;!--&lt;a id=&quot;authorLinkAnchor'+i+'&quot;&gt;&lt;img id=&quot;authorLinkButton'+i+'&quot; src=&quot;static/progress.gif&quot; border=&quot;0&quot; style=&quot;visibility: hidden&quot; /&gt;&lt;/a&gt; \
 		&lt;a href=&quot;//en.wikipedia.org/wiki/%s&quot; target=&quot;_blank&quot;&gt;&lt;img id=&quot;authorTryLink'+i+'&quot; src=&quot;static/external.png&quot; border=&quot;0&quot; style=&quot;visibility: hidden&quot; /&gt;&lt;/a&gt; --&gt; \
 		&lt;/td&gt; \
 		&lt;/tr&gt;';
   }
   form += '&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;coauthors&quot;&gt;Coauthors: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;coauthors&quot;&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;editor&quot;&gt;&amp;nbsp;Editor: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;editor&quot;&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;others&quot;&gt;&amp;nbsp;Others: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;others&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	&lt;/table&gt; \
 	&lt;table cellspacing=&quot;5&quot; width=&quot;100%&quot;&gt; \
 	&lt;tr&gt;&lt;td width=&quot;130&quot;&gt;&lt;label for=&quot;publisher&quot;&gt;Publisher: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;publisher&quot;&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;location&quot;&gt;&amp;nbsp;Location: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;location&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	\
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;date&quot;&gt;Publication&amp;nbsp;date or&amp;nbsp;year: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:140px&quot; id=&quot;date&quot;&gt; \
 	&lt;input id=&quot;dmy&quot; name=&quot;dateformat&quot; value=&quot;dmy&quot; type=&quot;radio&quot; tabindex=1 onclick=&quot;reformatDates()&quot;&gt;&lt;label for=&quot;dmy&quot;&gt;dmy&lt;/label&gt; \
 	&lt;input id=&quot;mdy&quot; name=&quot;dateformat&quot; value=&quot;mdy&quot; type=&quot;radio&quot; tabindex=1 onclick=&quot;reformatDates()&quot;&gt;&lt;label for=&quot;mdy&quot;&gt;md, y&lt;/label&gt; \
 	&lt;input id=&quot;ymd&quot; name=&quot;dateformat&quot; value=&quot;ymd&quot; type=&quot;radio&quot; tabindex=1 onclick=&quot;reformatDates()&quot;&gt;&lt;label for=&quot;ymd&quot;&gt;y-m-d&lt;/label&gt; \
 	&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;edition&quot;&gt;&amp;nbsp;Edition: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;edition&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	\
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;series&quot;&gt;Series: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;series&quot;&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;volume&quot;&gt;&amp;nbsp;Volume: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;volume&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	\
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;pages&quot;&gt;Page number(s):&lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;pages&quot; name=&quot;pages&quot; onFocus=&quot;this.style.backgroundColor=\'\';&quot;&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;chapter&quot;&gt;&amp;nbsp;Chapter: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;chapter&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	\
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;isbn&quot;&gt;ISBN: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;image&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png&quot; tabindex=1 alt=&quot;Fetch&quot; title=&quot;Fill in citation data based on ISBN from Diberri\'s tool.&quot; onClick=&quot;pullISBN(); return false;&quot; style=&quot;float:right&quot;&gt;&lt;span style=&quot;display: block;overflow: hidden;&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:97%&quot; id=&quot;isbn&quot;&gt;&lt;/span&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;language&quot;&gt;&amp;nbsp;Language: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;language&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	\
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;url&quot;&gt;URL: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;image&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png&quot; tabindex=1 alt=&quot;Fetch&quot; title=&quot;Fill in citation data based on a Google Books URL.&quot; onClick=&quot;pullJs(); return false;&quot; style=&quot;float:right&quot;&gt;&lt;span style=&quot;display: block;overflow: hidden;&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:97%&quot; id=&quot;url&quot;&gt;&lt;/span&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;accessdate&quot;&gt;&amp;nbsp;Access&amp;nbsp;date:&lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;accessdate&quot;&gt;&lt;/td&gt;&lt;/tr&gt; \
 	\
 	&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;otherfields&quot;&gt;Other&amp;nbsp;fields:&lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;otherfields&quot;&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;label for=&quot;refname&quot;&gt;&amp;nbsp;Ref&amp;nbsp;name: &lt;/label&gt;&lt;/td&gt; \
 	&lt;td&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;refname&quot;&gt;&lt;/td&gt; \
 	&lt;/tr&gt; \
 	&lt;/table&gt; \
 	\
 	&lt;input type=&quot;radio&quot; tabindex=1 name=&quot;template&quot; id=&quot;cite_book&quot; value=&quot;cite_book&quot; checked=&quot;1&quot;&gt;&lt;label for=&quot;cite_book&quot;&gt;\{\{cite book}}&lt;/label&gt; &lt;sup&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:Cite_book&quot; target=&quot;_blank&quot;&gt;[doc]&lt;/a&gt;&lt;/sup&gt; \
 	&lt;input type=&quot;radio&quot; tabindex=1 name=&quot;template&quot; id=&quot;citation&quot; value=&quot;citation&quot;&gt;&lt;label for=&quot;citation&quot;&gt;\{\{citation}}&lt;/label&gt; &lt;sup&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:Citation&quot; target=&quot;_blank&quot;&gt;[doc]&lt;/a&gt;&lt;/sup&gt; \
 	&lt;input type=&quot;radio&quot; tabindex=1 name=&quot;template&quot; id=&quot;plain&quot; value=&quot;plain&quot;&gt;&lt;label for=&quot;plain&quot;&gt;plain wikicode (experimental)&lt;/label&gt; \
 	&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;verbose&quot; id=&quot;verbose&quot; value=&quot;verbose&quot;&gt;&lt;label for=&quot;verbose&quot;&gt;Vertical form&lt;/label&gt; \
 	&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;extraparams&quot; id=&quot;extraparams&quot; value=&quot;extraparams&quot;&gt;&lt;label for=&quot;extraparams&quot;&gt;Extra parameters&lt;/label&gt; \
 	&lt;br /&gt;&lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;makeCiteBook()&quot;&gt; \
 	&lt;input type=&quot;button&quot; value=&quot;Preview citation&quot; onClick=&quot;previewCitationBook()&quot;&gt; \
 	&lt;img id=&quot;progress&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/5/59/RefToolbar_spinning_throbber.gif&quot; style=&quot;visibility: hidden&quot; /&gt; \
 	\
  	&lt;/fieldset&gt;&lt;span id=&quot;previewSpan&quot;&gt;&lt;/span&gt;&lt;/div&gt;';
    document.getElementById('refToolFormArea').innerHTML = form;
 }
 
 function citeJournal() {
   oldFormHide();
   var template = &quot;cite journal&quot;;
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;Cite journal&lt;/legend&gt;'+
     '&lt;table cellspacing=&quot;5&quot;&gt;'+
     '&lt;input type=&quot;hidden&quot; value=&quot;'+template+'&quot; id=&quot;template&quot;&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;last&quot;&gt;&amp;nbsp;Last name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;last&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;first&quot;&gt;&amp;nbsp;First name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;first&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;coauthors&quot;&gt;&amp;nbsp;Coauthors: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;coauthors&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;date&quot;&gt;&amp;nbsp;Publication date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;date&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;title&quot;&gt;&amp;nbsp;Title: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;title&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;journal&quot;&gt;&amp;nbsp;Journal: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;journal&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;publisher&quot;&gt;&amp;nbsp;Publisher: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;publisher&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;location&quot;&gt;&amp;nbsp;Location: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;location&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;volume&quot;&gt;&amp;nbsp;Volume: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;volume&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;issue&quot;&gt;&amp;nbsp;Issue: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;issue&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;pages&quot;&gt;&amp;nbsp;Pages: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;pages&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;issn&quot;&gt;&amp;nbsp;ISSN: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;issn&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;oclc&quot;&gt;&amp;nbsp;OCLC: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;oclc&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;doi&quot;&gt;&amp;nbsp;DOI: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;image&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png&quot; tabindex=1 alt=&quot;Fetch&quot; title=&quot;Fetch citation data for a DOI from crossref.org and fill in the other fields.&quot; onClick=&quot;pullDOI(); return false;&quot; style=&quot;float:right&quot;&gt;&lt;span style=&quot;display: block;overflow: hidden;&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:97%&quot; id=&quot;doi&quot;&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;pmid&quot;&gt;&amp;nbsp;PMID: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;image&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png&quot; tabindex=1 alt=&quot;Fetch&quot; title=&quot;Fetch citation data for a PMID&quot; onClick=&quot;pullPMID(); return false;&quot; style=&quot;float:right;visibility:hidden&quot;&gt;&lt;span style=&quot;display: block;overflow: hidden;&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:97%&quot; id=&quot;pmid&quot;&gt;&lt;/span&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;quote&quot;&gt;&amp;nbsp;Quote: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;quote&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;url&quot;&gt;&amp;nbsp;URL: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;url&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;accessdate&quot;&gt;&amp;nbsp;Access date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;accessdate&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;language&quot;&gt;&amp;nbsp;Language: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;language&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;refname&quot;&gt;&amp;nbsp;Reference name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:60%&quot; id=&quot;refname&quot;&gt;&lt;input type=&quot;button&quot; value=&quot;&lt;Last name&quot; onClick=&quot;lastNameToRefname()&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;/table&gt;'+
     '&lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;addcites()&quot;&gt;'+
 	' &lt;input type=&quot;button&quot; value=&quot;Preview citation&quot; onClick=&quot;previewCitationDefault()&quot;&gt; \
 	&lt;img id=&quot;progress&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/5/59/RefToolbar_spinning_throbber.gif&quot; style=&quot;visibility: hidden&quot; /&gt;'+
     '&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;verbose&quot; id=&quot;verbose&quot; value=&quot;verbose&quot;&gt;&lt;label for=&quot;verbose&quot;&gt;Vertical form&lt;/label&gt;'+
     '&lt;span style=&quot;float:right&quot;&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:'+template.replace(/ /g, '_')+'&quot; target=&quot;_blank&quot;&gt;[Template documentation]&lt;/a&gt;&lt;/span&gt;'+
     '&lt;/fieldset&gt;&lt;span id=&quot;previewSpan&quot;&gt;&lt;/span&gt;&lt;/div&gt;';
    document.getElementById('refToolFormArea').innerHTML = form;
 }
 
 function citeEncyclopedia() {
   oldFormHide();
   var template = &quot;cite encyclopedia&quot;;
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;Cite encyclopedia source&lt;/legend&gt;'+
     '&lt;table cellspacing=&quot;5&quot;&gt;'+
     '&lt;input type=&quot;hidden&quot; value=&quot;'+template+'&quot; id=&quot;template&quot;&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;last&quot;&gt;&amp;nbsp;Last name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;last&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;first&quot;&gt;&amp;nbsp;First name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;first&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;coauthors&quot;&gt;&amp;nbsp;Coauthors: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;coauthors&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;editors&quot;&gt;&amp;nbsp;Editors: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;editors&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;title&quot;&gt;&amp;nbsp;Entry title: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;title&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;encyclopedia&quot;&gt;&amp;nbsp;Encyclopedia: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;encyclopedia&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;publisher&quot;&gt;&amp;nbsp;Publisher: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;publisher&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;location&quot;&gt;&amp;nbsp;Location: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;location&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;year&quot;&gt;&amp;nbsp;Year: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;year&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;volume&quot;&gt;&amp;nbsp;Volume: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;volume&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;pages&quot;&gt;&amp;nbsp;Pages: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;pages&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;isbn&quot;&gt;&amp;nbsp;ISBN: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;isbn&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;url&quot;&gt;&amp;nbsp;URL: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;url&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;accessdate&quot;&gt;&amp;nbsp;Access date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;accessdate&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;language&quot;&gt;&amp;nbsp;Language: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;language&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;refname&quot;&gt;&amp;nbsp;Reference name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;refname&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;/table&gt;'+
     '&lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;addcites()&quot;&gt;'+
 	' &lt;input type=&quot;button&quot; value=&quot;Preview citation&quot; onClick=&quot;previewCitationDefault()&quot;&gt; \
 	&lt;img id=&quot;progress&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/5/59/RefToolbar_spinning_throbber.gif&quot; style=&quot;visibility: hidden&quot; /&gt;'+
     '&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;verbose&quot; id=&quot;verbose&quot; value=&quot;verbose&quot;&gt;&lt;label for=&quot;verbose&quot;&gt;Vertical form&lt;/label&gt;'+
     '&lt;span style=&quot;float:right&quot;&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:'+template.replace(/ /g, '_')+'&quot; target=&quot;_blank&quot;&gt;[Template documentation]&lt;/a&gt;&lt;/span&gt;'+
     '&lt;/fieldset&gt;&lt;span id=&quot;previewSpan&quot;&gt;&lt;/span&gt;&lt;/div&gt;';
    document.getElementById('refToolFormArea').innerHTML = form;
 }
 
 function citePressRelease() {
   oldFormHide();
   var template = &quot;cite press release&quot;;
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;Cite press release&lt;/legend&gt;'+
     '&lt;table cellspacing=&quot;5&quot;&gt;'+
     '&lt;input type=&quot;hidden&quot; value=&quot;'+template+'&quot; id=&quot;template&quot;&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;title&quot;&gt;&amp;nbsp;Title: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;title&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;publisher&quot;&gt;&amp;nbsp;Publisher: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;publisher&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;date&quot;&gt;&amp;nbsp;Date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;date&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;language&quot;&gt;&amp;nbsp;Language: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;language&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;url&quot;&gt;&amp;nbsp;URL: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;url&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;accessdate&quot;&gt;&amp;nbsp;Access date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;accessdate&quot; value=&quot;'+ getTime() +'&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;refname&quot;&gt;&amp;nbsp;Reference name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;refname&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;/table&gt;'+
     '&lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;addcites()&quot;&gt;'+
 	' &lt;input type=&quot;button&quot; value=&quot;Preview citation&quot; onClick=&quot;previewCitationDefault()&quot;&gt; \
 	&lt;img id=&quot;progress&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/5/59/RefToolbar_spinning_throbber.gif&quot; style=&quot;visibility: hidden&quot; /&gt;'+
     '&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;verbose&quot; id=&quot;verbose&quot; value=&quot;verbose&quot;&gt;&lt;label for=&quot;verbose&quot;&gt;Vertical form&lt;/label&gt;'+
     '&lt;span style=&quot;float:right&quot;&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:'+template.replace(/ /g, '_')+'&quot; target=&quot;_blank&quot;&gt;[Template documentation]&lt;/a&gt;&lt;/span&gt;'+
     '&lt;/fieldset&gt;&lt;span id=&quot;previewSpan&quot;&gt;&lt;/span&gt;&lt;/div&gt;';
    document.getElementById('refToolFormArea').innerHTML = form;
 }
 
 function citeMap() {
   oldFormHide();
   var template = &quot;cite map&quot;;
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;Cite map&lt;/legend&gt;'+
     '&lt;table cellspacing=&quot;5&quot;&gt;'+
     '&lt;input type=&quot;hidden&quot; value=&quot;'+template+'&quot; id=&quot;template&quot;&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;publisher&quot;&gt;&amp;nbsp;Publisher: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;publisher&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;title&quot;&gt;&amp;nbsp;Title: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;title&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;url&quot;&gt;&amp;nbsp;URL: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;url&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;accessdate&quot;&gt;&amp;nbsp;Access date: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;accessdate&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;edition&quot;&gt;&amp;nbsp;Edition: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;edition&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;date&quot;&gt;&amp;nbsp;Date or year: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;date&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;cartography&quot;&gt;&amp;nbsp;Cartography: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;cartography&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;scale&quot;&gt;&amp;nbsp;Scale: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;scale&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;series&quot;&gt;&amp;nbsp;Series: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;series&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;page&quot;&gt;&amp;nbsp;Page: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;page&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;section&quot;&gt;&amp;nbsp;Section: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;section&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;inset&quot;&gt;&amp;nbsp;Inset: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;inset&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;tr&gt;&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;isbn&quot;&gt;&amp;nbsp;ISBN: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;isbn&quot;&gt;&lt;/td&gt;'+
     '&lt;td width=&quot;120&quot;&gt;&lt;label for=&quot;refname&quot;&gt;&amp;nbsp;Reference name: &lt;/label&gt;&lt;/td&gt;'+
       '&lt;td width=&quot;400&quot;&gt;&lt;input type=&quot;text&quot; tabindex=1 style=&quot;width:100%&quot; id=&quot;refname&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'+
     '&lt;/table&gt;'+
     '&lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;addcites()&quot;&gt;'+
 	' &lt;input type=&quot;button&quot; value=&quot;Preview citation&quot; onClick=&quot;previewCitationDefault()&quot;&gt; \
 	&lt;img id=&quot;progress&quot; src=&quot;//upload.wikimedia.org/wikipedia/commons/5/59/RefToolbar_spinning_throbber.gif&quot; style=&quot;visibility: hidden&quot; /&gt;'+
     '&lt;input type=&quot;checkbox&quot; tabindex=1 name=&quot;verbose&quot; id=&quot;verbose&quot; value=&quot;verbose&quot;&gt;&lt;label for=&quot;verbose&quot;&gt;Vertical form&lt;/label&gt;'+
     '&lt;span style=&quot;float:right&quot;&gt;&lt;a href=&quot;//en.wikipedia.org/wiki/Template:'+template.replace(/ /g, '_')+'&quot; target=&quot;_blank&quot;&gt;[Template documentation]&lt;/a&gt;&lt;/span&gt;'+
     '&lt;/fieldset&gt;&lt;span id=&quot;previewSpan&quot;&gt;&lt;/span&gt;&lt;/div&gt;';
    document.getElementById('refToolFormArea').innerHTML = form;
 }
 
 function showRefSectionOptions() {
   oldFormHide();
   var template = &quot;cite encyclopedia&quot;;
   numforms++;
   var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
     '&lt;fieldset&gt;&lt;legend&gt;Add references section&lt;/legend&gt;\
 	Headline:&lt;br /&gt;\
 	&lt;input id=&quot;references&quot; name=&quot;headline&quot; type=&quot;radio&quot; tabindex=1 checked=&quot;checked&quot;&gt;&lt;label for=&quot;references&quot;&gt;== References ==&lt;/label&gt;&lt;br /&gt; \
 	&lt;input id=&quot;notes&quot; name=&quot;headline&quot; type=&quot;radio&quot; tabindex=1&gt;&lt;label for=&quot;notes&quot;&gt;== Notes ==&lt;/label&gt;&lt;br /&gt; \
 	Type:&lt;br /&gt; \
 	&lt;input id=&quot;type-references&quot; name=&quot;type&quot; type=&quot;radio&quot; tabindex=1&gt;&lt;label for=&quot;type-references&quot;&gt;&amp;lt;references/&amp;gt;&lt;/label&gt;&lt;br /&gt; \
 	&lt;input id=&quot;type-reflist&quot; name=&quot;type&quot; type=&quot;radio&quot; tabindex=1 checked=&quot;checked&quot;&gt;&lt;label for=&quot;type-reflist&quot;&gt;\{\{Reflist}}&lt;/label&gt;&lt;br /&gt; \
 	&lt;input id=&quot;type-reflist2&quot; name=&quot;type&quot; type=&quot;radio&quot; tabindex=1&gt;&lt;label for=&quot;type-reflist2&quot;&gt;\{\{Reflist|2}}&lt;/label&gt;&lt;br /&gt; \
 	&lt;input type=&quot;checkbox&quot; tabindex=1 id=&quot;ldr&quot;&gt;&lt;label for=&quot;ldr&quot;&gt;List-defined references&lt;/label&gt; (&lt;a href=&quot;//en.wikipedia.org/wiki/Wikipedia:Footnotes#List-defined_references&quot; target=&quot;_blank&quot;&gt;Info 1&lt;/a&gt;, &lt;a href=&quot;//en.wikipedia.org/wiki/Help:Footnotes#List-defined_references&quot; target=&quot;_blank&quot;&gt;Info 2&lt;/a&gt;)&lt;br /&gt;\
     &lt;input type=&quot;button&quot; value=&quot;Add references section&quot; onClick=&quot;addRefSection()&quot;&gt;'+
  '&lt;/fieldset&gt;&lt;/div&gt;';
    document.getElementById('citeselect').innerHTML += form;
 }
 
 function makeCiteCode() {
   cites = document.getElementById('citediv'+numforms).getElementsByTagName('input');
   var template = '';
   var citebegin = '&lt;ref';
   var citename = '';
   var citeinner = '';
   for (var i=0; i&lt;cites.length; i++) {
     var citeid = cites[i].id;
     var citevalue = cites[i].value;
     citevalue = citevalue.trim();    //Trim leading and trailing whitespace
     if (citeid == &quot;verbose&quot;) {
 	  if (cites[i].checked) {
 	    citeinner = citeinner.replace(/\|/g, &quot;\n|&quot;);
 	  }
     }
     else if (citevalue !== '' &amp;&amp; cites[i].type !== 'button' &amp;&amp; cites[i].type !== 'image') {
       if (citeid === &quot;refname&quot;) {
         citebegin += ' name=&quot;' + citevalue + '&quot;';
       }
       else if (citeid == &quot;template&quot;) {
         citename = '&gt;\{\{' + citevalue;
         template = citevalue;
       }
       else {
         if (citeid === &quot;pages&quot;) {
           if (citevalue.match(/^\w+$/) &amp;&amp; template != 'cite encyclopedia') {
             citeid = &quot;page&quot;;    //Use page= instead of pages= if only one page. Makes p. 5 instead of pp. 5.
           }
           else {
             citevalue = citevalue.replace(/-/g, &quot;–&quot;);    //Replace hyphens with en dashes [[WP:ENDASH]]
           }
         }
         else if (citeid == &quot;date&quot; &amp;&amp; citevalue.match(/^\d\d\d\d$/)) {
           citeid = &quot;year&quot;;  // Use year= instead of date= if only the year is specified
         }
         citeinner += &quot;|&quot; + citeid + &quot;=&quot; + citevalue;
       }
     }
   }
   cite = citebegin + citename + citeinner + &quot;}}&lt;/ref&gt;&quot;;
   return cite;
 }
 
 function addcites(template) {
   var cite = makeCiteCode();
   $(&quot;#wpTextbox1&quot;).focus();
   insertTags(cite, '', '');
   //document.getElementById('citediv'+numforms).style.display = 'none';
   oldFormHide();
 }
 
 function addRefSection() {
 	var wikicode = &quot;\n&quot;;
 	if (document.getElementById('references').checked) {
 		wikicode += &quot;== References ==\n&quot;;
 	}
 	else if (document.getElementById('notes').checked) {
 		wikicode += &quot;== Notes ==\n&quot;;
 	}
 	else {alert('No headline selected!');}
 	
 	if (document.getElementById('type-references').checked) {
 		if (document.getElementById('ldr').checked) {
 			wikicode += &quot;&lt;references&gt;\n\n&lt;/references&gt;\n&quot;;
 		}
 		else {
 			wikicode += &quot;&lt;references/&gt;\n&quot;;
 		}
 	}
 	else if (document.getElementById('type-reflist').checked || document.getElementById('type-reflist2').checked) {
 		var col2 = document.getElementById('type-reflist2').checked ? '|2' : '' ;
 		if (document.getElementById('ldr').checked) {
 			wikicode += &quot;\{\{Reflist&quot; + col2 + &quot;|refs=\n\n}}\n&quot;;
 		}
 		else {
 			wikicode += &quot;\{\{Reflist&quot; + col2 + &quot;}}\n&quot;;
 		}
 	}
 	else {alert('No type selected!');}
 	$(&quot;#wpTextbox1&quot;).focus();
 	insertTags(wikicode, '', '');
 	document.getElementById('citediv'+numforms).innerHTML = '';
 }
 
 function getNamedRefs(calls) {
   if (typeof(wikEdUseWikEd) != 'undefined') {
     if (wikEdUseWikEd == true) {
       WikEdUpdateTextarea();
     }
   }
   text = document.getElementById('wpTextbox1').value;
   var regex;
   if (calls) {
     regex = /&lt; *?ref +?name *?= *?(('([^']*?)')|(&quot;([^&quot;]*?)&quot;)|([^'&quot;\s]*?[^\/]\b)) *?\/ *?&gt;/gi //'
   } else {
     regex = /&lt; *?ref +?name *?= *?(('([^']*?)')|(&quot;([^&quot;]*?)&quot;)|([^'&quot;\s]*?[^\/]\b)) *?&gt;/gi //'
   }
   var namedrefs = new Array();
   var i=0;
   var nr=true;
   do {
     ref = regex.exec(text);
     if(ref != null){
       if (ref[5]) {
         namedrefs[i] = ref[5];
       } else if (ref[3]) {
         namedrefs[i] = ref[3];
       } else {
         namedrefs[i] = ref[6];
       }
       i++;
     } else {
       nr=false;
     }
   } while (nr==true);
   return namedrefs;
 }
 
 function citeNamedRef() {
   var namedrefs = getNamedRefs(false);
   if (namedrefs == '') {
     oldFormHide();
     numforms++;
     var out = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;&lt;fieldset&gt;'+
       '&lt;legend&gt;References in text&lt;/legend&gt;There are no named refs (&lt;tt&gt;&amp;lt;ref name=&quot;Name&quot;&amp;gt;&lt;/tt&gt;) in the text&lt;/fieldset&gt;&lt;/div&gt;';
     document.getElementById('citeselect').innerHTML += out;
   }
   else {
     oldFormHide();
     numforms++;
     var form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
       '&lt;fieldset&gt;&lt;legend&gt;References in article&lt;/legend&gt;'+
       '&lt;table cellspacing=&quot;5&quot;&gt;'+
       '&lt;tr&gt;&lt;td&gt;&lt;label for=&quot;namedrefs&quot;&gt;&amp;nbsp;Named references in text&lt;/label&gt;&lt;/td&gt;'+
             '&lt;td&gt;&lt;select name=&quot;namedrefs&quot; id=&quot;namedrefs&quot;&gt;';
     for (var i=0;i&lt;namedrefs.length;i++) {
       form+= '&lt;option value=&quot;'+namedrefs[i]+'&quot;&gt;'+namedrefs[i]+'&lt;/option&gt;';
     }
     form+= '&lt;/select&gt;'+
       '&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'+
       '&lt;input type=&quot;button&quot; value=&quot;Add citation&quot; onClick=&quot;addnamedcite()&quot;&gt;'+
       '&lt;/fieldset&gt;&lt;/div&gt;';
      document.getElementById('citeselect').innerHTML += form;
   }
 }
 
 function addnamedcite() {
   var name = document.getElementById('citediv'+numforms).getElementsByTagName('select')[0].value;
   var ref = '&lt;ref name=&quot;'+name+'&quot; /&gt;';
   $(&quot;#wpTextbox1&quot;).focus();
   insertTags(ref, '', '');
   document.getElementById('citediv'+numforms).style.display = 'none';
 }
 
 function getAllRefs() {
   if (typeof(wikEdUseWikEd) != 'undefined') {
     if (wikEdUseWikEd == true) {
       WikEdUpdateTextarea();
     }
   }
   var text = document.getElementById('wpTextbox1').value;
   var regex = /&lt; *?ref( +?name *?= *?(('([^']*?)')|(&quot;([^&quot;]*?)&quot;)|([^'&quot;\s]*?[^\/]\b)))? *?&gt;((.|\n)*?)&lt; *?\/? *?ref *?&gt;/gim //&quot;
   var allrefs = new Array();
   var i=0;
   var nr=true;
   do {
     ref = regex.exec(text);
     if(ref != null){
       if (ref[0].search(/[^\s]{150}/) != -1) {
         ref[0] = ref[0].replace(/\|([^\s])/g, &quot;| $1&quot;);
       }
       ref[0] = ref[0].replace(/&lt;/g, &quot;&amp;lt;&quot;);
       ref[0] = ref[0].replace(/&gt;/g, &quot;&amp;gt;&quot;);
       allrefs[i] = ref[0];
       i++;
     } else {
       nr=false;
     }
   } while (nr==true);
   return allrefs;
 }
 
 function NRcallError(namedrefs, refname) {
   for (var i=0; i&lt;namedrefs.length; i++) {
     if (namedrefs[i] == refname) {
       return true;
     }
   }
   return false;
 }
 
 function errorCheck() {
   var allrefs = getAllRefs();
   var allrefscontent = new Array();
   var samecontentexclude = new Array();
   var sx=0;
   var templateexclude = new Array();
   var tx=0;
   var skipcheck = false;
   var namedrefcalls = getNamedRefs(true);
   for (var i=0; i&lt;allrefs.length; i++) {
     allrefscontent[i] = allrefs[i].replace(/&amp;lt; *?ref( +?name *?= *?(('([^']*?)')|(&quot;([^&quot;]*?)&quot;)|([^'&quot;\s]*?[^\/]\b)))? *?&amp;gt;((.|\n)*?)&amp;lt; *?\/? *?ref *?&amp;gt;/gim, &quot;$8&quot;);  //&quot;
   }
   var namedrefs = getNamedRefs(false);
   var errorlist = new Array();
   var q=0;
   var unclosed = document.getElementById('unclosed').checked;
   var samecontent = document.getElementById('samecontent').checked;
   var templates = document.getElementById('templates').checked;
   var repeated = document.getElementById('repeated').checked;
   var undef = document.getElementById('undef').checked;
   for (var i=0; i&lt;allrefs.length; i++) {
     if (allrefs[i].search(/&amp;lt; *?\/ *?ref *?&amp;gt;/) == -1 &amp;&amp; unclosed) {
       errorlist[q] = '&lt;tr&gt;&lt;td width=&quot;75%&quot;&gt;&lt;tt&gt;'+allrefs[i]+'&lt;/tt&gt;&lt;/td&gt;';
       errorlist[q] += '&lt;td width=&quot;25%&quot;&gt;Unclosed &lt;tt&gt;&amp;lt;ref&amp;gt;&lt;/tt&gt; tag&lt;/td&gt;&lt;/tr&gt;';
       q++;
     }
     if (samecontent) {
       for (var d=0; d&lt;samecontentexclude.length; d++) {
         if (allrefscontent[i] == samecontentexclude[d]) {
           skipcheck = true;
         }
       }
       var p=0;
       while (p&lt;allrefs.length &amp;&amp; !skipcheck) {
         if (allrefscontent[i] == allrefscontent[p] &amp;&amp; i != p) {
           errorlist[q] = '&lt;tr&gt;&lt;td width=&quot;75%&quot;&gt;&lt;tt&gt;'+allrefscontent[i]+'&lt;/tt&gt;&lt;/td&gt;';
           errorlist[q] += '&lt;td width=&quot;25%&quot;&gt;Multiple refs contain this content, a &lt;a href=&quot;//en.wikipedia.org/wiki/Wikipedia:Footnotes#Naming_a_ref_tag_so_it_can_be_used_more_than_once&quot;&gt;named reference&lt;/a&gt; should be used instead&lt;/td&gt;&lt;/tr&gt;';
           q++;
           samecontentexclude[sx] = allrefscontent[i]
           sx++;
           break;
         }
         p++;
       }
      skipcheck=false;
     }
     if (templates) {
       if (allrefscontent[i].search(/\{\{cite/i) == -1 &amp;&amp; allrefscontent[i].search(/\{\{citation/i) == -1 &amp;&amp; allrefscontent[i].search(/\{\{Comic (book|strip) reference/i) == -1 &amp;&amp; allrefscontent[i].search(/\{\{Editorial cartoon reference/i) == -1 &amp;&amp; allrefscontent[i].search(/\{\{harv/i) == -1) {
         for (var x=0; x&lt;templateexclude.length; x++) {
           if (allrefscontent[i] == templateexclude[x]) {
             skipcheck = true;
           }
         }
         if (!skipcheck) {
           errorlist[q] = '&lt;tr&gt;&lt;td width=&quot;75%&quot;&gt;&lt;tt&gt;'+allrefs[i]+'&lt;/tt&gt;&lt;/td&gt;';
           errorlist[q] += '&lt;td width=&quot;25%&quot;&gt;Does not use a &lt;a href=&quot;//en.wikipedia.org/wiki/Wikipedia:Citation_templates&quot;&gt;citation template&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;';
           q++;
           templateexclude[tx] = allrefscontent[i];
           tx++;
         }
         skipcheck = false;
       }
     }
   }
   if (repeated) {
     var repeatnameexclude = new Array();
     var rx=0;
     for (var k=0; k&lt;namedrefs.length; k++) {
       for (var d=0; d&lt;repeatnameexclude.length; d++) {
         if (namedrefs[k] == repeatnameexclude[d]) {
           skipcheck = true;
         }
       }
       var z=0;
       while (z&lt;namedrefs.length &amp;&amp; !skipcheck) {
         if (namedrefs[k] == namedrefs[z] &amp;&amp; k != z) {
           errorlist[q] = '&lt;tr&gt;&lt;td width=&quot;75%&quot;&gt;&lt;tt&gt;'+namedrefs[k]+'&lt;/tt&gt;&lt;/td&gt;';
           errorlist[q] += '&lt;td width=&quot;25%&quot;&gt;Multiple references are given the same &lt;a href=&quot;//en.wikipedia.org/wiki/Wikipedia:Footnotes#Naming_a_ref_tag_so_it_can_be_used_more_than_once&quot;&gt;name&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;';
           q++;
           repeatnameexclude[rx] = namedrefs[z];
           rx++;
           break;
         }
         z++;
       }
      skipcheck = false;
     }
   }
   if (undef) {
     var undefexclude = new Array();
     var ux=0;
     for (var p=0; p&lt;namedrefcalls.length; p++) {
       for (var d=0; d&lt;undefexclude.length; d++) {
         if (allrefscontent[i] == undefexclude[d]) {
           skipcheck = true;
         }
       }
       if (!skipcheck) {
         if (!NRcallError(namedrefs, namedrefcalls[p])) {
           errorlist[q] = '&lt;tr&gt;&lt;td width=&quot;75%&quot;&gt;&lt;tt&gt;'+namedrefcalls[p]+'&lt;/tt&gt;&lt;/td&gt;';
           errorlist[q] += '&lt;td width=&quot;25%&quot;&gt;A &lt;a href=&quot;//en.wikipedia.org/wiki/Wikipedia:Footnotes#Naming_a_ref_tag_so_it_can_be_used_more_than_once&quot;&gt;named reference&lt;/a&gt; is used but not defined&lt;/td&gt;&lt;/tr&gt;';
           q++;
           undefexclude[ux] = namedrefs[p];
           ux++;
         }
       }
       skipcheck = false;
     }
  }
   if (q &gt; 0) {
     return errorlist;
   } else {
     return 0;
   }
 }
 
 function dispErrors() {
   oldFormHide();
   var form = '&lt;div id=&quot;errorform&quot;&gt;&lt;fieldset&gt;'+
     '&lt;legend&gt;Error checking&lt;/legend&gt;'+
     '&lt;b&gt;Check for:&lt;/b&gt;&lt;br/&gt;'+
     '&lt;input type=&quot;checkbox&quot; id=&quot;unclosed&quot; /&gt; Unclosed &lt;tt&gt;&amp;lt;ref&amp;gt;&lt;/tt&gt; tags&lt;br/&gt;'+
     '&lt;input type=&quot;checkbox&quot; id=&quot;samecontent&quot; /&gt; References with the same content&lt;br/&gt;'+
     '&lt;input type=&quot;checkbox&quot; id=&quot;templates&quot; /&gt; References not using a &lt;a href=&quot;//en.wikipedia.org/wiki/Wikipedia:Citation_templates&quot;&gt;citation template&lt;/a&gt;&lt;br/&gt;'+
     '&lt;input type=&quot;checkbox&quot; id=&quot;repeated&quot; /&gt; Multiple references with the same name&lt;br/&gt;'+
     '&lt;input type=&quot;checkbox&quot; id=&quot;undef&quot; /&gt; Usage of undefined named references&lt;br/&gt;'+
     '&lt;input type=&quot;button&quot; id=&quot;errorchecksubmit&quot; value=&quot;Check for selected errors&quot; onclick=&quot;doErrorCheck()&quot;/&gt;'+
     '&lt;/fieldset&gt;&lt;/div&gt;';
   document.getElementById('citeselect').innerHTML += form;
 }
 
 function doErrorCheck() {
   var errors = errorCheck();
   document.getElementById('citeselect').removeChild(document.getElementById('errorform'));
   if (errors == 0) {
     if (numforms != 0) {
       document.getElementById('citediv'+numforms).style.display = 'none';
     }
     numforms++;
     out = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;&lt;fieldset&gt;'+
       '&lt;legend&gt;Error checking&lt;/legend&gt;No errors found.&lt;/fieldset&gt;&lt;/div&gt;';
     document.getElementById('citeselect').innerHTML += out;
   }
   else {
     if (numforms != 0) {
       document.getElementById('citediv'+numforms).style.display = 'none';
     }
     numforms++;
     form = '&lt;div id=&quot;citediv'+numforms+'&quot;&gt;'+
       '&lt;fieldset&gt;&lt;legend&gt;Error checking&lt;/legend&gt;'+
       '&lt;table border=&quot;1px&quot;&gt;';
     for (var i=0; i&lt;errors.length; i++) {
       form+=errors[i];
     }
     form+= '&lt;/table&gt;'+
       '&lt;/fieldset&gt;&lt;/div&gt;';
      document.getElementById('citeselect').innerHTML += form;
   }
 }
 
 function makeBookCitationCode(callback) {
   var cite = '&lt;ref';
   var refname = document.getElementById('refname').value;
   if (/\S/.test(refname)) {
     cite += ' name=&quot;' + refname + '&quot;';
   }
   cite += '&gt;\{\{';
   
   if (document.getElementById('cite_book').checked || document.getElementById('plain').checked) {
     cite += 'cite book';
   }
   else if (document.getElementById('citation').checked) {
     cite += 'citation';
   }
   else {alert('No template selected.');}
   
   var authorcite = '';
   var prevauthor = 0;
   for (var i=3;i&gt;=1;i--) {
     //var author = document.getElementById('author' + i).value;
     var last = document.getElementById('last' + i).value;
     var first = document.getElementById('first' + i).value;
     var authorlink = document.getElementById('authorlink' + i).value;
     if (i==1 &amp;&amp; !prevauthor) { i = ''; }
     if (/\S/.test(authorlink)) {
       authorcite = '|authorlink' + i + '=' + authorlink + authorcite;
     }
     if (/\S/.test(last)) {
       authorcite = '|last' + i + '=' + last + '|first' + i + '=' + first + authorcite;
       prevauthor = 1;
     }
     /*else if (/\S/.test(author)) {
       authorcite = '|author' + i + '=' + author + authorcite;
       prevauthor = 1;
     }*/
   }
   cite += authorcite;
 
   var simplefields = [&quot;coauthors&quot;, &quot;editor&quot;, &quot;others&quot;, &quot;title&quot;, &quot;url&quot;, &quot;accessdate&quot;,&quot;edition&quot;,&quot;series&quot;,&quot;volume&quot;,&quot;date&quot;,&quot;publisher&quot;,&quot;location&quot;,&quot;language&quot;,&quot;isbn&quot;,&quot;pages&quot;,&quot;chapter&quot;];
   for (var i=0;i&lt;simplefields.length;i++) {
     var fieldname = simplefields[i];
     var value = document.getElementById(fieldname).value;
     if (/\S/.test(value) || fieldname == &quot;title&quot;) {
       if (fieldname == &quot;pages&quot;) {
         if (/^\w+$/.test(value)) {
           fieldname = &quot;page&quot;;    //Use page= instead of pages= if only one page. Makes p. 5 instead of pp. 5.
         }
         else {
           value = value.replace(/-/g, &quot;–&quot;);      //Replace hyphens with en dashes [[WP:ENDASH]]
           value = value.replace(/,\s*\s?/g, &quot;, &quot;);  //One space after each comma
         }
       }
       else if (fieldname == &quot;date&quot; &amp;&amp; /^\d\d\d\d$/.test(value)) {
         fieldname = &quot;year&quot;;  // Use year= instead of date= if only the year is specified
       }
       cite += '|' + fieldname + '=' + value;
     }
   }
  
 
   var otherfields = document.getElementById('otherfields').value;
   if (/\S/.test(otherfields)) {
     cite += '|' + otherfields;
   }
   
   if (document.getElementById('extraparams').checked) {
     cite += '|authormask=';
     if (!document.getElementById('citation').checked) {
       cite += '|trans_title=';
     }
     cite += '|format=';
     cite += '|origyear=';
     cite += '|oclc=';
     cite += '|doi=';
     cite += '|bibcode=';
     cite += '|id=';
     if (/\S/.test(document.getElementById('chapter').value)) {
       if (!document.getElementById('citation').checked) {
         cite += '|trans_chapter=';
       } 
       cite += '|chapterurl=';
     }
     cite += '|quote=';
     cite += '|laysummary=';
     cite += '|laydate=';
   }
 
   cite += &quot;}}&lt;/ref&gt;&quot;;
   
   
   if (document.getElementById('plain').checked) {
     var match = /^(.*?)(\{\{.*}})(.*?)$/.exec(cite);
     if (match) {
       var citebeg = match[1];
       var citemid = match[2];
       var citeend = match[3];
       citemid = citemid.replace(/cite book/, &quot;Vancite book&quot;);
       //alert(citebeg + ':::' + citemid + ':::' + citeend);
       //document.getElementById('fullcite').value = 'Updating...';
       var url = 'api.php?action=expandtemplates&amp;format=xml&amp;text=' + encodeURIComponent(citemid);
       document.getElementById('progress').style.visibility = &quot;visible&quot;;
       var xmlhttpExpand = new XMLHttpRequest();
       xmlhttpExpand.onreadystatechange=function() {
 		if(xmlhttpExpand.readyState==4) {	  
 			if(xmlhttpExpand.status==200) {
 				document.getElementById('progress').style.visibility = &quot;hidden&quot;;
 				var xmlDoc=xmlhttpExpand.responseXML.documentElement;
 				var expanded = xmlDoc.getElementsByTagName(&quot;expandtemplates&quot;)[0].textContent;
 				if (expanded == undefined) {
 					expanded = xmlDoc.getElementsByTagName(&quot;expandtemplates&quot;)[0].childNodes[0].nodeValue;
 				}
 				expanded = expanded.replace(/&lt;span.*?&gt;/ig, '');
 				expanded = expanded.replace(/&lt;\/span&gt;/ig, '');
 				expanded = expanded.replace(/&lt;nowiki\/?&gt;/ig, '');
 				expanded = expanded.replace(/\&amp;\#32\;/ig, ' ');
 				expanded = expanded.replace(/\&amp;\#59\;/ig, ';');
 				expanded = expanded.replace(/\&amp;\#91\;/ig, '[');
 				expanded = expanded.replace(/\&amp;\#93\;/ig, ']');
 				
 				plaincite = citebeg + expanded + citeend;
 				//alert(plaincite);
 				callback(plaincite);
 			}
 			else
 				alert('The query returned an error.');
 		}
       }
       xmlhttpExpand.open(&quot;GET&quot;,url,true);
       xmlhttpExpand.send(null);
     }
     else {alert('Error A1');}
   }
   else {
     if (document.getElementById('verbose').checked) {
       cite = cite.replace(/\|/g, &quot;\n|&quot;);
     }
     callback(cite);
   }
 }
 
 function makeCiteBook() {
   makeBookCitationCode(function(cite) { 
     $(&quot;#wpTextbox1&quot;).focus();
     insertTags(cite, '', ''); 
     if (!refToolDebug) { oldFormHide(); }
   });
 }
 
 function formatDate(datein, dateformat) {
   if (dateformat == '') {return (datein);}
   datein = datein.replace(/^\s*(.*?)\s*$/, &quot;$1&quot;);  //Trim whitespace
   var year = -1;
   var month = -1;
   var date = -1;
   var match = /^(\d\d\d\d)-(\d\d?)(-(\d\d?))?$/.exec(datein);
   if(match) {
     //alert(' match[1]=' + match[1] + ' match[2]=#' + match[2] + '# match[3]=' + match[3] + ' match[4]=' + match[4]  );
     year = parseInt(match[1], 10);	//10 forces decimal conversion
     month = parseInt(match[2], 10);
     if (match[4]) {
       date = parseInt(match[4], 10);
     }
   }
   else if (/^\d\d? \w+ \d\d\d\d$/.test(datein) || /^\w+ \d\d?, \d\d\d\d$/.test(datein)) {
     var DT = new Date(datein);
     year = DT.getUTCFullYear();
     month = DT.getUTCMonth()+1;
     date = DT.getUTCDate()+1;
   }
   else if (datein == 'today') {
     var DT = new Date();
     year = DT.getUTCFullYear();
     month = DT.getUTCMonth()+1;
     date = DT.getUTCDate();
   }
   else {return (datein);}
   //alert('datein=' + datein + ', y=' + year + ', m=' + month + ', d=' + date);
 
   var zmonth = '';
   if (month &lt; 10) {
     zmonth = &quot;0&quot;+month.toString();
   } else {
     zmonth = month.toString();
   }
   month = month.toString();
   var zdate = '';
   if (date &gt; -1) {
     if (date &lt; 10) {
       zdate = &quot;0&quot;+date.toString();
     } else {
       zdate = date.toString();
     }
     date = date.toString()
   }
   else { date = ''; }
   
   var datestr = dateformat;
   datestr = datestr.replace('&lt;date&gt;', date);
   datestr = datestr.replace('&lt;month&gt;', month);
   datestr = datestr.replace('&lt;zdate&gt;', zdate);
   datestr = datestr.replace('&lt;zmonth&gt;', zmonth);
   datestr = datestr.replace('&lt;monthname&gt;', months[month-1]);
   datestr = datestr.replace('&lt;year&gt;', year.toString());
   datestr = datestr.replace(/\s+/, ' ').replace(/^\s+/, '').replace(/(\D),/, '$1').replace(/-$/, '');
   return (datestr);
 }
 
 
 function getDateFormat() {
 	var dateformat = '';
 	if (document.getElementById('dmy')){
 		if (document.getElementById('dmy').checked) {dateformat = '&lt;date&gt; &lt;monthname&gt; &lt;year&gt;'}
 		else if (document.getElementById('mdy').checked) {dateformat = '&lt;monthname&gt; &lt;date&gt;, &lt;year&gt;'}
 		else if (document.getElementById('ymd').checked) {dateformat = '&lt;year&gt;-&lt;zmonth&gt;-&lt;zdate&gt;'}
 	}
 	else if (citeUserDateFormat) {
 		dateformat = citeUserDateFormat;
 	} else {
 		dateformat = citeGlobalDateFormat;
 	}
 	return (dateformat);
 }
 
 function reformatDates() {
   var dateformat = getDateFormat();
   //alert(':' + dateformat + ':');
   document.getElementById('accessdate').value = formatDate(document.getElementById('accessdate').value, dateformat);
   document.getElementById('date').value = formatDate(document.getElementById('date').value, dateformat);
   //document.getElementById('dateformat_hidden').value = getDateFormatShort();
 }
 
 /*function updateGetButton() {
 	document.getElementById('urlget').disabled = document.getElementById('url').value == '';
 }*/
 
 function preview(wikitext) {
     document.getElementById('progress').style.visibility = &quot;visible&quot;;
     wikitext += '&lt;references /&gt;';
     var url = &quot;api.php?action=parse&amp;format=xml&amp;prop=text&amp;text=&quot; + encodeURIComponent(wikitext);
     var xmlhttp = new XMLHttpRequest();
 	xmlhttp.onreadystatechange = function () {
 		if (xmlhttp.readyState==4) {
 			if(xmlhttp.status==200) {
 				document.getElementById('progress').style.visibility = &quot;hidden&quot;;
 				var xmlDoc=xmlhttp.responseXML.documentElement;
 				var previewHTML = xmlDoc.getElementsByTagName(&quot;text&quot;)[0].textContent;
 				if (previewHTML == undefined) {
 					previewHTML = xmlDoc.getElementsByTagName(&quot;text&quot;)[0].childNodes[0].nodeValue;
 				}
 				//alert(previewHTML);
 				previewHTML = previewHTML.replace(/href=&quot;\//gi, 'href=&quot;//en.wikipedia.org/');
 				document.getElementById('previewSpan').innerHTML = '&lt;fieldset&gt;&lt;legend&gt;Citation preview&lt;/legend&gt;' + previewHTML + '&lt;/fieldset&gt;';
 			}
 			else
 				alert('The query returned an error.');
 		}
     };
     xmlhttp.open(&quot;GET&quot;, url, true);
     xmlhttp.send(null)
 }
 
 function previewCitationBook() {
   makeBookCitationCode(preview);
 }
 
 function previewCitationDefault() {
 	var wikitext = makeCiteCode();
 	preview(wikitext);
 }
 
 function pullJs() {
 	var book_url = document.getElementById('url').value;
    	if (book_url) {
 		document.getElementById('progress').style.visibility = &quot;visible&quot;;
 		var book_url_enc = encodeURIComponent(book_url);
 		if(!refTagURL) {refTagURL = defaultRefTagURL;}
 		var baseurl = refTagURL + 'googlebooksjs.py';
 		var url = baseurl + '?book_url=' + book_url_enc + '&amp;callback=setFormValues';
 		/*var script = document.createElement(&quot;script&quot;);        
 		script.setAttribute(&quot;src&quot;,url);
 		script.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);                
 		document.body.appendChild(script);*/
 		JsonRequest(url);
 	}else{
 		alert('No URL.');
 	}
 }
 
 function pullISBN() {
 	var isbn = document.getElementById('isbn').value;
 	isbn = isbn.replace(/[^0-9]/g,&quot;&quot;);	//Digits only
    	if (isbn) {
 		document.getElementById('progress').style.visibility = &quot;visible&quot;;
 		if(!refTagURL) {refTagURL = defaultRefTagURL;}
 		var baseurl = refTagURL + 'getdiberri.py';
 		var url = baseurl + '?isbn=' + isbn + '&amp;callback=useDiberriData';
 		/*var script = document.createElement(&quot;script&quot;);
 		script.setAttribute(&quot;src&quot;,url);
 		script.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);
 		document.body.appendChild(script);*/
 		JsonRequest(url);
 	}else{
 		alert('No ISBN.');
 	}
 }
 
 function pullDOI() {
 	var doi = document.getElementById('doi').value;
    	if (doi) {
 		document.getElementById('progress').style.visibility = &quot;visible&quot;;
 		if(!refTagURL) {refTagURL = defaultRefTagURL;}
 		var baseurl = refTagURL + 'doifetchjs.py';
 		var url = baseurl + '?doi=' + encodeURIComponent(doi) + '&amp;callback=useDoiData';
 		JsonRequest(url);
 	}else{
 		alert('No DOI.');
 	}
 }
 
 function pullPMID() {
 	alert('Not implemented yet...');
 	/*var doi = document.getElementById('doi').value;
    	if (doi) {
 		document.getElementById('progress').style.visibility = &quot;visible&quot;;
 		if(!refTagURL) {refTagURL = defaultRefTagURL;}
 		var baseurl = refTagURL + 'doifetchjs.py';
 		var url = baseurl + '?doi=' + encodeURIComponent(doi) + '&amp;callback=useDoiData';
 		JsonRequest(url);
 	}else{
 		alert('No DOI.');
 	}*/
 }
 
 function pullURL() {
 	var url = document.getElementById('url').value;
    	if (url) {
 		document.getElementById('progress').style.visibility = &quot;visible&quot;;
 		if(!refTagURL) {refTagURL = defaultRefTagURL;}
 		var baseurl = refTagURL + 'urlfetchjs.py';
 		var url = baseurl + '?url=' + encodeURIComponent(url) + '&amp;callback=useUrlData';
 		JsonRequest(url);
 	}else{
 		alert('No URl.');
 	}
 }
 
 function JsonRequest(url) {
 	//mw.loader.load(url)  //Bad: does not import the same script more than once
 	var script = document.createElement(&quot;script&quot;);        
 	script.setAttribute(&quot;src&quot;,url);
 	script.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);                
 	//document.body.appendChild(script);
 	document.getElementsByTagName('head')[0].appendChild(script);
 }
 
 function setFormValues(bookdata) {
 	document.getElementById('progress').style.visibility = &quot;hidden&quot;;
 	//alert(bookdata);
 	//alert(bookdata.page);
 	if (bookdata.title.length != 0) { document.getElementById('title').value = bookdata.title; }
 	if (bookdata.isbn.length != 0) { document.getElementById('isbn').value = bookdata.isbn; }
 	if (bookdata.publisher.length != 0) { document.getElementById('publisher').value = bookdata.publisher; }
 	if (bookdata.pages.length != 0) { 
 		document.getElementById('pages').value = bookdata.pages; 
 		document.getElementById('pages').style.backgroundColor = '#FFFF99';
 	}
 	if (bookdata.url.length != 0) { document.getElementById('url').value = bookdata.url; }
 	if (bookdata.date.length != 0) { document.getElementById('date').value = bookdata.date; }
 
 	for (var i=0;i&lt;bookdata.authors.length &amp;&amp; i&lt;=2;i++) {
 		authorn = i+1;
   		var author = bookdata.authors[i];
   		var match = /(.+)\s+(.+)/.exec(author);
 		if (match) {
 			document.getElementById('first' + authorn).value = match[1];
 			document.getElementById('last' + authorn).value = match[2];
 		}
 		else {
 			document.getElementById('last' + authorn).value = author;
 		}
   	}
 	document.getElementById('coauthors').value = bookdata.authors.splice(3).join(', ')
 	setAccessDateToday()
 	makeRefname()
 }
 
 function useDiberriData(bookdata) {
 	document.getElementById('progress').style.visibility = &quot;hidden&quot;;
 	if (bookdata.title.length != 0) { document.getElementById('title').value = bookdata.title; }
 	if (bookdata.isbn.length != 0) { document.getElementById('isbn').value = bookdata.isbn; }
 	if (bookdata.publisher.length != 0) { document.getElementById('publisher').value = bookdata.publisher; }
 	if (bookdata.location.length != 0) { document.getElementById('location').value = bookdata.location; }
 	if (bookdata.year.length != 0) { document.getElementById('date').value = bookdata.year; }
 	if (bookdata.authors.length != 0) {
 		authors = bookdata.authors.split(';', 4);
 		for (var i=0;i&lt;authors.length &amp;&amp; i&lt;=2;i++) {
 			authorn = i+1;
 	  		nameparts = authors[i].split(',', 2);
 			document.getElementById('last' + authorn).value = nameparts[0].trim();
 			if (nameparts.length == 2) {
 				document.getElementById('first' + authorn).value = nameparts[1].trim();
 			}
 		}
 		if (authors[3]) { document.getElementById('coauthors').value = authors[3].trim(); }
 	}
 	makeRefname()	
 }
 
 function useDoiData(bookdata) {
 	document.getElementById('progress').style.visibility = &quot;hidden&quot;;
 	if (bookdata.title) { document.getElementById('title').value = bookdata.title; }
 	//if (bookdata.isbn.length != 0) { document.getElementById('isbn').value = bookdata.isbn; }
 	//if (bookdata.publisher.length != 0) { document.getElementById('publisher').value = bookdata.publisher; }
 	//if (bookdata.location.length != 0) { document.getElementById('location').value = bookdata.location; }
 	if (bookdata.year) { document.getElementById('date').value = bookdata.year; }
 	if (bookdata.issn) { document.getElementById('issn').value = bookdata.issn; }
 	if (bookdata.journal) { document.getElementById('journal').value = bookdata.journal; }
 	if (bookdata.volume) { document.getElementById('volume').value = bookdata.volume; }
 	if (bookdata.issue) { document.getElementById('issue').value = bookdata.issue; }
 	if (bookdata.pages) { document.getElementById('pages').value = bookdata.pages; }
 
 	if (bookdata.authors) {
 		var coauthors = [];
 		for (var i=0;i&lt;bookdata.authors.length;i++) {
 			var authorn = i+1;
 			var author = bookdata.authors[i];
 			if (authorn == 1) {
 				if (author.last) { document.getElementById('last').value = author.last.trim(); }
 				if (author.first) { document.getElementById('first').value = author.first.trim(); }
 			}
 			else {
 				var authorparts = [];
 				if (author.first) { authorparts.push( author.first.trim() ); }
 				if (author.last) { authorparts.push( author.last.trim() ); }
 				coauthors.push(authorparts.join(' '));
 			}
 		}
 		if (coauthors[0]) { document.getElementById('coauthors').value = coauthors.join(', '); }
 	}
 	makeRefname();
 }
 
 function useUrlData(data) {
 	document.getElementById('progress').style.visibility = &quot;hidden&quot;;
 	if (data.title) { document.getElementById('title').value = data.title; }
 	if (data.work) { document.getElementById('work').value = data.work; }
 	if (data.page) { document.getElementById('pages').value = data.page; }
 	if (data.date) {
 		document.getElementById('date').value = formatDate(data.date, getDateFormat());
 	}
 	/*if (data.author) {
 		var authors = data.author.replace(/ [Aa]nd /, ', ');
 		var match = /(.+),\s*(.+)/.exec(authors);
 		var firstauthor = '';
 		if (match) {
 			firstauthor = match[1];
 			var coauthors = match[2];
 			document.getElementById('coauthors').value = coauthors;
 		}
 		else {
 			firstauthor = data.author;
 		}
 		var match = /(.+)\s+(.+)/.exec(firstauthor);
 		if (match) {
 			document.getElementById('first').value = match[1];
 			document.getElementById('last').value = match[2];
 		}
 		else {
 			document.getElementById('last').value = author;
 		}
 	}*/
 	if (data.authors) {
 		var coauthors = [];
 		for (var i=0;i&lt;data.authors.length;i++) {
 			var authorn = i+1;
 			var author = data.authors[i];
 			if (authorn == 1) {
 				var match = /(.+)\s+(.+)/.exec(author);
 				if (match) {
 					document.getElementById('first').value = match[1].trim();
 					document.getElementById('last').value = match[2].trim();
 				}
 				else {
 					document.getElementById('last').value = author.trim();
 				}
 			}
 			else {
 				coauthors.push(author);
 			}
 		}
 		if (coauthors[0]) { document.getElementById('coauthors').value = coauthors.join(', '); }
 	}
 }