/*Random Quests by Godkillah
written as a add-on for Divinity Rpg V2
copyrigh to phantom-designs.net & thecodingzone.com*/
function MakeName(){
ar=[]
ar[0]='bcdfghjklmnpqrstvwxz'.split('')
ar[1]='aeiouy'.split('')
ii='34567'.split('')
ii=ii[Math.floor(Math.random()*ii.length)]
name='';a=[0,1];a=a[Math.floor(Math.random()*a.length)]
for(i=0;i<ii;i++){
name+=ar[a][Math.floor(Math.random()*ar[a].length)]
if(a>0){
a--
}else{
a++
}}
ii='34567'.split('')
ii=ii[Math.floor(Math.random()*ii.length)]
name+=' ';a=[0,1];a=a[Math.floor(Math.random()*a.length)]
for(i=0;i<ii;i++){
name+=ar[a][Math.floor(Math.random()*ar[a].length)]
if(a>0){
a--
}else{
a++
}}
return name
}

function complete(){
document.getElementById('remove_in_battle').innerHTML='Congratulations!\nYou have completed '+rands[0]+'`s quest to return his/her '+items[rands[2]]+'!\nAs reward you gain 3 times as much expierience and money as usual'
rands=[MakeName(),Math.floor(Math.random()*avatars.length),Math.floor(Math.random()*items.length)]
stuff='<div><img src="'+avatars[rands[1]]+'"><Br><i>Hello, my name is '+rands[0]+'<i><Br>I have heard stories about you and thought you might be able to help me<br>a few days ago:<br><I>'+situations[Math.floor(Math.random()*situations.length)]+' '+causes[Math.floor(Math.random()*causes.length)]+' '+did[Math.floor(Math.random()*did.length)]+' my '+items[rands[2]]+'</I><br>Would you be able to get me my '+items[rands[2]]+' back?<br><a href="javascript:accept()">Yes!<a> | <a href="javascript:deny()">No!<a></div>'
User_Win(2)
setTimeout('document.getElementById("remove_in_battle").innerHTML=navigationstuff',1000)
}
function runasfastasyoucan(){
clearTimeout(checktm)
Flee(1)
}
function check(){
if(document.getElementById('remove_in_battle') && document.getElementById('remove_in_battle').innerHTML.match(/You were victorious/i)){
document.getElementById('remove_in_battle').getElementsByTagName("div")[0].innerHTML='You have returned the '+items[rands[2]]+' to '+rands[0]+'!<br><a href="javascript:void(0)" onclick="complete()">Complete quest</a>'
}else{
checktm=setTimeout('check()',25)
}}
function accept(){
Pick_Monster()
r=Math.floor(Math.random()*Monsters.length)
Monsters[r][2]=Monsters[r][2]+25
Monsters[r][7]=Monsters[r][7]*3
Monsters[r][8]=Monsters[r][8]*3
FightMonster(Monsters[r][1])
document.getElementById('remove_in_battle').getElementsByTagName("div")[5].onclick=function(){
runasfastasyoucan()
}
checktm=setTimeout('check()',25)
}
function deny(){
location.href=location.href
}

var avatars=['http://209.85.12.227/11838/143/upload/p683647.gif','http://209.85.12.227/11838/143/upload/p683631.gif','http://209.85.12.227/11838/143/upload/p683627.gif','http://209.85.12.227/11838/143/upload/p683643.gif','http://209.85.12.227/11838/143/upload/p683635.gif','http://209.85.12.227/11838/143/upload/p671626.gif','http://209.85.12.227/11838/143/upload/p683653.gif']
var situations=['while I was walking through the forest','while I was reading','while I was sleeping','while I was taking a shortcut home']
var intros=['Are you an adventurer?  I need some help.','Something terrible has happened, can you help me?','You&acute;re that hero, right?  I have a mission for you.','I could really use some help, and you look like you might be able to do it.']
var causes=['someone','something','a unknown person or beast','this thing','a monster','a horrible monster']
var did=['stole','escaped with','ran away with','mugged me and took']
var items=['necklace','ring','family heirloom','wallet','supplies','bag of gold','book']
var rands=[MakeName(),Math.floor(Math.random()*avatars.length),Math.floor(Math.random()*items.length)]
var stuff='<div><img src="'+avatars[rands[1]]+'"><Br><i>'+intros[Math.floor(Math.random()*intros.length)]+'<br>A few days ago <I>'+situations[Math.floor(Math.random()*situations.length)]+' '+causes[Math.floor(Math.random()*causes.length)]+' '+did[Math.floor(Math.random()*did.length)]+' my '+items[rands[2]]+'</I><br>Would you be able to get me my '+items[rands[2]]+' back?<br><a href="javascript:accept()">Yes!<a> | <a href="javascript:deny()">No!<a></div>'

if(location.href.match(/act=rpg&fight/i)){
function mice(){
if(document.cookie.match("quickdesc=1")){
return false;
}
meh = document.getElementById('rpg_dataz');
meh.style.display = 'block';
meh.innerHTML = "<div class='tableborder'><div class='titlemedium' align='center'>Quick Area Description</div><br />Meet hundreds of people who are in trouble and need your help, The monsters you fight all have 25 hp more than others of their kind but slaying them rewards you with 3 times as much expierience and gold as usual!<br><b>Warning, All kind of monsters can be found, from extremely weak to extremely stong monsters</B></div>";
}
document.getElementById('remove_in_battle').innerHTML+='<br><br><b>- <small><i>Random Quest</i></small></b><br>-- <a onmouseout="mouse(3);" onmouseover="mice();" href="javascript:void(0);" onclick="randomQuest()">Random Quest</a>'
function randomQuest(){
navigationstuff=document.getElementById("remove_in_battle").innerHTML
document.getElementById("rpg_profile_info").innerHTML=stuff
}}
