var lolopt = true; // LULZ ARE DORMANT

if(window.location.href.indexOf('rplol=rofl') > 0){ lolopt = false }

rpf = 11125

function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); }
function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); }
function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); }
function ptrim(stringToTrim) { return stringToTrim.replace(/\.$/,""); }

function getrebuke(text)
{ text = trim(text)
  rebuke = "" 
  if(text.match(/\!+$/)){ rebuke = " "+ retrieve_loretext(0)} 
  else if (text.match(/\?+$/)){ rebuke = " "+ retrieve_loretext(1)} 
  else if (text.match(/\.{3}$/)){ rebuke = " "+ retrieve_loretext(6)} 
  else rebuke = ", "+ retrieve_loretext(2)
  return rebuke;
	}

lorearray = [
                [ "exclaimed CHAR, angrily wiggling HIS TARGET at onlookers!","HE yelled, feverishly plumbing HIS pockets for change!","screamed CHAR, feeling a sharp, stabbing pain in HIS TARGET!","HE shouted, shaking HIS mighty fist in anger!", "frothed CHAR, daintily stamping HIS foot in frustration.", "CHAR bawled, hot tears of secret shame tumbling down HIS face.", "intoned CHAR, jowels shaking furiously, sending bits of gravy flying wildly!","HE growled gutturally into the codec.","opined CHAR, knowing in HIS heart that HE'd always be a triple-threat."
                 ],
                ["pondered CHAR as HE groped around in the darkness for the stifling comfort of HIS trusted companion.","wondered CHAR aloud. HE then went to HIS mystical chest to retrieve HIS TARGET, and bade it sleep 'til the morrow.","queried CHAR quizzically.","HE wondered, savoring the delicate taste of gravitas.", "CHAR asked, causing the strange bear to run up and strike HIM in the face!", "CHAR mused, HIS mind a swirling miasma of scintillating thoughts and turgid ideas.","HE postulated wildly.","questioned CHAR."
                 ],
                ["HE said to no one in particular.", "HE said whimsically to HIS TARGET.", "HE said, brushing back a lock of silvery hair.","HE said, putting on HIS robe and wizard's hat.", "HE concluded, cast to the wastes of REALM.","HE uttered, finding only one word to sum up HIS feelings: SCRUMTRILESCENT.",
                 "HE remarked, HIS leather corset beginning to chafe uncomfortably.","HE declared, as HE pondered the ridiculous possibility of adding another pizza for just 25 copper more.","HE stated, as HE liberally applied HIS custom fragrance, which was made with bits of real nightsaber.","HE said with an air of nonchalance.","said CHAR, hair dancing madly in the summer wind.","HE said with a half-smile, half-frown, half-smirk.","said CHAR without remorse."

                 ],
                ["CHAR's brow furrowed in concentration as HE studied the blueprints of the orc fortress.",
"Astride HIS mighty nightsaber, CHAR rode through the moonlit forests of REALM as an unexplainable itching sensation began to overtake HIM.",
"Sweat glistening off HIS furrowed brow, CHAR crouched low in a battle stance, poised to strike.",
"Drops of dew glistened off CHAR's bare shoulders in the moonlight, which stood in sharp contrast to the evidence of fresh bite marks.",
"The black cloak HE wore fluttering against the cold wind, CHAR moved through the empty streets of Dalaran in search of a mythical Blowbough.",
"As HE walked towards the market eating the exotic fruit, HIS mind tarried on the RACE in HIS dreams.",
"In the near-darkness, CHAR quickly changed into HIS garb of choice - a leather belt which bestowed four measures of both strength and stamina. HUNGGGHH HUNNNNGGHHH",
"Simultaneously, the hairs on the back of CHAR's neck stood on end, beads of sweat appeared on HIS forehead, and HIS brow furrowed.",
" In HIS dreams, a drifting CHAR tried to reach for the fluctuating shape, but it vanished just as HE almost caught it.","Readying HIS best moves, CHAR hoped the \"Iron Lotus\" would be enough to secure that final quarter star."

],
                ["Mopping the dew from HIS moist visage, HE looked to the sky and waved HIS TARGET.",
                 "And so CHAR continued on HIS fateful journey, sliding perilously down the dripping, gaping maw of fate as if it were a waterslide.",
                 "As night fell, CHAR and HIS boon companions withdrew to the safety of the hills - where they would be free from the clutches of the Wolfoids &hellip; for now.",
                 "And so, CHAR turned HIS attention to other matters.",
                 "But HIS efforts were for naught; as HIS hair was a bird, HE found HIS point to be invalid.",
                 "And so CHAR sailed away on HIS magnificent craft, HIS nautical-themed pashmina Afghan flapping in the salty breeze.",
                 "As HE left the Moonglade, CHAR heard the lilting elvish melody descend from leaf, branch and bough:<br/><em>~ ten' lle ier urra ar' lle ier cold / you ier uma ar' lle ier no / you ier e' ar' lle ier out / you ier de ar' lle ier ndu ~</em>", 
				 "CHAR looked over HIS shoulder, motioning that HE still had one thing up HIS sleeve &hellip; make that three things &hellip; on each hand, so, like, six things total.","CHAR was suddenly surrounded by a gang of sharks, a cracked bat as HIS only protection!"
                 ],
                ["CHAR's features twisted in agony and HE managed to spit,", "Summoning all of HIS courage, CHAR roared,", "A single tear rolled down CHAR's face as HE mournfully intoned,", "CHAR loosened HIS blade in its scabbard.", "CHAR loosened HIS blade in its scabbard.", "CHAR forced HIMself to continue.","An uncomfortable tingle rand up and down CHAR's spine.", "Eyes bulging, CHAR was at a loss.", "Pointing the ice cream cone aggressively, CHAR mananged to utter,"
],
                [ "HE trailed off.","mumbled CHAR to no one in particular.", "HE said, eyes glazed over in a stare not unlike stale porridge.", "HE said, nodding listlessly to some unseen rhythm.","said CHAR wistfully."
                 
                ]
                ]



targetobjects = ["trusted companion","britches","savory morsel","many bladed razor, perfect for smoothing HIS jagged features", "favored blunt weapon, Stumpy","wand","stuffed bear, Colin","mighty fist", "feline companion, Mr. Fiddlebritches","Franklin Badge"]

function getTarget() { return targetobjects[Math.floor(Math.random()*(targetobjects.length))] }

function retrieve_loretext(rtype) { return lorearray[rtype][Math.floor(Math.random()*(lorearray[rtype].length))].replace(/TARGET/g,getTarget).replace(/CHAR/g,yon_hero).replace(/HIS/g,possess).replace(/HE/g,third).replace(/HIM/g,dobject).replace(/RACE/g,race).replace(/REALM/g,realm); }

function getBeginning() { return retrieve_loretext(5) + " " }
function getflavor(first){ fair_class = (first)?"class='dropcappe'":""; flavtarg=(first)?3:4; return "<p "+fair_class+">"+ retrieve_loretext(flavtarg) +"</p>" }

function arrpee(yeoldeposition)
{ getok() 
 
if(global_nav_lang == "en_us" && !lolopt){ 

if(document.getElementById('rp_'+yeoldeposition))
	{ yon_post = document.getElementById('rp_'+yeoldeposition);
	  innards = yon_post.innerHTML.split("<br>"); 
	  for(p in innards) { 
	  
	  if(innards[p].length > 3 && innards[p].indexOf("blockquote>")<0 && innards[p]!="[b][/b]" ) {
	  intro = (Math.random()*1000>800)?getBeginning():""
	  innards[p] = "<p>"+intro+"&ldquo;"+ ptrim(trim(innards[p])).replace(/\"|“|”/g,"'").replace(/\<pre\>|\<\/pre\>/g,"") + "&rdquo;"+getrebuke(innards[p])+"</p>" 
	   }
	  if(innards[p] == "<br>") { innards[p]=""}
	  }
	  yon_post.innerHTML = getflavor(true) + innards.join("") + getflavor();

	}
  }
}

function getok() {  if(!lolopt) lolopt = (currforum == "11112" || currforum == "11110" || currforum == "10023" || currforum == "11111" || currforum == "11113" || currforum == "11572")?true:false }

function getlol() { return lolarray[Math.floor(Math.random()*(lolarray.length))] }

function lulz(pos){ //The Lulz. Do it for them.

/* added to thread.ftl
currforum = ${selectedForum.id}
lolstring = "<fmt:message key="lol"/>"
*/

if(global_nav_lang == "en_us" && !lolopt){ 

lolarray = lolstring.split(", ");

if(document.getElementById('lol'+pos)){
targlol = document.getElementById('lol'+pos);

if(targlol.innerHTML.match(/(\.\s|\?\s|\!\s)/g)){

if(targlol.innerHTML.match(/(\.\s)/g)){
loldot = (targlol.innerHTML.match(/(\.\s)/g)>200)?200:targlol.innerHTML.match(/(\.\s)/g)
for(i=0; i<loldot.length; i++) { targlol.innerHTML = targlol.innerHTML.replace(/(\.\s)/, " " + getlol() + ".&nbsp;");} }

if(targlol.innerHTML.match(/(\?\s)/g)){
lolq = (targlol.innerHTML.match(/(\?\s)/g)>200)?200:targlol.innerHTML.match(/(\?\s)/g)
for(i=0; i<lolq.length; i++) { targlol.innerHTML = targlol.innerHTML.replace(/(\?\s)/, " " + getlol() + "?&nbsp;");} }

if(targlol.innerHTML.match(/(\!\s)/g)){
lolexc = (targlol.innerHTML.match(/(\!\s)/g)>200)?200:targlol.innerHTML.match(/(\!\s)/g)
for(i=0; i<lolexc.length; i++) { targlol.innerHTML = targlol.innerHTML.replace(/(\!\s)/, " " + getlol() + "!&nbsp;");} }

}

targlol.innerHTML += "<br/><br/>" + lolarray[0] + ". "

}

}


}