//Code by Slaytanist, Slayer766, Fierce
//some code taken from "Simple Money Hack" by Gornakle
//DO NOT STEAL WITHOUT PERMISSION - thou wilst be smited
//Modifications must include this copyright !at the top!
//http://s15.invisionfree.com/RPGHaven/
//http://s12.invisionfree.com/World_Of_Starcraft/
//http://s13.invisionfree.com/Hamsoft/
//END OF COPYRIGHT



itemlist["nothing"]=[3500,"scimitar2.gif", "http://slaytanist.viracocha.co.uk/RPG_Stuffs/swordofdeathplustwenty.gif", "nothing","A sword forged from pure solid gold."," ",0,0,1,1,"Monkery",1,1,0,0,0,0,0,0,0];
classes["NoClass"] = ["No Class",1,0,0,0,0,NoClassPic,false,NoClassPic,NoClassPic,NoClassPicF,NoClassPicF,NoClassPicF,""]

var lastWinner = [];
var lastJackpot = [];

var nextDraw = "Tommorrow";
var lastDraw = "Nevar!";
var DrawTime = "Whenever";

lastWinner[0] = "NA";
lastWinner[1] = "NA";
lastWinner[2] = "NA";
lastWinner[3] = "NA";
lastWinner[4] = "NA";

lastJackpot[0] = "NA";
lastJackpot[1] = "NA";
lastJackpot[2] = "NA";
lastJackpot[3] = "NA";
lastJackpot[4] = "NA";

var BiggestEverJackpot = "0";

var rawr = "";

var MID=[];
var ticket=[];
var BoughtTicket=[];
var ticketsSold = 0;
var itamz=[];
var cats=[];
var banked=[];
var XP=[];
var uclass=[];
var posts=[];
var reputation=[];
var repped=[];
var Richest=[];
var fight=[];
var MemberNum=[];
var PMs=[];
var level=[];
var results=[];
var theresults=[];

var BattlesWon=[];
var BattlesLost=[];
var Gender=[];
var Auction=[];
var Stats=[];

var itemboxno = 0;
var mymembernum = 0;
var numpms = 0;

var theskirmish="";

var theMOTD = "None";
var MOTDsetter = "No one";

var alsodone = 0;
var BoughtURLs=[];

var preline=[];
preline[0]="mutters darkly"
preline[1]="screams unto the winds"
preline[2]="turns their gaze to the heavens and yells"
preline[3]="exhults"
preline[4]="yells"
preline[5]="screams"
preline[6]="shouts victoriously"
preline[7]="glances at the body before them and mutters"
preline[8]="turns and yells"
preline[9]="looks closely at the body and says"
preline[10]="wipes the defeated's pathetic blood from their hand and mumbles"

var line=[];
line[0]="Aybabtu!"
line[1]="I have not seen such bravery!"
line[2]="Seeing you in action is a joke."
line[3]="Omfg n00b!"
line[4]="Have we learnt the lesson from today?"
line[5]="Mess with the best, die like the rest!"
line[6]="Remembering why you lost is more important than winning."
line[7]="What's that? You can't lose? Hah hah hah, heard it all before!"


//Various one-liners contributed by JoeyJo0, Thesilentpyro, CSPhilips and Aznshorty67


if (location.href.indexOf("?") != -1)
var BaseURL = location.href.split("?")[0];
else
var BaseURL = location.href;
var RBUrl = BaseURL + "?act=battles";
var StoreURL = BaseURL + "?act=store";
var PMUrl = BaseURL + "?act=Msg&CODE=4"
var searchurl = ShowTopicURL + "&st=";


 skirmishpic = "<img src='http://slaytanist.viracocha.co.uk/RPG_Stuffs/rpgskirm.gif'>"

isAdmin = 0;
a = document.getElementById("userlinks");
b = a.getElementsByTagName("A");
if (b[0])
if (b[0].href.indexOf("Login") == -1)
{
theUrl = b[0].href;
usar = b[0].innerHTML;
}
for (i=0;i<b.length;i++)
if (b[i].href.match("admin"))
isAdmin = 1;
mymembernum = theUrl.split("showuser=")[1];


if(top.location==location)
{
if (location.href.indexOf("act=lottery") != -1)
{
a = "<div class='borderwrap'>"
a += "<table width='100%'>"
a += "<tr>"
a += "<td width='25%' valign='top'>"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Navigation</div>"
a += "<div class='row4'><br /><a href='"+BaseURL+"?act=lottery'>Main</a> | <a href='"+BaseURL+"?act=idx'>Forum</a> | <a href='"+BaseURL+"?act=winners'>Recent Winners</a><br>"
a += "<br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Drawing Time</div>"
a += "<div class='row4'><br /><b>All drawings are daily at #Time#</b><br>"
a += "<br>"
a += "Current Time: <b>"+Date();
a += "</b><br>"
a += "<br>"
a += "Next Drawing: #Time#<br>"
a += "<br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> <b><i>STATUS</b></i></div>"
a += "<div class='row4'><br />"
a += "» <b>Total Jackpot worth:</b> #Money#<br>"
a += "» Largest Jackpot ever: #Money#<br>"
a += "* Tickets add $5 to Jackpot.<br>"
a += "<br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Purchase Ticket</div>"
a += "<div class='row4'><br /><br><center>Ticket Cost: $10<br>"
a += "+-----+<a href='javascript:PostIt()'><u>Click Here</u></a>+-----+<br /></center>"
a += "<br><br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Debug Info</div>"
a += "<div class='row4'><br />If there are any bugs that you encounter with using the Lottery Drawing PM an <a href='"+BaseURL+"?act=Msg&CODE=4&MID=1'><u>Administrator</u></a> and we will take care of it."
a += "<br><br /></div>"
a += "</div>"
a += "<br />"
a += "<div id='lottery_draw'></div>"
a += "</td>"
a += "<td width='85%' valign='top'>"
a += "<center><div class='tablepad' style='border:4px solid gray'>"
a += "<b><h3>.::Welcome to the Lottery Drawing::.</h3><br>"
a += "<table border='2'>"
a += "<tr>"
a += "  <td><span style='color:blue'>Current Money: $Current</span></td>"
a += "</tr>"
a += "</table><br>"
a += "<h3><b><u>How the Lottery Works</h3></b></u>"
a += "The text below will tell you exactly how this Lottery works."
a += "<p>"
a += "<b>Basically its just a regular old lottery drawing. Everyone pays into the jackpot, one out of all the people that participated gets the money in the jackpot. The jackpot starts at $100, and tickets costs $10 (+5 to the jackpot)."
a += "<p>"
a += "Double accounts are against the rules. Using multiple accounts to enhance your odds of winning -might- just get you a warn, or suspended depending on how an Admin feels about it. Attempting to exploit a vulnerability in the code is definate grounds for a ban.</b>"
a += "<br>"
a += "<br>"
a += "<br>"
a += "<fieldset><legend><span style='color:blue'>Previous Winner</span></legend><br>"
a += "Member: $name<br>"
a += "Money Won: $earned<br>"
a += "</fieldset><br></div>"
a += "<center>Script hosted by <a href='https://www.ixwebhosting.com/cgi-bin/affiliates/clickthru.cgi?id=rpghaven'>IX Webhosting</a></center>"
theBoard.innerHTML = a;
}
else if (location.href.indexOf("act=store") != -1)
{
a = "<div class='tableborder'>"
a += "  <div class='maintitle'>Store v4</div>"
a += "  <div class='tablepad'><br>"
a += "<div class='tableborder'>"
a += "<div class='maintitle' align='center'></div>"
a += "<div class='row1'></div><div class='tableborder'>"
a += "<br>"
a += "<div class='borderwrap'>"
a += "<table width='100%'>"
a += "<tr>"
a += "<td width='25%' valign='top'>"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Navigation</div>"
a += "<div class='row4'><br /><a href='"+BaseURL+"?act=store'>Main</a> | <a href='"+BaseURL+"?act=idx'>Forums</a>  | <a href='"+BaseURL+"?act=richest'>Richest Members</a><br>"
a += "<br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Menu</div>"
a += "<div class='row4'><br /><center><b>Your money: <span id='thecash'></span></b></center><br>"
a += "<B>Current Time:</b>"
a += "<div style='color:'>"+Date()+"</div>"
a += "</div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> <b>Bank</b></div>"
a += "<div class='row4'><br />"
a += "» <a href='javascript:BankIt()'>Deposit</a><br>"
a += "» <a href='javascript:WithdrawIt()'>Withdraw</a><br>"
a += "<br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> <b>Store categories</b></div>"
a += "<div class='row4'><br />"
a += "<div id='tehcats'>"
a += "</div>"
a += "<br />"
a += "</div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Debug Info</div>"
a += "<div class='row4'><br />If there are any bugs that you encounter with using the Automated Store Hack v4 PM an <a href='"+BaseURL+"?act=Members&max_results=30&filter=4&sort_order=asc&sort_key=name&st=0'><u>Administrator</u></a> and we will take care of it."
a += "<br><br /></div>"
a += "</div>"
a += "<br />"
a += "<div id='lottery_draw'></div>"
a += "</td>"
a += "<td width='85%'  valign='top'>"
a += "<center><DIV class=tablepad style='border:4px solid gray'>"
a += "<b><h3><br><!-- Blue Box Code made by IF Board //-->"
a += "<table align='center' width='45%' cellspacing='6' id='userlinks'>"
a += "<tr>"
a += "<td><div align='center'>Welcome to the Automated Store v4</div></div></td></tr></table>"
a += "<div class='borderwrap'></b></h3><br>"
a += "<br>"
a += "<br><table width='450' border='4' id='tehtabel'>"
a += " <tr>"
a += "  <th align='left' width='50%'>Item Name</th>"
a += "  <th align='left' width='10%'>Icon</th>"
a += "  <th align='left' width='20%'>Stock</th>"
a += "  <th align='left' width='20%'>Item Price</th>"
a += " </tr>"
a += " <tr class='darkrow2'>"
a += "  <td align='left'> </td>"
a += "  <td align='center'> </td>"
a += "  <td align='right'> </td>"
a += "  <td align='right'> </td>"
a += " </tr>"
a += "</table>"
a += "<table width='450' border='4'>"
a += " <tr height='100px'>"
a += "  <td align='middle' width='100px' id='tehitempix'> </td>"
a += "  <td align='right' id='tehitemdesc'> </td>"
a += " </tr>"
a += "</table>"
a += "<br>"
a += "<br></div>"
a += "<center>Script hosted by <a href='https://www.ixwebhosting.com/cgi-bin/affiliates/clickthru.cgi?id=rpghaven'>IX Webhosting</a></center>"
theBoard.innerHTML = a;
}
else if (location.href.indexOf("act=winners") != -1)
{
a = "<div class='tablepad'><center>Hello, $user. Welcome to $board's Lottery Hack: Recent Winners. You $choice(have/have not) been a recent winner.</center>"
a += "<table align='center' border='0'><tr><td>"
a += "<div class='tableborder'>"
a += "<div class='maintitle' align='left' style='text-align:left'><img src='http://67.18.37.15/style_images/1/nav_m.gif' border='0' alt='>' width='8' height='8' />Recent Winners</div>"
a += "<div class='titlemedium'>Members</div>"
a += "<table width='50%' border='0' cellspacing='1' cellpadding='4'><tr><td class='row1'>"
a += "<center><table border='2'>"
a += "<tr>"
a += "  <td>Automated Lottery Hacks <b>Recent Winners</b></td>"
a += "</tr>"
a += "</table></center>"
a += "<br>"
a += "<br>"
a += "<br><table width='450' border='4'>"
a += " <tr>"
a += "  <th align='left'>Recent Winners</th>"
a += "  <th align='left'>Money Won</th>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 1</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 2</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 3</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <th align='left'></b>Member 4</th>"
a += "  <th align='left'>$0</th>"
a += " </tr>"
a += "</table>"
a += "<br>"
a += "<br><fieldset><legend><i>Options</i>:</legend>"
a += "<a href='index.php?act=Login&CODE=03'/>"
a += "<b>>>Logout<<</b></a><br>"
a += "<a href='"+BaseURL+"?act=lottery'><b>>>Back to Lottery<<</b></a></fieldset>"
a += "</td>"
a += "</tr>"
a += "</table>"
a += "</div>"
a += "</td></tr></table>"
a += "</div></tr></td></div></div></table></div>"
theBoard.innerHTML = a;
}
else if (location.href.indexOf("act=richest") != -1)
{
a = "<div class='tablepad'><center>Hello, $user. Welcome to $board's Lottery Hack: Richest Members. You $choice one of the five richest members.</center>"
a += "<table align='center' border='0'><tr><td>"
a += "<div class='tableborder'>"
a += "<div class='maintitle' align='left' style='text-align:left'><img src='http://67.18.37.15/style_images/1/nav_m.gif' border='0' alt='>' width='8' height='8' />Richest Members</div>"
a += "<div class='titlemedium'>Members</div>"
a += "<table width='50%' border='0' cellspacing='1' cellpadding='4'><tr><td class='row1'>"
a += "<center><table border='2'>"
a += "<tr>"
a += "  <td>Automated Lottery Hacks <b>Richest Members</b></td>"
a += "</tr>"
a += "</table></center>"
a += "<br>"
a += "<br>"
a += "<br><table width='450' border='4'>"
a += " <tr>"
a += "  <th align='left'>Richest Members</th>"
a += "  <th align='left'>Money Banked</th>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 1</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 2</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 3</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <td align='left'>Member 4</td>"
a += "  <td align='left'>$0</td>"
a += " </tr>"
a += " <tr>"
a += "  <th align='left'></b>Member 5</th>"
a += "  <th align='left'>$0</th>"
a += " </tr>"
a += "</table>"
a += "<br>"
a += "<br><fieldset><legend><i>Options</i>:</legend>"
a += "<a href='index.php?act=Login&CODE=03'/>"
a += "<b>>>Logout<<</b></a><br>"
a += "<a href='"+BaseURL+"?act=store'><b>>>Back to the Store<<</b></a></fieldset>"
a += "</td>"
a += "</tr>"
a += "</table>"
a += "</div>"
a += "</td></tr></table>"
a += "</div></tr></td></div></div></table></div>"
theBoard.innerHTML = a;
}
else if (location.href.indexOf("act=battles") != -1)
{
a = "<table cellspacing='0' cellpadding='0' width='100%'>"
a += "<tr>"
a += " <td id='ucpmenu' valign='top'>"
a += "    <div class='maintitle'>Menu</div>"
a += "	 <div class='pformstrip'>Personal Links</div>"
a += "	 <p>"
a += "	 · <b><a href='"+BaseURL+"?act=store'>Store</a></b><br />"
a += "	 · <b><a href='"+BaseURL+"?act=lottery'>Lottery</a></b><br />"
a += "         · <b><a href='"+BaseURL+"?act=richest'>Richest Members</a></b><br />"
a += "         · <b><a href='"+BaseURL+"?act=winners'>Recent Winners</a></b><br />"
a += "         · <b><a href='"+BaseURL+"?act=skirmish'>Skirmish</a></b><br />"
a += "	 </p>"
a += "         <div class='pformstrip'>Fighters</div>"
a += "	 <p>"
a += "	 <div id='TehFightars'></div>"
a += "	 </p>"
a += " </td>"
a += " <td style='padding:2px'><!-- --></td>"
a += " <td id='ucpcontent' valign='top'>"
a += "  <div class='maintitle'>Battle Statistics</div>            <div class='pformstrip'></div>"
a += "     <table border='0' cellspacing='0' cellpadding='4' width='100%'>"
a += "        <tr>"
a += "          <td id='TehBattal'>"
a += "			</td></tr></table><BR></td>"
theBoard.innerHTML = a;
}
else if (location.href.indexOf("act=skirmish") != -1)
{
a = "<table cellspacing='0' cellpadding='0' width='100%'>"
a += "<tr>"
a += " <td id='ucpmenu' valign='top'>"
a += "    <div class='maintitle'>Menu</div>"
a += "	 <div class='pformstrip'>Personal Links</div>"
a += "	 <p>"
a += "	 · <b><a href='"+BaseURL+"?act=store'>Store</a></b><br />"
a += "	 · <b><a href='"+BaseURL+"?act=lottery'>Lottery</a></b><br />"
a += "         · <b><a href='"+BaseURL+"?act=richest'>Richest Members</a></b><br />"
a += "         · <b><a href='"+BaseURL+"?act=winners'>Recent Winners</a></b><br />"
a += "         · <b><a href='"+BaseURL+"?act=battles'>Recent Battles</a></b><br />"
a += "	 </p>"
a += "         <div class='pformstrip'>Fighters</div>"
a += "	 <p>"
a += "	 <div id='TehFightars'></div>"
a += "	 </p>"
a += " </td>"
a += " <td style='padding:2px'><!-- --></td>"
a += " <td id='ucpcontent' valign='top'>"
a += "  <div class='maintitle'>Battle Statistics</div>            <div class='pformstrip'></div>"
a += "     <table border='0' cellspacing='0' cellpadding='4' width='100%'>"
a += "        <tr>"
a += "          <td id='TehBattal'>"
a += "			</td></tr></table><BR></td>"
theBoard.innerHTML = a;
}
else if (location.href.indexOf("act=auction") != -1)
{
a = "<div class='borderwrap'>"
a += "<table width='100%'>"
a += "<tr>"
a += "<td width='25%' valign='top'>"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Navigation</div>"
a += "<div class='row4'><br /><a href='"+BaseURL+"?act=auction'>Main</a> | <a href='"+BaseURL+"'>Forums</a>  | <a href='"+StoreURL+"'>Store</a><br>"
a += "<br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Your Auction</div>"
a += "<div class='row4'><br />"
a += "Current Money: <span id='thecash'></span><br>"
a += "<br>"
a += "<center><div id='theAuction'></div></center>"
a += "<br><br /></div>"
a += "</div>"
a += "<br />"
a += "<div class='tableborder'>"
a += "<div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Debug Info</div>"
a += "<div class='row4'><br />If there are any bugs that you encounter with using the Auction System PM an <a href='URL TO ADMIN'><u>Administrator</u></a> and we will take care of it."
a += "<br><br /></div>"
a += "</div>"
a += "<br />"
a += "</td>"
a += "<td width='85%' valign='top'>"
a += "<center><div class='tablepad' style='border:4px solid gray'>"
a += "<b><h3>Auction System v4</h3><br>"
a += "<br>"
a += "<table width='450' border='4' id='tehtabel'>"
a += " <tr>"
a += "  <th align='left' width='50%'>Item Name</th>"
a += "  <th align='left' width='10%'>Icon</th>"
a += "  <th align='left' width='20%'>Bidder</th>"
a += "  <th align='left' width='20%'>Bid</th>"
a += " </tr>"
a += " <tr class='darkrow2'>"
a += "  <td align='left'> </td>"
a += "  <td align='center'> </td>"
a += "  <td align='right'> </td>"
a += "  <td align='right'> </td>"
a += " </tr>"
a += "</table>"
a += "<table width='450' border='4'>"
a += " <tr height='100px'>"
a += "  <td align='middle' width='100px' id='tehitempix'> </td>"
a += "  <td align='right' id='tehitemdesc'> </td>"
a += " </tr>"
a += "</table>"
a += "<br>"
a += "<br></div>"
theBoard.innerHTML = a;
}

if (classavatars == "Switch")
{
if (!document.cookie.match("classavatars=false"))
{

for (i=0;i<document.links.length;i++)
if ((document.links[i].href.match("CODE=06")) && (document.links[i].href.match("act=Login")))
 {document.links[i].parentNode.innerHTML = "<a href='Javascript:ToggleAvas();'>Forum Avatars</a>&nbsp;&middot;&nbsp;" + document.links[i].parentNode.innerHTML;break;}

classavatars = true;

}
else
{
for (i=0;i<document.links.length;i++)
if ((document.links[i].href.match("CODE=06")) && (document.links[i].href.match("act=Login")))
 {document.links[i].parentNode.innerHTML = "<a href='Javascript:ToggleAvas();'>RPG Avatars</a>&nbsp;&middot;&nbsp;" + document.links[i].parentNode.innerHTML;break;}

classavatars = false;

}}


if ((!(document.cookie.match("RPGoff=true")))||(location.href.indexOf("act=showuser") != -1)||(location.href.indexOf("act=store") != -1)||(location.href.indexOf("act=skirmish") != -1)||(location.href.indexOf("act=store") != -1)||(location.href.indexOf("act=winners") != -1)||(location.href.indexOf("act=richest") != -1)||(location.href.indexOf("act=battles") != -1)||(location.href.indexOf("act=lottery") != -1)||(noRPG))
{
document.write("<iframe id=cackhander name=cackhander style='display:none' src='"+searchurl+"'></iframe>");
document.write("<iframe id=doh name=doh height='0px' width='0px' frameborder= '0' src='"+BaseURL+"'></iframe>");
if (isAdmin)
document.write("<iframe id=whankhandle name=whankhandle style='display:none' frameborder= '0' src='"+Adminpost+"'></iframe>");

if (!noRPG)
{
for (i=0;i<document.links.length;i++)
if ((document.links[i].href.match("CODE=06")) && (document.links[i].href.match("act=Login")))
 {document.links[i].parentNode.innerHTML = "<a href='Javascript:ToggleRPG();'>Forum Mode</a>&nbsp;&middot;&nbsp;" + document.links[i].parentNode.innerHTML;break;}
}

}
else if (!noRPG)
{
for (i=0;i<document.links.length;i++)
if ((document.links[i].href.match("CODE=06")) && (document.links[i].href.match("act=Login")))
 {document.links[i].parentNode.innerHTML = "<a href='Javascript:ToggleRPG();'>RPG Mode</a>&nbsp;&middot;&nbsp;" + document.links[i].parentNode.innerHTML;break;}

}}



else if (document.title.match("Viewing Profile"))
{
a = document.getElementsByTagName("TD");
for(i=0;i<a.length;i++)
if (a[i].innerHTML.match("Total Cumulative Posts"))
if (navigator.appName == "Microsoft Internet Explorer")
{
postcount = a[i+1].innerHTML.split("</B>")[0];
postcount = parseInt(postcount.split("<B>")[1]);
}
else
{
postcount = a[i+1].innerHTML.split("</b>")[0];
postcount = parseInt(postcount.split("<b>")[1]);
}
if (parent.mode == 2)
parent.DoLottery();
else
parent.GetCash();
}
else if (location.href.indexOf(Adminpost) != -1)
{
a = document.getElementsByTagName('A');
for(i=0;i<a.length;i++)
parent.BoughtURLs[a[i].innerHTML]=a[i].href;
parent.alsodone = 1;
}
else if (location.href.indexOf(PMUrl) != -1)
{
a = document.getElementsByTagName('input');
for(i=0;i<a.length;i++)
{
if(a[i].name == 'entered_name')
a[i].value = parent.recipient
else if(a[i].name == 'msg_title')
a[i].value = parent.messagetitle
}
a = document.getElementsByTagName('textarea');
for(i=0;i<a.length;i++)
if(a[i].name == 'Post')
a[i].value = parent.messagebody
a = document.getElementsByTagName('input');
for(i=0;i<a.length;i++)
if(a[i].value == 'Send Message')
a[i].click();
}
else if (parent.mode == 7)
{
parent.DoPMs();
}
else if (document.title.match("Replying in"))
{
a = document.getElementsByTagName('textarea');
for(i=0;i<a.length;i++)
if(a[i].name == 'Post')
a[i].value = 'Amount: '+ parent.amount + "     Bought: "+parent.what;
a = document.getElementsByTagName('input');
for(i=0;i<a.length;i++)
if(a[i].value == 'Add Reply')
a[i].click();
}
else if (document.title.match("Editing Post"))
{
if (parent.mode == 5)
{GetEditString(0);parent.mode = 0;}
else
GetEditString(1);
a = document.getElementsByTagName('textarea');
for(i=0;i<a.length;i++)
if(a[i].name == 'Post')
a[i].value = rawr;
a = document.getElementsByTagName('input');
for(i=0;i<a.length;i++)
if(a[i].value == 'Submit Modified Post')
a[i].click();
}
else if ((document.title.match("This is teh post!")) && (parent.done == 1) && (parent.mode == 1))
{
a = document.getElementsByTagName("a");
done = 0;
for (i=0;i<a.length;i++)
if(a[i].href.match("delete_post"))
{
b=a[i].href.split("'")[1];
b=b.split("'")[0];
window.location = b;
done = 1;
break;
}
if (done == 0)
parent.DoPMs();
}
else if ((document.title.match("This is teh post!")) && (parent.done == 1) && (parent.mode == 2))
{
parent.Khillem();
}
else if ((document.title.match("This is teh post!")) && (parent.mode == 5))
{
ParsePostForMoney(0);
window.location = EditURL;
}
else if ((document.title.match("This is teh post!")) && (parent.done == 0))
{
ParsePostForMoney(1);
a = document.getElementsByTagName("TD");
var doanother = 1;
for(i=0;i<a.length;i++)
if ((a[i].innerHTML.match("javascript:multi_page_jump")) && (a[i].width == "20%"))
{
if (navigator.appName == "Microsoft Internet Explorer")
b = a[i].innerHTML.split("</B>")[1];
else
b = a[i].innerHTML.split("</b>")[1];
if (b)
if (b.match("showtopic"))
{
parent.searchnum += postsperpage;
window.location = parent.searchurl + parent.searchnum;
doanother = 0;
}
}
if (doanother == 1)
window.location = theUrl;
}
else if ((document.title.match("This is teh post!")) && (parent.done == 1) && (parent.mode == 4))
{
parent.location.href = parent.location.href;
}
else
{
document.body.style.display = "NONE";
}

function ToggleRPG()
{
if (document.cookie.match("RPGoff=true"))
 document.cookie = "RPGoff=false;"
else
 document.cookie = "RPGoff=true;"

window.location.href = window.location.href;
}


function ToggleAvas()
{
if (document.cookie.match("classavatars=true"))
 document.cookie = "classavatars=false;"
else
 document.cookie = "classavatars=true;"

window.location.href = window.location.href;
}



var done = 0;
var mode = 0;

var searchnum = 0;

var what = ""
var amount = ""

function PostIt()
{
mode = 4;
what = "Lottery Ticket"
amount = "$10"
if ((usar != "Log In") && (done == 1))
{
if (mycash < 10)
alert ("You don't have the cash!")
else if (BoughtTicket[usar] == "Very Yes")
alert ("You've already bought a ticket!")
else
parent.frames['doh'].location = PostURL;
}}

function ChangeCash(tehname,tehmoney)
{
mode = 5;
MID = null;
itamz = null;
banked = null;
MID = [];
itamz = [];
banked = [];
MID[tehname]=tehmoney;
parent.frames['doh'].location = searchurl;
}

function EditIt()
{

if (ticket.length == 0)
winner = "NO ENTRANTS";
else
{
i = Math.floor(Math.random()*ticket.length)
winner = ticket[i];
if (MID[winner])
MID[winner] += Jackpot;
else
MID[winner] = Jackpot;
}

if (parseInt(Jackpot) > parseInt(BiggestEverJackpot))
 BiggestEverJackpot = Jackpot;

for (blah in banked)
banked[blah]=Math.floor(banked[blah] * (100+interest) / 100);

for (blah in Auction)
{
if (Auction[blah][1] == 1)
{
itamz[Auction[blah][2]]+=","+Auction[blah][0];
MID[blah] += Auction[blah][3];
Auction[blah][1] = 0;
}
else if (Auction[blah][1] > 0)
Auction[blah][1] --;
}

results = null;results=[];

for(blah in fight)
 results[blah]=DoFight(blah,fight[blah]);

mode = 2;
parent.frames['doh'].location = EditURL;
}


function Khillem()
{
mode = 1
parent.frames['doh'].location = ShowTopicURL;
}

function ParsePostForMoney(all)
{
a = document.getElementsByTagName("TD");
for(i=0;i<a.length;i++)
if((a[i].className == "post2") || (a[i].className == "post1"))
{
usar = a[i-3].getElementsByTagName("a")[0].innerHTML;
while (usar.match("<"))
{usar = usar.split(">")[1];usar = usar.split("<")[0];}
if (usar == parent.theAdmin)
{
b=a[i].getElementsByTagName("a");
c=a[i].getElementsByTagName("i");
for(j=0;j<b.length;j++)
{
usar = b[j].innerHTML;
if (!parent.MID[usar])
parent.MID[usar] = 0;
if (parseInt(c[j].innerHTML))
parent.MID[usar] = parent.MID[usar] +  parseInt(c[j].innerHTML);
if (!parent.itamz[usar])
parent.itamz[usar] = "";
parent.itamz[usar] += c[j].innerHTML.split("#")[1].split("%")[0];
if (!parent.banked[usar])
parent.banked[usar] = 0;
parent.banked[usar] += parseInt(c[j].innerHTML.split("%")[1].split("^")[0]);
parent.uclass[usar] = c[j].innerHTML.split("^")[1].split("*")[0];
if (!parent.XP[usar])
parent.XP[usar] = 0;
parent.XP[usar] += parseInt(c[j].innerHTML.split("*")[1].split("~")[0]);
parent.level[usar] = parseInt(c[j].innerHTML.split("~")[1].split("£")[0]);
if (!parent.reputation[usar])
parent.reputation[usar] = 0;
parent.reputation[usar] = parseInt(c[j].innerHTML.split("£")[1]);

if (c[j].innerHTML.split("@")[2])
{
parent.BattlesWon[usar] = parseInt(c[j].innerHTML.split("@")[1]);
parent.BattlesLost[usar] = parseInt(c[j].innerHTML.split("@")[2]);
parent.Gender[usar] = c[j].innerHTML.split("@")[3];
parent.Auction[usar] = [];
parent.Auction[usar][0] = parseInt(c[j].innerHTML.split("@")[4]);
parent.Auction[usar][1] = parseInt(c[j].innerHTML.split("@")[5]);
parent.Auction[usar][2] = parseInt(c[j].innerHTML.split("@")[6]);
parent.Auction[usar][3] = parseInt(c[j].innerHTML.split("@")[7]);
parent.Stats[usar] = [];
parent.Stats[usar][0] = parseInt(c[j].innerHTML.split("@")[8]);
parent.Stats[usar][1] = parseInt(c[j].innerHTML.split("@")[9]);
parent.Stats[usar][2] = parseInt(c[j].innerHTML.split("@")[10]);
parent.Stats[usar][3] = parseInt(c[j].innerHTML.split("@")[11]);
parent.Stats[usar][4] = parseInt(c[j].innerHTML.split("@")[12]);
parent.Stats[usar][5] = parseInt(c[j].innerHTML.split("@")[13]);
}
else
{
parent.BattlesWon[usar] = 0;
parent.BattlesLost[usar] = 0;
}

}
if (c[j])
parent.lastJackpot[0]=c[j].innerHTML;
if (c[j+1])
parent.lastWinner[0]=c[j+1].innerHTML;
if (c[j+2])
parent.BiggestEverJackpot=c[j+2].innerHTML;
if (c[j+3])
parent.lastWinner[1]=c[j+3].innerHTML;
if (c[j+4])
parent.lastWinner[2]=c[j+4].innerHTML;
if (c[j+5])
parent.lastWinner[3]=c[j+5].innerHTML;
if (c[j+6])
parent.lastWinner[4]=c[j+6].innerHTML;
if (c[j+7])
parent.lastJackpot[1]=c[j+7].innerHTML;
if (c[j+8])
parent.lastJackpot[2]=c[j+8].innerHTML;
if (c[j+9])
parent.lastJackpot[3]=c[j+9].innerHTML;
if (c[j+10])
parent.lastJackpot[4]=c[j+10].innerHTML;
if (c[j+11])
parent.lastDraw=c[j+11].innerHTML;
if (c[j+12])
parent.nextDraw=c[j+12].innerHTML;
if (c[j+13])
parent.DrawTime=c[j+13].innerHTML;
if (c[j+14])
parent.theMOTD=c[j+14].innerHTML;
if (c[j+15])
parent.MOTDsetter=c[j+15].innerHTML;
if (c[j+16])
for (k=(j+16);k<c.length;k++)
{
b = c[k].innerHTML;
d = b.split("#")[0];
b = b.split("#")[1];
e = b.split("~")[0];
b = b.split("~")[1];

 parent.results[d] = c[k].innerHTML;

if (!parent.theresults[d])
 parent.theresults[d] = b;
else
 parent.theresults[d]+=b;


if (!parent.theresults[e])
 parent.theresults[e] = b;
else
 parent.theresults[e]+=b;
}
}
else if (all == 1)
{
if(a[i-3].getElementsByTagName("a").length != 0)
if(a[i].innerHTML.match("Amount: "))
{

sPost=a[i-1].getElementsByTagName("SPAN")[0]
if(sPost.innerHTML.replace(",","").replace('.','').replace(' ','').match(/Posts: (\d+)/)) parent.posts[usar] = parseInt(RegExp.$1)
if (!parent.MID[usar])
parent.MID[usar] = 0;
c = a[i].innerHTML.split("$")[1];
if (parseInt(c))
if (parseInt(c) > 0)
parent.MID[usar] = parent.MID[usar] -  parseInt(c);


if (a[i].innerHTML.match("BuyMOTD"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (parseInt(c) >= MOTDprice)
{
parent.theMOTD = d;
parent.MOTDsetter = usar;
}}



else if (a[i].innerHTML.match("Item"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if(itemlist[d])
if(parseInt(c) == itemlist[d][0])
if (CanUse(parent.uclass[usar],d))
if (parent.itemlist[d][6] > 0)
{if(!(parent.itamz[usar]))
 parent.itamz[usar] = "";
if (itemlist[d][8] == 4)
{if ((parent.Stats[usar])&&((parent.Stats[usar][0] + itemlist[d][9])>2)&&((parent.Stats[usar][1] + itemlist[d][10])>2)&&((parent.Stats[usar][2] + itemlist[d][11])>2)&&((parent.Stats[usar][3] + itemlist[d][12])>2)&&((parent.Stats[usar][4] + itemlist[d][13])>2)&&((parent.Stats[usar][5] + itemlist[d][14])>2))
{
parent.Stats[usar][0] += itemlist[d][9];
parent.Stats[usar][1] += itemlist[d][10];
parent.Stats[usar][2] += itemlist[d][11];
parent.Stats[usar][3] += itemlist[d][12];
parent.Stats[usar][4] += itemlist[d][13];
parent.Stats[usar][5] += itemlist[d][14];
}
}
else if(!parent.itamz[usar].match(d))
{parent.itamz[usar]+=","+d;parent.itemlist[d][6] -= 1;
if (itemlist[d][8] == 2)
{
parent.PMs[parent.numpms]=[];
parent.PMs[parent.numpms][0]=2;
parent.PMs[parent.numpms][1]=usar;
parent.PMs[parent.numpms][2]=d;
parent.numpms++;
}
}}
}

else if (a[i].innerHTML.match("Sell"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if(itemlist[d])
if(parseInt(c) >= Math.floor(itemlist[d][0]/2))
if((parent.itamz[usar].match(d))&&(itemlist[d][8] != 2))
{parent.itamz[usar]=parent.itamz[usar].replace(","+d,"");parent.MID[usar] = parent.MID[usar] + itemlist[d][0];parent.itemlist[d][6] += 1;
}
}


else if (a[i].innerHTML.match("Auction"))
{
if ((!parent.Auction[usar]) || (parent.Auction[usar][1] < 1))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (!parent.Auction[usar])
 parent.Auction[usar] = [];
if(itemlist[d])
if (parent.itamz[usar].match(d))
{
parent.Auction[usar][0] = d;
parent.Auction[usar][1] = 7;
parent.Auction[usar][2] = usar;
parent.Auction[usar][3] = 0;
parent.itamz[usar]=parent.itamz[usar].replace(","+d,"");
}
}
}

else if (a[i].innerHTML.match("Bid"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (d != usar)
if (parent.Auction[d])
if (parent.Auction[d][1] > 0)
if (parseInt(c) > parent.Auction[d][3])
if (CanUse(parent.uclass[usar],parent.Auction[d][0]))
{
parent.MID[parent.Auction[d][2]] += parent.Auction[d][3];
parent.Auction[d][2] = usar;
parent.Auction[d][3] = parseInt(c);
}}


else if (a[i].innerHTML.match("Gender"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (!parent.MID[usar])
parent.MID[usar] = 0;
if((d=="M") || (d=="F"))
{
g=0;
if(parent.Gender[usar])
if (parent.Gender[usar] != "0")
g=1;
if (g==0)
{
parent.Gender[usar] = d;
if(!parent.uclass[usar])
parent.uclass[usar] = "NoClass";
}}}

else if (a[i].innerHTML.match("Class"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if(classes[d])
{
if (!parent.MID[usar])
parent.MID[usar] = 0;
g=0;
if(parent.uclass[usar])
if (parent.uclass[usar] != "NoClass")
g=1;
if (g==0)
parent.uclass[usar] = d;
}}

else if (a[i].innerHTML.match("Donation"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (!parent.MID[d])
parent.MID[d] = parseInt(c);
else
parent.MID[d] += parseInt(c);
parent.PMs[parent.numpms]=[];
parent.PMs[parent.numpms][0]=1;
parent.PMs[parent.numpms][1]=usar;
parent.PMs[parent.numpms][2]=d;
parent.PMs[parent.numpms][3]=parseInt(c);
parent.numpms++;
}

else if ((a[i].innerHTML.match("Addrep")) && (parent.repped[usar] != "Very Yes"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (usar != d)
{
if (!parent.MID[d])
parent.MID[d] = 0;
if (!parent.reputation[d])
parent.reputation[d] = 1;
else
parent.reputation[d]++;
parent.repped[usar] = "Very Yes";
}}

else if ((a[i].innerHTML.match("Subrep")) && (parent.repped[usar] != "Very Yes"))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (!parent.MID[d])
parent.MID[d] = 0;
if (!parent.reputation[d])
parent.reputation[d] = -1;
else
parent.reputation[d]--;
parent.repped[usar] = "Very Yes";
}

else if ((a[i].innerHTML.match("Fight")) && (!parent.fight[usar]))
{
d = a[i].innerHTML.split("(")[1];
d = d.split(")")[0];
if (usar != d)
{
if (!parent.MID[d])
parent.MID[d] = 0;
if (parent.uclass[d])
if(parent.uclass[d] != "NoClass")
if (parent.uclass[usar])
if(parent.uclass[usar] != "NoClass")
parent.fight[usar] = d;
}}

else if (a[i].innerHTML.match("Withdrawal"))
{
if (parent.banked[usar])
if (parent.banked[usar] >= parseInt(c))
{
parent.MID[usar] += 2*parseInt(c);
parent.banked[usar] -= parseInt(c);
}
}

else if (a[i].innerHTML.match("Payed In"))
{
if (parent.banked[usar])
parent.banked[usar] += parseInt(c);
else
parent.banked[usar] = parseInt(c);
}


else if ((parseInt(c)==10) && (a[i].innerHTML.match("Lottery Ticket")) && (parent.BoughtTicket[usar] != "Very Yes"))
{
parent.BoughtTicket[usar] = "Very Yes";
parent.Jackpot = parseInt(parent.Jackpot) + 5;
parent.ticket[parseInt (parent.ticketsSold)] = usar;
parent.ticketsSold = parseInt (parent.ticketsSold) + 1;
}
}}

}}

function GetCash() {

mycash = parent.frames['cackhander'].postcount * PerPost;
if (MID[usar])
mycash += parseInt(MID[usar]);
mycash += parseInt(default_amount);

for (blah in posts)
if (XP[blah])
level[blah]=GetLevel(XPPerPost*posts[blah] + XP[blah],blah);
else
level[blah]=GetLevel(XPPerPost*posts[blah],blah);



if (done == 0)
{
//Change this bit to suit the frontscreen

if (location.href.indexOf("act=battles") != -1)
{
for (blah in theresults)
document.getElementById("TehFightars").innerHTML+= '&middot;&nbsp;<b><a href="'+RBUrl+"&fighter="+blah+'">'+blah+'</a></b><br/>';

if (location.href.match("fighter"))
{
a = location.href.split("fighter=")[1].replace("%20"," ");
if (theresults[a])
{
d = theresults[a].replace(/<br>/,"|").split("*");
for (j=0;j<(d.length-1);j++)
{
c = d[j].split("|");
document.getElementById("TehBattal").innerHTML += "<h3><blockquote>"+c[0]+"</blockquote></h3><hr>";
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[1]+"<br>"+c[2]+"</blockquote>";
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[3]+"<br>"+c[4]+"</blockquote><hr>";
for (i=5;i<c.length-2;i++)
document.getElementById("TehBattal").innerHTML += "<br />"+c[i];
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[c.length-1]+"</blockquote><hr><br>";
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[c.length-2]+"</blockquote><hr><br><br><br><br>";
}}
else
 document.getElementById("TehBattal").innerHTML = "No battles for "+a;
}
}

if (location.href.indexOf("act=skirmish") != -1)
{
a = "";
b = 0;
for (blah in uclass)
if (uclass[blah] != "NoClass")
if (Stats[blah])
{a += '<option value='+blah+'>'+blah; if (b == 0) theskirmish=blah;b=1;}

document.getElementById("TehFightars").innerHTML = "<select onChange='SkirmishChange(this.options[this.selectedIndex].value);'>"+a+"</select><br><br><input type='button' onClick='SkirmishIt();' value='Skirmish!'><br><br><div id='theSkirmish'></div>";

if (location.href.match("fighter"))
{
a = location.href.split("fighter=")[1].replace("%20"," ");
theskirmish=a;

d = DoFight(usar,a).replace(/<br>/,"|").split("*");
for (j=0;j<(d.length-1);j++)
{
c = d[j].split("|");
document.getElementById("TehBattal").innerHTML += "<h3><blockquote>"+c[0].split("~")[1]+"</blockquote></h3><hr>";
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[1]+"<br>"+c[2]+"</blockquote>";
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[3]+"<br>"+c[4]+"</blockquote><hr>";
for (i=5;i<c.length-2;i++)
document.getElementById("TehBattal").innerHTML += "<br />"+c[i];
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[c.length-1].split("!")[0]+"!</blockquote><hr><br>";
document.getElementById("TehBattal").innerHTML += "<blockquote>"+c[c.length-2]+"</blockquote><hr><br><br><br><br>";
}
}

SkirmishChange(theskirmish);

}


if (location.href.indexOf("act=auction") != -1)
{
a=document.getElementById("thecash");
a.innerHTML=sign+mycash;
if (banked[usar])
a.innerHTML+="<br/>Banked: "+sign+banked[usar];

ims =[];

if ((Auction[usar]) && (Auction[usar][1] > 0))
{theAuction.innerHTML+=itemlist[Auction[usar][0]][3]}
else
{
a = "<form><select onChange='AuctionIt(this.options[this.selectedIndex].value);'><option>None"
for (blah in itemlist)
if (HaveItem(usar,blah))
a += "<option value='"+blah+"'>"+itemlist[blah][3];
a+="</select></form>"
theAuction.innerHTML+=a;
}

for (blah in Auction)
if (Auction[blah][1] > 0)
{
a = document.getElementById("tehtabel");
b = a.getElementsByTagName('TR');
c = b[1].cloneNode(true);
c.className="";
b[1].parentNode.insertBefore(c,b[1])
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[0].innerHTML="<a href='Javascript:Bid("+'"'+blah+'"'+")' onMouseOver=(storeboxchange('"+Auction[blah][0]+"')); onMouseOut=(storeboxblank());>"+itemlist[Auction[blah][0]][3]+"</a>";
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[1].innerHTML="<img src='"+itemlist[Auction[blah][0]][2]+"'onMouseOver=(storeboxchange('"+Auction[blah][0]+"')); onMouseOut=(storeboxblank());>";
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[2].innerHTML=Auction[blah][2];
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[3].innerHTML=sign+Auction[blah][3];
}



}


if ((location.href.indexOf("act=store") != -1) && (location.href.indexOf("sell") != -1))
{
a=document.getElementById("thecash");
a.innerHTML=sign+mycash;
if (banked[usar])
a.innerHTML+="<br/>Banked: "+sign+banked[usar];

ims =[];

catshtml = "";
for(blah in itemlist)
{
if (itemlist[blah][8] != 2)
if (HaveItem(usar,blah))
{AddItemToSellList(blah);
 if (document.images)
 {ims[blah]=new Image(100,100);
  ims[blah].src = itemlist[blah][1];}
}
if ((!cats[itemlist[blah][5]]) && (blah != "nothing"))
{
cats[itemlist[blah][5]] = 1;
catshtml += '» <a href="' + StoreURL + "&category=" + itemlist[blah][5].replace(" ","%20") +'">'+ itemlist[blah][5] +"</a><br>"
}
}
catshtml += '» <a href="' + StoreURL + '&sell">Sell Items</a><br>';
catshtml += '» <a href="' + BaseURL + '?act=auction">Auctions</a><br>';
a=document.getElementById("tehcats");
a.innerHTML = catshtml;

}
else if (location.href.indexOf("act=store") != -1)
{
a=document.getElementById("thecash");
a.innerHTML=sign+mycash;
if (banked[usar])
a.innerHTML+="<br/>Banked: "+sign+banked[usar];

ims =[];
storeitems = [];
storeitemindex=0;

if (location.href.indexOf("category") != -1)
{
b = location.href;
b = b.split("&category=")[1];
b = b.replace("%20"," ");
defaultstorecategory = b;
}
catshtml = "";
for(blah in itemlist)
{
if ((defaultstorecategory == itemlist[blah][5]) && (itemlist[blah][3] != "nothing"))
{
//AddItemToList(blah);
storeitems[storeitemindex++]=blah;
if (document.images)
{ims[blah]=new Image(100,100);
ims[blah].src = itemlist[blah][1];}
}
if (!cats[itemlist[blah][5]])
{
cats[itemlist[blah][5]] = 1;
catshtml += '» <a href="' + StoreURL + "&category=" + itemlist[blah][5].replace(" ","%20") +'">'+ itemlist[blah][5] +"</a><br>"
}
}
storeitems.sort(SortByPrice);
for (blah=0;blah<storeitems.length;blah++)
AddItemToList(storeitems[blah]);
catshtml += '» <a href="' + StoreURL + '&sell">Sell Items</a><br>';
catshtml += '» <a href="' + BaseURL + '?act=auction">Auctions</a><br>';
a=document.getElementById("tehcats");
a.innerHTML = catshtml;

}

if (location.href.indexOf("act=lottery") != -1)
{
a=document.getElementsByTagName("DIV");
for (i=0;i<a.length;i++)
if (a[i].innerHTML.match("Current Money"))
{
a[i].innerHTML = a[i].innerHTML.replace("$earned",sign+lastJackpot[0]);
a[i].innerHTML = a[i].innerHTML.replace("$Current",sign+mycash);
a[i].innerHTML = a[i].innerHTML.replace("$name",lastWinner[0]);
}
if (isAdmin)
{
document.getElementById("hahaha").value = DrawTime;
document.getElementById("pwnt").value = GetTommorrow();
}}

if (document.getElementById("MOTD_Here"))
{
document.getElementById("MOTD_Here").innerHTML = theMOTD;
if (document.getElementById("MOTD_Setter"))
document.getElementById("MOTD_Setter").innerHTML = MOTDsetter;
}


if ((document.getElementById("ucpcontent")) && (!noRPG))
{
a = "<div class='pformstrip'>Your Character Info</div>"
a += '<table width="100%" border="0" cellspacing="0" cellpadding="4">'
a += "<tr>"
a += '<td width="40%">Character Class:</td>'
a += '<td width="60%">'
b = '<form><select onChange="ChangeClass(this.options[this.selectedIndex].value);">'
b += '<option value="NoClass">No Class';
for (blah in classes)
if (blah != "NoClass")
if (classes[blah][7])
b += '<option value="'+blah+'">'+classes[blah][0];
b += '</select></form>'
if (Gender[usar]=="M")
b += '</td></tr><tr><td id="thepic"><img src="'+classes["NoClass"][6]+'" height="100px" width="100px"></td><td id="thestats"></td></td></table><br></table>'
else
b += '</td></tr><tr><td id="thepic"><img src="'+classes["NoClass"][10]+'" height="100px" width="100px"></td><td id="thestats"></td></td></table><br></table>'
if (uclass[usar])
if (uclass[usar] != "NoClass")
b = classes[uclass[usar]][0];
a += b;

if ((!(Gender[usar])) || (Gender[usar] == 0))
 a+= "<br><br>"+'<form><select onChange="ChangeGender(this.options[this.selectedIndex].value);">'+'<option value="0">Gender<option value="M">Male<option value="F">Female</select></form>';


document.getElementById("ucpcontent").innerHTML += a;
}

if ((document.getElementById("profilename")) && (!noRPG))
{
uname = document.getElementById("profilename").innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,"");

a = document.getElementsByTagName("TD");
for(i=0;i<a.length;i++)
if (a[i].innerHTML.match("Total Cumulative Posts"))
if (navigator.appName == "Microsoft Internet Explorer")
{
postcount = a[i+1].innerHTML.split("</B>")[0];
postcount = parseInt(postcount.split("<B>")[1]);
}
else
{
postcount = a[i+1].innerHTML.split("</b>")[0];
postcount = parseInt(postcount.split("<b>")[1]);
}
Posts = postcount;

a=document.getElementsByTagName("TABLE");
for (i=0;i<a.length;i++)
if ((a[i].align == "center") && (a[i].cellPadding == 0) && (a[i].cellSpacing == 2) && (a[i].width == "100%"))
{

if(MID[uname]){ EXP = (parseInt(MID[uname]) + (Posts * PerPost))+parseInt(default_amount) }
else{ EXP = (Posts * PerPost)+parseInt(default_amount) }

c = "<table width='100%' class='tableborder' align='left'><tr><td width='100%' align='left'>";

for (blah in itemlist)
{
if (HaveItem(uname,blah))
c += "<img src='"+itemlist[blah][2]+"' onMouseOver=(itemboxchange('"+itemboxno+"','"+blah+"')); onMouseOut=(itemboxclear('"+itemboxno+"'));> &nbsp;"
}
c += "<\/td><\/tr><tr height='20px'><td width = '100%' id=itembox"+itemboxno+">";
itemboxno++;
c += "&nbsp;<\/td><\/tr><\/table>";
c +="<br/>"

if (uclass[uname])
d = classes[uclass[uname]][0];
else
d ="No Class";

if (XP[uname])
e = XPPerPost*Posts + XP[uname];
else
e = XPPerPost*Posts;

f = sign+EXP;

g = "";
if (isAdmin)
g +="<a href='Javascript:ReduceCash("+'"'+uname+'"'+")'>"+minuspic+"</a>&nbsp;&nbsp;"
g +="<a href='Javascript:Donate("+'"'+uname+'"'+")'>"+donatepic+"</a>"
if (isAdmin)
g +="&nbsp;&nbsp;<a href='Javascript:IncreaseCash("+'"'+uname+'"'+")'>"+pluspic+"</a>"

if (BoughtTicket[uname]=="Very Yes")
 h = "Bought Ticket"
else
 h = "<i>Not bought ticket</i>"

b = '	 <table cellspacing="1" cellpadding="6" width="100%">'
b += '	  <tr>'
b += '		<td align="center" colspan="2" class="maintitle">Items</td>'
b += '	  </tr>'
b += '	  <tr>'
b += '		<td class="row3" width="30%" valign="top"><b>Inventory</b></td>'
b += '		<td align="left" width="70%" class="row1">'+c+'</td>'
b += '	  </tr>'
b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>'+name+'</b></td>'
b += '		<td align="left" class="row1"><b>'+f+'</b></td>'
b += '	  </tr>'
b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Donate</b></td>'
b += '		<td align="left" class="row1">'+g+'</td>'
b += '	  </tr>'
b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Lottery</b></td>'
b += '		<td align="left" class="row1">'+h+'</td>'
b += '	  </tr>'
//b += '	  <tr>'
//b += '		<td class="row3" valign="top"><b>Users local time</b></td>'
//b += '		<td align="left" class="row1">Dec 31 2005, 10:03 PM</td>'
//b += '	  </tr>'
b += '	  </table>'

l = '	 <table cellspacing="1" cellpadding="6" width="100%">'
l += '	  <tr>'
l += '		<td align="center" colspan="2" class="maintitle">RPG</td>'
l += '	  </tr>'

l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b>Class</b></td>'
l += '		<td align="left" width="70%" class="row1">'+d+'</td>'
l += '	  </tr>'

l += '	  <tr>'
l += '		<td class="row3" valign="top"><b>Experience</b></td>'
l += '		<td align="left" class="row1"><b>'+e+'</b></td>'
l += '	  </tr>'

l += '	  <tr>'
l += '		<td class="row3" valign="top"><b>Level</b></td>'
l += '		<td align="left" class="row1">'+GetLevel(e,uname)+'</td>'
l += '	  </tr>'

l += '	  <tr>'
l += '		<td class="row3" valign="top"><b>Experience Until Next Level</b></td>'
if (uclass[uname])
l += '		<td align="left" class="row1">'+(Math.floor((Math.exp(GetLevel(e,uname)+1)*classes[uclass[uname]][1])-e))+'</td>'
else
l += '		<td align="left" class="row1"><i>No Class</i></td>'
l += '	  </tr>'

l += '	  <tr>'
l += '		<td class="row3" valign="top"><b>Hit Points</b></td>'
if ((uclass[uname]) && (Stats[uname]))
l += '		<td align="left" class="row1">'+(5+parseInt(level[uname])*(parseInt(classes[uclass[uname]][3])+GetBonus(Stats[uname][5])))+'</td>'
else
l += '		<td align="left" class="row1"><i>No Class</i></td>'
l += '	  </tr>'

l += '	  <tr>'
l += '		<td class="row3" valign="top"><b>Gender</b></td>'
if (Gender[uname])
{
if (Gender[uname] == "M")
l += '		<td align="left" class="row1">Male</td>'
else if (Gender[uname] == "F")
l += '		<td align="left" class="row1">Female</td>'
else
l += '		<td align="left" class="row1"><i>Not selected yet</i></td>'
}
else
l += '		<td align="left" class="row1"><i>Not selected yet</i></td>'
l += '	  </tr>'

l += '	  </table>'

a[i].insertRow(-1);
a[i].rows[2].insertCell(-1);
a[i].rows[2].insertCell(-1);
a[i].rows[2].cells[0].innerHTML = b;
a[i].rows[2].cells[1].innerHTML = l;
a[i].rows[2].cells[0].vAlign= "top";
a[i].rows[2].cells[1].vAlign= "top";
a[i].rows[2].cells[0].className= "plainborder";
a[i].rows[2].cells[1].className= "plainborder";

b = '	 <table cellspacing="1" cellpadding="6" width="100%">'
b += '	  <tr>'
b += '		<td align="center" colspan="2" class="maintitle">Battles</td>'
b += '	  </tr>'
b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Battles Won/Lost</b></td>'
if ((BattlesWon[uname]) || (BattlesLost[uname]))
b += '		<td align="left" class="row1"><b>'+BattlesWon[uname]+'/'+BattlesLost[uname]+'</b></td>'
else
b += '		<td align="left" class="row1"><i>None yet</i></td>'
b += '	  </tr>'

b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Recent Battles</b></td>'
if (theresults[uname])
b += '		<td align="left" class="row1"><a href="'+RBUrl+"&fighter="+uname+'">Readout</a></td>'
else
b += '		<td align="left" class="row1"><i>None</i></td>'
b += '	  </tr>'

b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Fight</b></td>'
b += '		<td align="left" class="row1">'
b+= "<a href='Javascript:AddFight("+'"'+uname+'"'+")'>"+fightpic+"</a>"
b+='</td>'
b += '	  </tr>'

b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Skirmish</b></td>'
b += '		<td align="left" class="row1">'
b+= "<a href='"+BaseURL+"?act=skirmish&fighter="+uname+"'>"+skirmishpic+"</a>"
b+='</td>'
b += '	  </tr>'

b += '	  <tr>'
b += '		<td class="row3" valign="top"><b>Reputation</b></td>'
b += '		<td align="left" class="row1">'
b +="<a href='Javascript:Subrep("+'"'+uname+'"'+")'>"+minuspic+"</a>&nbsp;&nbsp;"
if (reputation[uname])
b +=reputation[uname]
else
b+= "0";
b +="&nbsp;&nbsp;<a href='Javascript:Addrep("+'"'+uname+'"'+")'>"+pluspic+"</a>"
b+='</td>'
b += '	  </tr>'

b += '	  </table>'

l = '	 <table cellspacing="1" cellpadding="6" width="100%">'
l += '	  <tr>'
l += '		<td align="center" colspan="2" class="maintitle">Stats</td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b><acronym title="'+thestats[1]+'">'+thestats[0]+'</acronym></b></td>'
if (Stats[uname])
l += '		<td align="left" width="70%" class="row1">'+Stats[uname][0]+'</td>'
else
l += '		<td align="left" width="70%" class="row1"><i>Not Rolled</i></td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b><acronym title="'+thestats[3]+'">'+thestats[2]+'</acronym></b></td>'
if (Stats[uname])
l += '		<td align="left" width="70%" class="row1">'+Stats[uname][1]+'</td>'
else
l += '		<td align="left" width="70%" class="row1"><i>Not Rolled</i></td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b><acronym title="'+thestats[5]+'">'+thestats[4]+'</acronym></b></td>'
if (Stats[uname])
l += '		<td align="left" width="70%" class="row1">'+Stats[uname][2]+'</td>'
else
l += '		<td align="left" width="70%" class="row1"><i>Not Rolled</i></td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b><acronym title="'+thestats[7]+'">'+thestats[6]+'</acronym></b></td>'
if (Stats[uname])
l += '		<td align="left" width="70%" class="row1">'+Stats[uname][3]+'</td>'
else
l += '		<td align="left" width="70%" class="row1"><i>Not Rolled</i></td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b><acronym title="'+thestats[9]+'">'+thestats[8]+'</acronym></b></td>'
if (Stats[uname])
l += '		<td align="left" width="70%" class="row1">'+Stats[uname][4]+'</td>'
else
l += '		<td align="left" width="70%" class="row1"><i>Not Rolled</i></td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td class="row3" width="30%" valign="top"><b><acronym title="'+thestats[11]+'">'+thestats[10]+'</acronym></b></td>'
if (Stats[uname])
l += '		<td align="left" width="70%" class="row1">'+Stats[uname][5]+'</td>'
else
l += '		<td align="left" width="70%" class="row1"><i>Not Rolled</i></td>'
l += '	  </tr>'
l += '	  </table>'

a[i].insertRow(-1);
a[i].rows[3].insertCell(-1);
a[i].rows[3].insertCell(-1);
a[i].rows[3].cells[0].innerHTML = b;
a[i].rows[3].cells[1].innerHTML = l;
a[i].rows[3].cells[0].vAlign= "top";
a[i].rows[3].cells[1].vAlign= "top";
a[i].rows[3].cells[0].className= "plainborder";
a[i].rows[3].cells[1].className= "plainborder";

b="";
for (blah in itemlist)
if (itemlist[blah][8]==5)
if (HaveItem(uname,blah))
b += "<img src='"+itemlist[blah][10]+"' onMouseOver=ShowAwardDetails('"+blah+"') onMouseOut=HideAwardDetails('&nbsp;')>";

if (b!="")
{

l = '	 <table cellspacing="1" cellpadding="6" width="100%">'
l += '	  <tr>'
l += '		<td align="center" class="maintitle">Collectables</td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td align="left" width="100%" class="row1"><center>'+b+'</center></td>'
l += '	  </tr>'
l += '	  <tr>'
l += '		<td align="left" width="100%" class="row1" align="center" id="awarddetails"></td>'
l += '	  </tr>'
l += '	  </table>'



a[i].insertRow(-1);
a[i].rows[4].insertCell(-1);
a[i].rows[4].cells[0].colSpan=2;
a[i].rows[4].cells[0].innerHTML = l;
a[i].rows[4].cells[0].vAlign= "top";
a[i].rows[4].cells[0].className= "plainborder";
}


}
}

a=document.getElementsByTagName("DIV");
for (i=0;i<a.length;i++)
if ((a[i].innerHTML.match("Total Jackpot worth:")) && (a[i].className == "row4"))
{
a[i].innerHTML = a[i].innerHTML.replace("#Money#",sign+Jackpot);
a[i].innerHTML = a[i].innerHTML.replace("#Money#",sign+BiggestEverJackpot);}
else if ((a[i].innerHTML.match("Next Drawing: #Time#")) && (a[i].className == "row4"))
{
a[i].innerHTML = a[i].innerHTML.replace("Next Drawing: #Time#","Next Drawing: "+nextDraw);
a[i].innerHTML = a[i].innerHTML.replace("at #Time#","at "+DrawTime);
}
else if ((a[i].innerHTML.match("Recent Winners")) && (a[i].className == "maintitle"))
{
b = document.getElementsByTagName("TD");
for (j=0;j<b.length;j++)
if (b[j].innerHTML == "Member 1")
{
b[j].innerHTML = lastWinner[1];
b[j+2].innerHTML = lastWinner[2];
b[j+4].innerHTML = lastWinner[3];
b[j+1].innerHTML = sign+lastJackpot[1];
b[j+3].innerHTML = sign+lastJackpot[2];
b[j+5].innerHTML = sign+lastJackpot[3];
}
b = document.getElementsByTagName("TH");
for (j=0;j<b.length;j++)
if (b[j].innerHTML.match("Member 4"))
{
b[j].innerHTML = "<b>"+lastWinner[4]+"</b>";
b[j+1].innerHTML = "<b>"+sign+lastJackpot[4]+"</b>";
}
b = document.getElementsByTagName("DIV");
for (j=0;j<b.length;j++)
if (b[j].className == "tablepad")
{
var have = 1;
b[j].innerHTML = b[j].innerHTML.replace("$user",usar);
if (lastWinner[0] != usar)
if (lastWinner[1] != usar)
if (lastWinner[2] != usar)
if (lastWinner[3] != usar)
if (lastWinner[4] != usar) {
b[j].innerHTML = b[j].innerHTML.replace("$choice(have/have not)","have not"); have = 0;}
if (have == 1)
b[j].innerHTML = b[j].innerHTML.replace("$choice(have/have not)","have");
c = document.title.split(" ->")[0];
b[j].innerHTML = b[j].innerHTML.replace("$board",c);
}
}
else if ((a[i].innerHTML.match("Richest Members")) && (a[i].className == "maintitle"))
{
for(i=0;i<5;i++)
Richest[i]=["No one",0];
for (blah in banked)
{
if (banked[blah] > Richest[0][1])
{
Richest[4][0]=Richest[3][0];
Richest[3][0]=Richest[2][0];
Richest[2][0]=Richest[1][0];
Richest[1][0]=Richest[0][0];
Richest[4][1]=Richest[3][1];
Richest[3][1]=Richest[2][1];
Richest[2][1]=Richest[1][1];
Richest[1][1]=Richest[0][1];
Richest[0][1]=banked[blah];
Richest[0][0]=blah;
}
else if (banked[blah] > Richest[1][1])
{
Richest[4][0]=Richest[3][0];
Richest[3][0]=Richest[2][0];
Richest[2][0]=Richest[1][0];
Richest[4][1]=Richest[3][1];
Richest[3][1]=Richest[2][1];
Richest[2][1]=Richest[1][1];
Richest[1][1]=banked[blah];
Richest[1][0]=blah;
}
else if (banked[blah] > Richest[2][1])
{
Richest[4][0]=Richest[3][0];
Richest[3][0]=Richest[2][0];
Richest[4][1]=Richest[3][1];
Richest[3][1]=Richest[2][1];
Richest[2][1]=banked[blah];
Richest[2][0]=blah;
}
else if (banked[blah] > Richest[3][1])
{
Richest[4][0]=Richest[3][0];
Richest[4][1]=Richest[3][1];
Richest[3][1]=banked[blah];
Richest[3][0]=blah;
}
else if (banked[blah] > Richest[4][1])
{
Richest[4][1]=banked[blah];
Richest[4][0]=blah;
}
}
//Sloppy but i'm tired :D

b = document.getElementsByTagName("TD");
for (j=0;j<b.length;j++)
if (b[j].innerHTML == "Member 1")
{
b[j].innerHTML = Richest[0][0];
b[j+2].innerHTML = Richest[1][0];
b[j+4].innerHTML = Richest[2][0];
b[j+6].innerHTML = Richest[3][0];
b[j+1].innerHTML = sign+Richest[0][1];
b[j+3].innerHTML = sign+Richest[1][1];
b[j+5].innerHTML = sign+Richest[2][1];
b[j+7].innerHTML = sign+Richest[3][1];
}
b = document.getElementsByTagName("TH");
for (j=0;j<b.length;j++)
if (b[j].innerHTML.match("Member 5"))
{
b[j].innerHTML = "<b>"+Richest[4][0]+"</b>";
b[j+1].innerHTML = "<b>"+sign+Richest[4][1]+"</b>";
}
b = document.getElementsByTagName("DIV");
for (j=0;j<b.length;j++)
if (b[j].className == "tablepad")
{
var have = 1;
b[j].innerHTML = b[j].innerHTML.replace("$user",usar);
if (Richest[0][0] != usar)
if (Richest[1][0] != usar)
if (Richest[2][0] != usar)
if (Richest[3][0] != usar)
if (Richest[4][0] != usar) {
b[j].innerHTML = b[j].innerHTML.replace("$choice","are not"); have = 0;}
if (have == 1)
b[j].innerHTML = b[j].innerHTML.replace("$choice","are");
c = document.title.split(" ->")[0];
b[j].innerHTML = b[j].innerHTML.replace("$board",c);
}
break;
}


tds=document.getElementsByTagName("td");
for (p=0; p<tds.length; p++) {
temp=tds[p].getElementsByTagName("span");
for(x=0;x<temp.length;x++){
  if ((temp[x].className=="normalname") && (temp[x].getElementsByTagName("a").length==1))
{
if (itamz[temp[x].getElementsByTagName("a")[0].innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,"")])
{
for (blah in itemlist)
if (itemlist[blah][8] == 6)
if (HaveItem(temp[x].getElementsByTagName("a")[0].innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,""),blah))
if(tds[p+1].getElementsByTagName("SPAN").length==1)
{
    tds[p+1].getElementsByTagName("SPAN")[0].style.color= itemlist[blah][9];
    tds[p+1].getElementsByTagName("SPAN")[0].style.backgroundColor= itemlist[blah][10];
for (i=p;i<p+4;i++)
{

    tds[i].style.color= itemlist[blah][9];
    tds[i].style.backgroundColor= itemlist[blah][10];
}}}
    }
  }
}

tds=document.getElementsByTagName("td");
for (p=0; p<tds.length; p++) {
temp=tds[p].getElementsByTagName("span");
for(x=0;x<temp.length;x++){
  if ((temp[x].className=="normalname") && (temp[x].getElementsByTagName("a").length==1))
{
if (itamz[temp[x].getElementsByTagName("a")[0].innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,"")])
{
for (blah in itemlist)
if (itemlist[blah][8] == 7)
if (HaveItem(temp[x].getElementsByTagName("a")[0].innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,""),blah))
if(tds[p+1].getElementsByTagName("SPAN").length==1)
    tds[p+3].style.backgroundImage= "url("+itemlist[blah][9]+")";
    //tds[p+3].style.backgroundRepeat= itemlist[blah][10];
}
    }
  }
}

a = document.getElementsByTagName("A");
for (i=0;i<a.length;i++)
{
b = a[i].innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,"")
if (itamz[b])
{
for (blah in itemlist)
if (itemlist[blah][8] == 3)
if (HaveItem(b,blah))
{
a[i].innerHTML = itemlist[blah][9] + a[i].innerHTML + itemlist[blah][10];
}}}
HookYourOwnStuffHere();
done = 1;
}

// Money code
// By Gornakle of InvisionFree.com

// No need to edit below this line!
td=document.getElementsByTagName("TD")
for(i=0;i<td.length;i++) {
if((td[i].className=="post1"||td[i].className=="post2")&&td[i].innerHTML.match("Posts: ")&&td[i].width!="100%") {
 sPost=td[i].getElementsByTagName("SPAN")[0]
 if(sPost.innerHTML.replace(",","").replace('.','').replace(' ','').match(/Posts: (\d+)/)) Posts = parseInt(RegExp.$1)  
 uname = td[i-2].innerHTML.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,"")
  if(MID[uname]){ EXP = (parseInt(MID[uname]) + (Posts * PerPost))+parseInt(default_amount) }
else{ EXP = (Posts * PerPost)+parseInt(default_amount) }

if (!noRPG)
sPost.innerHTML += "<br/><br/><br/><center><b>Items</b></center>"
a = "<table width='100%' class='tableborder' align='left'><tr><td width='100%' align='left'>";

if (noRPG)
 a = "";

if (!noRPG)
{
for (blah in itemlist)
{
if ((HaveItem(uname,blah)) && (itemlist[blah][7] != 0))
a += "<img src='"+itemlist[blah][2]+"' onMouseOver=(itemboxchange('"+itemboxno+"','"+blah+"')); onMouseOut=(itemboxclear('"+itemboxno+"'));> &nbsp;"
}
a += "<\/td><\/tr><tr height='20px'><td width = '100%' id=itembox"+itemboxno+">";
itemboxno++;
a += "&nbsp;<\/td><\/tr><\/table>";
a +="<br/><br/><br/><br/>"

if (XP[uname])
var theXP = XPPerPost*Posts + XP[uname];
else
var theXP = XPPerPost*Posts;

if (navigator.appName == "Microsoft Internet Explorer")
a+="<br /><br /><br />"

if (uclass[uname])
a += "<br/><br/>" + classes[uclass[uname]][0];
else
a += "<br/><br/>No Class";

a += "<br/>Level: "+GetLevel(theXP, uname);

a += "<br>XP: "+theXP;
}

a +="<br>Reputation: <a href='Javascript:Subrep("+'"'+uname+'"'+")'>"+minuspic+"</a>&nbsp;&nbsp;"
if (reputation[uname])
a +=reputation[uname]
else
a+= "0";
a +="&nbsp;&nbsp;<a href='Javascript:Addrep("+'"'+uname+'"'+")'>"+pluspic+"</a>"


a += "<br>"+name+": "+sign+EXP;

a += "<center>";
if (isAdmin)
a +="<a href='Javascript:ReduceCash("+'"'+uname+'"'+")'>"+minuspic+"</a>&nbsp;&nbsp;"
a +="<a href='Javascript:Donate("+'"'+uname+'"'+")'>"+donatepic+"</a>"
if (isAdmin)
a +="&nbsp;&nbsp;<a href='Javascript:IncreaseCash("+'"'+uname+'"'+")'>"+pluspic+"</a>"
a+="</center>"

if (!noRPG)
a +="<br><center><a href='"+BaseURL+"?act=skirmish&fighter="+uname+"'>"+skirmishpic+"</a><br><br><a href='Javascript:AddFight("+'"'+uname+'"'+")'>"+fightpic+"</a></center>"


if(noRPG == 0)
{
if (classavatars)
{
if (uclass[uname])
{
if (GetLevel(theXP, uname) < 36)
{
b = sPost.getElementsByTagName("IMG");
for (j=0;j<b.length;j++)
if (b[j].alt == "")
 b[j].style.display = "none";
if (Gender[uname] == "F")
{
if (GetLevel(theXP, uname) < 9)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][10] + "' width='100px' height='100px'>" + sPost.innerHTML;
else if (GetLevel(theXP, uname) < 18)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][11] + "' width='100px' height='100px'>" + sPost.innerHTML;
else
sPost.innerHTML = "<img src='" + classes[uclass[uname]][12] + "' width='100px' height='100px'>" + sPost.innerHTML;
}
else
{
if (GetLevel(theXP, uname) < 9)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][6] + "' width='100px' height='100px'>" + sPost.innerHTML;
else if (GetLevel(theXP, uname) < 18)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][8] + "' width='100px' height='100px'>" + sPost.innerHTML;
else
sPost.innerHTML = "<img src='" + classes[uclass[uname]][9] + "' width='100px' height='100px'>" + sPost.innerHTML;
}
}
}
else
{
b = sPost.getElementsByTagName("IMG");
for (j=0;j<b.length;j++)
if (b[j].alt == "")
 b[j].style.display = "none";
if (Gender[uname] == "F")
sPost.innerHTML = "<img src='" + classes["NoClass"][10] + "' width='100px' height='100px'>" + sPost.innerHTML;
else
sPost.innerHTML = "<img src='" + classes["NoClass"][6] + "' width='100px' height='100px'>" + sPost.innerHTML;
}
}

if (!classavatars)
{
if (uclass[uname])
{
if (GetLevel(theXP, uname) < 36)
{
b = sPost.getElementsByTagName("IMG");
c = 1;
for (j=0;j<b.length;j++)
if (b[j].alt == "")
 c = 0;
if (c == 1)
{
if (Gender[uname] == "F")
{
if (GetLevel(theXP, uname) < 9)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][10] + "' width='100px' height='100px'>" + sPost.innerHTML;
else if (GetLevel(theXP, uname) < 18)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][11] + "' width='100px' height='100px'>" + sPost.innerHTML;
else
sPost.innerHTML = "<img src='" + classes[uclass[uname]][12] + "' width='100px' height='100px'>" + sPost.innerHTML;
}
else
{
if (GetLevel(theXP, uname) < 9)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][6] + "' width='100px' height='100px'>" + sPost.innerHTML;
else if (GetLevel(theXP, uname) < 18)
sPost.innerHTML = "<img src='" + classes[uclass[uname]][8] + "' width='100px' height='100px'>" + sPost.innerHTML;
else
sPost.innerHTML = "<img src='" + classes[uclass[uname]][9] + "' width='100px' height='100px'>" + sPost.innerHTML;
}
}
}
}
else
{
b = sPost.getElementsByTagName("IMG");
c = 1;
for (j=0;j<b.length;j++)
if (b[j].alt == "")
 c = 0;
if (c == 1)
{
if (Gender[uname] == "F")
sPost.innerHTML = "<img src='" + classes["NoClass"][10] + "' width='100px' height='100px'>" + sPost.innerHTML;
else
sPost.innerHTML = "<img src='" + classes["NoClass"][6] + "' width='100px' height='100px'>" + sPost.innerHTML;
}
}
}

}
sPost.innerHTML += a;
}

}

}

function GetEditString(lotterydone)
{
for (blah in parent.MID)
{
rawr += "[url=http://www.google.co.uk]"+blah+"[/url] [i]" + parent.MID[blah]+"#";
if(parent.itamz[blah])
rawr += parent.itamz[blah];
rawr += "%";
if (parent.banked[blah])
rawr += parent.banked[blah];
else
rawr += "0";
rawr += "^";
if (parent.uclass[blah])
rawr += parent.uclass[blah];
else
rawr += "NoClass";
rawr += "*";
if (parent.XP[blah])
rawr += parent.XP[blah];
else
rawr += "0";
rawr += "~";
if (parent.level[blah])
rawr += parent.level[blah];
else
rawr += "0";
rawr += "£";
if (parent.reputation[blah])
rawr += parent.reputation[blah];
else
rawr += "0";
rawr += "@";
if (parent.BattlesWon[blah])
rawr += parent.BattlesWon[blah];
else
rawr += 0;
rawr += "@";
if (parent.BattlesLost[blah])
rawr += parent.BattlesLost[blah];
else
rawr += 0;
rawr += "@";
if (parent.Gender[blah])
rawr += parent.Gender[blah];
else
rawr += 0;
rawr += "@";
if (parent.Auction[blah])
rawr+= parent.Auction[blah][0]+"@"+ parent.Auction[blah][1]+"@"+ parent.Auction[blah][2]+"@"+ parent.Auction[blah][3]+"@";
else
rawr+="0@0@0@0@";
if (parent.Stats[blah])
rawr+= parent.Stats[blah][0]+"@"+ parent.Stats[blah][1]+"@"+ parent.Stats[blah][2]+"@"+ parent.Stats[blah][3]+"@"+ parent.Stats[blah][4]+"@"+ parent.Stats[blah][5]+"@";
else
rawr+=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3)+"@"+Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3)+"@"+Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3)+"@"+Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3)+"@"+Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3)+"@"+Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3)+"@";

rawr += "[/i] ";
}
if (lotterydone == 1)
{
rawr += "Last Jackpot: [i]" + parent.Jackpot + "[/i] ";
rawr += "Last Winner: [i]" + parent.winner + "[/i] ";
rawr += "Biggest Ever Jackpot: [i]" + parent.BiggestEverJackpot + "[/i]";
rawr += "Last Winner -1: [i]" + parent.lastWinner[0] + "[/i] ";
rawr += "Last Winner -2: [i]" + parent.lastWinner[1] + "[/i] ";
rawr += "Last Winner -3: [i]" + parent.lastWinner[2] + "[/i] ";
rawr += "Last Winner -4: [i]" + parent.lastWinner[3] + "[/i] ";
rawr += "Last Jackpot -1: [i]" + parent.lastJackpot[0] + "[/i] ";
rawr += "Last Jackpot -2: [i]" + parent.lastJackpot[1] + "[/i] ";
rawr += "Last Jackpot -3: [i]" + parent.lastJackpot[2] + "[/i] ";
rawr += "Last Jackpot -4: [i]" + parent.lastJackpot[3] + "[/i] ";
rawr += "Last Draw: [i]" + Date() + "[/i] ";
rawr += "Next Draw: [i]" + parent.document.getElementById('pwnt').value + "[/i]";
rawr += "Daily Draw: [i]" + parent.document.getElementById('hahaha').value + "[/i]";
}
else
{
rawr += "Last Jackpot: [i]" + parent.lastJackpot[0] + "[/i] ";
rawr += "Last Winner: [i]" + parent.lastWinner[0] + "[/i] ";
rawr += "Biggest Ever Jackpot: [i]" + parent.BiggestEverJackpot + "[/i]";
rawr += "Last Winner -1: [i]" + parent.lastWinner[1] + "[/i] ";
rawr += "Last Winner -2: [i]" + parent.lastWinner[2] + "[/i] ";
rawr += "Last Winner -3: [i]" + parent.lastWinner[3] + "[/i] ";
rawr += "Last Winner -4: [i]" + parent.lastWinner[4] + "[/i] ";
rawr += "Last Jackpot -1: [i]" + parent.lastJackpot[1] + "[/i] ";
rawr += "Last Jackpot -2: [i]" + parent.lastJackpot[2] + "[/i] ";
rawr += "Last Jackpot -3: [i]" + parent.lastJackpot[3] + "[/i] ";
rawr += "Last Jackpot -4: [i]" + parent.lastJackpot[4] + "[/i] ";
rawr += "Last Draw: [i]" + parent.lastDraw + "[/i] ";
rawr += "Next Draw: [i]" + parent.nextDraw + "[/i]";
rawr += "Daily Draw: [i]" + parent.DrawTime + "[/i]";
}
rawr += "MOTD: [i]" + parent.theMOTD + "[/i]";
rawr += "Setter: [i]" + parent.MOTDsetter + "[/i]";
for (blah in parent.results)
rawr += "Fight: [i]" + parent.results[blah] + "[/i]";
}

if ((location.href.indexOf("act=lottery") != -1) && (isAdmin == 1))
{
a = document.getElementById("lottery_draw");
a.innerHTML = "<div class='tableborder'><div class='maintitle'><img src='http://67.18.37.14/style_images/1/nav_m.gif'> Admin CP</div><div class='row4'><center><br />Next Draw<br /><textarea rows='4' cols='20' id='pwnt'></textarea><br><br>Time of daily draw<br /><textarea rows='1' cols='20' id='hahaha'></textarea><br><br><a href='javascript:EditIt()'>Do Draw</a><br><br /></div></div><br /></center>"
}

function GetTommorrow()
{
tommorrow = new Date();
tommorrow.setDate(tommorrow.getDate()+1)
var days = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var months = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var day = days[tommorrow.getDay()];
var month = months[tommorrow.getMonth()];
var lollerskates = day + " " + tommorrow.getDate() + " " + month + " " + tommorrow.getFullYear() + ", " + DrawTime;
return lollerskates;
}

function HaveItem(theUser,tehItam)
{
if (!itamz[theUser])
return false;
if(itamz[theUser].match(tehItam))
return true;
return false;
}

function itemboxchange(thebox,thename) {
thebox = "itembox"+thebox;
a = document.getElementById(thebox);
a.innerHTML = itemlist[thename][3];
}

function itemboxclear(thebox) {
thebox = "itembox"+thebox;
a = document.getElementById(thebox);
a.innerHTML = "&nbsp;";
}

function storeboxchange(theitem) {
a = document.getElementById("tehitempix");
a.innerHTML = "<img src='"+itemlist[theitem][1]+"' width='100px' height='100px'>";
a = document.getElementById("tehitemdesc");
a.innerHTML = itemlist[theitem][4];
}

function storeboxblank() {
a = document.getElementById("tehitempix");
a.innerHTML = "&nbsp;";
a = document.getElementById("tehitemdesc");
a.innerHTML = "&nbsp;";
}

function BuyIt(tehItam)
{
mode = 4;
if (itemlist[tehItam])
{
what = "Item("+tehItam+")";
amount = "$"+itemlist[tehItam][0];
if ((usar != "Log In") && (done == 1))
{
if (mycash <  itemlist[tehItam][0])
alert ("You don't have the cash!")
else if (HaveItem(usar,tehItam))
alert ("You already have one!")
else if (itemlist[tehItam][6] < 1)
alert ("None in stock!")
else if (!CanUse(uclass[usar],tehItam))
alert ("You can't use this!")
else
parent.frames['doh'].location = PostURL;
}}}

function SellIt(tehItam)
{
mode = 4;
if (itemlist[tehItam])
{
what = "Sell("+tehItam+")";
amount = "$"+Math.floor(itemlist[tehItam][0]/2);
if ((usar != "Log In") && (done == 1))
{
if (!HaveItem(usar,tehItam))
alert ("You don't have one!")
else
parent.frames['doh'].location = PostURL;
}}}

function AddItemToList(itam)
{
a = document.getElementById("tehtabel");
b = a.getElementsByTagName('TR');
c = b[1].cloneNode(true);
c.className="";
b[1].parentNode.insertBefore(c,b[1])
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[0].innerHTML="<a href='Javascript:BuyIt("+'"'+itam+'"'+")' onMouseOver=(storeboxchange('"+itam+"')); onMouseOut=(storeboxblank());>"+itemlist[itam][3]+"</a>";
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[1].innerHTML="<img src='"+itemlist[itam][2]+"'onMouseOver=(storeboxchange('"+itam+"')); onMouseOut=(storeboxblank());>";
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[2].innerHTML=itemlist[itam][6];
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[3].innerHTML=sign+itemlist[itam][0];
}

function AddItemToSellList(itam)
{
a = document.getElementById("tehtabel");
b = a.getElementsByTagName('TR');
c = b[1].cloneNode(true);
c.className="";
b[1].parentNode.insertBefore(c,b[1])
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[0].innerHTML="<a href='Javascript:SellIt("+'"'+itam+'"'+")' onMouseOver=(storeboxchange('"+itam+"')); onMouseOut=(storeboxblank());>"+itemlist[itam][3]+"</a>";
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[1].innerHTML="<img src='"+itemlist[itam][2]+"'onMouseOver=(storeboxchange('"+itam+"')); onMouseOut=(storeboxblank());>";
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[2].innerHTML=itemlist[itam][6];
a.getElementsByTagName('TR')[1].getElementsByTagName("TD")[3].innerHTML=sign+Math.floor(itemlist[itam][0]/2);
}

function BuyMOTD()
{
mode = 4;
amount = "$"+MOTDprice;
if ((usar != "Log In") && (done == 1))
{
if (mycash <  MOTDprice)
alert ("You don't have the cash!")
else
{
what = "BuyMOTD("+prompt("Enter MOTD:","").replace("(","[").replace(")","]").replace(/<[^>]+>/g,"").replace(/&nbsp;/g,"")+")";
parent.frames['doh'].location = PostURL;
}}}


function Bid(who)
{
mode = 4;
what = "Bid("+who+")";
amount = prompt("How much to bid?","10");
amount = amount.replace(/[^\d]+/g, '');
if ((usar != "Log In") && (done == 1))
{
if (mycash < parseInt(amount))
alert ("You don't have the cash!")
else if (parseInt(amount) < Auction[who][3])
alert ("Bid must be higher!")
else if (usar == who)
alert ("No bidding on yourself!")
else if (amount.length == 0)
alert ("Please enter a number")
else if (!CanUse(uclass[usar], Auction[who][0]))
alert ("You can't use this!")
else
{
amount = "$"+amount;
parent.frames['doh'].location = PostURL;
}}}

function Donate(who)
{
mode = 4;
what = "Donation("+who+")";
amount = prompt("How much to donate?","10");
amount = amount.replace(/[^\d]+/g, '');
if ((usar != "Log In") && (done == 1))
{
if (mycash < parseInt(amount))
alert ("You don't have the cash!")
else if (parseInt(amount) < 0)
alert ("No stealing kthx")
else if (amount.length == 0)
alert ("Please enter a number")
else
{
amount = "$"+amount;
parent.frames['doh'].location = PostURL;
}}}

function Addrep(who)
{
mode = 4;
what = "Addrep("+who+")";
amount = "$"+0;
if ((usar != "Log In") && (done == 1))
{
if (repped[usar]=="Very Yes")
alert ("You have already repped today!")
else if (usar == who)
alert ("No repping yourself!")
else
parent.frames['doh'].location = PostURL;
}}

function Subrep(who)
{
mode = 4;
what = "Subrep("+who+")";
amount = "$"+0;
if ((usar != "Log In") && (done == 1))
{
if (repped[usar]=="Very Yes")
alert ("You have already repped today!")
else if (usar == who)
alert ("No repping yourself!")
else
parent.frames['doh'].location = PostURL;
}}

function AddFight(who)
{
mode = 4;
what = "Fight("+who+")";
amount = "$"+0;
if ((usar != "Log In") && (done == 1))
{
if (fight[usar])
alert ("You have already challenged today!")
else if (usar == who)
alert ("No fighting yourself!")
else if (!uclass[who])
alert ("No fighting non-players!")
else if (uclass[who] == "NoClass")
alert ("No fighting non-players!")
else if (!uclass[usar])
alert ("Please select a class in My Controls before battle.")
else if (uclass[usar] == "NoClass")
alert ("Please select a class in My Controls before battle.")
else
{
parent.frames['doh'].location = PostURL;
alert ("Challenged! Fight will be run at "+nextDraw)
}}}

function ReduceCash(who)
{
amount = prompt("How much to reduce by?","10");
amount = amount.replace(/[^\d]+/g, '');
if (isAdmin)
ChangeCash(who,0-parseInt(amount));
}

function IncreaseCash(who)
{
amount = prompt("How much to increase by?","10");
amount = amount.replace(/[^\d]+/g, '');
if (isAdmin)
ChangeCash(who,parseInt(amount));
}

function BankIt()
{
mode = 4;
amount = prompt("How much to pay in?","10");
amount = parseInt(amount.replace(/[^\d]+/g, ''));
what = "Payed In";
if ((usar != "Log In") && (done == 1))
{
if (mycash < amount)
alert ("You don't have the cash!")
else
{
amount = "$" + amount;
parent.frames['doh'].location = PostURL;
}}}

function WithdrawIt()
{
mode = 4;
amount = prompt("How much to withdraw?","10");
amount = parseInt(amount.replace(/[^\d]+/g, ''));
what = "Withdrawal";
if ((usar != "Log In") && (done == 1) && (banked[usar]))
{
if (banked[usar] < amount)
alert ("You don't have the cash!")
else
{
amount = "$" + amount;
parent.frames['doh'].location = PostURL;
}}}

function PostClass(theclass)
{
mode = 4;
amount = "$"+0;
what = "Class("+theclass+")";
if ((usar != "Log In") && (done == 1))
parent.frames['doh'].location = PostURL;
}

function ChangeClass(theclass)
{
if (Gender[usar] == "M")
document.getElementById("thepic").getElementsByTagName("IMG")[0].src=classes[theclass][6];
else
document.getElementById("thepic").getElementsByTagName("IMG")[0].src=classes[theclass][10];
a = "<table><th><b>Stats</b></th><tr><td>EXP Speed:</td><td>"
if (classes[theclass][1] > 12)
 a += "Slow"
else if (classes[theclass][1] < 9)
 a += "Fast"
else
 a += "Midrange"
a += "</td></tr><tr><td>Hit Chance:</td><td>"
if (classes[theclass][2] > 2)
 a += "Bad"
else if (classes[theclass][2] < 1.5)
 a += "Good"
else
 a += "Midrange"
a += "</td></tr><tr><td>Health:</td><td>"
if (classes[theclass][3] > 9)
 a += "High"
else if (classes[theclass][3] < 7)
 a += "Low"
else
 a += "Midrange"
a += "</td></tr><tr><td>Proficiency:</td><td>"
 a += classes[theclass][4].replace(/@/g,", ");
a += "</td></tr><tr><td>Deficiency:</td><td>"
 a += classes[theclass][5].replace(/@/g,", ");
a += "</td></tr><tr><td>Unusable:</td><td>"
 a += classes[theclass][13].replace(/@/g,", ");

a += "</td></tr></table><br>"

a+= "<input type ='button' onclick='Javascript:PostClass("+'"'+theclass+'"'+")' value='Choose "+classes[theclass][0]+"'>";
document.getElementById("thestats").innerHTML = a;
}

function ChangeGender(thegender)
{
mode = 4;
amount = "$"+0;
what = "Gender("+thegender+")";
if ((usar != "Log In") && (done == 1))
parent.frames['doh'].location = PostURL;
}

function AuctionIt(theItem)
{
mode = 4;
amount = "$"+0;
what = "Auction("+theItem+")";
if ((usar != "Log In") && (done == 1))
parent.frames['doh'].location = PostURL;
}

function DoPMs()
{
mode = 7;
numpms--;
if (numpms >= 0)
{
if (PMs[numpms][0] == 1)
{
messagetitle = "Donation from " + PMs[numpms][1];
messagebody = PMs[numpms][1] +" " + DonateMessage + " "+sign+PMs[numpms][3]+"!";
recipient = PMs[numpms][2];
}
else if (PMs[numpms][0] == 2)
{
messagetitle = "Your Item"
messagebody = "The url for your item is " + BoughtURLs[itemlist[PMs[numpms][2]][9]] + ". If there are any issues please contact an admin. Enjoy your purchase!";
recipient = PMs[numpms][1];
}
parent.frames['doh'].location = PMUrl;


}
}

function SortByPrice(y,z)
{
if (itemlist[y][0] < itemlist[z][0])
 return 1;
else if (itemlist[y][0] > itemlist[z][0])
 return -1;
else
 return 0;
}

function GetLevel(xp, theusar)
{
if (!uclass[theusar])
 return 0;
if (uclass[theusar] == "NoClass")
 return 0;
z = classes[uclass[theusar]][1];
z = Math.floor((Math.log(xp/z)));
return z;
}

function CanUse(theclass,theitem)
{
t = classes[theclass][13].split("@");
if (noRPG)
 return true;
for (u = 0;u<t.length;u++)
if (t[u]==itemlist[theitem][10])
 return false;
return true;

}

function Proficient(theclass,theitem)
{
t = classes[theclass][4].split("@");
for (u = 0;u<t.length;u++)
if (t[u]==itemlist[theitem][10])
 return true;
return false;

}


function Deficient(theclass,theitem)
{
t = classes[theclass][5].split("@");
for (u = 0;u<t.length;u++)
if (t[u]==itemlist[theitem][10])
 return true;
return false;

}

function GetBonus(thestat)
{
   if (thestat < 6)
     return -4;
   if (thestat > 18)
     return 3;
   return (Math.floor((thestat - 12)/2));
}

function ShowAwardDetails(feck)
{
awarddetails.innerHTML="<center>"+itemlist[feck][9]+"</center>";

}

function HideAwardDetails(feck)
{
awarddetails.innerHTML="&nbsp;";

}

function SkirmishChange(whatever)
{
 theskirmish = whatever;
uname = whatever;


a = "<br/><center><b>Items</b></center>"
a += "<table width='100%' class='tableborder' align='left'><tr><td width='100%' align='left'>";


for (blah in itemlist)
{
if ((HaveItem(uname,blah)) && (itemlist[blah][7] != 0))
a += "<img src='"+itemlist[blah][2]+"' onMouseOver=(itemboxchange('"+itemboxno+"','"+blah+"')); onMouseOut=(itemboxclear('"+itemboxno+"'));> &nbsp;"
}
a += "<\/td><\/tr><tr height='20px'><td width = '100%' id=itembox"+itemboxno+">";
itemboxno++;
a += "&nbsp;<\/td><\/tr><\/table>";
a +="<br/><br/>"


a += classes[uclass[uname]][0];

a += "<br/>Level: "+level[uname];

if (Gender[uname] == "F")
{
if (level[uname] < 9)
b = "<img src='" + classes[uclass[uname]][10] + "' width='100px' height='100px'>";
else if (level[uname] < 18)
b = "<img src='" + classes[uclass[uname]][11] + "' width='100px' height='100px'>";
else
b = "<img src='" + classes[uclass[uname]][12] + "' width='100px' height='100px'>";
}
else
{
if (level[uname] < 9)
b = "<img src='" + classes[uclass[uname]][6] + "' width='100px' height='100px'>";
else if (level[uname] < 18)
b = "<img src='" + classes[uclass[uname]][8] + "' width='100px' height='100px'>";
else
b = "<img src='" + classes[uclass[uname]][9] + "' width='100px' height='100px'>";
}

document.getElementById("theSkirmish").innerHTML = "<center>"+b +"</center>"+ a;

}

function SkirmishIt()
{
window.location.href=BaseURL+"?act=skirmish&fighter="+theskirmish;
}

function DoFight(user1, user2)
{
str = user1 + "#" + user2 + "~";
str += user1 +" challenges " + user2 + "!|"

var itemnum1=0;
var itemnum2=0;
var theitems1=[];
var theitems2=[];
var ranged1 = 0;
var ranged2 = 0;
var melee1 = 0;
var melee2 = 0;

var belt1= [];
var belt2 = [];

var num = 0;
var theitemlist=[];

var itamzz=[];

if (!Stats[user1])
{
Stats[user1]=[];
Stats[user1][0]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user1][1]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user1][2]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user1][3]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user1][4]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user1][5]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
}


if (!Stats[user2])
{
Stats[user2]=[];
Stats[user2][0]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user2][1]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user2][2]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user2][3]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user2][4]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
Stats[user2][5]=Math.floor(Math.random()*6+Math.random()*6+Math.random()*6+3);
}
for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==1)
if (HaveItem(user1,blah))
{theitemlist[num]=blah;num++;}
if (num == 0)
melee1 = "nothing"
else
melee1 = theitemlist[Math.floor(Math.random()*num)];

num=0;
for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==1)
if (HaveItem(user2,blah))
{theitemlist[num]=blah;num++;}
if (num == 0)
melee2 = "nothing"
else
melee2 = theitemlist[Math.floor(Math.random()*num)];

num=0;
for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==2)
if (HaveItem(user1,blah))
{theitemlist[num]=blah;num++;}
if (num == 0)
ranged1 = "nothing"
else
ranged1 = theitemlist[Math.floor(Math.random()*num)];

num=0;
for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==2)
if (HaveItem(user2,blah))
{theitemlist[num]=blah;num++;}
if (num == 0)
ranged2 = "nothing"
else
ranged2 = theitemlist[Math.floor(Math.random()*num)];

for (rawr in itemlist)
if (HaveItem(user1,rawr))
if ((!itamzz[itemlist[rawr][9]]) && ([itemlist[rawr][9]] > 2))
{
num=0;
for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==itemlist[rawr][9])
if (HaveItem(user1,blah))
{theitemlist[num]=blah;num++;}
theitems1[itemnum1] = theitemlist[Math.floor(Math.random()*num)];
itemnum1++;
itamzz[itemlist[rawr][9]]=true;
}

itamzz = null; itamzz = [];

for (rawr in itemlist)
if (HaveItem(user2,rawr))
if ((!itamzz[itemlist[rawr][9]]) && ([itemlist[rawr][9]] > 2))
{
num=0;
for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==itemlist[rawr][9])
if (HaveItem(user2,blah))
{theitemlist[num]=blah;num++;}
theitems2[itemnum2] = theitemlist[Math.floor(Math.random()*num)];
itemnum2++;
itamzz[itemlist[rawr][9]]=true;
}

for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==0)
if (HaveItem(user1,blah))
belt1[blah]=true;

for (blah in itemlist)
if (itemlist[blah][8]==1)
if (itemlist[blah][9]==0)
if (HaveItem(user2,blah))
belt2[blah]=true;


str += user1 +" wields " + itemlist[melee1][3] + ", and " + itemlist[ranged1][3] + " as a ranged weapon!|"
if (itemnum1 == 0)
str += user1 +" wears nothing! |";
else
{str += user1 + " wears "
if (itemnum1 == 1)
str += itemlist[theitems1[0]][3]
else
for (blah in theitems1)
{
if (itemnum1 >1)
str += itemlist[theitems1[blah]][3] + ", ";
else
str += "and " + itemlist[theitems1[blah]][3];
itemnum1--;
}
str += "!|";
}

str += user2 +" wields " + itemlist[melee2][3] + ", and " + itemlist[ranged2][3] + " as a ranged weapon!|"
if (itemnum2 == 0)
str += user2 +" wears nothing! |";
else
{str += user2 + " wears "
if (itemnum2 == 1)
str += itemlist[theitems2[0]][3]
else
for (blah in theitems2)
{
if (itemnum2 >1)
str += itemlist[theitems2[blah]][3] + ", ";
else
str += "and " + itemlist[theitems2[blah]][3];
itemnum2--;
}
str += "!|";
}

var ac1 = 10+itemlist[ranged1][14];
var ac2 = 10+itemlist[ranged2][14];
if (itemlist[ranged1][17] == 1)
var thaco1 = 20 - Math.floor(parseInt(level[user1])/parseInt(classes[uclass[user1]][2])) + itemlist[ranged1][13];
else
var thaco1 = 20 + itemlist[ranged1][13];
if (itemlist[ranged2][17] == 1)
var thaco2 = 20 - Math.floor(parseInt(level[user2])/parseInt(classes[uclass[user2]][2])) + itemlist[ranged2][13];
else
var thaco2 = 20 + itemlist[ranged2][13];
var hp1 = 5+parseInt(level[user1])*(parseInt(classes[uclass[user1]][3])+GetBonus(Stats[user1][5]));
var hp2 = 5+parseInt(level[user2])*(parseInt(classes[uclass[user2]][3])+GetBonus(Stats[user2][5]));
var dam1 = itemlist[ranged1][11];
var dam2 = itemlist[ranged2][11];
var damplus1 = itemlist[ranged1][12];
var damplus2 = itemlist[ranged2][12];

var maxhp1 = hp1;
var maxhp2 = hp2;

var frozen1 = 0;
var frozen2 = 0;
var onfire1 = 0;
var onfire2 = 0;
var poisoned1 = 0;
var poisoned2 = 0;

GoldSteal1 = GoldSteal2 = GoldSteal;


freezepowers1 = 0;
freezepowers2 = 0;
poisonpowers1 = 0
poisonpowers2 = 0;
firepowers1 = 0;
firepowers2 = 0;
//I should have done this with arrays. Maybe later when I do that big cleanup
//(Sorry HolySaviour!)
powers1=[];
powers2=[];


for (blah in theitems1)
{
ac1 += itemlist[theitems1[blah]][14];
thaco1 += itemlist[theitems1[blah]][13];
damplus1 += itemlist[theitems1[blah]][12];
if ((itemlist[theitems1[blah]][15] == "Freeze") || (itemlist[theitems1[blah]][16] == "Freeze"))
freezepowers1 = 1;
if ((itemlist[theitems1[blah]][15] == "Poison") || (itemlist[theitems1[blah]][16] == "Poison"))
poisonpowers1 = 1;
if ((itemlist[theitems1[blah]][15] == "Fire") || (itemlist[theitems1[blah]][16] == "Fire"))
firepowers1 = 1;
powers1[itemlist[theitems1[blah]][15]] = true;
powers1[itemlist[theitems1[blah]][16]] = true;
}

for (blah in theitems2)
{
ac2 += itemlist[theitems2[blah]][14];
thaco2 += itemlist[theitems2[blah]][13];
damplus2 += itemlist[theitems2[blah]][12];
if ((itemlist[theitems2[blah]][15] == "Freeze") || (itemlist[theitems2[blah]][16] == "Freeze"))
freezepowers2 = 1;
if ((itemlist[theitems2[blah]][15] == "Poison") || (itemlist[theitems2[blah]][16] == "Poison"))
poisonpowers2 = 1;
if ((itemlist[theitems2[blah]][15] == "Fire") || (itemlist[theitems2[blah]][16] == "Fire"))
firepowers2 = 1;
powers2[itemlist[theitems2[blah]][15]] = true;
powers2[itemlist[theitems2[blah]][16]] = true;
}

if ((itemlist[ranged1][15] == "Freeze") || (itemlist[ranged1][16] == "Freeze"))
freezepowers1 = 1;
if ((itemlist[ranged2][15] == "Freeze") || (itemlist[ranged2][16] == "Freeze"))
freezepowers2 = 1;
if ((itemlist[ranged1][15] == "Poison") || (itemlist[ranged1][16] == "Poison"))
poisonpowers1 = 1;
if ((itemlist[ranged2][15] == "Poison") || (itemlist[ranged2][16] == "Poison"))
poisonpowers2 = 1;
if ((itemlist[ranged1][15] == "Fire") || (itemlist[ranged1][16] == "Fire"))
firepowers1 = 1;
if ((itemlist[ranged2][15] == "Fire") || (itemlist[ranged2][16] == "Fire"))
firepowers2 = 1;
powers1[itemlist[ranged1][15]] = true;
powers1[itemlist[ranged1][16]] = true;
powers2[itemlist[ranged2][15]] = true;
powers2[itemlist[ranged2][16]] = true;

if (Proficient(uclass[user1],ranged1))
 damplus1 += level[user1];
else if (Deficient(uclass[user1],ranged1))
 {damplus1 = Math.floor(damplus1/2); dam1 = Math.floor(dam1 / 2); thaco1 += 5;}

if (Proficient(uclass[user2],ranged2))
 damplus2 += level[user2];
else if (Deficient(uclass[user2],ranged2))
 {damplus2 = Math.floor(damplus2/2); dam2 = Math.floor(dam2 / 2); thaco2 += 5;}

damplus1 += GetBonus(Stats[user1][itemlist[ranged1][18]]);
damplus2 += GetBonus(Stats[user2][itemlist[ranged2][18]]);

thaco1 += GetBonus(Stats[user1][itemlist[ranged1][19]]);
thaco2 += GetBonus(Stats[user2][itemlist[ranged2][19]]);

ac1 += GetBonus(Stats[user1][itemlist[ranged2][20]]);
ac2 += GetBonus(Stats[user2][itemlist[ranged1][20]]);

turn = TurnsOfRanged;

if(powers1["Flight"])
 turn = turn*2;
if(powers2["Flight"])
 turn = turn*2;

if(powers1["Speed"])
 turn = Math.floor(turn/2);
if(powers2["Speed"])
 turn = Math.floor(turn/2);

var acmod2 = 0;

while ((hp1 > 0) && (hp2 > 0) && (turn > 0))
{
if (powers1["Regen"])
 hp1 += 2;
if (hp1 > maxhp1)
 hp1 = maxhp1;
if (freezepowers1)
 onfire1 = 0;
if (powers1["Antidote"])
 poisoned1 = 0;
if (frozen1 == 1)
{
frozen1 = 0;
str += user1 +" is frozen!|"
}
else if (powers2["Sleep"])
{
powers2["Sleep"] = false;
str += user1 +" has been slept!|"
}
else if (powers2["Sneak"])
{
powers2["Sneak"] = false;
str += user2 +" avoids " +user1 +"!|"
}
else
{
dammod1 = 0;
acmod1 = 0;
luckmod1 = 0;
thacmod1 = 0;

for (blah in belt1)
if (belt1[blah])
if (((Math.floor (Math.random() * 20) < itemlist[blah][18]) || (Proficient(uclass[user1],blah) && (Math.floor (Math.random() * 20) < itemlist[blah][18]))) && ((hp1 + itemlist[blah][11]) <= maxhp1) && ((hp1 + itemlist[blah][11]) > 0))
{luckmod1 += itemlist[blah][17];
hp1 += itemlist[blah][11];
if (hp1 > maxhp1) hp1 = maxhp1;
dammod1 += itemlist[blah][12];
thacmod1 += itemlist[blah][13];
acmod1 += itemlist[blah][14];
if (itemlist[blah][15] == "Fire")
 firepowers1 = 1;
else if (itemlist[blah][15] == "Freeze")
 freezepowers1 = 1;
if (itemlist[blah][15] == "Poison")
 poisonpowers1 = 1;
else
 powers1[itemlist[blah][15]] = true;
if (itemlist[blah][16] == 0)
{
belt1[blah] = false;
itamz[user1]=itamz[user1].replace(","+blah,"");
}
str += user1 +" uses " + itemlist[blah][3]+"!|"
}

roll = Math.floor (Math.random() * 20) + 1 + luckmod1;
theroll = roll + ac2 + acmod2 - thacmod1;
if ((theroll < thaco1) && (roll != 20) && (powers1["Fury"]))
{roll = Math.floor (Math.random() * 20) + 1 + luckmod1;theroll = roll + ac2 + acmod2 - thacmod1;}
if ((theroll >= thaco1) || (roll >= 20))
{
if ((powers1["Vorpal"]) && (roll >= 20))
{
 hp2 = 0;
 str += user1 +" decapitates " + user2 + "!|"
}
else
{
if (roll >= 20)
 roll = 12;
else
roll = Math.floor (Math.random() * 6) + Math.floor (Math.random() * 6) + 2;
if ((roll >= 10) && (powers1["Smash"]))
 hp2 = Math.floor((hp2*3)/4);
if ((roll >= 10) && (freezepowers1 == 1))
 {frozen2 = 1;if (onfire2 == 1) onfire2 = 0;}
if ((roll >= 12) && (poisonpowers1 == 1))
 poisoned2 = 1;
if (firepowers1 == 1)
 onfire2 = 1;
if (powers1["Fire1"])
 onfire2 = 1;
theroll = Math.floor(roll/12 * dam1) + damplus1 + dammod1;
if ((roll >= 10) && (powers1["Critical"]))
 theroll = theroll * 2;
if (powers1["Backstab"])
 theroll = theroll * 3;
if (theroll < 0)
 theroll = 0;
hp2 -= theroll;
if (powers1["Leach"])
 hp1+=Math.floor(theroll / 4);
str += user1 +" hits " + user2 + " for "+theroll+" damage!|"
}}
if (poisoned2 == 1)
 {hp2 -= Math.floor(Math.random() * 6);str +=user2 + " takes poison damage!|";}
if (onfire2 == 1)
 {hp2 -= Math.floor(Math.random() * 4);str +=user2 + " burns!|";}
}
if (hp2 > 0)
{
if (powers2["Regen"])
 hp2 += 2;
if (hp2 > maxhp2)
 hp2 = maxhp2;
if (freezepowers2)
 onfire2 = 0;
if (powers2["Antidote"])
 poisoned2 = 0;
if (frozen2 == 1)
{
frozen2 = 0;
str += user2 +" is frozen!|"
}
else if (powers1["Sleep"])
{
powers1["Sleep"] = false;
str += user2 +" has been slept!|"
}
else if (powers1["Sneak"])
{
powers1["Sneak"] = false;
str += user1 +" avoids " +user2 +"!|"
}
else
{
dammod2 = 0;
acmod2 = 0;
luckmod2 = 0;
thacmod2 = 0;

for (blah in belt2)
if (belt2[blah])
if (((Math.floor (Math.random() * 20) < itemlist[blah][18]) || (Proficient(uclass[user2],blah) && (Math.floor (Math.random() * 20) < itemlist[blah][18]))) && ((hp2 + itemlist[blah][11]) <= maxhp2) && ((hp2 + itemlist[blah][11]) > 0))
{luckmod2 += itemlist[blah][17];
hp2 += itemlist[blah][11];
if (hp2 > maxhp2) hp2 = maxhp1;
dammod2 += itemlist[blah][12];
thacmod2 += itemlist[blah][13];
acmod2 += itemlist[blah][14];
if (itemlist[blah][15] == "Fire")
 firepowers2 = 1;
else if (itemlist[blah][15] == "Freeze")
 freezepowers2 = 1;
if (itemlist[blah][15] == "Poison")
 poisonpowers2 = 1;
else
 powers2[itemlist[blah][15]] = true;
if (itemlist[blah][16] == 0)
{
belt2[blah] = false;
itamz[user2]=itamz[user2].replace(","+blah,"");
}
str += user2 +" uses " + itemlist[blah][3]+"!|"
}

roll = Math.floor (Math.random() * 20) + 1 + luckmod2;
theroll = roll + ac1 + acmod1 - thacmod2;
if ((theroll < thaco2) && (roll != 20) && (powers2["Fury"]))
{
roll = Math.floor (Math.random() * 20) + 1 + luckmod2;
theroll = roll + ac1 + acmod1 - thacmod2;
}
if ((theroll >= thaco2) || (roll >= 20))
{
if ((powers2["Vorpal"]) && (roll >= 20))
{
 hp1 = 0;
 str += user2 +" decapitates " + user1 + "!|"
}
else
{
if (roll >= 20)
 roll = 12;
else
roll = Math.floor (Math.random() * 6) + Math.floor (Math.random() * 6) + 2;
if ((roll >= 10) && (powers2["Smash"]))
 hp1 = Math.floor((hp1*3)/4);
if ((roll >= 10) && (freezepowers2 == 1))
 {frozen1 = 1;if (onfire1 == 1) onfire1 = 0;}
if ((roll >= 12) && (poisonpowers2 == 1))
 poisoned1 = 1;
if (firepowers2 == 1)
 onfire1 = 1;
if (powers2["Fire1"])
 onfire1 = 1;
theroll = Math.floor(roll/12 * dam2) + damplus2 + dammod2;
if ((roll >= 10) && (powers2["Critical"]))
 theroll = theroll * 2;
if (powers2["Backstab"])
 theroll = theroll * 3;
if (theroll < 0)
 theroll = 0;
hp1 -= theroll;
if (powers2["Leach"])
 hp2+=Math.floor(theroll / 4);
str += user2 +" hits " + user1 + " for "+theroll+" damage!|"
}}
if (poisoned1 == 1)
 {hp1 -= Math.floor(Math.random() * 6);str +=user1 + " takes poison damage!|";}
if (onfire1 == 1)
 {hp1 -= Math.floor(Math.random() * 4);str +=user1 + " burns!|";}
}
}
turn--;
if (powers1["Smoke"])
{if ((Math.random()*20) > 15)
 {turn = 0;str+=user2+" loses "+user1+"!|No party wins!*";return str;}
powers1["Smoke"] = false;
}
if (powers2["Smoke"])
{if ((Math.random()*20) > 15)
 {turn = 0;str+=user1+" loses "+user2+"!|No party wins!*";return str;}
powers2["Smoke"] = false;
}
powers1["Backstab"] = false;
powers2["Backstab"] = false;
powers1["Fire1"] = false;
powers2["Fire1"] = false;
}

if ((hp1 > 0) && (hp2 > 0))
str += "The fighters close in...|"

//Change to melee
var ac1 = 10+itemlist[melee1][14];
var ac2 = 10+itemlist[melee2][14];
if (itemlist[melee1][17] == 1)
var thaco1 = 20 - Math.floor(parseInt(level[user1])/parseInt(classes[uclass[user1]][2])) + itemlist[melee1][13];
else
var thaco1 = 20 + itemlist[melee1][13];
if (itemlist[melee2][17] == 1)
var thaco2 = 20 - Math.floor(parseInt(level[user2])/parseInt(classes[uclass[user2]][2])) + itemlist[melee2][13];
else
var thaco2 = 20 + itemlist[melee2][13];
var dam1 = itemlist[melee1][11];
var dam2 = itemlist[melee2][11];
var damplus1 = itemlist[melee1][12];
var damplus2 = itemlist[melee2][12];

freezepowers1 = 0;
freezepowers2 = 0;
poisonpowers1 = 0
poisonpowers2 = 0;
firepowers1 = 0;
firepowers2 = 0;

powers1=null;powers1=[];
powers2=null;powers2=[];

for (blah in theitems1)
{
ac1 += itemlist[theitems1[blah]][14];
thaco1 += itemlist[theitems1[blah]][13];
damplus1 += itemlist[theitems1[blah]][12];
if ((itemlist[theitems1[blah]][15] == "Freeze") || (itemlist[theitems1[blah]][16] == "Freeze"))
freezepowers1 = 1;
if ((itemlist[theitems1[blah]][15] == "Poison") || (itemlist[theitems1[blah]][16] == "Poison"))
poisonpowers1 = 1;
if ((itemlist[theitems1[blah]][15] == "Fire") || (itemlist[theitems1[blah]][16] == "Fire"))
firepowers1 = 1;
powers1[itemlist[theitems1[blah]][15]] = true;
powers1[itemlist[theitems1[blah]][16]] = true;
}

for (blah in theitems2)
{
ac2 += itemlist[theitems2[blah]][14];
thaco2 += itemlist[theitems2[blah]][13];
damplus2 += itemlist[theitems2[blah]][12];
if ((itemlist[theitems2[blah]][15] == "Freeze") || (itemlist[theitems2[blah]][16] == "Freeze"))
freezepowers2 = 1;
if ((itemlist[theitems2[blah]][15] == "Poison") || (itemlist[theitems2[blah]][16] == "Poison"))
poisonpowers2 = 1;
if ((itemlist[theitems2[blah]][15] == "Fire") || (itemlist[theitems2[blah]][16] == "Fire"))
firepowers2 = 1;
powers2[itemlist[theitems2[blah]][15]] = true;
powers2[itemlist[theitems2[blah]][16]] = true;
}

if ((itemlist[melee1][15] == "Freeze") || (itemlist[melee1][16] == "Freeze"))
freezepowers1 = 1;
if ((itemlist[melee2][15] == "Freeze") || (itemlist[melee2][16] == "Freeze"))
freezepowers2 = 1;
if ((itemlist[melee1][15] == "Poison") || (itemlist[melee1][16] == "Poison"))
poisonpowers1 = 1;
if ((itemlist[melee2][15] == "Poison") || (itemlist[melee2][16] == "Poison"))
poisonpowers2 = 1;
if ((itemlist[melee1][15] == "Fire") || (itemlist[melee1][16] == "Fire"))
firepowers1 = 1;
if ((itemlist[melee2][15] == "Fire") || (itemlist[melee2][16] == "Fire"))
firepowers2 = 1;
powers1[itemlist[melee1][15]] = true;
powers1[itemlist[melee1][16]] = true;
powers2[itemlist[melee2][15]] = true;
powers2[itemlist[melee2][16]] = true;

if (Proficient(uclass[user1],melee1))
 damplus1 += level[user1];
else if (Deficient(uclass[user1],melee1))
 {damplus1 = Math.floor(damplus1/2); dam1 = Math.floor(dam1 / 2); thaco1 += 5;}

if (Proficient(uclass[user2],melee2))
 damplus2 += level[user2];
else if (Deficient(uclass[user2],melee2))
 {damplus2 = Math.floor(damplus2/2); dam2 = Math.floor(dam2 / 2); thaco2 += 5;}

damplus1 += GetBonus(Stats[user1][itemlist[melee1][18]]);
damplus2 += GetBonus(Stats[user2][itemlist[melee2][18]]);

thaco1 += GetBonus(Stats[user1][itemlist[melee1][19]]);
thaco2 += GetBonus(Stats[user2][itemlist[melee2][19]]);

ac1 += GetBonus(Stats[user1][itemlist[melee2][20]]);
ac2 += GetBonus(Stats[user2][itemlist[melee1][20]]);

turn = 1000;

while ((hp1 > 0) && (hp2 > 0) && (turn > 0))
{
if (powers1["Regen"])
 hp1 += 2;
if (hp1 > maxhp1)
 hp1 = maxhp1;
if (freezepowers1)
 onfire1 = 0;
if (powers1["Antidote"])
 poisoned1 = 0;
if (frozen1 == 1)
{
frozen1 = 0;
str += user1 +" is frozen!|"
}
else if (powers2["Sleep"])
{
powers2["Sleep"] = false;
str += user1 +" has been slept!|"
}
else if (powers2["Sneak"])
{
powers2["Sneak"] = false;
str += user2 +" avoids " +user1 +"!|"
}
else
{
dammod1 = 0;
acmod1 = 0;
luckmod1 = 0;
thacmod1 = 0;

for (blah in belt1)
if (belt1[blah])
if (((Math.floor (Math.random() * 20) < itemlist[blah][18]) || (Proficient(uclass[user1],blah) && (Math.floor (Math.random() * 20) < itemlist[blah][18]))) && ((hp1 + itemlist[blah][11]) <= maxhp1) && ((hp1 + itemlist[blah][11]) > 0))
{luckmod1 += itemlist[blah][17];
hp1 += itemlist[blah][11];
if (hp1 > maxhp1) hp1 = maxhp1;
dammod1 += itemlist[blah][12];
thacmod1 += itemlist[blah][13];
acmod1 += itemlist[blah][14];
if (itemlist[blah][15] == "Fire")
 firepowers1 = 1;
else if (itemlist[blah][15] == "Freeze")
 freezepowers1 = 1;
if (itemlist[blah][15] == "Poison")
 poisonpowers1 = 1;
else
 powers1[itemlist[blah][15]] = true;
if (itemlist[blah][16] == 0)
{
belt1[blah] = false;
itamz[user1]=itamz[user1].replace(","+blah,"");
}
str += user1 +" uses " + itemlist[blah][3]+"!|"
}

roll = Math.floor (Math.random() * 20) + 1 + luckmod1;
theroll = roll + ac2 + acmod2 - thacmod1;
if ((theroll < thaco1) && (roll != 20) && (powers1["Fury"]))
{
roll = Math.floor (Math.random() * 20) + 1 + luckmod1;
theroll = roll + ac2 + acmod2 - thacmod1;
}
if ((theroll >= thaco1) || (roll >= 20))
{
if ((powers1["Vorpal"]) && (roll >= 20))
{
 hp2 = 0;
 str += user1 +" decapitates " + user2 + "!|"
}
else
{
if (roll >= 20)
 roll = 12;
else
roll = Math.floor (Math.random() * 6) + Math.floor (Math.random() * 6) + 2;
if ((roll >= 10) && (powers1["Smash"]))
 hp2 = Math.floor((hp2*3)/4);
if ((roll >= 10) && (freezepowers1 == 1))
 {frozen2 = 1;if (onfire2 == 1) onfire2 = 0;}
if ((roll >= 12) && (poisonpowers1 == 1))
 poisoned2 = 1;
if (firepowers1 == 1)
 onfire2 = 1;
if (powers1["Fire1"])
 onfire2 = 1;
theroll = Math.floor(roll/12 * dam1) + damplus1 + dammod1;
if ((roll >= 10) && (powers1["Critical"]))
 theroll = theroll * 2;
if (powers1["Backstab"])
 theroll = theroll * 3;
if (theroll < 0)
 theroll = 0;
hp2 -= theroll;
if (powers1["Leach"])
 hp1+=Math.floor(theroll / 4);
if (powers2["Shock"])
 hp1-=(Math.floor(Math.random() * 5) + 1);
str += user1 +" hits " + user2 + " for "+theroll+" damage!|"
}}
if (poisoned2 == 1)
 {hp2 -= Math.floor(Math.random() * 6);str +=user2 + " takes poison damage!|";}
if (onfire2 == 1)
 {hp2 -= Math.floor(Math.random() * 4);str +=user2 + " burns!|";}
}
if (hp2 > 0)
{
if (powers2["Regen"])
 hp2 += 2;
if (hp2 > maxhp2)
 hp2 = maxhp2;
if (freezepowers2)
 onfire2 = 0;
if (powers2["Antidote"])
 poisoned2 = 0;
if (frozen2 == 1)
{
frozen2 = 0;
str += user2 +" is frozen!|"
}
else if (powers1["Sleep"])
{
powers1["Sleep"] = false;
str += user2 +" has been slept!|"
}
else if (powers1["Sneak"])
{
powers1["Sneak"] = false;
str += user1 +" avoids " +user2 +"!|"
}
else
{
dammod2 = 0;
acmod2 = 0;
luckmod2 = 0;
thacmod2 = 0;

for (blah in belt2)
if (belt2[blah])
if (((Math.floor (Math.random() * 20) < itemlist[blah][18]) || (Proficient(uclass[user2],blah) && (Math.floor (Math.random() * 20) < itemlist[blah][18]))) && ((hp2 + itemlist[blah][11]) <= maxhp2) && ((hp2 + itemlist[blah][11]) > 0))
{luckmod2 += itemlist[blah][17];
hp2 += itemlist[blah][11];
if (hp2 > maxhp2) hp2 = maxhp1;
dammod2 += itemlist[blah][12];
thacmod2 += itemlist[blah][13];
acmod2 += itemlist[blah][14];
if (itemlist[blah][15] == "Fire")
 firepowers2 = 1;
else if (itemlist[blah][15] == "Freeze")
 freezepowers2 = 1;
if (itemlist[blah][15] == "Poison")
 poisonpowers2 = 1;
else
 powers2[itemlist[blah][15]] = true;
if (itemlist[blah][16] == 0)
{
belt2[blah] = false;
itamz[user2]=itamz[user2].replace(","+blah,"");
}
str += user2 +" uses " + itemlist[blah][3]+"!|"
}

roll = Math.floor (Math.random() * 20) + 1 + luckmod2;
theroll = roll + ac1 + acmod1 - thacmod2;
if ((theroll < thaco2) && (roll != 20) && (powers2["Fury"]))
{
roll = Math.floor (Math.random() * 20) + 1 + luckmod2;
theroll = roll + ac1 + acmod1 - thacmod2;
}
if ((theroll >= thaco2) || (roll >= 20))
{
if ((powers2["Vorpal"]) && (roll >= 20))
{
 hp1 = 0;
 str += user2 +" decapitates " + user1 + "!|"
}
else
{
if (roll >= 20)
 roll = 12;
else
roll = Math.floor (Math.random() * 6) + Math.floor (Math.random() * 6) + 2;
if ((roll >= 10) && (powers2["Smash"]))
 hp1 = Math.floor((hp1*3)/4);
if ((roll >= 10) && (freezepowers2 == 1))
 {frozen1 = 1;if (onfire1 == 1) onfire1 = 0;}
if ((roll >= 12) && (poisonpowers2 == 1))
 poisoned1 = 1;
if (firepowers2 == 1)
 onfire1 = 1;
if (powers2["Fire1"])
 onfire1 = 1;
theroll = Math.floor(roll/12 * dam2) + damplus2 + dammod2;
if ((roll >= 10) && (powers2["Critical"]))
 theroll = theroll * 2;
if (powers2["Backstab"])
 theroll = theroll * 3;
if (theroll < 0)
 theroll = 0;
hp1 -= theroll;
if (powers2["Leach"])
 hp2+=Math.floor(theroll / 4);
if (powers1["Shock"])
 hp2-=(Math.floor(Math.random() * 5) + 1);
str += user2 +" hits " + user1 + " for "+theroll+" damage!|"
}}
if (poisoned1 == 1)
 {hp1 -= Math.floor(Math.random() * 6);str +=user1 + " takes poison damage!|";}
if (onfire1 == 1)
 {hp1 -= Math.floor(Math.random() * 4);str +=user1 + " burns!|";}
}
}
turn--;
if (powers1["Smoke"])
{if ((Math.random()*20) > 15)
 {turn = 0;str+=user2+" loses "+user1+"!|No party wins!*";return str;}
powers1["Smoke"] = false;
}
if (powers2["Smoke"])
{if ((Math.random()*20) > 15)
 {turn = 0;str+=user1+" loses "+user2+"!|No party wins!*";return str;}
powers2["Smoke"] = false;
}
if (powers1["Steal"])
 {GoldSteal1 += level[user1];powers1["Steal"] = false;}
if (powers2["Steal"])
 {GoldSteal2 += level[user2];powers2["Steal"] = false;}
powers1["Backstab"] = false;
powers2["Backstab"] = false;
powers1["Fire1"] = false;
powers2["Fire1"] = false;
}


//award gold and xp
if (hp1 < 1)
{
XPGain = Math.exp(level[user1])*classes[uclass[user1]][1];
XPGain = Math.floor(XPGain * XPpercent / 100);
GoldGain = Math.floor(XPGain * GoldSteal2 * (hp2/maxhp2)*(Math.random()+Math.random()+Math.random()));
XP[user2]+=XPGain;
MID[user2]+=GoldGain;
str += user2 +" " + preline[Math.floor(Math.random() * preline.length)]+' "'+line[Math.floor(Math.random() * line.length)]+'"|'; 
str += user1 +" falls unconscious! " + user2 + " gains " + XPGain +" XP and " + sign+GoldGain +"!*"; 
if (BattlesWon[user2])
 BattlesWon[user2]++;
else
 BattlesWon[user2] = 1;
if (BattlesLost[user1])
 BattlesLost[user1]++;
else
 BattlesLost[user1] = 1;
}
else if (hp2 < 1)
{
XPGain = Math.exp(level[user2])*classes[uclass[user2]][1];
XPGain = Math.floor(XPGain * XPpercent / 100);
GoldGain = Math.floor(XPGain * GoldSteal1 * (hp1/maxhp1)*(Math.random()+Math.random()+Math.random()));
XP[user1]+=XPGain;
MID[user1]+=GoldGain;
str += user1 +" " + preline[Math.floor(Math.random() * preline.length)]+' "'+line[Math.floor(Math.random() * line.length)]+'"|';
str += user2 +" falls unconscious! " + user1 + " gains " + XPGain +" XP and " + sign+GoldGain +"!*";
if (BattlesWon[user1])
 BattlesWon[user1]++;
else
 BattlesWon[user1] = 1;
if (BattlesLost[user2])
 BattlesLost[user2]++;
else
 BattlesLost[user2] = 1;
}
else
{
str+="Stalemate!|Neither party can win!*"
}
return str;
}