var numforms = 0; var wikEdAutoUpdateUrl; var citeUserDateFormat; var refTagURL; var defaultRefTagURL = 'http://reftag.appspot.com/'; var refToolDebug;  //Variable declaration var option1="ওয়েব উদ্ধৃত করুন "; var option2="খবর উদ্ধৃত করুন"; var option3="বই উদ্ধৃত করুন"; var option4="জার্নাল উদ্ধৃত করুন"; var option5="cite encyclopedia"; var option6="cite press release";  String.prototype.trim = function() { 	return this.replace(/^\s+|\s+$/g,""); }  function refbuttons() {   if (mwCustomEditButtons && document.getElementById('toolbar') ) {     var button = document.createElement('a');     button.href = "javascript:easyCiteMain()";     button.title = "Insert Citation";     var buttonimage = document.createElement('img');     buttonimage.src = "//upload.wikimedia.org/wikipedia/commons/e/ea/Button_easy_cite.png";     buttonimage.alt = "Insert Citation";     button.appendChild(buttonimage);     var toolbar = document.getElementById('toolbar');     if (navigator.userAgent.indexOf('MSIE') == -1) {       if (toolbar.style != null) {         toolbar.style.height = 'auto';       }       else {       	toolbar.setAttribute('style', 'margin-bottom: 6px; height: auto;');       }       toolbar.appendChild(button);       var citemain = document.createElement('div');       citemain.style.display = 'none';       citemain.style.margin = '0.2em 0 -0.2em 0';       citemain.setAttribute('Id', 'citeselect');       citemain.appendChild( addOption("citeWeb()", option1) );       citemain.appendChild( addOption("citeNews()", option2) );       citemain.appendChild( addOption("citeBook()", option3) );       citemain.appendChild( addOption("citeJournal()", option4) );       citemain.appendChild( addOption("citeNamedRef()", "Named references") );       citemain.appendChild( addOption("dispErrors()", "Error check") );       citemain.appendChild( addOption("showMore()", "More") );       citemain.appendChild( addOption("hideInitial()", "Cancel") );              var citemore = document.createElement('div');       citemore.style.display = 'none';       citemore.setAttribute('Id', 'citemore');       citemore.appendChild( addOption("citeEncyclopedia()", "Encyclopedia") );       citemore.appendChild( addOption("citePressRelease()", "Press release") );       citemore.appendChild( addOption("citeMap()", "Map") );       citemore.appendChild( addOption("showRefSectionOptions()", "Ref Section") );       citemain.appendChild(citemore);              toolbar.appendChild(citemain);     }     else {       toolbar.appendChild(button);       var citeselect = document.createElement('div');       citeselect.style.display = "none";       citeselect.innerHTML = ''+       ''+       ''+       ''+       ''+       ''+       ''+       ''+       '\       \       \       \       \       ';       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 == "object") {     var placeholder = document.getElementById("editpage-specialchars");     EditTools.createEditTools (placeholder);   } }  function addOption(script, text) {   var option = document.createElement('input');   option.setAttribute('type', 'button');   option.setAttribute('onclick', script);   option.setAttribute("value", 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 = "<date> <monthname> <year>"; function getTime() {   var datestr = ;   if (citeUserDateFormat) {     datestr = citeUserDateFormat;   } else {     datestr = citeGlobalDateFormat;   }   var DT = new Date();   var zmonth = ;   var month = DT.getUTCMonth()+1;   if (month < 10) {     zmonth = "0"+month.toString();   } else {     zmonth = month.toString();   }   month = month.toString();   var zdate = ;   var date = DT.getUTCDate()   if (date < 10) {     zdate = "0"+date.toString();   } else {     zdate = date.toString();   }   date = date.toString()   datestr = datestr.replace('<date>', date);   datestr = datestr.replace('<month>', month);   datestr = datestr.replace('<zdate>', zdate);   datestr = datestr.replace('<zmonth>', zmonth);   datestr = datestr.replace('<monthname>', months[DT.getUTCMonth()]);   datestr = datestr.replace('<year>', 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<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*$/, "$1");       return;     }   } }  function setAccessDateToday() {   document.getElementById('accessdate').value = getTime(); /*  var fields = document.getElementById('citediv'+numforms).getElementsByTagName('input');   for (var i=0; i<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() {   if (document.getElementById('last1')) {     var refname = document.getElementById('last1').value + document.getElementById('last2').value;   }   else{ 	var 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(option1); } function citeNews() {   citeNewsWeb(option2); }  function citeNewsWeb(templatename) {   oldFormHide();   var template = templatename;   var legend;   if (template == option1) {     legend = "Cite web source";   } else {     legend = "Cite news source";   }   var newtime = getTime();   numforms++;   var form = ''+     ''+legend+''+     ''+     '<input type="hidden" value="'+template+'" id="template">'+     ' URL: '+       '<input type="image" src="//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png" tabindex=1 alt="Fetch" title="' + ((template == option2) ? '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.') + '" onClick="pullURL(); return false;" style="float:right"><input type="text" tabindex=1 style="width:97%" id="url">'+     ' Title: '+       '<input type="text" tabindex=1 style="width:100%" id="title">'+     ' Last name: '+       '<input type="text" tabindex=1 style="width:100%" id="last">'+     ' First name: '+       '<input type="text" tabindex=1 style="width:100%" id="first">'+     ' Coauthors: '+       '<input type="text" tabindex=1 style="width:100%" id="coauthors">'+     ' Publication date: '+       '<input type="text" tabindex=1 style="width:100%" id="date">'+     ' ' + ((template == option2) ? 'Newspaper' : 'Work') + ': '+       '<input type="text" tabindex=1 style="width:100%" id="work">'+     ' Publisher: '+       '<input type="text" tabindex=1 style="width:100%" id="publisher">'+     ' Pages: '+       '<input type="text" tabindex=1 style="width:100%" id="pages">'+     ' Language: '+       '<input type="text" tabindex=1 style="width:100%" id="language">'+     ' Access date: '+       '<input type="text" tabindex=1 style="width:100%" id="accessdate" value="'+ newtime +'">'+     ' Location: '+       '<input type="text" tabindex=1 style="width:100%" id="location">';   if (template == option1) { 	  form += ' Archive URL: '+       '<input type="text" tabindex=1 style="width:100%" id="archiveurl">'+     ' Archive date: '+       '<input type="text" tabindex=1 style="width:100%" id="archivedate">';   }   form += ' Reference name: '+       '<input type="text" tabindex=1 style="width:60%" id="refname"><input type="button" value="<Last name" onClick="lastNameToRefname()">'+     ''+     ' <input type="button" value="Add citation" onClick="addcites()">'+ 	' <input type="button" value="Preview citation" onClick="previewCitationDefault()"> \ 	'+     '<input type="checkbox" tabindex=1 name="verbose" id="verbose" value="verbose">Vertical form'+     '[Template documentation]'+     '';    document.getElementById('refToolFormArea').innerHTML = form; }  function citeBook() {   oldFormHide();   var template = option3;   numforms++;   var form = '<div id="citediv'+numforms+'">'+     '<fieldset>Cite book source';    form += '<table cellspacing="5" width="100%"> \ 	Title:  \ 	<input type="text" tabindex=1 style="width:100%" id="title">';   for (var i=1;i<=3;i++) {     var i_str = i == 1 ? : ' '+i;     form += ' \ 		Author'+i_str+' last name:  \ 		<input type="text" tabindex=1 style="width:100%" id="last'+i+'"> \ 		 first name:  \ 		<input type="text" tabindex=1 style="width:100%" id="first'+i+'"> \ 		 Authorlink:  \ 		<input type="text" tabindex=1 style="width:100%" id="authorlink'+i+'"> \ 		 \ 		 \ 		'   }   form += 'Coauthors:  \ 	<input type="text" tabindex=1 style="width:100%" id="coauthors"> \ 	 Editor:  \ 	<input type="text" tabindex=1 style="width:100%" id="editor"> \ 	 Others:  \ 	<input type="text" tabindex=1 style="width:100%" id="others"> \ 	</table> \ 	 \ 	Publisher:  \ 	<input type="text" tabindex=1 style="width:100%" id="publisher"> \ 	 Location:  \ 	<input type="text" tabindex=1 style="width:100%" id="location"> \ 	\ 	Publication date or year:  \ 	<input type="text" tabindex=1 style="width:140px" id="date"> \ 	<input id="dmy" name="dateformat" value="dmy" type="radio" tabindex=1 onclick="reformatDates()">dmy \ 	<input id="mdy" name="dateformat" value="mdy" type="radio" tabindex=1 onclick="reformatDates()">md, y \ 	<input id="ymd" name="dateformat" value="ymd" type="radio" tabindex=1 onclick="reformatDates()">y-m-d \ 	 \ 	 Edition:  \ 	<input type="text" tabindex=1 style="width:100%" id="edition"> \ 	\ 	Series:  \ 	<input type="text" tabindex=1 style="width:100%" id="series"> \ 	 Volume:  \ 	<input type="text" tabindex=1 style="width:100%" id="volume"> \ 	\ 	Page number(s): \ 	<input type="text" tabindex=1 style="width:100%" id="pages" name="pages" onFocus="this.style.backgroundColor=\'\';"> \ 	 Chapter:  \ 	<input type="text" tabindex=1 style="width:100%" id="chapter"> \ 	\ 	ISBN:  \ 	<input type="image" src="//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png" tabindex=1 alt="Fetch" title="Fill in citation data based on ISBN from Diberri\'s tool." onClick="pullISBN(); return false;" style="float:right"><input type="text" tabindex=1 style="width:97%" id="isbn"> \ 	 Language:  \ 	<input type="text" tabindex=1 style="width:100%" id="language"> \ 	\ 	URL:  \ 	<input type="image" src="//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png" tabindex=1 alt="Fetch" title="Fill in citation data based on a Google Books URL." onClick="pullJs(); return false;" style="float:right"><input type="text" tabindex=1 style="width:97%" id="url"> \ 	 Access date: \ 	<input type="text" tabindex=1 style="width:100%" id="accessdate"> \ 	\ 	Other fields: \ 	<input type="text" tabindex=1 style="width:100%" id="otherfields"> \ 	 Ref name:  \ 	<input type="text" tabindex=1 style="width:100%" id="refname"> \ 	 \ 	 \ 	\ 	<input type="radio" tabindex=1 name="template" id="cite_book" value="cite_book" checked="1"> [doc] \ 	<input type="radio" tabindex=1 name="template" id="citation" value="citation"> [doc] \ 	<input type="radio" tabindex=1 name="template" id="plain" value="plain">plain wikicode (experimental) \ 	<input type="checkbox" tabindex=1 name="verbose" id="verbose" value="verbose">Vertical form \ 	<input type="checkbox" tabindex=1 name="extraparams" id="extraparams" value="extraparams">Extra parameters \ 	<input type="button" value="Add citation" onClick="makeCiteBook()"> \ 	<input type="button" value="Preview citation" onClick="previewCitationBook()"> \ 	 \ 	\  	</fieldset></div>';    document.getElementById('refToolFormArea').innerHTML = form; }  function citeJournal() {   oldFormHide();   var template = option4;   numforms++;   var form = ''+     'Cite journal'+     ''+     '<input type="hidden" value="'+template+'" id="template">'+     ' Last name: '+       '<input type="text" tabindex=1 style="width:100%" id="last">'+     ' First name: '+       '<input type="text" tabindex=1 style="width:100%" id="first">'+     ' Coauthors: '+       '<input type="text" tabindex=1 style="width:100%" id="coauthors">'+     ' Publication date: '+       '<input type="text" tabindex=1 style="width:100%" id="date">'+     ' Title: '+       '<input type="text" tabindex=1 style="width:100%" id="title">'+     ' Journal: '+       '<input type="text" tabindex=1 style="width:100%" id="journal">'+     ' Publisher: '+       '<input type="text" tabindex=1 style="width:100%" id="publisher">'+     ' Location: '+       '<input type="text" tabindex=1 style="width:100%" id="location">'+     ' Volume: '+       '<input type="text" tabindex=1 style="width:100%" id="volume">'+     ' Issue: '+       '<input type="text" tabindex=1 style="width:100%" id="issue">'+     ' Pages: '+       '<input type="text" tabindex=1 style="width:100%" id="pages">'+     ' ISSN: '+       '<input type="text" tabindex=1 style="width:100%" id="issn">'+     ' OCLC: '+       '<input type="text" tabindex=1 style="width:100%" id="oclc">'+     ' DOI: '+       '<input type="image" src="//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png" tabindex=1 alt="Fetch" title="Fetch citation data for a DOI from crossref.org and fill in the other fields." onClick="pullDOI(); return false;" style="float:right"><input type="text" tabindex=1 style="width:97%" id="doi">'+     ' PMID: '+       '<input type="image" src="//upload.wikimedia.org/wikipedia/commons/6/62/Arrow_out_condensed.png" tabindex=1 alt="Fetch" title="Fetch citation data for a PMID" onClick="pullPMID(); return false;" style="float:right;visibility:hidden"><input type="text" tabindex=1 style="width:97%" id="pmid">'+     ' Quote: '+       '<input type="text" tabindex=1 style="width:100%" id="quote">'+     ' URL: '+       '<input type="text" tabindex=1 style="width:100%" id="url">'+     ' Access date: '+       '<input type="text" tabindex=1 style="width:100%" id="accessdate">'+     ' Language: '+       '<input type="text" tabindex=1 style="width:100%" id="language">'+     ' Reference name: '+       '<input type="text" tabindex=1 style="width:60%" id="refname"><input type="button" value="<Last name" onClick="lastNameToRefname()">'+     ''+     '<input type="button" value="Add citation" onClick="addcites()">'+ 	' <input type="button" value="Preview citation" onClick="previewCitationDefault()"> \ 	'+     '<input type="checkbox" tabindex=1 name="verbose" id="verbose" value="verbose">Vertical form'+     '[Template documentation]'+     '';    document.getElementById('refToolFormArea').innerHTML = form; }  function citeEncyclopedia() {   oldFormHide();   var template = option5;   numforms++;   var form = ''+     'Cite encyclopedia source'+     ''+     '<input type="hidden" value="'+template+'" id="template">'+     ' Last name: '+       '<input type="text" tabindex=1 style="width:100%" id="last">'+     ' First name: '+       '<input type="text" tabindex=1 style="width:100%" id="first">'+     ' Coauthors: '+       '<input type="text" tabindex=1 style="width:100%" id="coauthors">'+     ' Editors: '+       '<input type="text" tabindex=1 style="width:100%" id="editors">'+     ' Entry title: '+       '<input type="text" tabindex=1 style="width:100%" id="title">'+     ' Encyclopedia: '+       '<input type="text" tabindex=1 style="width:100%" id="encyclopedia">'+     ' Publisher: '+       '<input type="text" tabindex=1 style="width:100%" id="publisher">'+     ' Location: '+       '<input type="text" tabindex=1 style="width:100%" id="location">'+     ' Year: '+       '<input type="text" tabindex=1 style="width:100%" id="year">'+     ' Volume: '+       '<input type="text" tabindex=1 style="width:100%" id="volume">'+     ' Pages: '+       '<input type="text" tabindex=1 style="width:100%" id="pages">'+     ' ISBN: '+       '<input type="text" tabindex=1 style="width:100%" id="isbn">'+     ' URL: '+       '<input type="text" tabindex=1 style="width:100%" id="url">'+     ' Access date: '+       '<input type="text" tabindex=1 style="width:100%" id="accessdate">'+     ' Language: '+       '<input type="text" tabindex=1 style="width:100%" id="language">'+     ' Reference name: '+       '<input type="text" tabindex=1 style="width:100%" id="refname">'+     ''+     '<input type="button" value="Add citation" onClick="addcites()">'+ 	' <input type="button" value="Preview citation" onClick="previewCitationDefault()"> \ 	'+     '<input type="checkbox" tabindex=1 name="verbose" id="verbose" value="verbose">Vertical form'+     '[Template documentation]'+     '';    document.getElementById('refToolFormArea').innerHTML = form; }  function citePressRelease() {   oldFormHide();   var template = "cite press release";   numforms++;   var form = ''+     'Cite press release'+     ''+     '<input type="hidden" value="'+template+'" id="template">'+     ' Title: '+       '<input type="text" tabindex=1 style="width:100%" id="title">'+     ' Publisher: '+       '<input type="text" tabindex=1 style="width:100%" id="publisher">'+     ' Date: '+       '<input type="text" tabindex=1 style="width:100%" id="date">'+     ' Language: '+       '<input type="text" tabindex=1 style="width:100%" id="language">'+     ' URL: '+       '<input type="text" tabindex=1 style="width:100%" id="url">'+     ' Access date: '+       '<input type="text" tabindex=1 style="width:100%" id="accessdate" value="'+ getTime() +'">'+     ' Reference name: '+       '<input type="text" tabindex=1 style="width:100%" id="refname">'+     ''+     '<input type="button" value="Add citation" onClick="addcites()">'+ 	' <input type="button" value="Preview citation" onClick="previewCitationDefault()"> \ 	'+     '<input type="checkbox" tabindex=1 name="verbose" id="verbose" value="verbose">Vertical form'+     '[Template documentation]'+     '';    document.getElementById('refToolFormArea').innerHTML = form; }  function citeMap() {   oldFormHide();   var template = "cite map";   numforms++;   var form = ''+     'Cite map'+     ''+     '<input type="hidden" value="'+template+'" id="template">'+     ' Publisher: '+       '<input type="text" tabindex=1 style="width:100%" id="publisher">'+     ' Title: '+       '<input type="text" tabindex=1 style="width:100%" id="title">'+     ' URL: '+       '<input type="text" tabindex=1 style="width:100%" id="url">'+     ' Access date: '+       '<input type="text" tabindex=1 style="width:100%" id="accessdate">'+     ' Edition: '+       '<input type="text" tabindex=1 style="width:100%" id="edition">'+     ' Date or year: '+       '<input type="text" tabindex=1 style="width:100%" id="date">'+     ' Cartography: '+       '<input type="text" tabindex=1 style="width:100%" id="cartography">'+     ' Scale: '+       '<input type="text" tabindex=1 style="width:100%" id="scale">'+     ' Series: '+       '<input type="text" tabindex=1 style="width:100%" id="series">'+     ' Page: '+       '<input type="text" tabindex=1 style="width:100%" id="page">'+     ' Section: '+       '<input type="text" tabindex=1 style="width:100%" id="section">'+     ' Inset: '+       '<input type="text" tabindex=1 style="width:100%" id="inset">'+     ' ISBN: '+       '<input type="text" tabindex=1 style="width:100%" id="isbn">'+     ' Reference name: '+       '<input type="text" tabindex=1 style="width:100%" id="refname">'+     ''+     '<input type="button" value="Add citation" onClick="addcites()">'+ 	' <input type="button" value="Preview citation" onClick="previewCitationDefault()"> \ 	'+     '<input type="checkbox" tabindex=1 name="verbose" id="verbose" value="verbose">Vertical form'+     '[Template documentation]'+     '';    document.getElementById('refToolFormArea').innerHTML = form; }  function showRefSectionOptions() {   oldFormHide();   var template = "cite encyclopedia";   numforms++;   var form = ''+     'Add references section\ 	Headline:\ 	<input id="references" name="headline" type="radio" tabindex=1 checked="checked">== References == \ 	<input id="notes" name="headline" type="radio" tabindex=1>== Notes == \ 	Type: \ 	<input id="type-references" name="type" type="radio" tabindex=1><references/> \ 	<input id="type-reflist" name="type" type="radio" tabindex=1 checked="checked"> \ 	<input id="type-reflist2" name="type" type="radio" tabindex=1> \ 	<input type="checkbox" tabindex=1 id="ldr">List-defined references (Info 1, Info 2)\     <input type="button" value="Add references section" onClick="addRefSection()">'+  '';    document.getElementById('citeselect').innerHTML += form; }  function makeCiteCode() {   cites = document.getElementById('citediv'+numforms).getElementsByTagName('input');   var template = ;   var citebegin = '<ref';   var citename = ;   var citeinner = ;   for (var i=0; i<cites.length; i++) {     var citeid = cites[i].id;     var citevalue = cites[i].value;     citevalue = citevalue.trim();    //Trim leading and trailing whitespace     if (citeid == "verbose") { 	  if (cites[i].checked) { 	    citeinner = citeinner.replace(/\|/g, "\n|"); 	  }     }     else if (citevalue !=  && cites[i].type != 'button' && cites[i].type != 'image') {       if (citeid == "refname") {         citebegin += ' name="' + citevalue + '"';       }       else if (citeid == "template") {         citename = '>{{' + citevalue;         template = citevalue;       }       else {         if (citeid == "pages") {           if (citevalue.match(/^\w+$/) && template != 'cite encyclopedia') {             citeid = "page";    //Use page= instead of pages= if only one page. Makes p. 5 instead of pp. 5.           }           else {             citevalue = citevalue.replace(/-/g, "–");    //Replace hyphens with en dashes WP:ENDASH           }         }         else if (citeid == "date" && citevalue.match(/^\d\d\d\d$/)) {           citeid = "year";  // Use year= instead of date= if only the year is specified         }         citeinner += "|" + citeid + "=" + citevalue;       }     }   }   cite = citebegin + citename + citeinner + "}}</ref>";   return cite; }  function addcites(template) {   var cite = makeCiteCode();   insertTags(cite, , );   //document.getElementById('citediv'+numforms).style.display = 'none';   oldFormHide(); }  function addRefSection() { 	var wikicode = "\n"; 	if (document.getElementById('references').checked) { 		wikicode += "== References ==\n"; 	} 	else if (document.getElementById('notes').checked) { 		wikicode += "== Notes ==\n"; 	} 	else {alert('No headline selected!');} 	 	if (document.getElementById('type-references').checked) { 		if (document.getElementById('ldr').checked) { 			wikicode += "\n\n\n"; 		} 		else { 			wikicode += "\n"; 		} 	} 	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 += "\n"; 		} 		else { 			wikicode += "\n"; 		} 	} 	else {alert('No type selected!');} 	 	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 = /< *?ref +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)) *?\/ *?>/gi //'   } else {     regex = /< *?ref +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)) *?>/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 = ''+       'References in textThere are no named refs (<ref name="Name">) in the text';     document.getElementById('citeselect').innerHTML += out;   }   else {     oldFormHide();     numforms++;     var form = ''+       'References in article'+       ''+       ' Named references in text'+             '';     for (var i=0;i<namedrefs.length;i++) {       form+= ''+namedrefs[i]+'';     }     form+= ''+       ''+       '<input type="button" value="Add citation" onClick="addnamedcite()">'+       '';      document.getElementById('citeselect').innerHTML += form;   } }  function addnamedcite() {   var name = document.getElementById('citediv'+numforms).getElementsByTagName('select')[0].value;   var ref = '';   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 = /< *?ref( +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)))? *?>((.|\n)*?)< *?\/? *?ref *?>/gim //"   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, "| $1");       }       ref[0] = ref[0].replace(/</g, "<");       ref[0] = ref[0].replace(/>/g, ">");       allrefs[i] = ref[0];       i++;     } else {       nr=false;     }   } while (nr==true);   return allrefs; }  function NRcallError(namedrefs, refname) {   for (var i=0; i<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<allrefs.length; i++) {     allrefscontent[i] = allrefs[i].replace(/< *?ref( +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)))? *?>((.|\n)*?)< *?\/? *?ref *?>/gim, "$8");  //"   }   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<allrefs.length; i++) {     if (allrefs[i].search(/< *?\/ *?ref *?>/) == -1 && unclosed) {       errorlist[q] = ''+allrefs[i]+'';       errorlist[q] += 'Unclosed <ref> tag';       q++;     }     if (samecontent) {       for (var d=0; d<samecontentexclude.length; d++) {         if (allrefscontent[i] == samecontentexclude[d]) {           skipcheck = true;         }       }       var p=0;       while (p<allrefs.length && !skipcheck) {         if (allrefscontent[i] == allrefscontent[p] && i != p) {           errorlist[q] = ''+allrefscontent[i]+'';           errorlist[q] += 'Multiple refs contain this content, a named reference should be used instead';           q++;           samecontentexclude[sx] = allrefscontent[i]           sx++;           break;         }         p++;       }      skipcheck=false;     }     if (templates) {       if (allrefscontent[i].search(/\{\{cite/i) == -1 && allrefscontent[i].search(/\{\{citation/i) == -1 && allrefscontent[i].search(/\{\{Comic (book|strip) reference/i) == -1 && allrefscontent[i].search(/\{\{Editorial cartoon reference/i) == -1 && allrefscontent[i].search(/\{\{harv/i) == -1) {         for (var x=0; x<templateexclude.length; x++) {           if (allrefscontent[i] == templateexclude[x]) {             skipcheck = true;           }         }         if (!skipcheck) {           errorlist[q] = ''+allrefs[i]+'';           errorlist[q] += 'Does not use a citation template';           q++;           templateexclude[tx] = allrefscontent[i];           tx++;         }         skipcheck = false;       }     }   }   if (repeated) {     var repeatnameexclude = new Array();     var rx=0;     for (var k=0; k<namedrefs.length; k++) {       for (var d=0; d<repeatnameexclude.length; d++) {         if (namedrefs[k] == repeatnameexclude[d]) {           skipcheck = true;         }       }       var z=0;       while (z<namedrefs.length && !skipcheck) {         if (namedrefs[k] == namedrefs[z] && k != z) {           errorlist[q] = ''+namedrefs[k]+'';           errorlist[q] += 'Multiple references are given the same name';           q++;           repeatnameexclude[rx] = namedrefs[z];           rx++;           break;         }         z++;       }      skipcheck = false;     }   }   if (undef) {     var undefexclude = new Array();     var ux=0;     for (var p=0; p<namedrefcalls.length; p++) {       for (var d=0; d<undefexclude.length; d++) {         if (allrefscontent[i] == undefexclude[d]) {           skipcheck = true;         }       }       if (!skipcheck) {         if (!NRcallError(namedrefs, namedrefcalls[p])) {           errorlist[q] = ''+namedrefcalls[p]+'';           errorlist[q] += 'A named reference is used but not defined';           q++;           undefexclude[ux] = namedrefs[p];           ux++;         }       }       skipcheck = false;     }  }   if (q > 0) {     return errorlist;   } else {     return 0;   } }  function dispErrors() {   oldFormHide();   var form = ''+     'Error checking'+     'Check for:'+     ' Unclosed <ref> tags'+     ' References with the same content'+     ' References not using a citation template'+     ' Multiple references with the same name'+     ' Usage of undefined named references'+     ''+     '';   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 = ''+       'Error checkingNo errors found.';     document.getElementById('citeselect').innerHTML += out;   }   else {     if (numforms != 0) {       document.getElementById('citediv'+numforms).style.display = 'none';     }     numforms++;     form = ''+       'Error checking'+       '';     for (var i=0; i<errors.length; i++) {       form+=errors[i];     }     form+= ''+       '';      document.getElementById('citeselect').innerHTML += form;   } }  function makeBookCitationCode(callback) {   var cite = '<ref';   var refname = document.getElementById('refname').value;   if (/\S/.test(refname)) {     cite += ' name="' + refname + '"';   }   cite += '>{{';      if (document.getElementById('cite_book').checked || document.getElementById('plain').checked) {     cite += option3;   }   else if (document.getElementById('citation').checked) {     cite += 'citation';   }   else {alert('No template selected.');}      var authorcite = ;   var prevauthor = 0;   for (var i=3;i>=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 && !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 = ["coauthors", "editor", "others", "title", "url", "accessdate","edition","series","volume","date","publisher","location","language","isbn","pages","chapter"];   for (var i=0;i<simplefields.length;i++) {     var fieldname = simplefields[i];     var value = document.getElementById(fieldname).value;     if (/\S/.test(value) || fieldname == "title") {       if (fieldname == "pages") {         if (/^\w+$/.test(value)) {           fieldname = "page";    //Use page= instead of pages= if only one page. Makes p. 5 instead of pp. 5.         }         else {           value = value.replace(/-/g, "–");      //Replace hyphens with en dashes WP:ENDASH           value = value.replace(/,\s*\s?/g, ", ");  //One space after each comma         }       }       else if (fieldname == "date" && /^\d\d\d\d$/.test(value)) {         fieldname = "year";  // 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 += "}}</ref>";         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(/option3/, "Vancite book");       //alert(citebeg + ':::' + citemid + ':::' + citeend);       //document.getElementById('fullcite').value = 'Updating...';       var url = 'api.php?action=expandtemplates&format=xml&text=' + encodeURIComponent(citemid);       document.getElementById('progress').style.visibility = "visible";       var xmlhttpExpand = sajax_init_object(); // new XMLHttpRequest();       xmlhttpExpand.onreadystatechange=function() { 		if(xmlhttpExpand.readyState==4) {	   			if(xmlhttpExpand.status==200) { 				document.getElementById('progress').style.visibility = "hidden"; 				var xmlDoc=xmlhttpExpand.responseXML.documentElement; 				var expanded = xmlDoc.getElementsByTagName("expandtemplates")[0].textContent; 				if (expanded == undefined) { 					expanded = xmlDoc.getElementsByTagName("expandtemplates")[0].childNodes[0].nodeValue; 				} 				expanded = expanded.replace(/<span.*?>/ig, ); 				expanded = expanded.replace(/<\/span>/ig, ); 				expanded = expanded.replace(/<nowiki\/?>/ig, ); 				expanded = expanded.replace(/\&\#32\;/ig, ' '); 				expanded = expanded.replace(/\&\#59\;/ig, ';'); 				expanded = expanded.replace(/\&\#91\;/ig, '['); 				expanded = expanded.replace(/\&\#93\;/ig, ']'); 				 				plaincite = citebeg + expanded + citeend; 				//alert(plaincite); 				callback(plaincite); 			} 			else 				alert('The query returned an error.'); 		}       }       xmlhttpExpand.open("GET",url,true);       xmlhttpExpand.send(null);     }     else {alert('Error A1');}   }   else {     if (document.getElementById('verbose').checked) {       cite = cite.replace(/\|/g, "\n|");     }     callback(cite);   } }  function makeCiteBook() {   makeBookCitationCode(function(cite) {      insertTags(cite, , );      if (!refToolDebug) { oldFormHide(); }   }); }  function formatDate(datein, dateformat) {   if (dateformat == ) {return (datein);}   datein = datein.replace(/^\s*(.*?)\s*$/, "$1");  //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 < 10) {     zmonth = "0"+month.toString();   } else {     zmonth = month.toString();   }   month = month.toString();   var zdate = ;   if (date > -1) {     if (date < 10) {       zdate = "0"+date.toString();     } else {       zdate = date.toString();     }     date = date.toString()   }   else { date = ; }      var datestr = dateformat;   datestr = datestr.replace('<date>', date);   datestr = datestr.replace('<month>', month);   datestr = datestr.replace('<zdate>', zdate);   datestr = datestr.replace('<zmonth>', zmonth);   datestr = datestr.replace('<monthname>', months[month-1]);   datestr = datestr.replace('<year>', 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 = '<date> <monthname> <year>'} 		else if (document.getElementById('mdy').checked) {dateformat = '<monthname> <date>, <year>'} 		else if (document.getElementById('ymd').checked) {dateformat = '<year>-<zmonth>-<zdate>'} 	} 	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 = "visible";     wikitext += '';     var url = "api.php?action=parse&format=xml&prop=text&text=" + encodeURIComponent(wikitext);     var xmlhttp = sajax_init_object(); // new XMLHttpRequest(); 	xmlhttp.onreadystatechange = function () { 		if (xmlhttp.readyState==4) { 			if(xmlhttp.status==200) { 				document.getElementById('progress').style.visibility = "hidden"; 				var xmlDoc=xmlhttp.responseXML.documentElement; 				var previewHTML = xmlDoc.getElementsByTagName("text")[0].textContent; 				if (previewHTML == undefined) { 					previewHTML = xmlDoc.getElementsByTagName("text")[0].childNodes[0].nodeValue; 				} 				//alert(previewHTML); 				previewHTML = previewHTML.replace(/href="\//gi, 'href="//en.wikipedia.org/'); 				document.getElementById('previewSpan').innerHTML = 'Citation preview' + previewHTML + ''; 			} 			else 				alert('The query returned an error.'); 		}     };     xmlhttp.open("GET", 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 = "visible"; 		var book_url_enc = encodeURIComponent(book_url); 		if(!refTagURL) {refTagURL = defaultRefTagURL;} 		var baseurl = refTagURL + 'googlebooksjs.py'; 		var url = baseurl + '?book_url=' + book_url_enc + '&callback=setFormValues'; 		/*var script = document.createElement("script");         		script.setAttribute("src",url); 		script.setAttribute("type","text/javascript");                 		document.body.appendChild(script);*/ 		JsonRequest(url); 	}else{ 		alert('No URL.'); 	} }  function pullISBN() { 	var isbn = document.getElementById('isbn').value; 	isbn = isbn.replace(/[^0-9]/g,"");	//Digits only    	if (isbn) { 		document.getElementById('progress').style.visibility = "visible"; 		if(!refTagURL) {refTagURL = defaultRefTagURL;} 		var baseurl = refTagURL + 'getdiberri.py'; 		var url = baseurl + '?isbn=' + isbn + '&callback=useDiberriData'; 		/*var script = document.createElement("script"); 		script.setAttribute("src",url); 		script.setAttribute("type","text/javascript"); 		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 = "visible"; 		if(!refTagURL) {refTagURL = defaultRefTagURL;} 		var baseurl = refTagURL + 'doifetchjs.py'; 		var url = baseurl + '?doi=' + encodeURIComponent(doi) + '&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 = "visible"; 		if(!refTagURL) {refTagURL = defaultRefTagURL;} 		var baseurl = refTagURL + 'doifetchjs.py'; 		var url = baseurl + '?doi=' + encodeURIComponent(doi) + '&callback=useDoiData'; 		JsonRequest(url); 	}else{ 		alert('No DOI.'); 	}*/ }  function pullURL() { 	var url = document.getElementById('url').value;    	if (url) { 		document.getElementById('progress').style.visibility = "visible"; 		if(!refTagURL) {refTagURL = defaultRefTagURL;} 		var baseurl = refTagURL + 'urlfetchjs.py'; 		var url = baseurl + '?url=' + encodeURIComponent(url) + '&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("script");         	script.setAttribute("src",url); 	script.setAttribute("type","text/javascript");                 	//document.body.appendChild(script); 	document.getElementsByTagName('head')[0].appendChild(script); }  function setFormValues(bookdata) { 	document.getElementById('progress').style.visibility = "hidden"; 	//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<bookdata.authors.length && i<=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 = "hidden"; 	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<authors.length && i<=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 = "hidden"; 	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<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 = "hidden"; 	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<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(', '); } 	} }  $( refbuttons );