function character(num, name, pic, reward)
{
this.pic = pic;
this.name = name;
this.num = num;
this.stats = "Stats";
this.backstory = "Back Story";
this.onset = "Onset of Pathology";
this.cur = "Current State";
this.righttreat = "0";
this.treated  = "Hurray! " + this.name + " made a full recovery!";
this.death = "Oh no! " + this.name + " is dead now! Are you sure you know what you\'re doing?";
this.reward = reward;
}

character.prototype.display = function(){
  
  if(this.name == 'merchant')
  {
    document.getElementById('mainArea').innerHTML =
    '<div class = "container page">\
    <img id="charimage" src="'+ this.pic +'"></img>\
    <div id="chartext"></div>\
    <div id="charchoices">\
    <button class="charbutton" onclick="' + this.name + '.showstore()">***Store***</button>\
    <button class="charbutton" onclick="' + this.name + '.showstats()">Stats</button>\
    <button class="charbutton" onclick="' + this.name + '.showbackstory()">Back Story</button>\
    <button class="charbutton" onclick="' + this.name + '.showonset()">Onset of Pathology</button>\
    <button class="charbutton" onclick="' + this.name + '.showcurrent()">Current State</button>\
    <button class="charbutton" onclick="' + this.name + '.treat()">Treat</button>\
    </div>\
    </div>';
    this.showstore();
}
  else
  {
    document.getElementById('mainArea').innerHTML =
    '<div class = "container page">\
    <img id="charimage" src="'+ this.pic +'"></img>\
    <div id="chartext"></div>\
    <div id="charchoices">\
    <button class="charbutton" onclick="' + this.name + '.showstats()">Stats</button>\
    <button class="charbutton" onclick="' + this.name + '.showbackstory()">Back Story</button>\
    <button class="charbutton" onclick="' + this.name + '.showonset()">Onset of Pathology</button>\
    <button class="charbutton" onclick="' + this.name + '.showcurrent()">Current State</button>\
    <button class="charbutton" onclick="' + this.name + '.treat()">Treat</button>\
    </div>\
    </div>';
    this.showstats();
}

};

character.prototype.showstats = function(){
document.getElementById('chartext').innerHTML = this.stats;
};

character.prototype.showbackstory = function(){
document.getElementById('chartext').innerHTML = this.backstory;
};

character.prototype.showonset = function(){
document.getElementById('chartext').innerHTML = this.onset;
};

character.prototype.showcurrent = function(){
document.getElementById('chartext').innerHTML = this.cur;
};

character.prototype.showtreated = function(){
document.getElementById('chartext').innerHTML = this.treated;
};

character.prototype.showdeath = function(){
document.getElementById('chartext').innerHTML = this.death;
};

character.prototype.treatchoice = function(mednum, num)
{
	
	var choicenum = mednum;
	if(choicenum == this.num)
		{
		this.righttreat = 1;
		this.showtreated();
		alert('You recieved ' + this.reward + ' Gil');
		mygil=mygil+this.reward;
		}
	if(choicenum == 99)
	{
	  alert('You don\'t have an item in that slot');
	}
	else
		{
		this.righttreat = 0;
		this.showdeath();
		}
		mystock[num] = new item();
};

character.prototype.treat = function(){
document.getElementById('chartext').innerHTML = '<table id="medchoices">\
<tr>\
    <th colspan="3"></th>\
  </tr>\
  <tr>\
    <td id="choice" onmouseover="mystock[0].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[0].num, 0)"><img id="choiceitempic" src="'+mystock[0].pic+'"></img></td>\
    <td id="choice" onmouseover="mystock[1].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[1].num, 1)"><img id="choiceitempic" src="'+mystock[1].pic+'"></img></td>\
    <td id="choice" onmouseover="mystock[2].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[2].num, 2)"><img id="choiceitempic" src="'+mystock[2].pic+'"></img></td>\
  </tr>\
  <tr>\
    <td id="choice" onmouseover="mystock[3].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[3].num, 3)"><img id="choiceitempic" src="'+mystock[3].pic+'"></img></td>\
    <td id="choice" onmouseover="mystock[4].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[4].num, 4)"><img id="choiceitempic" src="'+mystock[4].pic+'"></img></td>\
    <td id="choice" onmouseover="mystock[5].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[5].num, 5)"><img id="choiceitempic" src="'+mystock[5].pic+'"></img></td>\
  </tr>\
  <tr>\
    <td id="choice" onmouseover="mystock[6].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[6].num, 6)"><img id="choiceitempic" src="'+mystock[6].pic+'"></img></td>\
    <td id="choice" onmouseover="mystock[7].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[7].num, 7)"><img id="choiceitempic" src="'+mystock[7].pic+'"></img></td>\
    <td id="choice" onmouseover="mystock[8].showchoiceiteminfo()" onclick="'+this.name+'.treatchoice(mystock[8].num, 8)"><img id="choiceitempic" src="'+mystock[8].pic+'"></img></td>\
  </tr>\
</table>\
<div id="choiceiteminfo">Choose the proper treatment from your inventory</div>';
};


var tidus = new character(10, 'tidus', "/characters/tidus.jpg", 50);
var dorothy = new character(7, 'dorothy', "/characters/dorothy.png", 25);

var merchant = new character(0, 'merchant', "/characters/merchant.jpg", 25);
merchant.store = 'store';
character.prototype.showstore = function(){
document.getElementById('chartext').innerHTML = '<table id="storeinventory">\
<tr>\
    <th colspan="3"></th>\
  </tr>\
  <tr>\
    <td class="storeitem" onmouseover="stock[0].showiteminfo()" onclick="stock[0].purchase()"><img id="storeitempic"  src="'+stock[0].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[5].showiteminfo()" onclick="stock[5].purchase()"><img id="storeitempic" src="'+stock[5].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[3].showiteminfo()" onclick="stock[3].purchase()"><img id="storeitempic" src="'+stock[3].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[9].showiteminfo()" onclick="stock[9].purchase()"><img id="storeitempic" src="'+stock[9].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[11].showiteminfo()" onclick="stock[11].purchase()"><img id="storeitempic" src="'+stock[11].pic+'"></img></td>\
  </tr>\
  <tr>\
    <td class="storeitem" onmouseover="stock[2].showiteminfo()" onclick="stock[2].purchase()"><img id="storeitempic" src="'+stock[2].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[8].showiteminfo()" onclick="stock[8].purchase()"><img id="storeitempic" src="'+stock[8].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[10].showiteminfo()" onclick="stock[10].purchase()"><img id="storeitempic" src="'+stock[10].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[7].showiteminfo()" onclick="stock[7].purchase()"><img id="storeitempic" src="'+stock[7].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[4].showiteminfo()" onclick="stock[4].purchase()"><img id="storeitempic" src="'+stock[4].pic+'"></img></td>\
  </tr>\
  <tr>\
    <td class="storeitem" onmouseover="stock[10].showiteminfo()" onclick="stock[10].purchase()"><img id="storeitempic" src="'+stock[10].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[4].showiteminfo()" onclick="stock[4].purchase()"><img id="storeitempic" src="'+stock[4].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[8].showiteminfo()" onclick="stock[8].purchase()"><img id="storeitempic" src="'+stock[8].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[6].showiteminfo()" onclick="stock[6].purchase()"><img id="storeitempic" src="'+stock[6].pic+'"></img></td>\
    <td class="storeitem" onmouseover="stock[8].showiteminfo()" onclick="stock[8].purchase()"><img id="storeitempic" src="'+stock[8].pic+'"></img></td>\
  </tr>\
</table>\
<div id="iteminfo"></div>';
};

var leon = new character(8, 'leon', "/characters/leon.jpg", 75);
var kai = new character(11, 'kai', "/characters/Kai.jpg", 200);
var cheshirecat = new character(6, 'cheshirecat', "/characters/cheshire-cat.jpg", 2);
var sephiroth = new character(5, 'sephiroth', "/characters/sephiroth.jpg", 50);
var ginger = new character(4, 'ginger', "/characters/ginger2.jpg", 15);
var akasha = new character(3, 'akasha', "/characters/stoneakasha.jpg", 200);
var carlybeth = new character(9, 'carlybeth', "/characters/carlybeth.jpg", 5);
var coraline = new character(1, 'coraline', "/characters/coraline.jpg", 25);
var lain = new character(2, 'lain', "/characters/lain.png", 150);