Item		= new Array();
Enchant		= new Array();
ForumHover	= new Array();

document.onmouseup = mouseUp;
var originDiv = null;
function mouseUp(){
	if(originDiv != null)
		originDiv = null;
}

function cancelBubble(e){
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function buildExlink(ex_sitename, ex_language, ex_description, ex_features){
	hoverText = "<div class='hover_body' style='text-align: left; width: 250px;'>";
	hoverText+= "<div><span style='font-weight: bold; font-size: 14px; color: #ffd599;'>"+ex_sitename+"</span>";
	hoverText+=  "<span style='color: #88654a; font-size: 10px;'> - "+ex_language+"</span></div>";
	hoverText+= "<div>"+ex_description+"</div>";
	hoverText+= "<div style='padding-top: 4px; font-style: italic; color: #AAAAAA;'><span style='font-weight: bold;'>Features</span>: "+ex_features+"</div>";
	hoverText+= "</div>";
	return overlib(hoverText, FULLHTML);
}

//Creates all the variables below for reference in item creation calls
varStart = -21000; varCount = varStart;
createVars("nostat,level,std_minatk,std_maxatk,adv_minatk,adv_maxatk,std_prob,adv_prob,std_pierce,adv_pierce,std_vly,adv_vly,std_num,adv_num,std_radar,adv_radar,std_reatk,adv_reatk,std_radius,adv_radius,adv_valid,std_dist,adv_dist,std_def,adv_def,std_eva,adv_eva,energy,shield,fuel_amount");
function createVars(varString){
	varArray = varString.split(",");
	for (var i = 0; i< varArray.length; i++) {
		eval(varArray[i].toUpperCase()+'='+varCount++);
	}
}

//Will disable any selection by the user.
//		target: the object.
function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
		target.style.cursor = "default"
}

//Will change the Display of the passed object.
//		method: "Show", "Hide", or "Toggle"
//		thisDiv: the object, can be anything with an ID.
function DivDisplay(method, thisDiv) {
	var ele = document.getElementById(thisDiv);
	if(method == "Hide") {
    	ele.style.display = "none";
  	}else if (method == "Show"){
		ele.style.display = "block";
	}else if (method == "Toggle"){
		if(ele.style.display == "" && ele.offsetWidth != undefined && ele.offsetHeight != undefined)
			ele.style.display = (ele.offsetWidth != 0 && ele.offsetHeight != 0) ? "block" : "none";
		ele.style.display = (ele.style.display == "" || ele.style.display == "block") ? "none" : "block";
	}
}

//Will change the visibility of the passed object.
//		method: "Show", "Hide", or "Toggle"
//		thisDiv: the object, can be anything with an ID.
function DivVisible(method, thisDiv) {
	var ele = document.getElementById(thisDiv);
	if(method == "Hide") {
    	ele.style.visibility = "hidden";
  	}else if (method == "Show"){
		ele.style.visibility = "visible";
	}else if (method == "Toggle"){
		if(ele.style.visibility == "" && ele.offsetWidth != undefined && ele.offsetHeight != undefined)
			ele.style.visibility = (ele.offsetWidth != 0 && ele.offsetHeight != 0) ? "visible" : "hidden";
		ele.style.visibility = (ele.style.visibility == "" || ele.style.visibility == "visible") ? "hidden" : "visible";
	}
}

//COOKIE FUNCTIONS//////////////////////////////////////////////////////
//Code used from http://www.w3schools.com/js/js_cookies.asp
////////////////////////////////////////////////////////////////////////

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
//END COOKIE////////////////////////////////////////////////////////////


//TRANSFER FUNCTIONS////////////////////////////////////////////////////
//These functions deal with the movement and display of the transfer tab.
////////////////////////////////////////////////////////////////////////

//Creates the Transfer object and preps it for use.
Transfer = new Object();
Transfer.item = new Array();

//Loop that initializes the .item array to 5 empty slots.
for(var iter = 0; iter < 5; iter++)
	Transfer.item[iter] = new ItemConstruct('', 'any', 'transfer_0'+iter, 'Transfer.item['+iter+']');

//The .state variable tells what state the tab should be in: closed(0) or open(1). This information is 
//stored in a cookie when changed. Here, it is extracted from the cookie, if is exists.
if(getCookie("ac_transfer") == "")
		Transfer.state = 1;
else	Transfer.state = parseInt(getCookie("ac_transfer"));

//Reload function. Linked to the reload button on the transfer tab.  Refreshes all the items from server.
Transfer.reload = function(){
	if(typeof(curRe) == 'undefined') curRe = false;
	if(curRe) return;
	
	ajaxCall("/scripts/refreshTransfer.scripts.php", "JS", "curRe = false;");
	
	curRe = true;
}

//Scroll function. When the screen is scrolled by the user, it is checked if the tab should move along
//with it.
Transfer.scroll = function(){
	//Check to see the transfer object exists.
	if(!document.getElementById('transfer'))
		return;
	
	if(Transfer.state) //Statement true if open; false if closed.
			document.getElementById('transfer').style.top = window.pageYOffset+'px';
	else	document.getElementById('transfer').style.top = 0;
}

//Open function. If the tab is closed, this function will reopen it and save the new state.
Transfer.open = function(){
	DivDisplay('Show', 'transfer_items');
	DivDisplay('Hide', 'transfer_collapsed');
	Transfer.state = 1;
	setCookie("ac_transfer", Transfer.state, 365);
	Transfer.scroll(); //Must be called to ensure screen moves correctly after change.
}

//Close function. If the tab is open, this function will close it and save the new state.
Transfer.close = function(){
	DivDisplay('Hide', 'transfer_items');
	DivDisplay('Show', 'transfer_collapsed');
	Transfer.state = 0;
	setCookie("ac_transfer", Transfer.state, 365);
	Transfer.scroll(); //Must be called to ensure screen moves correctly after change.
}
//END TRANSFER//////////////////////////////////////////////////////////

function buildFunctionLine(theBody){
	return "<div>Function: <span style='color: green;'>" + theBody + "</span></div>";
}

//This function is used as a construct for the Effect class.  Allows this class to be held in an array
function newEffect(name, id){
	if(typeof(Effect)=='undefined') Effect = new Array();
	if(Effect[id] === undefined)
	Effect[id] = new EffectConstruct(name, id);
}

function EffectConstruct(name, id){
	this.name = name;
	this.id = id;
}



function newBuff(){
	if(typeof(Buff)=='undefined') Buff = new Array();
	if(Buff[newBuff.arguments[0]] === undefined)
	Buff[newBuff.arguments[0]] = new BuffConstruct(newBuff.arguments);
}

function BuffConstruct(arg){
	this.id			 = arg[0];
	this.name		 = arg[1];
	this.level		 = parseInt(arg[2]);
	this.skilllevel	 = parseInt(arg[3]);
	this.gear		 = arg[4];
	this.spcost		 = arg[5];
	this.duration	 = parseInt(arg[6]);
	this.cooldown	 = parseInt(arg[7]);
	if(arg[8] == "")	this.picture = "";
	else				this.picture = "/pics/item_large/" + arg[8];
	if(arg[9] == "")	this.minipicture = "/pics/item_mini/unknown.gif";
	else				this.minipicture = "/pics/item_mini/" + arg[9];
	this.parent		 = arg[10];
	this.child		 = arg[11];
	
	injectTokens(this, arg, 12);
}

function newCharm(){
	if(typeof(Charm)=='undefined') Charm = new Array(); 
	if(Charm[newCharm.arguments[0]] === undefined)
	Charm[newCharm.arguments[0]] = new CharmConstruct(newCharm.arguments);
}

function CharmConstruct(arg){
	this.id			 = arg[0];
	this.name		 = arg[1];
	this.category	 = arg[2];
	this.gear		 = arg[3];
	this.level		 = arg[4];
	this.weight		 = arg[5];
	if(arg[6] == "")	this.picture = "";
	else				this.picture = "/pics/item_large/" + arg[6];
	if(arg[7] == "")	this.minipicture = "/pics/item_mini/unknown.gif";
	else				this.minipicture = "/pics/item_mini/" + arg[7];
	
	injectTokens(this, arg, 8);
}

//Injects the tokens given from the argument array (arg) into the given object (cons)
//The start point is where to start parsing the tokens. If not set, it defaults 0.
//No token value can be equal to -21000 to -20500 or they will be parsed as indicators.
function injectTokens(cons, arg, start){
	if(typeof(start)=='undefined') start = 0;
	else start = parseInt(start);
	
	cons.funct = new Array();
	//Initialize all possible variables to zero.
	for(var i = varStart ; i <= varCount ; i++){ cons.funct[i] = 0; }
	//Transpost all argument data into the appropriate variables.
	for(var i = start ; i < arg.length ; i++){
		if (arg[i]==NOSTAT)		{ ++i; continue; }
		if (arg[i]==LEVEL)		{ cons.funct[LEVEL]			= parseInt(arg[++i]);	continue; }
		if (arg[i]==STD_MINATK) { cons.funct[STD_MINATK]	= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_MINATK) { cons.funct[ADV_MINATK]	= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_MAXATK) { cons.funct[STD_MAXATK]	= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_MAXATK) { cons.funct[ADV_MAXATK]	= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_PROB)	{ cons.funct[STD_PROB]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_PROB)	{ cons.funct[ADV_PROB]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_PIERCE)	{ cons.funct[STD_PIERCE]	= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_PIERCE)	{ cons.funct[ADV_PIERCE]	= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_VLY)	{ cons.funct[STD_VLY]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==ADV_VLY)	{ cons.funct[ADV_VLY]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==STD_NUM)	{ cons.funct[STD_NUM]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==ADV_NUM)	{ cons.funct[ADV_NUM]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==STD_RADAR)	{ cons.funct[STD_RADAR]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==ADV_RADAR)	{ cons.funct[ADV_RADAR]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==STD_REATK)	{ cons.funct[STD_REATK]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_REATK)	{ cons.funct[ADV_REATK]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_DIST)	{ cons.funct[STD_DIST]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==ADV_DIST)	{ cons.funct[ADV_DIST]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==STD_RADIUS)	{ cons.funct[STD_RADIUS]	= parseInt(arg[++i]);	continue; }
		if (arg[i]==ADV_RADIUS)	{ cons.funct[ADV_RADIUS]	= parseInt(arg[++i]);	continue; }
		if (arg[i]==ADV_VALID)	{ cons.funct[ADV_VALID]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_DEF)	{ cons.funct[STD_DEF]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_DEF)	{ cons.funct[ADV_DEF]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==STD_EVA)	{ cons.funct[STD_EVA]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ADV_EVA)	{ cons.funct[ADV_EVA]		= parseFloat(arg[++i]);	continue; }
		if (arg[i]==ENERGY)		{ cons.funct[ENERGY]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==SHIELD)		{ cons.funct[SHIELD]		= parseInt(arg[++i]);	continue; }
		if (arg[i]==FUEL_AMOUNT){ cons.funct[FUEL_AMOUNT]	= parseInt(arg[++i]);	continue; }
		
	}
}


//This function is used as a constructor for the Weapon class.  Allows this class to be held in an array.
function newWeapon(name, id, category, eok, picture, minipicture, unique, wpnclass, type, agear, level, atkmin, atkmax, 
	volley, number, prob, pierce, dist, reatk, heat, valid, speed, induct, radius, weight, price, parentwpn, childwpn, legend, legendchance, upgradechance){
	if(typeof(Weapon)     == 'undefined') Weapon = new Array();
	if(typeof(Weapon[id]) == 'undefined') 
    Weapon[id] = new WeaponConstruct(name, id, category, eok, picture, minipicture, unique, wpnclass, type, agear, level, atkmin, 
    atkmax, volley, number, prob, pierce, dist, reatk, heat, valid, speed, induct, radius, weight, price, parentwpn, childwpn, legend, legendchance, upgradechance);
}
//This is the class that holds all the information for all the weapons. The data from the XML is loaded into this class.
function WeaponConstruct(name, id, category, eok, picture, minipicture, unique, wpnclass, type, agear, level, atkmin, atkmax, volley, 
number, prob, pierce, dist, reatk, heat, valid, speed, induct, radius, weight, price, parentwpn, childwpn, legend, legendchance, upgradechance){
	this.name			= name;
	this.id				= id;
	this.category		= category;
	if(parseInt(eok) == 0)	this.eok = false;
	else					this.eok = true;
	if(picture == "")		this.picture = "";
	else					this.picture = "/pics/item_large/" + picture;
	if(minipicture == "")	this.minipicture = "/pics/item_mini/unknown.gif";
	else					this.minipicture = "/pics/item_mini/" + minipicture;
	this.unique			= unique;
	this.rank			= unique;
	this.wpnclass		= wpnclass;
	this.type			= type;
	if(parseInt(agear) == 1)	this.agear = true;
	else						this.agear = false;
	this.level			= parseInt(level);
	this.atkmin			= parseFloat(atkmin);
	this.atkmax			= parseFloat(atkmax);
	this.volley			= parseInt(volley);
	this.volleynumber	= parseInt(number);
	this.prob			= parseFloat(prob);
	this.pierce			= parseFloat(pierce);
	this.dist			= parseInt(dist);
	this.reatk			= parseFloat(reatk);
	this.heat			= parseInt(heat);
	this.valid			= parseInt(valid);
	this.speed			= parseInt(speed);
	this.induct			= parseInt(induct);
	this.radius			= parseInt(radius);
	this.weight			= parseInt(weight);
	this.price			= parseInt(price);
	this.parentwpn		= parentwpn;
	this.parentitem		= parentwpn;
	this.childwpn		= childwpn;
	this.childitem		= childwpn;
	this.legend			= legend;
	this.legendchance	= parseInt(legendchance);
	this.upgradechance	= parseInt(upgradechance);
}

//This function is used as a constructor for the Fix class.  Allows this class to be held in an array.
function newFix(name, id, item_type, category, validcalc, validcrtr, gamble, family, chance, oldname, level, adv_atkmin, adv_atkmax, std_atkmin, std_atkmax, 
				adv_lock, std_lock, adv_prob, std_prob, adv_pierce, std_pierce, dist, reatk, heat, valid, weight, energy_repair, shield_repair, 
				sp_repair, adv_speed, overheat, exp_rate, drop_rate){
	if(typeof(Fix)     == 'undefined') Fix = new Array();
	if(typeof(Fix[id]) == 'undefined') 
	Fix[id] = new FixConstruct(name, id, item_type, category, validcalc, validcrtr, gamble, family, chance, oldname, level, adv_atkmin, adv_atkmax, std_atkmin, 
							   std_atkmax, adv_lock, std_lock, adv_prob, std_prob, adv_pierce, std_pierce, dist, reatk, heat, valid, weight, energy_repair, 
							   shield_repair, sp_repair, adv_speed, overheat, exp_rate, drop_rate);
}
//This is the class that holds all the information for all the fixs.  The data from the XML is loaded into this class
function FixConstruct(name, id, item_type, category, validcalc, validcrtr, gamble, family, chance, oldname, level, adv_atkmin, adv_atkmax, std_atkmin, std_atkmax, 
					  adv_lock, std_lock, adv_prob, std_prob, adv_pierce, std_pierce, dist, reatk, heat, valid, weight, energy_repair, shield_repair, 
					  sp_repair, adv_speed, overheat, exp_rate, drop_rate){
	this.name		= name;
	this.id			= id;
	this.item_type	= item_type;
	this.category	= category;
	this.validcalc	= validcalc;
	this.validcrtr	= validcrtr;
	this.gamble		= gamble;
	this.family		= family;
	this.chance		= parseInt(chance);
	this.old		= oldname;
	this.level		= parseInt(level);
	this.std_atkmin	= parseInt(std_atkmin);
	this.std_atkmax	= parseInt(std_atkmax);
	this.adv_atkmin	= parseInt(adv_atkmin);
	this.adv_atkmax	= parseInt(adv_atkmax);
	this.adv_lock	= parseInt(adv_lock);
	this.std_lock	= parseInt(std_lock);
	this.adv_prob	= parseFloat(adv_prob);
	this.std_prob	= parseFloat(std_prob);
	this.adv_pierce	= parseFloat(adv_pierce);
	this.std_pierce	= parseFloat(std_pierce);
	this.dist		= parseInt(dist);
	this.reatk		= parseInt(reatk);
	this.heat		= parseInt(heat);
	this.valid		= parseFloat(valid);
	this.weight		= parseInt(weight);
	this.energy_repair = parseInt(energy_repair);
	this.shield_repair = parseInt(shield_repair);
	this.sp_repair	= parseInt(sp_repair);
	this.adv_speed	= parseInt(adv_speed);
	this.overheat	= parseFloat(overheat);
	this.exp_rate	= parseInt(exp_rate);
	this.drop_rate	= parseInt(drop_rate);
	this.bonus		= "00";
}

//This function is used as a constructor for the Armor class.  Allows this class to be held in an array.
function newArmor(name, id, rank, eok, picture, minipicture, type, gear, aclass, level, weight, explanation, price, parentitem, childitem, legend, legendchance, upgradechance, r_version, d_version, e_version, funct){
	if(typeof(Armor)     == 'undefined') Armor = new Array();
	if(typeof(Armor[id]) == 'undefined') 
	Armor[id] = new ArmorConstruct(name, id, rank, eok, picture, minipicture, type, gear, aclass, level, weight, explanation, price, parentitem, childitem, legend, legendchance, upgradechance, r_version, d_version, e_version, funct);
}
//This is the class that holds all the information for all the armor. The data from the XML is loaded into this class.
function ArmorConstruct(name, id, rank, eok, picture, minipicture, type, gear, aclass, level, weight, explanation, price, parentitem, childitem, legend, legendchance, upgradechance, r_version, d_version, e_version, funct){
	this.name			= name;
	this.id				= id;
	this.rank			= rank;
	if(eok == "0")		this.eok = false;
	else				this.eok = true;
	if(picture == "")		this.picture = "";
	else					this.picture = "/pics/item_large/" + picture;
	if(minipicture == "")	this.minipicture = "/pics/item_mini/unknown.gif";
	else					this.minipicture = "/pics/item_mini/" + minipicture;
	this.type			= type;
	this.gear			= gear;
	this.aclass			= aclass;
	this.level			= parseInt(level);
	this.weight			= parseInt(weight);
	this.explanation	= explanation;
	this.price			= parseInt(price);
	this.parentitem		= parentitem;
	this.childitem		= childitem;
	this.legend			= legend;
	this.legendchance	= parseInt(legendchance);
	this.upgradechance	= parseInt(upgradechance);
	this.r_version		= r_version;
	this.d_version		= d_version;
	this.e_version		= e_version;
	this.funct			= funct;
}

function FunctConstruct(energy, shield, defense, evasion, shieldregen, spregen, hpregen, radarrange, adv_pierce, std_pierce){
	this.energy		= parseInt(energy);
	this.shield		= parseInt(shield);
	this.defense	= parseFloat(defense);
	this.evasion	= parseFloat(evasion);
	this.shieldregen= parseFloat(shieldregen);
	this.spregen	= parseFloat(spregen);
	if(hpregen == 1)	this.hpregen = true;
	else				this.hpregen = false;
	this.radarrange	= parseFloat(radarrange);
	this.adv_pierce	= parseFloat(adv_pierce);
	this.std_pierce	= parseFloat(std_pierce);
}

//This function is used as a constructor for the Armor class.  Allows this class to be held in an array.
function newCPU(name, id, gear, rank, picture, minipicture, level, attack, defense, fuel, spirit, agility, shield, weight, price, explanation){
	if(typeof(CPU)     == 'undefined') CPU = new Array();
	if(typeof(CPU[id]) == 'undefined') 
	CPU[id] = new CPUConstruct(name, id, gear, rank, picture, minipicture, level, attack, defense, fuel, spirit, agility, shield, weight, price, explanation);
}
//This is the class that holds all the information for all the armor. The data from the XML is loaded into this class.
function CPUConstruct(name, id, gear, rank, picture, minipicture, level, attack, defense, fuel, spirit, agility, shield, weight, price, explanation){
	this.name			= name;
	this.id				= id;
	this.gear			= gear;
	this.rank			= rank;
	if(picture == "")		this.picture = "";
	else					this.picture = "/pics/item_large/" + picture;
	if(minipicture == "")	this.minipicture = "/pics/item_mini/unknown.gif";
	else					this.minipicture = "/pics/item_mini/" + minipicture;
	this.level			= parseInt(level);
	this.attack			= parseInt(attack);
	this.defense		= parseInt(defense);
	this.fuel			= parseInt(fuel);
	this.spirit			= parseInt(spirit);
	this.agility		= parseInt(agility);
	this.shield			= parseInt(shield);
	this.weight			= parseInt(weight);
	this.price			= parseInt(price);
	this.explanation	= explanation;
}

//This is the class that holds all the information about the currect enchants.
function ArmorEnchantConstruct(){
	this.total		= 0;
	this.order		= new Array();
	this.energy		= new EnchantSubstruct(200, 400, "H");
	this.shield		= new EnchantSubstruct(150, 300, "S");
	this.mix		= new EnchantSubstruct(100, 200, "M");
	this.defense	= new EnchantSubstruct(1.18, 2.75, "D");
	this.evasion	= new EnchantSubstruct(1.18, 2.75, "E");
}

//This is the class that holds all the information about the currect enchants.
function WeaponEnchantConstruct(){
	this.total		= 0;
	this.order		= new Array();
	this.attack		= new EnchantSubstruct(3, 6, "A");
	this.prob		= new EnchantSubstruct(2.746, 5.492, "P");
	this.pierce		= new EnchantSubstruct(2, 4, "I");
	this.dist		= new EnchantSubstruct(3, 3, "D");
	this.reatk		= new EnchantSubstruct(2, 3, "R");
	this.speed		= new EnchantSubstruct(6, 6, "S");
	this.heat		= new EnchantSubstruct(3, 3, "H");
	this.radius		= new EnchantSubstruct(5, 5, "E");
	this.weight		= new EnchantSubstruct(5, 5, "W");
}

function EnchantSubstruct(normalmult, hypermult, id){
	this.total		= 0;
	this.normal		= new EnchantChild(normalmult);
	this.hyper		= new EnchantChild(hypermult);
	this.id		 	= id;
}
EnchantSubstruct.prototype.value = function(){
	return (this.normal.total * this.normal.multiplier) + (this.hyper.total * this.hyper.multiplier);
}

function EnchantChild(mult){
	this.total		= 0;
	this.multiplier	= mult;
}

function newCreatorItem(){
	if(typeof(CreatorItem)=='undefined') CreatorItem = new Array(); 
	if(CreatorItem[newCreatorItem.arguments[0]] === undefined)
	CreatorItem[newCreatorItem.arguments[0]] = new CreatorItemConstruct(newCreatorItem.arguments);
}

function CreatorItemConstruct(args){
	var iter = 0; //Used to dynamically run through the args.
	this.id			= args[iter++];
	this.name		= args[iter++];
	this.type		= args[iter++];
	this.group		= args[iter++];
	this.equiptype	= args[iter++];
	this.stackable	= (parseInt(args[iter++]) == 1);
	this.consumable	= (parseInt(args[iter++]) == 1);
	if(args[iter] == ""){	this.picture = ""; iter++;
	}else{					this.picture = "/pics/item_large/" + args[iter++]; }
	if(args[iter] == ""){	this.minipicture = "/pics/item_mini/unknown.gif"; iter++;
	}else{					this.minipicture = "/pics/item_mini/" + args[iter++]; }
	this.buyamount	= parseInt(args[iter++]);
	this.buytype	= args[iter++];
	this.sellamount	= parseInt(args[iter++]);
	this.selltype	= args[iter++];
	this.shop		= args[iter++];
	this.event		= args[iter++];
	this.hoverbody	= args[iter++];
	this.description= args[iter++];
	this.action		= args[iter++];
}

////////////////////////////////////////////////////////////////////////////////////////////////
///////Start Item Construct functions///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

//This function is used as a constructor for all items.
function ItemConstruct(Type, Limit, DivID, varName, enableItem, enableDuplication){
	if(typeof(enableItem) == 'undefined') enableItem = true;
	if(typeof(enableDuplication) == 'undefined') enableDuplication = true;
	if(typeof(Type) == 'undefined') Type = "";
	this.type		= Type;
	this.limit		= Limit;
	this.varName	= varName;
	this.enableItem	= enableItem;
	this.enableDuplication	= enableDuplication;
	this.active		= false;
	this.amount		= 0;
	this.stackable	= false;
	this.consumable	= false;
	this.prevHoverID = "";
	this.prevHoverAmount = 0;
	this.prevHoverString = "";
	this.loadStatus = 0;
	
	this.groupName = "";
	this.groupTransferIn = true;
	this.groupTransferOut = true;
	
	if(DivID == "none")		this.div	= "no_div_given";
	else					this.div	= DivID;
}

//Checks the status of the loading item and runs the passed js once completed
//If returns a 0 immediatly, the item is not currently loading or is in error.
ItemConstruct.prototype.onLoad = function(funct){ with(this){
	
	switch(this.loadStatus){
		case 2: //If item is loaded
			eval(funct);
			break;
		case 1: //If item is still loading
			setTimeout(this.varName+".onLoad('"+funct+"');", 500);
		break;
		default: return 0; //If item is not loading and/or in error
	}
}}

//Returns true or false on whether the item is loaded
ItemConstruct.prototype.loaded = function(){ with(this){
	if(this.loadStatus == 2)	return true;
	else						return false;
}}

ItemConstruct.prototype.buildHover = function(HoverDir){ with(this){
	if(typeof(this.type) == 'undefined') return;
	if(this.type == "") return;
	var thePicture = "";
	var theTitle = "";
	var theTitleClass = "normal";
	var theBody = "";
	
	if(item.picture) thePicture = item.picture;
	
	if(exportItem() != prevHoverID || prevHoverAmount != this.amount){
		switch(type.toLowerCase()){
			case "armor":
				var tempvar;
				if (item.rank == "Boss")			var theTitleClass = "boss";
				else if (item.rank == "Unique")		var theTitleClass = "unique";
				else if (item.rank == "Legendary")	var theTitleClass = "legendary";
				else if (enchants.total > 0)		var theTitleClass = "enchant";
				else								var theTitleClass = "normal";
				theTitle = "<span class='" + theTitleClass + "'>" + item.name + "</span>";
				
				if(prefix.id != "00")
					theTitle  = "<span class='fix'>" + prefix.name + " </span>" + theTitle;
				if(suffix.id != "00")
					theTitle += "<span class='fix'> of " + suffix.name + "</span>";
				
				theBody += "<div>Type : "+item.type+" type</div>";
				theBody += "<div>Gear type : "+item.gear+"-Gear</div>";
				theBody += "<div>Required : <span style='text-transform: uppercase;'>Level</span>["+item.level+"]</div>";
				theBody += "<div>Weight : "+item.weight+"</div>";
				
				with(enchants){
					if(energy.total + mix.total > 0)
						 var e_energy = ["<span class='enchant'>[+", (energy.value() + mix.value()).toFixed(2), "]</span>"].join("");
					else var e_energy = "";
					if(shield.total + mix.total > 0)
						 var e_shield = ["<span class='enchant'>[+", (shield.value() + mix.value()).toFixed(2), "]</span>"].join("");
					else var e_shield = "";
					if(defense.total)
						 var e_defense = ["<span class='enchant'>[+", (defense.value()).toFixed(2), "%]</span>"].join("");
					else var e_defense = "";
					if(evasion.total)
						 var e_evasion = ["<span class='enchant'>[+", (evasion.value()).toFixed(2), "%]</span>"].join("");
					else var e_evasion = "";
				}
				if(item.funct.energy > 0 || e_energy != "")
					theBody += buildFunctionLine("[Energy: +" + (item.funct.energy).toFixed(2) + e_energy + "]");
				if(item.funct.shield > 0 || e_shield != "")
					theBody += buildFunctionLine("[Shield: +" + (item.funct.shield).toFixed(2) + e_shield + "]");
				if(item.funct.defense > 0 || e_defense != ""){
					theBody += buildFunctionLine("[Defense against Standard Weapons: " + (item.funct.defense).toFixed(2) + "%" + e_defense + "]");
					theBody += buildFunctionLine("[Defense against Advanced Weapons: " + (item.funct.defense).toFixed(2) + "%" + e_defense + "]"); }
				if(item.funct.evasion > 0 || e_evasion != ""){
					theBody += buildFunctionLine("[Evasion against Standard Weapons: " + (item.funct.evasion).toFixed(2) + "%" + e_evasion + "]");
					theBody += buildFunctionLine("[Evasion against Advanced Weapons: " + (item.funct.evasion).toFixed(2) + "%" + e_evasion + "]"); }
				
				tempvar = prefix.std_prob + suffix.std_prob;
				if(tempvar > 0)	theBody += buildFunctionLine("[Standard Weapon&rsquo;s Probability: +" + tempvar.toFixed(2) + "%]");
				
				tempvar = prefix.adv_prob + suffix.adv_prob;
				if(tempvar > 0)	theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Probability: +" + tempvar.toFixed(2) + "%]");
				
				tempvar = item.funct.hpregen + prefix.energy_repair + suffix.energy_repair;
				if(tempvar > 0)	theBody += buildFunctionLine("[Enables HP recovery while flying]");
				
				tempvar = item.funct.shieldregen + prefix.shield_repair + suffix.shield_repair;
				if(tempvar > 0)	theBody += buildFunctionLine("[Shield recovery rate: +" + tempvar + "%]");
				
				tempvar = prefix.std_pierce + suffix.std_pierce;
				if(tempvar > 0)	theBody += buildFunctionLine("[Std Weapon Pierce: +" + tempvar.toFixed(2) + "%]");
				
				tempvar = prefix.adv_pierce + suffix.adv_pierce;
				if(tempvar > 0)	theBody += buildFunctionLine("[Adv Weapon Pierce: +" + tempvar.toFixed(2) + "%]");
				
				tempvar = item.funct.spregen + prefix.sp_repair + suffix.sp_repair;
				if(tempvar > 0)	theBody += buildFunctionLine("[SP recovery speed: +" + tempvar + "%]");
				
				tempvar = item.funct.radarrange + prefix.std_lock + suffix.std_lock;
				if(tempvar > 0)	theBody += buildFunctionLine("[Standard Weapon Radar Range: +" + tempvar + "%]");
				
				tempvar = item.funct.radarrange + prefix.adv_lock + suffix.adv_lock;
				if(tempvar > 0)	theBody += buildFunctionLine("[Advanced Weapon Radar Range: +" + tempvar + "%]");
				
				tempvar = + prefix.std_atkmin + suffix.std_atkmin;
				if(tempvar > 0)	theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (min): +" + tempvar + "%]");
				
				tempvar = + prefix.std_atkmax + suffix.std_atkmax;
				if(tempvar > 0)	theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (max): +" + tempvar + "%]");
				
				tempvar = + prefix.adv_atkmin + suffix.adv_atkmin;
				if(tempvar > 0)	theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (min): +" + tempvar + "%]");
				
				tempvar = + prefix.adv_atkmax + suffix.adv_atkmax;
				if(tempvar > 0)	theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (max): +" + tempvar + "%]");
				
				tempvar = + prefix.adv_speed + suffix.adv_speed;
				if(tempvar > 0)	theBody += buildFunctionLine("[Speed: +" + tempvar + "%]");
				
				tempvar = + prefix.exp_rate + suffix.exp_rate;
				if(tempvar > 0)	theBody += buildFunctionLine("[EXP from Monsters: +" + tempvar + "%]");
				
				tempvar = + prefix.drop_rate + suffix.drop_rate;
				if(tempvar > 0)	theBody += buildFunctionLine("[Drop rate from Monsters: +" + tempvar + "%]");
				
				tempvar = + prefix.overheat + suffix.overheat;
				if(tempvar > 0)	theBody += buildFunctionLine("[Engine Overheat: +" + tempvar.toFixed(2) + "sec]");
				
				theBody += "<div>Price : " + item.price + "(SPI)</div>";
				if(item.explanation != "")
					theBody += "<div style='max-width: 250px;'>Explanation : " + item.explanation + "</div>";
			break;
			//end case "armor"
			case "weapon":
				if (item.unique == "Boss")				var theTitleClass = "boss";
				else if (item.unique == "Unique")		var theTitleClass = "unique";
				else if (item.unique == "Legendary")	var theTitleClass = "legendary";
				else if (enchants.total > 0)			var theTitleClass = "enchant";
				else									var theTitleClass = "normal";
				theTitle = "<span class='" + theTitleClass + "'>" + item.name + "</span>";
				
				if(prefix.id != "00")
					theTitle  = "<span class='fix'>" + prefix.name + " </span>" + theTitle;
				if(suffix.id != "00")
					theTitle += "<span class='fix'> of " + suffix.name + "</span>";
				
				theBody += "<div>Type : "+item.type+" type</div>";
				theBody += "<div>Gear type : " + (item.agear?"A-GEAR":"B-GEAR M-GEAR I-GEAR") + "</div>";
				theBody += "<div>Demand : <span style='text-transform: uppercase;'>Level</span>["+item.level+"]</div>";
				
				with(enchants){
					if(attack.total > 0)
						 var e_attack = ["<span class='enchant'>[+", attack.value(), "%]</span>"].join("");
					else var e_attack = "";
					if(prob.total > 0)
						 var e_prob = ["<span class='enchant'>[+", (prob.value()).toFixed(2), "%]</span>"].join("");
					else var e_prob = "";
					if(pierce.total > 0)
						 var e_pierce = ["<span class='enchant'>[+", pierce.value(), "%]</span>"].join("");
					else var e_pierce = "";
					if(dist.total > 0)
						 var e_dist = ["<span class='enchant'>[+", dist.value(), "%]</span>"].join("");
					else var e_dist = "";
					if(reatk.total > 0)
						 var e_reatk = ["<span class='enchant'>[-", reatk.value(), "%]</span>"].join("");
					else var e_reatk = "";
					if(speed.total > 0)
						 var e_speed = ["<span class='enchant'>[+", speed.value(), "%]</span>"].join("");
					else var e_speed = "";
					if(radius.total > 0)
						 var e_radius = ["<span class='enchant'>[+", radius.value(), "%]</span>"].join("");
					else var e_radius = "";
					if(heat.total > 0)
						 var e_heat = ["<span class='enchant'>[+", heat.value(), "%]</span>"].join("");
					else var e_heat = "";
					if(weight.total > 0)
						 var e_weight = ["<span class='enchant'>[-", weight.value(), "%]</span>"].join("");
					else var e_weight = "";
				}
				{
					if(prefix.level > 0 || suffix.level > 0)
						 var f_level = ["<span class='fix'>[-", prefix.level + suffix.level, "]</span>"].join("");
					else var f_level = "";
					if(prefix.adv_atkmin > 0 || suffix.adv_atkmin > 0)
						 var f_atkmin = ["<span class='fix'>[+", prefix.adv_atkmin + suffix.adv_atkmin, "%]</span>"].join("");
					else var f_atkmin = "";
					if(prefix.adv_atkmax > 0 || suffix.adv_atkmax > 0)
						 var f_atkmax = ["<span class='fix'>[+", prefix.adv_atkmax + suffix.adv_atkmax, "%]</span>"].join("");
					else var f_atkmax = "";
					if(prefix.adv_prob > 0 || suffix.adv_prob > 0)
						 var f_prob = ["<span class='fix'>[+", (prefix.adv_prob + suffix.adv_prob).toFixed(2), "%]</span>"].join("");
					else var f_prob = "";
					if(prefix.adv_pierce > 0 || suffix.adv_pierce > 0)
						 var f_pierce = ["<span class='fix'>[+", prefix.adv_pierce + suffix.adv_pierce, "%]</span>"].join("");
					else var f_pierce = "";
					if(prefix.dist > 0 || suffix.dist > 0)
						 var f_dist = ["<span class='fix'>[+", prefix.dist + suffix.dist, "%]</span>"].join("");
					else var f_dist = "";
					if(prefix.reatk > 0 || suffix.reatk > 0)
						 var f_reatk = ["<span class='fix'>[-", prefix.reatk + suffix.reatk, "%]</span>"].join("");
					else var f_reatk = "";
					if(prefix.heat > 0 || suffix.heat > 0)
						 var f_heat = ["<span class='fix'>[+", prefix.heat + suffix.heat, "%]</span>"].join("");
					else var f_heat = "";
					if(prefix.valid > 0 || suffix.valid > 0)
						 var f_valid = ["<span class='fix'>[+", (prefix.valid + suffix.valid).toFixed(1), " degrees]</span>"].join("");
					else var f_valid = "";
					if(prefix.weight > 0 || suffix.weight > 0)
						 var f_weight = ["<span class='fix'>[-", prefix.weight + suffix.weight, "%]</span>"].join("");
					else var f_weight = "";
				}
				theBody += "<div>Attack Power : (" + Math.round(item.atkmin) + e_attack + f_atkmin + " ~ " + Math.round(item.atkmax) + e_attack + f_atkmax + ") X (" + item.volley + " X " + item.volleynumber + ")</div>";
				theBody += "<div>Damage / sec : " + Math.round(this.dps("min")) + " ~ " + Math.round(this.dps("max")) + "</div>";
				theBody += "<div>Probability : " + (item.prob).toFixed(2) + "%" + e_prob + f_prob + "</div>";
				theBody += "<div>Pierce Probability : " + (item.pierce).toFixed(2) + "%" + e_pierce + f_pierce + "</div>";
				theBody += "<div>Distance : " + item.dist + "m" + e_dist + f_dist + "</div>";
				theBody += "<div>Reattack time : " + (item.reatk).toFixed(2) + "sec" + e_reatk + f_reatk + "</div>";
				if(item.category == "Standard"){
					theBody += "<div>Overheating time : " + (item.heat).toFixed(2) + "sec" + e_heat + f_heat + "</div>";
				}else if(item.category == "Advanced"){
					theBody += "<div>Valid Angle : " + item.valid + " degrees" + f_valid + "</div>";
					theBody += "<div>Speed : " + item.speed + " m/s" + e_speed + "</div>";
					theBody += "<div>Induction angle : " + item.induct + " degrees</div>";
					theBody += "<div>Explosion radius : " + item.radius + "m" + e_radius + "</div>";
				}
				theBody += "<div>Weight : " + item.weight + "" + e_weight + f_weight + "</div>";
				theBody += "<div>Effect : " + effect.name + "</div>";
				theBody += "<div>Price : " + item.price + "(SPI)</div>";
			break;
			//end case "weapon"
			case "fix":
				theTitle = "<span class='normal'>" + item.name + "</span>";
				theBody += "<div>Type: " + item.item_type + " fix</div>";
				
				if(item.category == "Both") var thisCateg = "Prefix & Suffix";
				else var thisCateg = item.category;
				theBody += "<div>Category: " + thisCateg + "</div>";
				theBody += "<div>Gamble: " + item.gamble + "</div>";
					
				if(item.std_atkmin > 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (min): +" + item.std_atkmin + "%]");
				if(item.std_atkmax > 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (max): +" + item.std_atkmax + "%]");
				if(item.adv_atkmin > 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (min): +" + item.adv_atkmin + "%]");
				if(item.adv_atkmax > 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (max): +" + item.adv_atkmax + "%]");
				if(item.std_prob > 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Probability: +" + (item.std_prob).toFixed(2) + "%]");
				if(item.adv_prob > 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Probability: +" + (item.adv_prob).toFixed(2) + "%]");
				if(item.dist > 0)			theBody += buildFunctionLine("[Weapon Range Increase: +" + item.dist + "%]");
				if(item.reatk > 0)			theBody += buildFunctionLine("[Weapon Reattack Rate: -" + item.reatk + "%]");
				if(item.heat > 0)			theBody += buildFunctionLine("[Standard Weapon Overheat Time: +" + item.heat + "%]");
				if(item.valid > 0)			theBody += buildFunctionLine("[Advanced Weapon Valid Angle: +" + item.valid + "degrees]");
				if(item.energy_repair > 0)	theBody += buildFunctionLine("[Enables HP recovery while flying]");
				if(item.shield_repair > 0)	theBody += buildFunctionLine("[Shield recovery rate: +" + item.shield_repair + "%]");
				if(item.std_pierce > 0)		theBody += buildFunctionLine("[Std Weapon Pierce: +" + (item.std_pierce).toFixed(2) + "%]");
				if(item.adv_pierce > 0)		theBody += buildFunctionLine("[Adv Weapon Pierce: +" + (item.adv_pierce).toFixed(2) + "%]");
				if(item.sp_repair > 0)		theBody += buildFunctionLine("[SP recovery speed: +" + item.sp_repair + "%]");
				if(item.std_lock > 0)		theBody += buildFunctionLine("[Standard Weapon Radar Range: +" + item.std_lock + "%]");
				if(item.adv_lock > 0)		theBody += buildFunctionLine("[Advanced Weapon Radar Range: +" + item.adv_lock + "%]");
				if(item.adv_speed > 0)		theBody += buildFunctionLine("[Speed: +" + item.adv_speed + "%]");
				if(item.exp_rate > 0)		theBody += buildFunctionLine("[EXP from Monsters: +" + item.exp_rate + "%]");
				if(item.drop_rate > 0)		theBody += buildFunctionLine("[Drop rate from Monsters: +" + item.drop_rate + "%]");
				if(item.overheat > 0)		theBody += buildFunctionLine("[Engine Overheat: +" + (item.overheat).toFixed(2) + "sec]");
				if(item.weight > 0)			theBody += buildFunctionLine("[Weight: -" + item.weight + "%]");
			break;
			//end case "fix"
			case "buff":
				theTitle = item.name;
				theBody += "<div>Gear type: ";
				if(item.gear.search("A") >= 0)	theBody += "A-Gear ";
				if(item.gear.search("B") >= 0)	theBody += "B-Gear ";
				if(item.gear.search("I") >= 0)	theBody += "I-Gear ";
				if(item.gear.search("M") >= 0)	theBody += "M-Gear ";
				theBody += "</div>";
				if(item.skilllevel !== undefined)	theBody += "<div>Skill level: [" + item.skilllevel + "]</div>";
				if(item.funct[LEVEL] !== undefined)	theBody += "<div>Required: LEVEL [" + item.level + "]</div>";
				if(item.spcost !== undefined)		theBody += "<div>SP (Skill Points): " + item.spcost + "</div>";
				if(item.duration !== undefined && item.duration > 0)
													theBody += "<div>Duration: " + (item.duration).toFixed(2) + " sec</div>";
				if(item.cooldown !== undefined && item.cooldown > 0)
													theBody += "<div>Cooldown time: " + (item.cooldown).toFixed(2) + " sec</div>";
				if(item.funct[STD_RADIUS] != 0)		theBody += buildFunctionLine("[Standard Weapon Explosion Radius:+" + item.funct[STD_RADIUS].toFixed(2) + "]");
				if(item.funct[ADV_RADIUS] != 0)		theBody += buildFunctionLine("[Advanced Weapon Explosion Radius:+" + item.funct[ADV_RADIUS].toFixed(2) + "]");
				if(item.funct[STD_VLY] != 0)		theBody += buildFunctionLine("[Continuous fire for Standard Weapons:+" + item.funct[STD_VLY] + "]");
				if(item.funct[ADV_VLY] != 0)		theBody += buildFunctionLine("[Continuous fire for Advanced Weapons:+" + item.funct[ADV_VLY] + "]");
				if(item.funct[STD_NUM] != 0)		theBody += buildFunctionLine("[Number of shots fired:+" + item.funct[STD_NUM] + "]");
				if(item.funct[ADV_NUM] != 0)		theBody += buildFunctionLine("[Number of missles fired:+" + item.funct[ADV_NUM] + "]");
				if(item.funct[STD_MINATK] != 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (min):+" + item.funct[STD_MINATK] + "%]");
				if(item.funct[STD_MAXATK] != 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (max):+" + item.funct[STD_MAXATK] + "%]");
				if(item.funct[ADV_MINATK] != 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (min):+" + item.funct[ADV_MINATK] + "%]");
				if(item.funct[ADV_MAXATK] != 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (max):+" + item.funct[ADV_MAXATK] + "%]");
				if(item.funct[STD_REATK] != 0)		theBody += buildFunctionLine("[Reattack time for Standard Weapons:<span style='color: red;'>-" + item.funct[STD_REATK] + "%</span>]");
				if(item.funct[ADV_REATK] != 0)		theBody += buildFunctionLine("[Reattack time for Advanced Weapons:<span style='color: red;'>-" + item.funct[ADV_REATK] + "%</span>]");
				if(item.funct[ADV_VALID] != 0)		theBody += buildFunctionLine("[Valid angle increase:+" + item.funct[ADV_VALID].toFixed(2) + "]");
				if(item.funct[STD_RADAR] != 0)		theBody += buildFunctionLine("[Standard Weapon Radar Range:+" + item.funct[STD_RADAR] + "%]");
				if(item.funct[ADV_RADAR] != 0)		theBody += buildFunctionLine("[Advanced Weapon Radar Range:+" + item.funct[ADV_RADAR] + "%]");
				if(item.funct[STD_DEF] != 0)		theBody += buildFunctionLine("[Defense against Standard Weapons:+" + (item.funct[STD_DEF]).toFixed(2) + "%]");
				if(item.funct[ADV_DEF] != 0)		theBody += buildFunctionLine("[Defense against Advanced Weapons:+" + (item.funct[ADV_DEF]).toFixed(2) + "%]");
				if(item.funct[STD_EVA] != 0)		theBody += buildFunctionLine("[Evasion against Standard Weapons:+" + (item.funct[STD_EVA]).toFixed(2) + "%]");
				if(item.funct[ADV_EVA] != 0)		theBody += buildFunctionLine("[Evasion against Advanced Weapons:+" + (item.funct[ADV_EVA]).toFixed(2) + "%]");
				if(item.funct[STD_DIST] != 0)		theBody += buildFunctionLine("[Standard Weapon distance:+" + item.funct[STD_DIST] + "%]");
				if(item.funct[ADV_DIST] != 0)		theBody += buildFunctionLine("[Advanced Weapon distance:+" + item.funct[ADV_DIST] + "%]");
				if(item.funct[STD_PROB] != 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Probability:+" + (item.funct[STD_PROB]).toFixed(2) + "%]");
				if(item.funct[ADV_PROB] != 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Probability:+" + (item.funct[ADV_PROB]).toFixed(2) + "%]");
			break;
			//end case "buff"
			case "charm":
				theTitle = item.name;
				theBody += "<div>Gear type: ";
				if(item.gear == "ABIM")
					theBody += "All Gears";
				else{
					if(item.gear.search("A") >= 0)	theBody += "A-Gear ";
					if(item.gear.search("B") >= 0)	theBody += "B-Gear ";
					if(item.gear.search("I") >= 0)	theBody += "I-Gear ";
					if(item.gear.search("M") >= 0)	theBody += "M-Gear "; }
				theBody += "</div>";
				if(item.level != 0)					theBody += "<div>Required: LEVEL [" + item.level + "]</div>";
				if(item.weight != 0)				theBody += "<div>Weight: " + item.weight + "</div>";
				if(item.funct[FUEL_AMOUNT] != 0)	theBody += buildFunctionLine("[Fuel:+" + item.funct[SHIELD].toFixed(2) + "]");
				if(item.funct[ENERGY] != 0)			theBody += buildFunctionLine("[Energy:+" + item.funct[ENERGY].toFixed(2) + "]");
				if(item.funct[SHIELD] != 0)			theBody += buildFunctionLine("[Shield:+" + item.funct[SHIELD].toFixed(2) + "]");
				if(item.funct[STD_RADIUS] != 0)		theBody += buildFunctionLine("[Standard Weapon Explosion Radius:+" + item.funct[STD_RADIUS].toFixed(2) + "]");
				if(item.funct[ADV_RADIUS] != 0)		theBody += buildFunctionLine("[Advanced Weapon Explosion Radius:+" + item.funct[ADV_RADIUS].toFixed(2) + "]");
				if(item.funct[STD_VLY] != 0)		theBody += buildFunctionLine("[Continuous fire for Standard Weapons:+" + item.funct[STD_VLY] + "]");
				if(item.funct[ADV_VLY] != 0)		theBody += buildFunctionLine("[Continuous fire for Advanced Weapons:+" + item.funct[ADV_VLY] + "]");
				if(item.funct[STD_NUM] != 0)		theBody += buildFunctionLine("[Number of shots fired:+" + item.funct[STD_NUM] + "]");
				if(item.funct[ADV_NUM] != 0)		theBody += buildFunctionLine("[Number of missles fired:+" + item.funct[ADV_NUM] + "]");
				if(item.funct[STD_MINATK] != 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (min):+" + item.funct[STD_MINATK] + "%]");
				if(item.funct[STD_MAXATK] != 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Attack (max):+" + item.funct[STD_MAXATK] + "%]");
				if(item.funct[ADV_MINATK] != 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (min):+" + item.funct[ADV_MINATK] + "%]");
				if(item.funct[ADV_MAXATK] != 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Attack (max):+" + item.funct[ADV_MAXATK] + "%]");
				if(item.funct[STD_REATK] != 0)		theBody += buildFunctionLine("[Reattack time for Standard Weapons:<span style='color: red;'>-" + item.funct[STD_REATK] + "%</span>]");
				if(item.funct[ADV_REATK] != 0)		theBody += buildFunctionLine("[Reattack time for Advanced Weapons:<span style='color: red;'>-" + item.funct[ADV_REATK] + "%</span>]");
				if(item.funct[ADV_VALID] != 0)		theBody += buildFunctionLine("[Valid angle increase:+" + item.funct[ADV_VALID].toFixed(2) + "]");
				if(item.funct[STD_RADAR] != 0)		theBody += buildFunctionLine("[Standard Weapon Radar Range:+" + item.funct[STD_RADAR] + "%]");
				if(item.funct[ADV_RADAR] != 0)		theBody += buildFunctionLine("[Advanced Weapon Radar Range:+" + item.funct[ADV_RADAR] + "%]");
				if(item.funct[STD_DEF] != 0)		theBody += buildFunctionLine("[Defense against Standard Weapons:+" + (item.funct[STD_DEF]).toFixed(2) + "%]");
				if(item.funct[ADV_DEF] != 0)		theBody += buildFunctionLine("[Defense against Advanced Weapons:+" + (item.funct[ADV_DEF]).toFixed(2) + "%]");
				if(item.funct[STD_EVA] != 0)		theBody += buildFunctionLine("[Evasion against Standard Weapons:+" + (item.funct[STD_EVA]).toFixed(2) + "%]");
				if(item.funct[ADV_EVA] != 0)		theBody += buildFunctionLine("[Evasion against Advanced Weapons:+" + (item.funct[ADV_EVA]).toFixed(2) + "%]");
				if(item.funct[STD_DIST] != 0)		theBody += buildFunctionLine("[Standard Weapon distance:+" + item.funct[STD_DIST] + "%]");
				if(item.funct[ADV_DIST] != 0)		theBody += buildFunctionLine("[Advanced Weapon distance:+" + item.funct[ADV_DIST] + "%]");
				if(item.funct[STD_PROB] != 0)		theBody += buildFunctionLine("[Standard Weapon&rsquo;s Probability:+" + (item.funct[STD_PROB]).toFixed(2) + "%]");
				if(item.funct[ADV_PROB] != 0)		theBody += buildFunctionLine("[Advanced Weapon&rsquo;s Probability:+" + (item.funct[ADV_PROB]).toFixed(2) + "%]");
				if(item.funct[STD_PIERCE] != 0)		theBody += buildFunctionLine("[Std Weapon Pierce:+" + (item.funct[STD_PIERCE]).toFixed(2) + "%]");
				if(item.funct[ADV_PIERCE] != 0)		theBody += buildFunctionLine("[Adv Weapon Pierce:+" + (item.funct[ADV_PIERCE]).toFixed(2) + "%]");
			break;
			//end case "charm"
			case "cpu":
				if (item.rank == "Unique")	var theTitleClass = "unique";
				else						var theTitleClass = "normal";
				theTitle = "<span class='" + theTitleClass + "'>" + item.name + "</span>";
				theBody += "<div>Gear type: ";
				if(item.gear == "ABIM")
					theBody += "All Gears";
				else{
					if(item.gear.search("A") >= 0)	theBody += "A-Gear ";
					if(item.gear.search("B") >= 0)	theBody += "B-Gear ";
					if(item.gear.search("I") >= 0)	theBody += "I-Gear ";
					if(item.gear.search("M") >= 0)	theBody += "M-Gear "; }
				theBody += "</div>";
				if(item.level !== undefined) theBody += "<div>Required: LEVEL [" + item.level + "]</div>";
				if(item.attack != 0) theBody += "<div>Function: <span class='fix'>[Attack:+" + item.attack.toFixed(2) + "]</span></div>";
				if(item.defense != 0) theBody += "<div>Function: <span class='fix'>[Defense:+" + item.defense.toFixed(2) + "]</span></div>";
				if(item.fuel != 0) theBody += "<div>Function: <span class='fix'>[Fuel:+" + item.fuel.toFixed(2) + "]</span></div>";
				if(item.spirit != 0) theBody += "<div>Function: <span class='fix'>[Spirit:+" + item.spirit.toFixed(2) + "]</span></div>";
				if(item.agility != 0) theBody += "<div>Function: <span class='fix'>[Agility:+" + item.agility.toFixed(2) + "]</span></div>";
				if(item.shield != 0) theBody += "<div>Function: <span class='fix'>[Shield:+" + item.shield.toFixed(2) + "]</span></div>";
				theBody += "<div>Weight: " + item.weight + "</div>";
				theBody += "<div>Price: " + item.price + "(SPI)</div>";
				if(item.explanation != "")
					theBody += "<div style='max-width: 250px;'>Explanation : " + item.explanation + "</div>";
			break;
			//end case "cpu"
			case "creator":
			 case "enchant":
			 case "gamble":
			 case "legend":
			 case "support":
			 case "change":
			 case "capsule":
			 case "misc":
				theTitle = "<span class='normal'>" + item.name + "</span>";
				theBody += "<div>Type: "+item.type+" type</div>";
				theBody += "<div>Amount: "+this.amount+"</div>";
				if(item.hoverbody != ""){
					theBody += item.hoverbody;
				}
				if(item.description != "")
					theBody += "<div style='max-width: 250px;'>Explanation : " + item.description + "</div>";
			break;
			default:
				try{
					theTitle = item.name;
					theBody = "<div style='color: gray;'>No format information available for '"+this.type+"' items.</div>";
				}catch(err){return;}
		}
		try{
			theHover = "<div class='hover_body'>";
			//Next line to be added only if external use of the tooltips is ever made available.
			//theHover += "<div style='position: absolute; top: 1px; right: 4px; color: #2A2A2A;'>acecalcs.net</div>";
			theHover += thePicture==""?"":"<div class='hover_picture'><img src='"+thePicture+"');' /></div>";
			theHover += theTitle==""?"":"<div class='hover_name'>"+theTitle+"</div>";
			theHover += "<div class='hover_content'>"+theBody+"</div>";
			theHover += "</div>";
			prevHoverID = exportItem();
			prevHoverAmount = this.amount;
			prevHoverString = theHover;
		}catch(err){theHover = "<div class='hover_body'>Error in building hover. Item data is malformed.</div>"}
	}else{
		theHover = prevHoverString;
	}
	return overlib(theHover, FULLHTML, VAUTO, HAUTO);
}}

//Items are moved from "that" to "this"
ItemConstruct.prototype.transferItem = function(that, forceDup, forceall){
	try{
		if(that === null) return false;
		if(typeof(forceDup) == 'undefined') forceDup = false;
		if(typeof(forceall) == 'undefined') forceall = false;
		
		that = eval(that);
		
		if(typeof(that) == 'undefined') return false;
		if(that.loadStatus != 2) return false;
		if(this.div == that.div) return false;
		
		if(this.groupName != that.groupName){
			if(!this.groupTransferIn){
				this.disallow();
				return false;
			}
			if(!that.groupTransferOut){
				this.disallow();
				return false;
			}
		}
		
		if(this.limit == "any" || this.limit.search(that.type) >= 0 || forceall){
				if(this.enableDuplication || forceDup){ //Will override destination with source item
					this.type = that.type;
					this.stackable = that.stackable;
					this.consumable = that.consumable;
					this.loadStatus = that.loadStatus;
					this.amount = that.amount;
					try{this.item	  = that.item;				}catch(err){}
					try{this.enchants = cloneObj(that.enchants);}catch(err){}
					try{this.prefix	  = cloneObj(that.prefix);  }catch(err){}
					try{this.suffix   = cloneObj(that.suffix);  }catch(err){}
					try{this.effect   = cloneObj(that.effect);  }catch(err){}
					if(this.enableItem) this.refreshIcon();
				}else{ //Perform only if the items are not to duplicate on movement
					if(that.stackable && this.exportItem() == that.exportItem()){ //If both items are the same type
						this.amount++;
						if(that.amount > 1)
							that.amount--;
						else
							that.trash();
					}else{ //If both items are diffirent; effectly becomes a swap
						if(this.type == ""){ //If moving to an empty slot
							this.transferItem(that.varName, true, forceall);
							that.trash();
						}else{
							MiddleVar = new ItemConstruct("", "any", "", "MiddleVar", false);
							MiddleVar.groupName = this.groupName;
							MiddleVar.transferItem(this.varName, true, forceall);
							this.transferItem(that.varName, true, forceall);
							that.transferItem(MiddleVar.varName, true, forceall);
							delete MiddleVar;
						}
					}
				}
				return true;
		}else
			this.disallow();
	}catch(err){this.error("e02");}
	return false;
}


ItemConstruct.prototype.importItem = function(rawImport, force){ with(this){
	var newImport = rawImport.split("/");
	if(typeof(force) == 'undefined') force = false;
	if(this.limit != "any" && (this.limit).search(newImport[0]) < 0 && !force){
		return -1;
	}
	switch(newImport[0]){
		case "armor":
			this.loadStatus = 1;
			var RAW_armorID = newImport[1];
			if(RAW_armorID.length > 2){
				var armorID  = RAW_armorID.substring(0,3);
				var prefixID = RAW_armorID.substring(3,5);
				var suffixID = RAW_armorID.substring(5,7);
			}else{
				var armorID  = "0"+RAW_armorID.substring(0,2);
				var prefixID = "00";
				var suffixID = "00";
			}
				if(prefixID == "") prefixID = "00";
				if(suffixID == "") suffixID = "00";
			if(typeof(newImport[2]) == "undefined")
					var enchantStr = 0;
			else	var enchantStr = newImport[2];
			var buildCall = "";
			if(!(armorID in Armor)){
				buildCall+="i0=armor/"+armorID+"&";
			}
			if(!(prefixID in Fix)){
				buildCall+="i1=fix/"+prefixID+"&";
			}
			if(!(suffixID in Fix)){
				buildCall+="i2=fix/"+suffixID;
			}
			if(buildCall != ""){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?"+buildCall, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			var newEnchant = new ArmorEnchantConstruct();
			with(newEnchant){
				if(enchantStr.length > 1){
					var e_add = "";
					for(i = 0 ; i < enchantStr.length ; i += 3){
						switch (enchantStr.charAt(i)){
							case "H": e_add = "energy";	 break;
							case "S": e_add = "shield";	 break;
							case "M": e_add = "mix";	 break;
							case "D": e_add = "defense"; break;
							case "E": e_add = "evasion"; break;
							default: continue;
						}
						eval(e_add+".normal.total = parseInt(enchantStr.charAt(i+1),36);");
						eval(e_add+".hyper.total  = parseInt(enchantStr.charAt(i+2),36);");
						eval(e_add+".total = "+e_add+".normal.total + "+e_add+".hyper.total;");
						eval("total += "+e_add+".total;");
					}
				}
			}
			this.type = "armor";
			this.item = Armor[armorID];
			this.prefix = Fix[prefixID];
			this.suffix = Fix[suffixID];
			this.enchants = newEnchant;
			break;
		//end case "armor"
		case "weapon":
			this.loadStatus = 1;
			var RAW_weaponID = newImport[1];
			if(RAW_weaponID.length > 2){
				var weaponID = RAW_weaponID.substring(0,2);
				var prefixID = RAW_weaponID.substring(2,4);
				var suffixID = RAW_weaponID.substring(4,6);
				var effectID = RAW_weaponID.substring(6,8);
			}else{
				var weaponID = RAW_weaponID.substring(0,2);
				var prefixID = "00";
				var suffixID = "00";
				var effectID = "00";
			}
			if(typeof(newImport[2]) == "undefined")
					var enchantStr = 0;
			else	var enchantStr = newImport[2];
			var buildCall = "";
			if(!(weaponID in Weapon)){
				buildCall+="i0=weapon/"+weaponID+"&";
			}
			if(!(prefixID in Fix)){
				buildCall+="i1=fix/"+prefixID+"&";
			}
			if(!(suffixID in Fix)){
				buildCall+="i2=fix/"+suffixID+"&";
			}
			if(!(effectID in Effect)){
				buildCall+="i3=effect/"+effectID;
			}
			if(buildCall != ""){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?"+buildCall, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			var newEnchant = new WeaponEnchantConstruct();
			with(newEnchant){
				if(enchantStr.length > 1){
					var e_add = "";
					for(i = 0 ; i < enchantStr.length ; i += 3){
						switch (enchantStr.charAt(i)){
							case "A": e_add = "attack";	break;
							case "P": e_add = "prob";	break;
							case "I": e_add = "pierce";	break;
							case "D": e_add = "dist";	break;
							case "R": e_add = "reatk";	break;
							case "H": e_add = "heat";	break;
							case "E": e_add = "radius";	break;
							case "W": e_add = "weight";	break;
							case "S": e_add = "speed";	break;
							default: continue;
						}
						eval(e_add+".normal.total = parseInt(enchantStr.charAt(i+1),36);");
						eval(e_add+".hyper.total  = parseInt(enchantStr.charAt(i+2),36);");
						eval(e_add+".total = "+e_add+".normal.total + "+e_add+".hyper.total;");
						eval("total += "+e_add+".total;");
					}
				}
			}
			
			this.type = "weapon";
			this.item = Weapon[weaponID];
			this.enchants = newEnchant;
			this.prefix = Fix[prefixID];
			this.suffix = Fix[suffixID];
			this.effect = Effect[effectID];
			break;
		//end case "weapon"
		case "fix":
			this.loadStatus = 1;
			var fixID = newImport[1];
			if(!(fixID in Fix)){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?i0=fix/"+fixID, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			this.type = "fix";
			this.item = Fix[fixID];
			break;
		//end case "fix"
		case "buff":
			this.loadStatus = 1;
			var buffID = newImport[1];
			if(!(buffID in Buff)){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?i0=buff/"+buffID, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			this.type = "buff";
			this.item = Buff[buffID];
			break;
		//end case "buff"
		case "charm":
			this.loadStatus = 1;
			var charmID = newImport[1];
			if(!(charmID in Charm)){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?i0=charm/"+charmID, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			this.type = "charm";
			this.item = Charm[charmID];
			break;
		//end case "charm"
		case "cpu":
			this.loadStatus = 1;
			var cpuID = newImport[1];
			if(!(cpuID in CPU)){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?i0=cpu/"+cpuID, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			this.type = "cpu";
			this.item = CPU[cpuID];
			break;
		//end case "cpu"
		case "creator":
			this.loadStatus = 1;
			var creatorID = newImport[1];
			if(!(creatorID in CreatorItem)){
				if(this.enableItem) document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
				ajaxCall("/scripts/importItemClass.scripts.php?i0=creator/"+creatorID, "JS", this.varName+".importItem('"+rawImport+"', "+force+");");
				return 0;
			}
			this.item		= CreatorItem[creatorID];
			this.type		= "creator";
			this.stackable	= this.item.stackable;
			this.consumable	= this.item.consumable;
			break;
		//end case "cpu"
		default: this.error("e01"); return -1;
	}
	this.amount = 1;
	try{this.refreshIcon();}catch(err){}
	this.loadStatus = 2;
	return 1;
}}

ItemConstruct.prototype.exportItem = function(){ with(this){
	retStr = this.encodeType() + "/" + this.encodeItem();
	switch(this.type){
		case "armor":
		case "weapon":
			retStr += "/" + this.encodeEnchants();
			break;
		default:
	}
	return retStr;
	
}}

ItemConstruct.prototype.encodeType = function(){ with(this){
	if(loaded() == false) return "ERROR";
	if(typeof(item) == 'undefined') return "ERROR";
	switch(this.type.toLowerCase()){
		case "support":
		case "enchant":
		case "gamble":
		case "capsule":
			return "creator";
		default: return this.type.toLowerCase();
	}
}}

ItemConstruct.prototype.encodeItem = function(){ with(this){
	if(loaded() == false) return 0;
	if(typeof(item) == 'undefined') return 0;
	var retStr = "";
	switch(this.type.toLowerCase()){
		case "armor":
			retStr  = item.id;
			retStr += (prefix.id!==undefined)?prefix.id:"00";
			retStr += (suffix.id!==undefined)?suffix.id:"00";
			return retStr;
		//end case "armor"
		case "weapon":
			retStr  = item.id;
			retStr += (prefix.id!==undefined)?prefix.id:"00";
			retStr += (suffix.id!==undefined)?suffix.id:"00";
			retStr += (effect.id!==undefined)?effect.id:"00";
			return retStr;
		//end case "weapon"
		default: retStr = item.id;
	}
	retStr = retStr.toUpperCase();
	return retStr;
}}

ItemConstruct.prototype.encodeEnchants = function(){ with(this){
	if(typeof(enchants) == 'undefined') return 0;
	switch(this.type.toLowerCase()){
		case "armor":
			var enchtarray = ["energy", "shield", "mix", "defense", "evasion"];
		break;
		case "weapon":
			var enchtarray = ["attack", "prob", "pierce", "dist", "reatk", "heat", "radius", "weight", "speed"];
		break;
		default: return 0;
	}
	
	if(enchants.total == 0) return 0;
	try{
		durl = "";
		for(var i = 0; i < enchtarray.length; i++){
			eval( "with(enchants."+enchtarray[i]+"){ if (normal.total > 0 || hyper.total > 0)"
				+ "durl += id + (normal.total).toString(36) + (hyper.total).toString(36); }"); }
		
		if (durl.length <= 1) durl += "0";
	}catch(err){ alert("Unable to encode enchant string."); return 0; }
	
	return durl;
	
}}

ItemConstruct.prototype.refreshIcon = function(){ with(this){
	if(!enableItem) return;
	
	if(typeof(this.item) == 'undefined' || typeof(item.minipicture) == 'undefined'){
		document.getElementById(this.div).style.backgroundImage = "url(/pics/item_mini/empty.gif)";
	}else{
		document.getElementById(this.div).style.backgroundImage = "url("+ item.minipicture +")";
	}
	
}}

//Saves the specified transfer slot item to the server/session
ItemConstruct.prototype.exportTransfer = function(){ with(this){

	if(this.varName == originDiv) return;
	
	document.getElementById(this.div).style.backgroundImage = "url('/pics/loading.gif')";
	ajaxCall("/scripts/importTransfer.scripts.php?transID="+this.div+"&item="+this.exportItem(), "JS", this.varName+".refreshIcon();");
}}

ItemConstruct.prototype.trash = function(){ with(this){
	try{
		this.type = "";
		delete this.item;
		try{delete this.enchants;}catch(err){}
		try{delete this.prefix;	 }catch(err){}
		try{delete this.suffix;	 }catch(err){}
		try{delete this.effect;	 }catch(err){}
		this.active = false;
		this.amount = 0;
		this.stackable = false;
		this.consumable = false;
		this.loadStatus = 0;
		this.prevHoverID = "";
		this.prevHoverString = "";
		this.refreshIcon();
		return true;
	}catch(e){ return false; }
}}

ItemConstruct.prototype.displayName = function(withColor){ with(this){
	try{
		if(withColor === undefined) withColor = false;
		if(typeof(prefix) == "undefined")	thePrefix = "";
		else if(prefix.id == "00")			thePrefix = "";
		else if(withColor)					thePrefix = "<span class='fix'>" + prefix.name + " </span>";
		else								thePrefix = prefix.name + " ";
		if(typeof(suffix) == "undefined")	theSuffix = "";
		else if(suffix.id == "00")			theSuffix = "";
		else if(withColor)					theSuffix = "<span class='fix'> of " + suffix.name + " </span>";
		else								theSuffix = " of " + suffix.name;
		if(withColor){
		
			var returnString = thePrefix;
			//if (item.unique == "Boss")				returnString += "<span class='boss'>";
			//else if (item.unique == "Unique")		returnString += "<span class='unique'>";
			//else if (item.unique == "Legendary")	returnString += "<span class='legendary'>";
			//else if (enchants.total > 0)			returnString += "<span class='enchant'>";
			//else									
			returnString += "<span style='color: white;'>";
			returnString += item.name + "</span>" + theSuffix;
			return returnString;
		}else{
			return thePrefix + item.name + theSuffix;
		}
	}catch(err){return "ERR/name";}
}}

//Calculates DPS for a weapon. Only works with the weapon class.
ItemConstruct.prototype.dmg = function(posi, wpnType, enableExtra, enableBuffs){ with(this){
	if(this.type != "weapon") return;
	if(typeof(enableExtra)=='undefined') enableExtra = true;
	if(typeof(enableBuffs)=='undefined') enableBuffs = false;
	if(typeof(wpnType)=='undefined') wpnType = "standard";
	
	if(wpnType == "standard") wpnTypeS = "STD_";
	else if(wpnType == "advanced") wpnTypeS = "ADV_";
	else{ enableBuffs = false; wpnTypeS = "STD_"; }
	
	try{
		if(enableBuffs){
			if(posi == "min")
				baseAtk = item.atkmin * (((enchants.attack.value() + prefix.adv_atkmin + suffix.adv_atkmin + buffTotal(eval(wpnTypeS+"MINATK")))/100 + 1));
			if(posi == "max")
				baseAtk = item.atkmax * (((enchants.attack.value() + prefix.adv_atkmax + suffix.adv_atkmax + buffTotal(eval(wpnTypeS+"MAXATK")))/100 + 1));
			if(baseAtk < 1) baseAtk = 1;
			return baseAtk;
		}else{
			if(posi == "min")
				baseAtk = item.atkmin * (((enchants.attack.value() + prefix.adv_atkmin + suffix.adv_atkmin)/100 + 1));
			if(posi == "max")
				baseAtk = item.atkmax * (((enchants.attack.value() + prefix.adv_atkmax + suffix.adv_atkmax)/100 + 1));
			if(baseAtk < 1) baseAtk = 1;
			return baseAtk;
		}
	}catch(err){return 0;}
}}

//Calculates DPS for a weapon. Only works with the weapon class.
ItemConstruct.prototype.dps = function(posi, wpnType, enableExtra, enableBuffs){ with(this){
	if(this.type != "weapon") return;
	if(typeof(enableExtra)=='undefined') enableExtra = true;
	if(typeof(enableBuffs)=='undefined') enableBuffs = false;
	if(typeof(wpnType)=='undefined') wpnType = "standard";
	
	if(wpnType == "standard") wpnTypeS = "STD_";
	else if(wpnType == "advanced") wpnTypeS = "ADV_";
	else{ enableBuffs = false; wpnTypeS = "STD_"; }
	
	//try{
		baseAtk = this.dmg(posi, wpnType, enableExtra, enableBuffs);
		if(enableBuffs){
			return (baseAtk * (item.volley + buffTotal(eval(wpnTypeS+"VLY"))) * (item.volleynumber + buffTotal(eval(wpnTypeS+"NUM")))) / (item.reatk * -((enchants.reatk.value() + prefix.reatk + suffix.reatk + buffTotal(eval(wpnTypeS+"REATK")))/100 - 1));
		}else{
			return (baseAtk * item.volley * item.volleynumber) / (item.reatk * -((enchants.reatk.value() + prefix.reatk + suffix.reatk)/100 - 1));
		}
	//}catch(err){return 0;}
}}

//Creates a small sublet for a buff. Only works with the buff class.
ItemConstruct.prototype.buildBuff = function(modifyLevels){
	if(this.type != "buff") return "<div class='buff_item'>Not a buff item</div>";
	if(typeof(modifyLevels)=='undefined') modifyLevels = false;
	
	hvar =	"<div class='buff_item"+((this.active)?"_active":"")+"' id='"+this.div+"_item' onClick='try{toggleBuff(this, "+this.varName+");}catch(err){}'";
	if(modifyLevels) hvar += " onMouseOver='DivDisplay(\"Show\", \""+this.div+"_ld\"); DivDisplay(\"Show\", \""+this.div+"_lu\")' onMouseOut='DivDisplay(\"Hide\", \""+this.div+"_ld\"); DivDisplay(\"Hide\", \""+this.div+"_lu\")'";
	hvar +=		"><div class='buff_image' id='"+this.div+"' onClick='"+this.varName+".buildHover();' onMouseDown=\"itemMouseDown('"+this.varName+"');\" onMouseUp=\"itemMouseUp('"+this.varName+"');\" onmouseover='"+this.varName+".buildHover();' onmouseout='return nd();'></div>"
				+"<div class='buff_body'>"
					+"<div id='"+this.div+"_lvl' class='buff_level'>LV"+this.item.skilllevel+"</div>"
					+"<div id='"+this.div+"_name' class='buff_name'>"+this.item.name+"</div>"
				+"</div>"
				+"<div id='"+this.div+"_ld' class='buff_level_down' onClick='changeBuffLevel("+this.varName+", -1);' onMouseOver='eAct = false;' onMouseOut='eAct = true;'></div>"
				+"<div id='"+this.div+"_lu' class='buff_level_up'   onClick='changeBuffLevel("+this.varName+",  1);' onMouseOver='eAct = false;' onMouseOut='eAct = true;'></div>"
			+"</div>";
	return hvar;
}

ItemConstruct.prototype.buildCharm = function(){
	hvar = 	"<div id='"+this.div+"' class='charm_item' onClick='try{toggleCharm(this, "+this.varName+");}catch(err){} "+this.varName+".buildHover();' onMouseDown=\"itemMouseDown('"+this.varName+"');\" onMouseUp=\"itemMouseUp('"+this.varName+"');\" onmouseover='"+this.varName+".buildHover();' onmouseout='return nd();'>"
				+"<img class='charm_image' src='"+this.item.minipicture+"'></img>"
				+"<div class='charm_body'>"
					+"<div class='charm_name'>"+this.item.name+"</div>"
				+"</div>"
			+"</div>";
	return hvar;
}

ItemConstruct.prototype.disallow = function(){ with(this){
	if(!this.enableItem) return;
	
	document.getElementById(this.div).style.backgroundImage = "url('/pics/item_mini/invalid_transfer.gif')";
	
	setTimeout(this.varName+".refreshIcon()", 1000);
	return;
}}

ItemConstruct.prototype.error = function(eCode){ with(this){
	if(!this.enableItem) return;
	
	document.getElementById(this.div).style.backgroundImage = "url('/pics/item_mini/error_transfer.gif')";
	setTimeout(this.varName+".refreshIcon();", 1500);
	return;
}}
////////////////////////////////////////////////////////////////////////////////////////////////
///////End Item Construct functions/////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////



//Creates a clone of an object. Extends from the base object class.
//Function written by Brian Huisman (http://my.opera.com/GreyWyvern/blog/show.dml/1725165)
//  Modified to use a function call instead of object prototype overload.
function cloneObj(o) {
	var newObj = (o instanceof Array) ? [] : {};
	for (i in o) {
		if (i == 'clone') continue;
		if (o[i] && typeof o[i] == "object") {
			newObj[i] = cloneObj(o[i]);
		} else newObj[i] = o[i]
	} return newObj;
};

function itemMouseDown(thisDiv){
	originDiv = thisDiv;
	try{nd();}catch(err){};
}

function itemMouseUp(thisDiv){
	try{
		thisDiv = eval(thisDiv);
		if(!thisDiv.transferItem(originDiv)) return false;
		thisDiv.buildHover();
		return true;
	}catch(err){alert("Unable to move item. Error in item mousedown operation."); return false;}
}

newArmor("", "000", "", 0, "", "empty.gif", "", "", "", 0, 0, "", 0, "", "", "", 0, 0, "", "", "", new FunctConstruct(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
newWeapon("", "00", "", 1, "", "empty.gif", "", "Normal", "", "", "", 0, 0, 0, 0, 0, 0, 0.00, 0, 0, 0, 0, 0, 0, 0, "", 0, 0);
newFix("", "00", "Weapon", "Both", 1, 1, "N/A", "All", 0, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
newEffect("Standard Effect", "00");
newBuff("00", "", 0, 0, "ABIM", 0, 0, 0, "", "empty.gif", "00", "00");
newCharm("00", "", "", "ABIM", 0, 0, "", "empty.gif");
newCPU("", "00", "", "", "", "empty.gif", 0, 0, 0, 0, 0, 0, 0, 0, 0, "");
newCreatorItem("00", "", "", "", "", false, false, "", "empty.gif", 0, "", 0, "", "", "", "", "", "");
