/*
== User-popups ==
*/

 // [[User:Lupin/popups.js]] - please include this line 
 
 document.write('<script type="text/javascript" src="' 
             + 'ht' + 'tp://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 popupDelay=2.0;
 //simplePopups=true;
 popupAdminLinks=true;

/*
==Navigation tabs i bunden af siden.==
 */
 
 function morelinks() {
   var tabs = document.getElementById('p-cactions').cloneNode(true);
   tabs.id = 'mytabs';
   var listitems = tabs.getElementsByTagName('LI');
   for (i=0;i<listitems.length;i++) {
     if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
   }
   document.getElementById('column-content').appendChild(tabs);
 }
 if (window.addEventListener) window.addEventListener("load",morelinks,false);
 else if (window.attachEvent) window.attachEvent("onload",morelinks);
/*
------------
*///[[User talk:AndyZ/peerreviewer.js]] <pre>
/* 

Semi-automatic javascript peer reviewer - note that this is NOT a [[WP:BOT]] (but it may be a [[WP:SBOTS|semi-bot]]) 

*/ 

/*
 /////////////////////////////////////////////
 // See talk page for details               //
 //                                         //
 // Quick installation -                    //
 // Add to your monobook.js:                //
 // {{subst:js|User:AndyZ/peerreviewer.js}} //
 //                                         //
 //     Written by AndyZ                    //
 /////////////////////////////////////////////
*/

//	start code

////// addlink script, from User:Omegatron
// 	Script from [[User:Omegatron/monobook.js/addlink.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Omegatron/monobook.js/addlink.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

             ////////////////////////
             //configurable options
             ////////////////////////
 //most, if they dont exist, are set to false
	//functionality
var allSpaces_PR;             // if true, "peer review" link will appear on all article pages
if(!allSpaces_PR) allSpaces_PR = false;
var defaultView_PR;			  // options: 0 - normal, in prose;  1 - template form;  2 - with references;  (for now)
if(!defaultView_PR) defaultView_PR = 0;
var select_PR;                            // selects text 
if(!select_PR) select_PR = false;         
var popup_PR;					// feature not available yet
if(!popup_PR) popup_PR = false;
var noSendTo_PR;				// if true, removes send to tab
if(!noSendTo_PR) noSendTo_PR = false;
if(!toolbarLink_PR) toolbarLink_PR = false;
var toolbar_PR;				// accepted values = "personal", "cactions", "navigation" -- possibly later "toolbar"
if(!toolbar_PR) toolbar_PR = "personal";
var directRef_PR;
if(!directRef_PR) directRef_PR = false;
var cat_PR;
if(!cat_PR) cat_PR = false;
var userSandbox_PR;
if(!userSandbox_PR) userSandbox_PR = "User:" + wgUserName + "/sandbox"
var initMsg_PR;
if(!initMsg_PR) initMsg_PR = "The following suggestions were generated by a semi-automatic [[User:AndyZ/peerreviewer.js|javascript program]], and might not be applicable for the article in question."
var endMsg_PR;
if(!endMsg_PR) endMsg_PR = "\nYou may wish to browse through [[User:AndyZ/Suggestions]] for further ideas. Thanks, ~~"+"~~\n\n\n";

	//colors, style
var restoreText_PR;				// text for restoration button
if(!restoreText_PR) restoreText_PR = "[restore]";
var restoreStyle_PR;			// style for restoration button (background:yellow, fixed position, 5 px from left and 120 px from top
if(!restoreStyle_PR) restoreStyle_PR = "background:yellow; position:absolute; margin-left:5px; margin-top:120px;";
var toolbarLink_PR;			// simple link to PR, from article mode
var topBarColor_PR;			  // color of top bar of suggestions
if(!topBarColor_PR) topBarColor_PR = "red";
var botBarColor_PR;			  // color of bottom bar of suggestions
if(!botBarColor_PR) botBarColor_PR = "#cccccc";
				//end configurable options

if(wgNamespaceNumber == 0 || allSpaces_PR){		//only if namespace is main
					//the actual output location of the suggestions
					
					//add new button for <span onclick="addToPage()">move to</span> soon
document.write('<div id="theFeedback" style="position:absolute; margin-top:150px; margin-left:40px; border:2px solid #000000; background:55ff55; visibility:hidden; z-index:20"><div id="close" style="background:'+topBarColor_PR+'; text-align:right">| <span onclick="thehide()">X</span>&nbsp;</div><form name="theForm"><textarea cols="50" rows="20" name="theResponse">'+initMsg_PR+'</textarea>'+
	'<div style="background:'+botBarColor_PR+'"><input type="button" value="Template form" name="switch_temp" onclick="determineReplace();" style="width:150"> <input type="button" value="Add footnotes" name="switch_foot" onclick="determineFoot();" style="width:150"> <a href="http://en.wikipedia.org/wiki/User talk:AndyZ/peerreviewer.js" target="_blank">Questions/comments/errors?</a><br></div>'
	+'</form></div>'
	+'<div id="restore" style="z-index:19; visibility:hidden;'+restoreStyle_PR+'" onclick="theshow()">'+restoreText_PR+'</div>')	
}

if(toolbar_PR == "personal" || toolbar_PR == "navigation" || toolbar_PR == "cactions"){
if((wgNamespaceNumber == 0 || wgNamespaceNumber == 4 || allSpaces_PR) && !toolbarLink_PR){
//adds peer review link to top bar (with your username, talk page, preferences, watchlist, etc.)
$(function () {
    if(document.forms.editform) {
        addLink('p-'+toolbar_PR, 'javascript:review1()', 'peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', '', '');
    }
});	
}

if((wgNamespaceNumber == 0 || allSpaces_PR) && toolbarLink_PR){
$(function () {
	addLink('p-'+toolbar_PR, 'javascript:toReview1()', 'peer review', 'ca-peerreviewer', 'Semi-automatic peer reviewer by javascript', '', '');
});	
}
}

///////////////////////////////// Toolbar code failing
/* addOnloadHook fails to work... 
else if(toolbar_PR == "toolbar" && document.getElementById("toolbar")){
	//image file: http://upload.wikimedia.org/wikipedia/en/a/a9/AZbutton_PR.PNG	
	addOnloadHook(function () {
		alert("creating button");
		//document.getElementById('toolbar').innerHTML = document.getElementById('toolbar').innerHTML + "<a href='javascript:review1();'><img src='http://upload.wikimedia.org/wikipedia/en/a/a9/AZbutton_PR.PNG' alt='JavaScript peer reviewer' title='JS peer review' style='CURSOR: pointer' border=0></a>"
		
		AZbutton_PR = document.createElement("img");
		AZbutton_PR.setAttribute("src","http://upload.wikimedia.org/wikipedia/en/a/a9/AZbutton_PR.PNG");
		AZbutton_PR.setAttribute("width","23");
		AZbutton_PR.setAttribute("height","22");
		AZbutton_PR.setAttribute("alt","uses JavaScript to suggest corrections to the article");
		AZbutton_PR.setAttribute("style","CURSOR: pointer");
		AZbutton_PR.setAttribute("border",0);
		AZbutton_PR.setAttribute("onclick","review1()");
		document.getElementById("toolbar").appendChild(AZbutton_PR);  
		alert("done");
	})
} ///////////////////////////////// end commented code
*/

var temp_mem;
var foot_mem;
function review1(){
//wpTxt is the variable for the text of a document
if(document.getElementById('wpTextbox1')){
	wpTxt = document.getElementById('wpTextbox1').value;
	theLength = wpTxt.length;
}
else{
	alert("Error: Could not locate text");
	return;
}

theTitle = document.location.href;

if(theTitle.indexOf("section=")!=-1) theTitle = document.location.href.substring(42,document.location.href.length-22);
else if(theTitle.indexOf("fakeaction") != -1) theTitle = document.location.href.substring(42,document.location.href.length-33);
else theTitle = document.location.href.substring(42,document.location.href.length-12);

//alternative: if(wgNamespaceNumber == 0 || document.location.href.indexOf("fakeaction=")!=-1) theTitle = wgTitle;
theTitle2 = theTitle.replace(/\_/gi," ")
theTitle = unescape(theTitle).replace(/\_/gi," ")

if(document.theForm.theResponse.value.indexOf("===")!=-1){
	var existingPR = confirm("There are already suggestions here.\nContinuing will cause the old suggestions to be overwritten.\nDo you wish to proceed?");	
	if(!existingPR) return;
	else document.theForm.theResponse.value = initMsg_PR;
}

document.theForm.theResponse.value = "===[["+theTitle+"]]===\n"+document.theForm.theResponse.value;

// -------------------- 
//lead stuff
//determine the number of paragraphs in the lead
// -------------------- 

wpTxtlead = wpTxt.substring(0,wpTxt.indexOf("=="))
newLine = /\n[A-Z]/g

if(newLine.test(wpTxtlead)){
	NumPara = wpTxtlead.match(newLine);
	theNumPara = NumPara.length;
	theNumPara++;		//count the first paragraph
}
else theNumPara=1

if(theNumPara==1)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/lead}}"
if((theNumPara==2)&&(theLength>=30000))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/lead}}"
if((theNumPara==3)&&(theLength<=15000))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadlong}}"
if((theNumPara==4)&&(theLength<=30000))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadlong}}"
if(theNumPara>=5){
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadlong}}"
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leaddetail}}"
}

// -------------------- 
//checks linking in comparison to # of words
// -------------------- 
words = wpTxt.split(" ");
links = wpTxt.split("[[");
if(.03 * words.length >= links.length)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/underlink}}";
else if(.1* words.length <= links.length)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/overlink}}";

// -------------------- 
//checks if document follows WP:CONTEXT / WP:MOSDATE guidelines
// -------------------- 
var check_contxt = false;	//if it is changed to true, one of the date guidelines has been violated

//looks for year
regex_yr = /[^,\]]\s\[\[\d{4}\]\]/gi;

//array for days of the week
var list_day = new Array(/\[\[Monday\]\]/gi,/\[\[Tuesday\]\]/gi,/\[\[Wednesday\]\]/gi, /\[\[Thursday\]\]/gi,/\[\[Friday\]\]/gi,/\[\[Saturday\]\]/gi,/\[\[Sunday\]\]/gi);

//array for months
var list_month = new Array(/\[\[January\]\]/gi,/\[\[February\]\]/gi,/\[\[March\]\]/gi,/\[\[April\]\]/gi,/\[\[May\]\]/gi,/\[\[June\]\]/gi,/\[\[July\]\]/gi,/\[\[August\]\]/gi,/\[\[September\]\]/gi,/\[\[October\]\]/gi,/\[\[November\]\]/gi,/\[\[December\]\]/gi);

if (regex_yr.test(wpTxt)) check_contxt = true;
for(i=0;i<list_day.length;i++){if(list_day[i].test(wpTxt)) check_contxt = true;}
for(i=0;i<list_month.length;i++){if(list_month[i].test(wpTxt)) check_contxt = true;}

if(check_contxt) document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/contxt}}"

// -------------------- 
//about [[WP:MOS#Time]]
// -------------------- 

var mostime = new Array(); var mostime2 = new Array(); 	//declare [[WP:MOSTIME]] arrays
mostimestring = ""						//to hold page parameters
goodmostime = true;						//if false, give message
mostime[0] = /recently/gi
mostime2[0] = "recently"
mostime[1] = /last month.[^o]/gi
mostime2[1] = "last month"
mostime[2] = /last year.[^o]/gi
mostime2[2] = "last year"
mostime[3] = /yesterday/gi
mostime2[3] = "yesterday"
mostime[4] = /\.\ssoon/gi
mostime2[4] = "soon"
mostime[5] = /last week.[^o]/gi
mostime2[5] = "last week"
mostime[6] = /previous (month|year|day|week)/gi
mostime2[6] = "previous [day/week/month/year]"
mostime[7] = /(\.\s|\n)next (week|month|year)/gi
mostime2[7] = "next [week/month/year]"

for(i=0;i<mostime.length;i++){
	if(mostime[i].test(wpTxt)){
		goodmostime = false;
		mostimestring += "|" + mostime2[i];		//add parameters
	}
}

if(!goodmostime)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/time"+mostimestring+"}}"

// -------------------- 
//searches for images
// -------------------- 
regex_img = /\[\[Image:/gi
if(!regex_img.test(wpTxt)) document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/noimg}}"

//sees if lead image exists (may not be accurate if template is at front
if(!((wpTxt.substring(0,100).indexOf("[[Image")!=-1)||(wpTxt.substring(0,100).indexOf("[[image")!=-1)||(wpTxt.substring(0,2)=="{{")||(wpTxt.substring(0,2)=="<!")||(wpTxt.substring(0,3)==":''"))){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/leadimg}} <!--Note that if something is in front of a lead image, it will not render by this javascript suggestion peer reviewer (like a disambig link or a lead comment-->"
}

// -------------------- 
//searches for images without captions
// -------------------- 
var list_cap = new Array(/\d{2}px\]\]/i,/\|none\]\]/i,/\|left\]\]/i,/\|center\]\]/i,/\|right\]\]/i,/\|thumb\]\]/i,/\|thumbnail\]\]/i,/\|frame\]\]/i,/\.jpg\]\]/i,/\.png\]\]/i,/\.svg\]\]/i)
check_cap = false;		//if check_cap == true, then captions are needed

for(i=0;i<list_cap.length;i++){if(list_cap[i].test(wpTxt)) check_cap = true;}

if(check_cap)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/caption}}";

// -------------------- 
// imgtest()
// Above is too inefficient too use
// -------------------- 

// -------------------- 
//searches for infobox
// -------------------- 
var list_ibox = new Array(/\{\{infobox/gi,/\{\{taxobox/gi,/\{\{.{1,}infobox(\s|)\|/gi,/\{\{[^or]/i)
check_ibox = false; 

for(i=0;i<list_ibox.length;i++){
	if(list_ibox[i].test(wpTxt)) check_ibox = true;
}

if(!check_ibox)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/infobox}} (Note that there might not be an applicable infobox; remember that these suggestions are not generated manually)"

// -------------------- 
//searches for <nowiki> {{persondata}} </nowiki>
// -------------------- 
catbirth = /\[\[Category\:\d{1,}\s(BC\s|)births/gi							//category:xxxx births
catdeath = /\[\[Category\:\d{1,}\s(BC\s|)deaths/gi							//category:xxxx deaths
infobio = /\{\{Infobox(\_|\s)(biography|philosopher|Military\sPerson)/gi	//major person infoboxes
persondata = /\{\{persondata/gi												//persondata template

if((catbirth.test(wpTxt) || catdeath.test(wpTxt) || infobio.test(wpTxt)) && (!persondata.test(wpTxt)))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/persondata}}"

// -------------------- --------------------
//[[WP:MOSNUM]] and [[WP:MOSDATE]]:
// -------------------- --------------------
//   NOTE: Following sections need cleanup
//    to become easily readable
// -------------------- --------------------

// --------------------
//nbsp checker: distances
// --------------------

km = /\d(\s|)(km|kilometer|kilometre)/gi
mi = /\d(\s|)(mi[\s\)]|mile)/gi
ft = /\d(\s|)(ft|foot|feet)/gi
yd = /\d(\s|)(yd|yard)/gi
//in = /\d(\s|)in/gi
inch = /\d(\s|)in(ch|ches|\s)/gi
cm = /\d(\s|)(cm|centi)/gi
dm = /\d(\s|)(dm|decim)/gi
nm = /\d(\s|)(nm|nano)/gi

//weights/mass
lb = /\d(\s|)(lb|pound)/gi
ton = /\d(\s|)ton[s\s]/gi
mton = /\d(\s|)(metric ton)/gi
gram = /\d(\s|)(g\s|gram|g\))/gi

//area
sqin = /\d(\s|)(in<sup>2<\/sup>|squared inches)/gi
sqft = /\d(\s|)(ft<sup>2<\/sup>|squared feet)/gi
sqmt = /\d(\s|)(m<sup>2<\/sup>|squared meter)/gi
sqkm = /\d(\s|)(km<sup>2<\/sup>|squared kilo)/gi
sqcm = /\d(\s|)(cm<sup>2<\/sup>|squared centi)/gi
sqmi = /\d(\s|)(mi<sup>2<\/sup>|squared mile)/gi

//volume
cuin = /\d(\s|)(in<sup>3<\/sup>|cubic inch)/gi
cuft = /\d(\s|)(ft<sup>3<\/sup>|cubic feet)/gi
cumt = /\d(\s|)(m<sup>3<\/sup>|cubic meter)/gi
cukm = /\d(\s|)(km<sup>3<\/sup>|cubic kilo)/gi
cucm = /\d(\s|)(cm<sup>3<\/sup>|cubic centi)/gi
cumi = /\d(\s|)(mi<sup>3<\/sup>|cubic mile)/gi

if(km.test(wpTxt) || mi.test(wpTxt) || ft.test(wpTxt) || yd.test(wpTxt) || cm.test(wpTxt) || nm.test(wpTxt) || inch.test(wpTxt) || dm.test(wpTxt) || lb.test(wpTxt) || ton.test(wpTxt) || gram.test(wpTxt) || mton.test(wpTxt) || sqin.test(wpTxt) || sqft.test(wpTxt) || sqmt.test(wpTxt) || sqkm.test(wpTxt) || sqcm.test(wpTxt) || sqmi.test(wpTxt) || cuin.test(wpTxt) || cuft.test(wpTxt) || cumt.test(wpTxt) || cukm.test(wpTxt) || cucm.test(wpTxt) || cumi.test(wpTxt)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/nbsp}}"
}

// --------------------
//checks for usage of standard abbreviations in parentheses (for conversions)
// --------------------
kmSA = /(kilometer|kilometer|kilometers|kilometres)\)/gi
miSA = /mile(s|)\)/gi
ftSA = /(foot|feet)\)/gi
ydSA = /yard(s|)\)/gi
inchSA = /(inch|inches)\)/gi
cmSA = /centimeter(s|)\)/gi
dmSA = /decimeter(s|)\)/gi
nmSA = /nanometer(s|)\)/gi

//weights/mass
lbSA = /(pound|pounds)\)/gi
gramSA = /(gram|grams)\)/gi
kgSA = /(kilogram|kilograms)\)/gi

//area
sqinSA = /squared inch(es|)\)/gi
sqftSA = /squared feet\)/gi
sqmtSA = /squared meter(s|)\)/gi
sqkmSA = /squared (kilometer|kilometer|kilometers|kilometres)\)/gi
sqcmSA = /squared centimeter(s|)\)/gi
sqmiSA = /squared mile(s|)\)/gi

//volume
cuinSA = /cubic inch(es|)\)/gi
cuftSA = /cubic (foot|feet)\)/gi
cumtSA = /cubic meter(s|)\)/gi
cukmSA = /cubic kilometer(s|)\)/gi
cucmSA = /cubic centimeter(s|)\)/gi
cumiSA = /cubic mile(s|)\)/gi

if(kmSA.test(wpTxt) || miSA.test(wpTxt) || ftSA.test(wpTxt) || ydSA.test(wpTxt) || cmSA.test(wpTxt) || nmSA.test(wpTxt) || inchSA.test(wpTxt) || dmSA.test(wpTxt) || lbSA.test(wpTxt) || gramSA.test(wpTxt) || kgSA.test(wpTxt) || sqinSA.test(wpTxt) || sqftSA.test(wpTxt) || sqmtSA.test(wpTxt) || sqkmSA.test(wpTxt) || sqcmSA.test(wpTxt) || sqmiSA.test(wpTxt) || cuinSA.test(wpTxt) || cuftSA.test(wpTxt) || cumtSA.test(wpTxt) || cukmSA.test(wpTxt) || cucmSA.test(wpTxt) || cumiSA.test(wpTxt)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/abbrev}}"
}

// --------------------
//checks that units are spelled out in text
// --------------------
kmSN = /km\s/gi
miSN = /\smi\s/gi
ftSN = /\sft\s/gi
ydSN = /yd\s/gi
cmSN = /cm\s/gi
dmSN = /dm\s/gi
nmSN = /nm\s/gi

//weights/mass
lbSN = /\slb\s/gi
gramSN = /\d\sg\s/gi
kgSN = /kg\s/gi

//area
sqinSN = /in<sup>2<\/sup>\s/gi
sqftSN = /ft<sup>2<\/sup>\s/gi
sqmtSN = /m<sup>2<\/sup>\s/gi
sqkmSN = /km<sup>2<\/sup>\s/gi
sqcmSN = /cm<sup>2<\/sup>\s/gi
sqmiSN = /mi<sup>2<\/sup>\s/gi

//volume
cuinSN = /in<sup>3<\/sup>\s/gi
cuftSN = /ft<sup>3<\/sup>\s/gi
cumtSN = /mt<sup>3<\/sup>\s/gi
cukmSN = /km<sup>3<\/sup>\s/gi
cucmSN = /cm<sup>3<\/sup>\s/gi
cumiSN = /mi<sup>3<\/sup>\s/gi

if(kmSN.test(wpTxt) || miSN.test(wpTxt) || ftSN.test(wpTxt) || ydSN.test(wpTxt) || cmSN.test(wpTxt) || nmSN.test(wpTxt) || dmSN.test(wpTxt) || lbSN.test(wpTxt) || gramSN.test(wpTxt) || kgSN.test(wpTxt) || sqinSN.test(wpTxt) || sqftSN.test(wpTxt) || sqmtSN.test(wpTxt) || sqkmSN.test(wpTxt) || sqcmSN.test(wpTxt) || sqmiSN.test(wpTxt) || cuinSN.test(wpTxt) || cuftSN.test(wpTxt) || cumtSN.test(wpTxt) || cukmSN.test(wpTxt) || cucmSN.test(wpTxt) || cumiSN.test(wpTxt)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/spellnum}}"
}

// --------------------
//checks for usage of standard abbreviations in parentheses (for conversions)
// --------------------
kmSN2 = /kms(\s|\))/gi
miSN2 = /mis(\s|\))/gi
ftSN2 = /\sfts(\s|\))/gi
ydSN2 = /yds(\s|\))/gi
inchSN2 = /\sins(\s|\))/gi
cmSN2 = /cms(\s|\))/gi
dmSN2 = /dms(\s|\))/gi
nmSN2 = /nms(\s|\))/gi

//weights/mass
lbSN2 = /lbs(\s|\))/gi
gramSN2 = /\sgs(\s|\))/gi
kgSN2 = /kgs(\s|\))/gi

if(kmSN2.test(wpTxt) || miSN2.test(wpTxt) || ftSN2.test(wpTxt) || ydSN2.test(wpTxt) || cmSN2.test(wpTxt) || nmSN2.test(wpTxt) || inchSN2.test(wpTxt) || dmSN2.test(wpTxt) || lbSN2.test(wpTxt) || gramSN2.test(wpTxt) || kgSN2.test(wpTxt)){
document.theForm.theResponse.value+="\n*When writing standard abbreviations, the abbreviations should not have a 's' to demark plurality (change kms to km and lbs to lb)."
}

// --------------------
// does not work; currently fixing
// --------------------
/*
km2 = /\d(\s|)(km|kilometer|kilometre)[^\}\s][^\(]/gi
mi2 = /\d(\s|)(mi|mile)[^\}\s][^\(]/gi
ft2 = /\d(\s|)(ft|foot|feet)[^\}\s][^\(]/gi
yd2 = /\d(\s|)(yd|yard)[^\}\s][^\(]/gi
//in2 = /\d(\s|)in[^\}\s][^\(]/gi
inch2 = /\d(\s|)in[^\}\s][^\(]/gi
cm2 = /\d(\s|)(cm|centi)[^\}\s][^\(]/gi
dm2 = /\d(\s|)(dm|decim)[^\}\s][^\(]/gi
nm2 = /\d(\s|)(nm|nano)[^\}\s][^\(]/gi

//weights/mass
lb2 = /\d(\s|)(lb|pound)[^\}\s][^\(]/gi
ton2 = /\d(\s|)(ton)[^\}\s][^\(]/gi
mton2 = /\d(\s|)(metric ton)[^\}\s][^\(]/gi
gram2 = /\d(\s|)(g\s|gram|g\))[^\}\s][^\(]/gi

//area
sqin2 = /\d(\s|)(in<sup>2<\/sup>|squared inches)[^\}\s][^\(]/gi
sqft2 = /\d(\s|)(ft<sup>2<\/sup>|squared feet)[^\}\s][^\(]/gi
sqmt2 = /\d(\s|)(m<sup>2<\/sup>|squared meter)[^\}\s][^\(]/gi
sqkm2 = /\d(\s|)(km<sup>2<\/sup>|squared kilo)[^\}\s][^\(]/gi
sqcm2 = /\d(\s|)(cm<sup>2<\/sup>|squared centi)[^\}\s][^\(]/gi
sqmi2 = /\d(\s|)(mi<sup>2<\/sup>|squared mile)[^\}\s][^\(]/gi

//volume
cuin2 = /\d(\s|)(in<sup>3<\/sup>|cubic inch)[^\}\s][^\(]/gi
cuft2 = /\d(\s|)(ft<sup>3<\/sup>|cubic feet)[^\}\s][^\(]/gi
cumt2 = /\d(\s|)(m<sup>3<\/sup>|cubic meter)[^\}\s][^\(]/gi
cukm2 = /\d(\s|)(km<sup>3<\/sup>|cubic kilo)[^\}\s][^\(]/gi
cucm2 = /\d(\s|)(cm<sup>3<\/sup>|cubic centi)[^\}\s][^\(]/gi
cumi2 = /\d(\s|)(mi<sup>3<\/sup>|cubic mile)[^\}\s][^\(]/gi

if(km2.test(wpTxt) || mi2.test(wpTxt) || ft2.test(wpTxt) || yd2.test(wpTxt) || cm2.test(wpTxt) || nm2.test(wpTxt) || inch2.test(wpTxt) || dm2.test(wpTxt) || lb2.test(wpTxt) || ton2.test(wpTxt) || gram2.test(wpTxt) || mton2.test(wpTxt) || sqin2.test(wpTxt) || sqft2.test(wpTxt) || sqmt2.test(wpTxt) || sqkm2.test(wpTxt) || sqcm2.test(wpTxt) || sqmi2.test(wpTxt) || cuin2.test(wpTxt) || cuft2.test(wpTxt) || cumt2.test(wpTxt) || cukm2.test(wpTxt) || cucm2.test(wpTxt) || cumi2.test(wpTxt)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/convert}}"
}
*/

// --------------------
//looks for unlinked dates
// --------------------
jan2= /\sJanuary\s(\d)(\d|)\D/gi
feb2= /\sFebruary\s(\d)(\d|)\D/gi
mar2= /\sMarch\s(\d)(\d|)\D/gi
apr2= /\sApril\s(\d)(\d|)\D/gi
may2= /\sMay\s(\d)(\d|)\D/gi
jun2= /\sJune\s(\d)(\d|)\D/gi
jul2= /\sJuly\s(\d)(\d|)\D/gi
aug2= /\sAugust\s(\d)(\d|)\D/gi
sep2= /\sSeptember\s(\d)(\d|)\D/gi
oct2= /\sOctober\s(\d)(\d|)\D/gi
nov2= /\sNovember\s(\d)(\d|)\D/gi
dec2= /\sDecember\s(\d)(\d|)\D/gi
if(jan2.test(wpTxt) || feb2.test(wpTxt) || mar2.test(wpTxt) || apr2.test(wpTxt) || may2.test(wpTxt) || jun2.test(wpTxt) || jul2.test(wpTxt) || aug2.test(wpTxt) || sep2.test(wpTxt) || oct2.test(wpTxt) || nov2.test(wpTxt) || dec2.test(wpTxt)){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/linkdate}}"
}

// --------------------
//date-th
// --------------------
var dateth = new Array(); var check_th = false;
dateth[0] = /(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)(th|st|nd|rd)/gi
dateth[1] = /\[\[(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)\]\](th|st|nd|rd)/gi
dateth[2] = /(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)<sup>(th|st|nd|rd)<\/sup>/gi
dateth[3] = /\[\[(january|february|march|april|may|june|july|august|september|october|november|december)\s\d(\d|)\]\]<sup>(th|st|nd|rd)<\/sup>/gi
dateth[4] = /\d(\d|)<sup>(th|st|nd|rd)<\/sup>\s(of\s|)(january|february|march|april|may|june|july|august|september|october|november|december)/gi
dateth[5] = /\d(\d|)(th|st|nd|rd)\s(january|february|march|april|may|june|july|august|september|october|november|december)/gi
		
for(i=0;i<dateth.length;i++){		//searches for above RegExps in document
	if(dateth[i].test(wpTxt)) check_th = true;
}

if(check_th)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/dateth}}";

// -------------------- --------------------
//checks for correct MOS heading styles
// -------------------- --------------------

// --------------------
//occurence of "the" at beginning
// --------------------
if(wpTxt.indexOf("==The ")!= -1 || wpTxt.indexOf("== The ")!= -1) document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/headingthe}}";

// --------------------
//existence of link in heading
// --------------------
regex_headlink = /==.{0,}\[\[.{1,}\]\].{0,}==/gi
if(regex_headlink.test(wpTxt))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/headinglink}}";

// --------------------
//checks if title is repeated in headings
// --------------------
var regex_headre = new RegExp("==.{0,}"+wgTitle+".{0,}==","gi")			//wgTitle is defined already as title of page
if(regex_headre.test(wpTxt))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/headingre}}"

// --------------------
//looks for ==trivia==, ==other facts==, ==miscellaneous==, etc.
// --------------------
var list_triv = new Array(/==(\s|)Trivia/gi,/==(\s|)Other\sf/gi,/==(\s|)Miscellaneous/gi,/==(\s|)Interesting\s/gi);
var check_triv = false;		//if true, found trivia section

for(i=0;i<list_triv.length;i++){if(list_triv[i].test(wpTxt)) check_triv = true;}	//for loop to ensure that each of the trivia
if(check_triv)																		//headings exist/don't exist
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/trivia}}";

// --------------------
//double checks if last sections follow WP:GTL in terms of order (see also - references - external links)
// --------------------
isgtl = true 

var Refsection = new Array("==Reference","==Source","==Footnote","==Cit","==Note","== Reference","== Source","== Footnote","== Cit","== Note")		
		//array to hold different possible names of the "references" section

var extlink_s = new Array("External link","External Link");
var extlink;
for(i=0;i<extlink_s.length;i++){
	if(wpTxt.indexOf(extlink_s[i])!=-1) extlink = extlink_s[i];		
}

var seealso_s = new Array("==See also","== See also","==See Also","== See Also");	//names for see also section
var seealso;
for(i=0;i<seealso_s.length;i++){
	if(wpTxt.indexOf(seealso_s[i])!=-1) seealso = seealso_s[i];						//find section see also
}

	//searching for headings against [[WP:GTL]]
if((wpTxt.indexOf(seealso) > wpTxt.indexOf(extlink)) && seealso && extlink)
	isgtl = false
for(i=0;i<Refsection.length;i++){
	if(wpTxt.indexOf(seealso) > wpTxt.indexOf(Refsection[i]) && wpTxt.indexOf(Refsection[i])!=-1 && seealso)
		isgtl = false
	if(wpTxt.indexOf(extlink) < wpTxt.indexOf(Refsection[i]) && extlink)
		isgtl = false
}

if(isgtl==false)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/gtl}}"

// --------------------
//looks for section named "List of..."					//not in use due to inaccuracy
// --------------------	
/*
list = /==(\s|)List/gi
if(list.test(wpTxt))
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/list}}"
*/

// --------------------	
//Checks if categories are in alphabetical order
// --------------------	
cat1 = /\[\[Category:.{1,}\]\]/gi
alphed = true; alphed2 = true;				 //first for [[WP:CAT]]s, [[WP:IL]]s
if(cat1.test(wpTxt)){
	theCats = wpTxt.match(cat1)				 //array to hold categories
	for(i=0;i<theCats.length;i++)
		theCats[i]=theCats[i].toLowerCase(); //moves categories to lower case
	
	//compares all cats to see if in alphabetical order
	for(i=0;i<theCats.length-1;i++){	     //compares all of the categories
		if(!(theCats[i+1]>theCats[i]))
			alphed = false					 //if any categories out of order
	}										 //set variable to false
}
else{										
document.theForm.theResponse.value+="\n*This article does not have any [[WP:CAT|categories]]. Please categorize it with relevant <code><nowiki>[[Category:Categories]]</nowiki></code>."	 //if no categories
}
					
il1 = /\[\[(.{2}|als|ang|frp|ast|zh-min-nan|pdc|ilo|jbo|nah|nrm|nds|sco|scn|simple|tpi|chr|vec|zh-yue):.{1,}\]\]/gi		//interlanguage links with
										//more than 2 letters; please add more if anymore exist

if(il1.test(wpTxt)){
	theIL = wpTxt.match(il1)				 //array to hold ILs
	for(i=0;i<theIL.length-1;i++){
		if(!(theIL[i+1]>theIL[i]))			 //compares all categories
			alphed2 = false					
	}
}
		//alphabetizing template (category template will only appear for those who desire it)
		//configurable variable: cat_PR (1/0)
if(!alphed && alphed2 && cat_PR)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/alpha|[[WP:CAT|categories]]}}"
if(!alphed2 && alphed)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/alpha}}"
if(!alphed && !alphed2 && !cat_PR)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/alpha}}"
if(!alphed && !alphed2 && cat_PR)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/alpha|[[WP:CAT|categories]] and [[WP:IL|interlanguage links]]}}"


// --------------------	
//looks at length of article:
// --------------------	

// --------------------	
//summary style -ToC and entire article-
// --------------------	
theLength = wpTxt.length
newHeading = /\n==/g
if(newHeading.test(wpTxt)){
	theSections = document.editform.wpTextbox1.value.match(/\n==/g)
if(theSections.length<=5)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/expand}}";
if(theSections.length>=24)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/toc}}";
if(theLength <= 7500 && theSections.length>5)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/expand}}";
}
else theSections = "none"

if(theLength<=7500 && theSections=="none")
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/expand}}"

if(theLength>=50000)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/SS}}"

// --------------------	
//looks for section-stub template
// --------------------	
//Template:sectstub, section stub, section-stub, sect-stub, stub-section
nosectstub = true;
var tempsectstub = new Array(/\{\{sectstub\}\}/gi,/\{\{sect-stub\}\}/gi,/\{\{section stub\}\}/gi,/\{\{section-stub\}\}/gi,/\{\{stub-section\}\}/gi);

for(s=0;s<tempsectstub.length;s++){
	if(tempsectstub[s].test(wpTxt)) nosectstub = false;
}

if(nosectstub==false)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/sectexpand}}";

// --------------------	
//looks for weasel words
// --------------------	
var ww = new Array(); var ww2 = new Array();
isww = false; awtstring = "";
ww[0] = "some people sa"
ww[1] = "it has been"
ww[2] = "many people have"
ww[3] = "many scientists believe"
ww[4] = "allege"
ww[5] = "many people sa"
ww[6] = "many people believe"
ww[7] = "arguably"
ww[8] = "it is claimed"
ww[9] = "correctly"
ww[10] = "apparently"
ww[11] = "people considered"
ww[12] = "many considered"
ww[13] = "is considered"
ww[14] = "are considered"

for(i=0;i<ww.length;i++) ww2[i] = new RegExp(ww[i],"gi")

Ref0 = /<ref/gi
Ref1 = /\{\{ref/gi
Ref2 = /\{\{fn/gi
Ref3 = /\{\{harv/gi
Ref4 = /\{\{Harv/gi

wpTxtawt = wpTxt; 	wwref = 300;	//wwref refers to the max. distance to search for a citation

for(i=0;i<ww.length;i++){
	while(ww2[i].test(wpTxtawt)){
		wpTxtawt = wpTxtawt.substring(wpTxtawt.indexOf(ww[i])+1,wpTxtawt.length);
		if(!(Ref0.test(wpTxtawt.substring(0,wwref)) || Ref1.test(wpTxtawt.substring(0,wwref)) || Ref2.test(wpTxtawt.substring(0,wwref)) || Ref3.test(wpTxtawt.substring(0,wwref)) || Ref4.test(wpTxtawt.substring(0,wwref)))){
			isww = true;
			if(awtstring.indexOf(ww[i]) == -1) awtstring=awtstring+"|''"+ww[i]+"''"
		}
	}
}

if(isww==true){
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/awt"+awtstring+"}} <!--This javascript cannot determine if a citation is provided; if all weasel terms are covered by citations, please strike this-->"
}

// --------------------	
//checks for redundancies - based on [[User:Tony1/How_to_satisfy_Criterion_2a#Redundancy]]
// --------------------	

redun1 = new Array()
redun1[0] = ""; redun1[1] = ""; redun1[2] = ""; redun1[3] = "";

additive = /(also|in\saddition|additionally|moreover|furthermore)/gi
if(additive.test(wpTxt)){
	theaddnum = wpTxt.match(additive)
	if((theaddnum.length>=8)&&(theaddnum.length >= wpTxt.length/2000)) redun1[0] = "1"	
}

vaguesize = /(some\s|a\svariety\sof|a\snumber\sof|a\smajority\sof|several|a\sfew|\smany|\sany\s|\sall\s)/gi
if(vaguesize.test(wpTxt)){
	thevsnum = wpTxt.match(vaguesize)
	if((thevsnum.length>=8)&&(thevsnum.length >= wpTxt.length/2000)) redun1[1] = "1"	
}

temporal = /(over\sthe\syears|currently|\snow\s|from\stime\sto\stime)/gi
if(temporal.test(wpTxt)){
	thetempnum = wpTxt.match(temporal)
	if(thetempnum.length>=6 && thetempnum.length >= wpTxt.length/2500) redun1[2] = "1"	
}

intheyear = /(in\sthe\syear|in\sthe\syear\sof)\s(\[\[|)(\d\d\d\d)/gi
if(intheyear.test(wpTxt)) redun1[3] = "1"; //exyear = RegExp.$3		

if((redun1[0]=="1") || (redun1[1]=="1") || (redun1[2]=="1") || (redun1[3]=="1")){
document.theForm.theResponse.value+="\n*Watch for [[User:Tony1/How_to_satisfy_Criterion_2a#Redundancy|redundancies]] that make the article too wordy instead of being crisp and concise. (You may wish to try Tony1's [[User:Tony1/How to satisfy Criterion 2a: redundancy exercises|redundancy exercises]].)"	
	
if(redun1[0]=="1")
	document.theForm.theResponse.value+="\n**While additive terms like “also”, “in addition”, “additionally”, “moreover”, and “furthermore” may sometimes be useful, overusing them when they aren't necessary can instead detract from the brilliancy of the article. This article has "+theaddnum.length+" additive terms, a bit too much."
	
if(redun1[1]=="1")
	document.theForm.theResponse.value+="\n**Vague terms of size often are unnecessary and redundant -  “some”, “a variety/number/majority of”, “several”, “a few”, “many”, “any”, and “all”. For example, “<font color='red'><s>All</s></font> pigs are pink, so we thought of <font color='red'><s>a number of</s></font> ways to turn them green.”"

if(redun1[2]=="1")
	document.theForm.theResponse.value+="\n**Temporal terms like “over the years”, “currently”, “now”, and “from time to time” often are too vague to be useful, but occasionally may be helpful. “I am <font color='red'><s>now</s></font> using a semi-bot to generate your peer review.”"

if(redun1[3]=="1")
	document.theForm.theResponse.value+="\n**“In <font color='red'><s>the year [of]</s></font> 1990”"
}

// --------------------	
//searches for footnotes
// --------------------	
var list_ref = new Array(/\<ref/gi,/\<ref/gi,/<ref/gi,/\{\{ref/gi,/\{\{fn/gi,/\{\{harv/gi,/\{\{Harv/gi);
var check_ref = 0;

if(list_ref[0].test(wpTxt) || list_ref[1].test(wpTxt)) check_ref=1;
else if(list_ref[2].test(wpTxt) || list_ref[3].test(wpTxt) || list_ref[4].test(wpTxt) || list_ref[5].test(wpTxt)) check_ref=2;
else check_ref=0

if(!check_ref)						// no footnotes
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/foot}}"
else if(check_ref==2)				//a method outside of the cite.php
	document.theForm.theResponse.value+="\n*You may wish to convert your form of references to the cite.php footnote system that [[WP:WIAFA]] 2(c) highly recommends."


// --------------------	
//checks footnote spacing following a period
// --------------------	
var list_sref = new Array(/<\/ref>\./gi,/\.\s<ref>/gi,/\{\{ref\|.{1,}\}\}\./gi,/\.\s\{\{ref\|.{1,}\}\}/gi,/\.\s\{\{fn\|.{1,}\}\}/gi,/\{\{fn\|.{1,}\}\}\./gi);
var check_sref = false;

for(i=0;i<list_sref.length;i++){
	if(list_sref[i].test(wpTxt)){check_sref=true; break;}
}

if(check_sref)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/footspace}}"

// --------------------	
//searches for reference section
// --------------------	
var list_refsect = new Array(/==(\s|)Reference/gi,/==(\s|)Source/gi,/==(\s|)Footnote/gi,/==(\s|)Cit/gi,/==(\s|)Note/gi);
var check_refsect = false;		//if check_refsect == true, then a reference section exists

for(i=0;i<list_refsect.length;i++){
	if(list_refsect[i].test(wpTxt)){check_refsect = true; break;}
}

if(!check_refsect)
	document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/ref}}"

// --------------------	
// looks for <nowiki>{{fact}} and {{citation needed}} </nowiki>	
// --------------------	
var list_fact = new Array(/\{\{fact\}\}/gi,/\{\{citation needed\}\}/gi);
var check_fact = false;

for(i=0;i<list_fact.length;i++){
	if(list_fact[i].test(wpTxt)){check_fact = true; break;}	
}

if(check_fact)
	document.theForm.theResponse.value += "\n*Please provide citations for all of the <code><nowiki>{{fact}}</nowiki></code>s.";

//all articles can always use copyediting:
document.theForm.theResponse.value+="\n{{subst:User:AndyZ/PR/copyedit}}"

//closing + signature
document.theForm.theResponse.value+=endMsg_PR;

// --------------------
// replacing template format with actual words; still in progress.
// replacing footnotes, still in progress
temp_mem = document.theForm.theResponse.value;
if(wgUserName != "AZPR"){
	if(defaultView_PR == 0){
		replaceTemp();
		replaceFoot();
	}
	else if(defaultView_PR == 2) replaceTemp();
}
// --------------------	

//show feedback
document.getElementById("theFeedback").style.visibility = "visible";

if(select_PR)				//selects suggestions, for easy copy+pasting
	document.theForm.theResponse.select();

//current date variables
    var current_date = new Date();
    var cur_month = current_date.getMonth();
    var cur_year = current_date.getFullYear();
    var y_abbrev = cur_year.toString().substring(2,4);
    var m_abbrev = new Array("J","F","M","A","MY","JN","JL","AU","S","O","N","D");
    var m_full = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

// --------------------	
//<nowiki> Summary on WP:PR/ 
// --------------------	

if((theTitle.indexOf("Wikipedia:Peer review")!=-1 || theTitle.indexOf("Wikipedia:WikiProject Military history/Peer review/")!=-1)&&(document.location.href.indexOf("/Automated")==-1)&&(document.editform.wpTextbox1.value.indexOf("*Please see [[User:AndyZ/peerreviewer.js|automated]] peer review")==-1))
{
document.editform.wpTextbox1.value += "\n*Please see [[User:AndyZ/peerreviewer.js|automated]] peer review suggestions [[Wikipedia:Peer review/Automated/"+m_full[cur_month]+" "+cur_year+"#"+theTitle2.substring(22,theTitle2.length)+"|here]]. Thanks, ~~~~"

// Add a tag to the summary box - ''stolen'' from [[User:Bobblewik]] 
    var txt = document.editform.wpSummary;
    var summary = "Automated peer review at [[WP:PRA/"+m_abbrev[cur_month]+y_abbrev+"#"+theTitle2.substring(22,theTitle2.length)+"]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}

thehide();
}

//</nowiki>

PRheader = /\{\{PR\-/gi
theArchive = ""

//<nowiki> - archiving of [[WP:PR/A|automated peer reviews]]
if(document.location.href=="http://en.wikipedia.org/w/index.php?title=Wikipedia:Peer_review/Automated&action=edit"){
	if(PRheader.test(document.theForm.theResponse.value)){
		thePRarticle = wpTxt.match(/===\[\[(.{1,})\]\]===/gi)
		for(i=0;i<thePRarticle.length;i++){
			if(document.theForm.theResponse.value.indexOf(thePRarticle[i].substring(5,thePRarticle[i].length-5))==-1){
				loc1 = wpTxt.indexOf(thePRarticle[i])
				wpTxt2 = wpTxt.substring(loc1+5,wpTxt.length)
				loc2 = ((wpTxt2.indexOf("===[[") < wpTxt2.indexOf("==Requests")) || (wpTxt2.indexOf("==Requests")==-1)) ? wpTxt2.indexOf("===[[") : wpTxt2.indexOf("==Requests")
				theArchive+="\n===[["
				theArchive+=wpTxt2.substring(0,loc2)
				document.editform.wpTextbox1.value = wpTxt.substring(0,loc1) + wpTxt2.substring(loc2,wpTxt2.length)
 				wpTxt = document.editform.wpTextbox1.value
			}
	}
	document.theForm.theResponse.value = theArchive
		
	// Add a tag to the summary box - ''stolen'' from [[User:Bobblewik]] 
    var txt = document.editform.wpSummary;
    var summary = "JS - [[Wikipedia:Peer review/Automated/Archive 1|archiving]] closed [[WP:PR|peer reviews]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
}			
}


//</nowiki>

//ending brace for first function
}
//

var temporprose = 0;     //if 0, convert to template, else, convert to prose
function determineReplace(){
     if(!temporprose) replaceProse();
     else replaceTemp();
     temporprose = !temporprose;
}

var footorremove = 0;      //if 0, add footnote, else remove them
function determineFoot(){
     if(!footorremove) replaceNoFoot();
     else replaceFoot();
     footorremove = !footorremove;
}

function replaceTemp(){			//replacing the textbox with the actual content of the templates, not just [[User:AndyZ/PR]] form
//temp_mem = document.theForm.theResponse.value;
//<nowiki>format: 
//document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/}}","g"),"{{subst:User:AndyZ/PR/}}"); 
//</nowiki>

//all templates containing parser functions have been commented temporarily 

document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/lead}}","g"),"*Please expand the lead to conform with guidelines at [[WP:LEAD]]. The article should have an appropriate number of paragraphs as is shown on [[WP:LEAD]], and should adequately summarize the article.");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/leadlong}}","g"),"*The lead of this article may be too long, or may contain too many paragraphs. Please follow guidelines at [[WP:LEAD]]; be aware that the lead should adequately summarize the article.");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/leaddetail}}","g"),"*The lead is for summarizing the rest of the article, and should not introduce new topics not discussed in the rest of the article, as per [[WP:LEAD]]. Please ensure that the lead adequately summarizes the article.");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/infobox}}","g"),"*There may be an applicable [[WP:INFOBOX|infobox]] for this article. For example, see [[Template:Infobox Biography]], [[Template:Infobox School]], or [[Template:Infobox City]].");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/contxt}}","g"),"*Per [[WP:CONTEXT]] and [[WP:MOSDATE]], months and days of the week generally should not be linked. Years, decades, and centuries can be linked if they provide [[WP:CONTEXT|context]] for the article.");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/linkdate}}","g"),"*Per [[WP:CONTEXT]] and [[WP:BTW]], years with full dates should be linked; for example, link [[January 15]], [[2006]], but do not link January 2006.");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/dateth}}","g"),"*As per [[WP:MOSDATE]], dates shouldn't use <sup>th</sup>; for example, instead of using ''[[January 30|January 30<sup>th</sup>]] was a great day'', use ''[[January 30]] was a great day''."); 
//document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/time}}","g"),"*Per [[WP:MOS#Time|WP:MOS]], avoid using words/phrases that indicate time periods relative to the current day. {{#if:{{{1|}}}|For example, ''{{{1}}}''}}{{#if:{{{2|}}}|{{#if:{{{3|}}}| ,|&nbsp;and}} ''{{{2}}}''}}{{#if:{{{3|}}}|{{#if:{{{4|}}}|,|, and}} ''{{{3}}}''}}{{#if:{{{4|}}}|{{#if:{{{5|}}}|,|, and}} ''{{{4}}}''}}{{#if:{{{5|}}}|{{#if:{{{6|}}}|,|, and}} ''{{{5}}}''}}{{#if:{{{6|}}}|, and ''{{{6}}}''}} {{#if:{{{1|}}}|might be terms that should be replaced with specific dates/times.}}<ref name='time'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/nbsp}}","g"),"*Per [[WP:MOSNUM#Units of measurement|WP:MOSNUM]], there should be a non-breaking space - <code>&amp;nbsp;</code> between a number and the unit of measurement. For example, instead of ''18mm'', use ''18&nbsp;mm'', which when you are editing the page, should look like: <tt>18&amp;nbsp;mm</tt>.<ref name='nbsp'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/spellnum}}","g"),"*Per [[WP:MOSNUM]], please spell out source units of measurements in text; for example, ''the Moon is 380,000 kilometres (240,000 mi) from Earth''.<ref name='spellnum'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/abbrev}}","g"),"*Per [[WP:MOSNUM]], when doing conversions, please use standard abbreviations: for example, miles -> mi, kilometers squared -> km<sup>2</sup>, and pounds -> lb."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/headingthe}}","g"),"*Per [[WP:MOS#Headings]], headings generally do not start with the word 'The'. For example, ''<nowiki>==The Biography==</nowiki>'' would be changed to ''<nowiki>==Biography==</nowiki>''."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/headingre}}","g"),"*Per [[WP:MOS#Headings]], headings generally should not repeat the title of the article. For example, if the article was [[Ferdinand Magellan]], instead of using the heading ''<nowiki>==Magellan's journey==</nowiki>'', use ''<nowiki>==Journey==</nowiki>''."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/headinglink}}","g"),"*As per [[WP:MOS#Headings|WP:MOS]], please do not [[WP:LINK|link]] words in headings."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/gtl}}","g"),"*Please reorder/rename the last few sections to follow guidelines at [[WP:GTL]]."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/overlink}}","g"),"*Consider removing links that add little to the article or that have been repeated in close proximity to other links to the same article, as per [[WP:MOS-L]] and [[WP:CONTEXT]]."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/underlink}}","g"),"*Consider adding more [[WP:LINK|links]] to the article; per [[WP:MOS-L]] and [[WP:BTW]], create links to relevant articles."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/footspace}}","g"),"*As done in [[WP:FOOTNOTE]], footnotes usually are located right after a punctuation mark (as recommended by the [[The Chicago Manual of Style|CMS]], but not mandatory), such that there is no space inbetween. For example, ''the sun is larger than the moon [2].'' is usually written as ''the sun is larger than the moon.[2]''"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/alpha}}","g"),"*Please alphabetize the [[WP:IL|interlanguage links]].<ref name='alpha'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/alpha|[[WP:CAT|categories]]}}","g"),"*Please alphabetize the [[WP:CAT|categories]].<ref name='alpha'>See footnote</ref>");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/alpha|[[WP:CAT|categories]] and [[WP:IL|interlanguage links]]}}","g"),"*Please alphabetize the [[WP:CAT|categories]] and [[WP:IL|interlanguage links]].<ref name='alpha'>See footnote</ref>");
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/ref}}","g"),"*The article will need references. See [[WP:CITE]] and [[WP:V]] for more information."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/foot}}","g"),"*This article needs [[WP:FOOTNOTE|footnotes]], preferably in the [http://meta.wikimedia.org/wiki/Cite/Cite.php cite.php] format recommended by [[WP:WIAFA]]. Simply, enclose inline citations, with [[WP:CITE]] or [[WP:CITE/ES]] information, with <nowiki><ref>THE FOOTNOTE</ref></nowiki>. At the bottom of the article, in a section named “References” or “Footnotes”, add <code><nowiki><div class=\"references-small\"><references/></div></nowiki></code>.<ref name='foot'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/noimg}}","g"),"*This article has no [[WP:IMAGE|images]]. Please see if there are any [[WP:IT|free use]] images that fall under [[WP:IUP]] and [[WP:IT]] that can be uploaded. To upload images on Wikipedia, go to [[Special:Upload]]; to upload non-[[WP:FU|fair use]] images on the [[Wikimedia Commons]], go to [[commons:special:upload]].<ref name='noimg'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/leadimg}}","g"),"*See if possible if there is a [[WP:IT|free use]] image that can go on the top right corner of this article.<ref name='leadimg'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/caption}}","g"),"*Per [[WP:WIAFA]], [[WP:IMAGE|Images]] should have concise captions.<ref name='caption'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/toc}}","g"),"*Per [[WP:WIAFA]], this article's table of contents (ToC) may be too long- consider shrinking it down by merging short sections or using a proper system of daughter pages as per [[WP:SS]].<ref name='toc'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/expand}}","g"),"*This article is a bit too short, and therefore may not be as comprehensive as [[WP:WIAFA]] critera 1(b) is looking for. Please see if anything can be expanded upon."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/SS}}","g"),"*This article may need to undergo [[WP:SS|summary style]], where a series of appropriate subpages are used. For example, if the article is [[United States]], than an appropriate subpage would be [[History of the United States]], such that a summary of the subpage exists on the mother article, while the subpage goes into more detail."); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/copyedit}}","g"),"*Please ensure that the article has gone through a thorough copyediting so that it exemplifies some of [[WP:WIAFA|Wikipedia's best work]]. See also [[User:Tony1/How to satisfy Criterion 1a]].<ref name='copyedit'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/list}}","g"),"*This article may be a bit list-weighty; in other words, some of the lists should be converted to prose (paragraph form).<ref name='list'>See footnote</ref>"); 
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(new RegExp("{{sub"+"st:User:AndyZ/PR/trivia}}","g"),"Generally, trivia sections are looked down upon; please either remove the trivia section or incorporate any important facts into the rest of the article."); 

//for footnote showing/hiding function:
foot_mem = document.theForm.theResponse.value;

// change the button's value
document.theForm.switch_temp.value = "Template form";
document.theForm.switch_temp.style.width = 150;
}

function replaceProse(){
document.theForm.theResponse.value = temp_mem;
document.theForm.switch_temp.value = "Prose form";
document.theForm.switch_temp.style.width = 150;
}
	
function replaceFoot(){					// removes the footnotes
//temp_mem = document.theForm.theResponse.value;	
//<nowiki>
document.theForm.theResponse.value = document.theForm.theResponse.value.replace(/<ref name='(\w{1,})'>See footnote<\/ref>/gi,"").replace(/<sup>\[\[User:AndyZ\/PRnotes#_note-(.{1,})\|(.{1,})\]\]<\/sup>/gi,"");
////																																										
// use link to WP:PR/A's footnotes: "<sup>[[User:AndyZ/PRnotes#_note-$1|$1]]</sup>"
////
//</nowiki>
document.theForm.switch_foot.value = "Show footnotes";
document.theForm.switch_foot.style.width = 150;
}

function replaceNoFoot(){				// shows the footnotes
if(wgUserName != "AZPR" || directRef_PR)				// will make into a configurable option
	document.theForm.theResponse.value = foot_mem.replace(/<ref name='(\w{1,})'>See footnote<\/ref>/gi,"<sup>[[User:AndyZ/PRnotes#_note-$1|$1]]</sup>");
else 
	document.theForm.theResponse.value = foot_mem;
document.theForm.switch_foot.value = "Remove footnotes";
document.theForm.switch_foot.style.width = 150;
}

function thehide(){
	document.getElementById("theFeedback").style.visibility = "hidden"
	document.getElementById("restore").style.visibility = "visible"
}

function theshow(){
	document.getElementById("theFeedback").style.visibility = "visible"
	document.getElementById("restore").style.visibility = "hidden"
}

//ideally the following function can be replaced by a menu
function addToPage(){
	replaceProse();	
	var faketarget;	//<nowiki>
	results_PR = document.theForm.theResponse.value;
	results_PR = results_PR.match(/\{\{subst:User:AndyZ\/PR\/(.*)\}\}/gi);
	for(i=0;i<results_PR.length;i++) results_PR[i] = results_PR[i].replace(/\{\{subst:User:AndyZ\/PR\/(.*)\}\}/gi,"$1");
								//</nowiki>
	
	var newPageName;
	var moveToPrompt = prompt("Move PR to: 1 - talk page  2 - article's peer review page  3 - personal sandbox  0 - Auto-PR page\tOr enter pagename","Enter the destination page name or a menu option")
	
	if(moveToPrompt.length == 1){ 
		faketarget = moveToPrompt + "," + wgTitle + "," + results_PR.join(",");
		fakeaction = "movePR";
	}
	else if(moveToPrompt.length > 1){
		faketarget = "9," + wgTitle + "," + results_PR.join(",");
	}
	
	if(moveToPrompt == "0"){		//add it to WP:PRA/?0?
		var cur_d = new Date(); var cur_yr = d.getFullYear(); var cur_m = d.getMonth();			//date elements
		newPageName = "Wikipedia:Peer_review/Automated/" + cur_m + "_" + cur_yr + "&section=2&fakeaction=movePR&faketarget="+faketarget;			
	}
	else if(moveToPrompt == "1")
		newPageName = "Talk:" + wgPageName +"&section=new&fakeaction=movePR&faketarget="+faketarget;
	else if(moveToPrompt == "2")
		newPageName = "Wikipedia:Peer review/" + wgPageName + "&fakeaction=movePR&faketarget="+faketarget;
	else if(moveToPrompt == "3")
		newPageName = userSandbox_PR + "&fakeaction=movePR&faketarget="+faketarget;	
	else if(moveToPrompt == null || moveToPrompt == "" || moveToPrompt == " " || moveToPrompt == "Enter the destination page name or a menu option") return;
	else
		newPageName = moveToPrompt + "&fakeaction=movePR&faketarget=" + faketarget;
	
	var newPage = window.open("http://en.wikipedia.org/w/index.php?title="+newPageName+"&action=edit")
	
		//do stuff on new pages
		/*
	if(moveToPrompt == "0"){
		newPage.document.getElementById('wpTextbox1').value = document.theForm.theResponse.value + newPage.document.getElementById('wpTextbox1').value;
		newPage.document.editform.wpSummary.value += " [["+wgTitle+"]]" 	
	}
	else if(moveToPrompt == "1"){
		newPage.document.getElementById('wpTextbox1').value = document.theForm.theResponse.value.replace(/===.*===/gi,"");
		newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions";
	}
	else if(moveToPrompt == "2"){
		newPage.document.getElementById('wpTextbox1').value += document.theForm.theResponse.value.replace(/===.*===/gi,"===JavaScript suggestions===");
		newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions";
	}
	else if(moveToPrompt == "3"){
		newPage.document.getElementById('wpTextbox1').value += document.theForm.theResponse.value;
		newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions";		
	}
	else{
		if(wgNamespaceNumber!=0){
			newPage.document.getElementById('wpTextbox1').value += document.theForm.theResponse.value;
			newPage.document.editform.wpSummary.value = "JavaScript peer review suggestions";
		}
		else alert("These suggestions should not be on an article page; please move them to a discussion page.");
	}	*/
}

//these functions auto-submit articles for WP:PR, modified from AutoVFD script 

function toReview1(){
	if(document.title.indexOf("Editing ") == 0) review1();
	else window.open('http://en.wikipedia.org/w/index.php?title='+wgPageName+'&action=edit&fakeaction=displayPR','Edit');	
}

function pr()
{
  var pagename = document.editform.action.substring(pagename.indexOf('title=') + 6,pagename.lastIndexOf('&action=submit'));

  window.open('http://en.wikipedia.org/w/index.php?title=Talk:' + unescape(pagename) + '&action=edit&fakeaction=prtemp','Talk', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');          
  window.open('/w/index.php?title=Wikipedia:Peer_review/' + unescape(pagename) + '&action=edit&fakeaction=prsub&faketarget=' + unescape(pagename),'PRnom', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');
  window.open('/w/index.php?title=Wikipedia:Peer_review&action=edit&fakeaction=prlist&faketarget=' + unescape(pagename), 'PRlisting', 'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}

function autopr()
{
  if (document.title.indexOf('Editing ') == 0)
    {
      var theaction = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                theaction = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
            }
        }
      if (theaction == 'prlist')
        {
          req = document.editform.wpTextbox1.value.indexOf("{{Wikipedia:Peer review/");
          document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.substring(0,req) + '{{Wikipedia:Peer review/' + target + '}}\n' + document.editform.wpTextbox1.value.substring(req,document.editform.wpTextbox1.value.length);
          document.editform.wpSummary.value = '[[Wikipedia:Peer review/' + target + ']]';
        }
      else if (theaction == 'prsub'){
          if (document.editform.wpTextbox1.value.length > 0)
              window.alert("There's an old peer review at the default location already.\n\n" +
                           'Please either move it out of the way (and update existing links to it), or file the PR by hand in another location (such as [[Wikipedia:Peer review/' + wgTitle.split("/")[1] + ' 2]]).');
          else
            document.editform.wpTextbox1.value += '===[[' + target + ']]===\n' +
              '<!--Reason for nomination.--> ~~' + '~~';
      }
      else if (theaction == 'prtemp'){
          if (document.editform.wpTextbox1.value.indexOf('{{peerreview}}') != -1)     
              window.alert("There has already been a peer review.");
          else{
              document.editform.wpTextbox1.value = '{{peerreview}}\n\n' + document.editform.wpTextbox1.value;
              document.editform.wpSummary.value = 'peer reviewing - [[Wikipedia:Peer review/' + target + ']]';
            }
        }
      else if (theaction == 'displayPR')
	    	    review1();
	  else if (theaction == 'movePR'){
			/*list_PR = target.split(",");
			if(list_PR[0] == 0){
				cur_txt = document.getElementById('wpTextbox1').value;
				document.getElementById('wpTextbox1').value = "===[[" + list_PR[1] + "]]===\n" + initMsg_PR + "\n";
				for(i=2;i<list_PR.length;i++)	//<nowiki>
					document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n"	
					//</nowiki>
				document.getElementById('wpTextbox1').value += document.theForm.theResponse.value+=endMsg_PR;
				document.getElementById('wpTextbox1').value += cur_txt;
				document.getElementById('wpSummary').value += "+ [["+list_PR[1]+"]]"
			}	  
			else if(list_PR[0] == 1){
				document.getElementById('wpTextbox1').value = "===[[" + list_PR[1] + "]]===\n" + initMsg_PR + "\n";
				for(i=2;i<list_PR.length;i++)	//<nowiki>
					document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n"	
					//</nowiki>
				document.getElementById('wpTextbox1').value += "document.theForm.theResponse.value+=endMsg_PR;
				document.getElementById('wpSummary').value = "JavaScript peer review suggestions"
			}
			else if(list_PR[0] == 2){
				document.getElementById('wpTextbox1').value += "\n\n===[[" + list_PR[1] + "]]===\n" + initMsg_PR + "\n";
				for(i=2;i<list_PR.length;i++)	//<nowiki>
					document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n"	
					//</nowiki>
				document.getElementById('wpTextbox1').value += "document.theForm.theResponse.value+=endMsg_PR;
				document.getElementById('wpSummary').value += "JavaScript-generated suggestions"
			}
			else if(list_PR[0] == 3){
				document.getElementById('wpTextbox1').value += "\n\n===[[" + list_PR[1] + "]]===\n" + initMsg_PR + "\n";
				for(i=2;i<list_PR.length;i++)	//<nowiki>
					document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n"	
					//</nowiki>
				document.getElementById('wpTextbox1').value += "document.theForm.theResponse.value+=endMsg_PR;
				document.getElementById('wpSummary').value += "JavaScript-generated suggestions for [[" + list_PR[1] + "]]";
			}
			else if(list_PR[0] == 9){
				if(wgNamespaceNumber == 0) alert("Please do not add these comments to an article; move them instead to a discussion page");
				else {
					document.getElementById('wpTextbox1').value += "\n\n===[[" + list_PR[1] + "]]===\n" + initMsg_PR + "\n";
					for(i=2;i<list_PR.length;i++)	//<nowiki>
						document.getElementById('wpTextbox1').value += "{{subst:User:AndyZ/PR/"+list_PR[i]+"}}\n"	
						//</nowiki>
					document.getElementById('wpTextbox1').value += "document.theForm.theResponse.value+=endMsg_PR;
					document.getElementById('wpSummary').value += "JavaScript-generated suggestions for [[" + list_PR[1] + "]]";
				}	
			}*/
		  
	  }
      else
        pr();
    }
}

if(!noSendTo_PR){
	addOnloadHook(function () {
	    if(document.forms.editform) {
	        addLink('p-cactions', 'javascript:autopr()', 'send to WP:PR', 'ca-peerreview', 'Submits article for peer review', '', '');
	    }
	});
}

if(document.location.href.indexOf("fakeaction") != -1)
	addOnloadHook(autopr);

//</pre> end

////////////////////////////////////////
/*List of things to do:
 // Determine the usage of commas with dates
 // <s>Determine the length of a lead (number of paragraphs)</s>
 // <s>Figure out if the lead is too short (1 paragraph) or too long (>=4 paragraphs), depending upon size of article</s>
 // <s>Determine if no-break spaces (&nbsp;) are used </s>
 // Determine if conversions are included
 // <s>Determine if standard abbreviations are used for conversions</s>
 // <s>Determine if units are spelled out in text</s>
 // <s>Determine if last few sections (see also, references, notes, external links) follow [[WP:GTL]]</s>
 // Determine if extraneous bolding is used
 // <s>Determine if categories and interlanguage links are alphabetized</s>
 // Determine if quotes have sources
 // Prove that images have proper image copyright tags
 // Show that all fair use images have proper fair use rationales
 // <s>Determine if all images have captions</s>
 // <s>Find out the number of sections</s>
 // Determine if sections or paragraphs are too short 
 // Determine if a list is used
 // <s>Determine if footnote spacing standards are used (as in [[WP:FOOTNOTE]])</s>
 // Determine if words in headings are capitalized
 // Find common [[User:Tony1/How to satisfy Criterion 2a|redunancies]]
 // <s>Time/future issues</s>
 // Check w/ U:SUGG to see if any other things are missing
 // <s>Automatic archiving</s>
 // Improving efficiency
 
 // Help out with [[WP:FL]]
 // Maybe [[WP:FPO]]?
 // simple links for easy copy+paste into sandboxes, talk pages, or [[WP:PR/A]] **
 // instaview version (somewhat like [[User:Pilaf]]'s, possibly) **
 // improving look 
 // embedding solutions beneath text, possibly (using innerHTML property) **
 // more configurable options that will be helpful to users

Second priority issues:
 // Add to list of units (for units, conversions, and standard abbreviations)
 // Add to list of weasel words
 // Improve the headingre function to exclude "the" and words in parentheses
 // infoboxes...
*/

// <pre> Specific to: User:AZPR (this simplifies the process of maintaining [[WP:PR/A]] - 
// to use this, inquire on [[User talk:AndyZ/peerreviewer.js]])
if(wgUserName == "AZPR"){
if((document.location.href.indexOf("http://en.wikipedia.org/w/index.php?title=Wikipedia:Peer_review/")!=-1) && (document.location.href.indexOf("section=1")!=-1) && (!(document.location.href.indexOf("Automated")!=-1))){
//mem = document.getElementById("wpTextbox1").value
$(review1);
//if(mem != document.getElementById("wpTextbox1").value) document.editform.submit();
}

if((document.location.href.indexOf("action=edit")!=-1) && (document.location.href.indexOf("WP:PR")==-1) && (document.location.href.indexOf("Wikipedia:")==-1)){
$(review1);
}
}

/*  /////////////////
    // Note:
    // I am quite aware 
    // that the layout and documentation
    // of my coding is pretty terrible;
    // feel free to edit this page
    // and help clean it up
    
    // (for non-admins, leave a note on the talk page)
    //
    
    // Please be aware that changes
    // may affect many users
    /////////////////
    
    [[Category:Wikipedia tools]]
*/

//cut out code can be found at [[User:AndyZ/peerreviewer.js/comment]]