
<!-- Current Resources Script -->
// define a few variables that are required
var vbmenu_usepopups = false;

// #############################################################################
// lets define the browser we have instead of multiple calls throughout the file
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = (navigator.product == 'Gecko');
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

// catch possible bugs with WebTV and other older browsers
var is_regexp = (window.RegExp) ? true : false;

// #############################################################################
// let's find out what DOM functions we can use
var vbDOMtype = '';
if (document.getElementById)
{
	// yay, a decent brower!
	vbDOMtype = "std";
}
else if (document.all)
{
	// mmm... probably IE4... ugh
	vbDOMtype = "ie4";
}
else if (document.layers)
{
	// eeew Netscape 4 - run away very fast!
	vbDOMtype = "ns4";
}

// make an array to store cached locations of objects called by fetch_object
var vBobjects = new Array();

// #############################################################################
// function to emulate document.getElementById
function fetch_object(idname, forcefetch)
{
	if (forcefetch || typeof(vBobjects[idname]) == "undefined")
	{
		switch (vbDOMtype)
		{
			case "std":
			{
				vBobjects[idname] = document.getElementById(idname);
			}
			break;
			
			case "ie4":
			{
				vBobjects[idname] = document.all[idname];
			}
			break;
			
			case "ns4":
			{
				vBobjects[idname] = document.layers[idname];
			}
			break;
		}
	}
	
	return vBobjects[idname];
}

// #############################################################################
// function to set a cookie
function set_cookie(name, value, expires)
{
	if (!expires)
	{
		expires = new Date();
	}
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

// #############################################################################
// function to retrieve a cookie
function fetch_cookie(name)
{
	cookie_name = name + "=";
	cookie_length = document.cookie.length;
	cookie_begin = 0;
	while (cookie_begin < cookie_length)
	{
		value_begin = cookie_begin + cookie_name.length;
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
		{
			var value_end = document.cookie.indexOf (";", value_begin);
			if (value_end == -1)
			{
				value_end = cookie_length;
			}
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
		if (cookie_begin == 0)
		{
			break;
		}
	}
	return null;
}

// #############################################################################
// function to toggle the collapse state of an object, and save to a cookie
function toggle_collapse(objid)
{
	obj = fetch_object("div_" + objid);
	btn = fetch_object("btn_" + objid);
	
	if (obj.style.display == "none")
	{
		obj.style.display = "";
		btn.innerHTML = "_";
		save_collapsed(objid, false);
	}
	else
	{
		obj.style.display = "none";
		btn.innerHTML = "+";
		save_collapsed(objid, true);
	}
	
	return false;
}

// #############################################################################
// function to collapse all divs
function collapse_all()
{
	
	if(document.getElementsByTagName) {
		divs = document.getElementsByTagName("div");
		for (var i = 0; i < divs.length; i++) {
			if(divs[i].id.substring(0,6) == "div_cr") 
			{
				btn = fetch_object("btn_" + divs[i].id.substring(4));
				divs[i].style.display = "none";
				btn.innerHTML = "+";
				save_collapsed(divs[i].id.substring(4), true);
			}
		}
	}

	return false;
}

// #############################################################################
// function to expand all divs
function expand_all()
{
	
	if(document.getElementsByTagName) {
		divs = document.getElementsByTagName("div");
		for (var i = 0; i < divs.length; i++) {
			if(divs[i].id.substring(0,6) == "div_cr") 
			{
				btn = fetch_object("btn_" + divs[i].id.substring(4));
				divs[i].style.display = "";
				btn.innerHTML = "_";
				save_collapsed(divs[i].id.substring(4), false);
			}
		}
	}

	return false;
}

// #############################################################################
// update vbulletin_collapse cookie with collapse preferences
function save_collapsed(objid, addcollapsed)
{
	var collapsed = fetch_cookie("swgemu_craft_collapse");		
	var tmp = new Array();
	
	if (collapsed != null)
	{
		collapsed = collapsed.split("\n");
		
		for (i in collapsed)
		{
			if (collapsed[i] != objid && collapsed[i] != "")
			{
				tmp[tmp.length] = collapsed[i];
			}
		}
	}

	if (addcollapsed)
	{
		tmp[tmp.length] = objid;
	}
	
	expires = new Date();
	expires.setTime(expires.getTime() + (1000 * 86400 * 365));
	set_cookie("swgemu_craft_collapse", tmp.join("\n"), expires);
}
<!-- End Current Resources Script -->


<!-- Prof Tree Script -->
var dofade=false;       // ENABLES FADE-IN EFFECT (FOR IE4+ AND NS6 ONLY)

var centertext=false;  // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA "STYLE" BECAUSE OF NS4.
                       // OTHERWISE, TEXT IS LEFT-JUSTIFIED.

var xoffset=-500;         // HORIZONTAL PIXEL COUNT FROM CURSOR

var yoffset=-200;        // VERTICAL PIXEL COUNT FROM CURSOR

var mousefollow=false; // ENABLES MOUSE FOLLOW MODE WHERE THE BOX CONTINUES TO FOLLOW THE MOUSE. SET TO false TO
                       // LOCK THE BOX WHEREVER IT INITIALLY APPEARS.

var hideDelay=300;     // DELAY IN MILLISECONDS ( 1 SECOND = 1000 MILLISECONDS) FROM WHEN YOU HOVER OUT OF LINK
                       // AND THE BOX DISAPPEARS ONLY WHEN "mousefollow" IS SET TO "false".
                       // THIS WILL GIVE THE USER TIME TO CLICK A LINK OR WHATEVER IN THE BOX BEFORE IT DISAPPEARS.

////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////

function altProps(){
this.w3c=(document.getElementById)?true:false;
this.ns4=(document.layers)?true:false;
this.ie4=(document.all && !this.w3c)?true:false;
this.ie5=(document.all && this.w3c)?true:false;
this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;
this.w_y=0;
this.w_x=0;
this.navtxt=null;
this.boxheight=0;
this.boxwidth=0;
this.ishover=false;
this.ieop=0;
this.op_id=0;
this.oktomove=false;
this.dy=0;
}

var AT=new altProps();

function toggle_centertext(){
centertext=!centertext;
}

function toggle_mousefollow(){
mousefollow=!mousefollow;
}

function toggle_dofade(){
dofade=!dofade;
if(!dofade)AT.ieop=100;
}


function getwindowdims(){
AT.w_y=(AT.ie5||AT.ie4)?document.body.clientHeight:window.innerHeight;
AT.w_x=(AT.ie5||AT.ie4)?document.body.clientWidth:window.innerWidth;
}

function getboxwidth(){
if(AT.ns4)AT.boxwidth=(AT.navtxt.document.width)? AT.navtxt.document.width : AT.navtxt.clip.width;
else if(AT.ie4)AT.boxwidth=(AT.navtxt.style.pixelWidth)? AT.navtxt.style.pixelWidth : AT.navtxt.offsetWidth;
else AT.boxwidth=(AT.navtxt.style.width)? parseInt(AT.navtxt.style.width) : parseInt(AT.navtxt.offsetWidth);
}

function getboxheight(){
if(AT.ns4)AT.boxheight=(AT.navtxt.document.height)? AT.navtxt.document.height : AT.navtxt.clip.height;
else if(AT.ie4)AT.boxheight=(AT.navtxt.style.pixelHeight)? AT.navtxt.style.pixelHeight : AT.navtxt.offsetHeight;
else AT.boxheight=parseInt(AT.navtxt.offsetHeight);
}

function movenavtxt(x,y){
if(AT.ns4)AT.navtxt.moveTo(x,y);
else{
AT.navtxt.style.left=x+'px';
AT.navtxt.style.top=y+'px';
}}

function getpagescrolly(){
if(AT.ie5||AT.ie4)return document.body.scrollTop;
else return window.pageYOffset;
}

function getpagescrollx(){
if(AT.ie5||AT.ie4)return document.body.scrollLeft;
else return window.pageXOffset;
}

function writeindiv(text){
if(AT.ns4){
AT.navtxt.document.open();
AT.navtxt.document.write(text);
AT.navtxt.document.close();
}
else AT.navtxt.innerHTML=text;
}

function writetxt(text){
if(dofade && (AT.ie4||AT.w3c))clearInterval(AT.op_id);
if(text!=0){
if(!mousefollow)clearTimeout(AT.dy);
AT.oktomove=true;
AT.ishover=true;
if(AT.ns4)text='<div class="navtext">'+((centertext)?'<center>':'')+text+((centertext)?'</center>':'')+'</div>';
if(AT.w3c||AT.ie4)AT.navtxt.style.textAlign=(centertext)?"center":"left";
writeindiv(text);
if(AT.ns4)AT.navtxt.visibility="show";
else{
AT.navtxt.style.visibility="visible";
AT.navtxt.style.display="block";
}
getboxheight();
if((AT.w3c||AT.ie4) && dofade){
if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity=0)";
if(AT.ns6)AT.navtxt.style.MozOpacity=0;
AT.ieop=0;
AT.op_id=setInterval('incropacity()',50);
}}else{
if(mousefollow)hideAlttxt();
else AT.dy=setTimeout('hideAlttxt()',hideDelay);
}}

function hideAlttxt(){
if(AT.ns4)AT.navtxt.visibility="hide";
else{
AT.navtxt.style.display="none";
AT.navtxt.style.visibility="hidden";
}
movenavtxt(-AT.boxwidth-10,0);
writeindiv('');
}

function incropacity(){
if(AT.ieop<=100){
AT.ieop+=7;
if(AT.ie4||AT.ie5)AT.navtxt.style.filter="alpha(opacity="+AT.ieop+")";
if(AT.ns6)AT.navtxt.style.MozOpacity=AT.ieop/100;
}else clearInterval(AT.op_id);
}

function moveobj(evt){
mx=(AT.ie5||AT.ie4)?event.clientX:evt.pageX;
my=(AT.ie5||AT.ie4)?event.clientY:evt.pageY;
if(AT.ishover && AT.oktomove){
margin=(AT.ie4||AT.ie5)?5:25;
if(AT.ns6)if(document.height+27-window.innerHeight<0)margin=15;
if(AT.ns4)if(document.height-window.innerHeight<0)margin=10;
if(AT.ns4||AT.ns6)mx-=getpagescrollx();
if(AT.ns4)my-=getpagescrolly();
xoff=mx+xoffset;
yoff=(my+AT.boxheight+yoffset-((AT.ns6)?getpagescrolly():0)>=AT.w_y)? -5-AT.boxheight-yoffset: yoffset;
movenavtxt( Math.min(AT.w_x-AT.boxwidth-margin , Math.max(2,xoff))+getpagescrollx(), my+yoff+((!AT.ns6)?getpagescrolly():0));
if(!mousefollow)AT.oktomove=false;
}}


window.onload=function(){
  AT.navtxt=(AT.ns4)?document.layers['navtxt']:(AT.ie4)?document.all['navtxt']:(AT.w3c)?document.getElementById('navtxt'):null;
  getboxwidth();
  getboxheight();
  getwindowdims();
  if(AT.ie4||AT.ie5&&dofade)AT.navtxt.style.filter="alpha(opacity=100)";
  AT.navtxt.onmouseover=function(){
  if(!mousefollow)clearTimeout(AT.dy);
  }
  AT.navtxt.onmouseout=function(){
  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);
  }
  if(AT.ns4)document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=moveobj;
  window.onresize=getwindowdims;
}
<!-- End Prof Tree Script -->


<!-- Make Lower Case -->
function lower(ustr)
{
	var str=ustr.value;
	ustr.value=str.toLowerCase();
}
<!-- End Make Lower Case -->


<!-- Add Resources 2 -->
function handleControls(control, count) {

	var resType = eval("document.res." + control + ".value");
	var resSubType = resType.substr(resType.length - 3, 3);

	switch(resSubType) {
<!-- gemstones -->
		case "cry": case "amo": case "gst":
			eval("setControl(document.res." + "cr" + count + ", false);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", false);");
			eval("setControl(document.res." + "ma" + count + ", false);");
			eval("setControl(document.res." + "pe" + count + ", true);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", false);");
			eval("setControl(document.res." + "ut" + count + ", false);");
			eval("setControl(document.res." + "er" + count + ", false);");
			break;
<!-- ores -->
		case "sil": case "crb": case "uns": case "ext": case "int": case "uni":
			eval("setControl(document.res." + "cr" + count + ", false);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", false);");
			eval("setControl(document.res." + "ma" + count + ", false);");
			eval("setControl(document.res." + "pe" + count + ", true);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", false);");
			eval("setControl(document.res." + "ut" + count + ", false);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
<!-- metals -->
		case "cpr": case "alu": case "nfr": case "stl": case "irn": case "fer":
			eval("setControl(document.res." + "cr" + count + ", false);");
			eval("setControl(document.res." + "cd" + count + ", false);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", false);");
			eval("setControl(document.res." + "ma" + count + ", false);");
			eval("setControl(document.res." + "pe" + count + ", true);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", false);");
			eval("setControl(document.res." + "ut" + count + ", false);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
<!-- known radioactive, unknown radioactive, known solid petrofuel, unknown solid petrofuel, known liquid petrofuel, unknown liquid petrofuel -->
		case "krd": case "urd": case "ksp": case "usp": case "kpf": case "upf":
			eval("setControl(document.res." + "cr" + count + ", true);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", true);");
			eval("setControl(document.res." + "ma" + count + ", true);");
			eval("setControl(document.res." + "pe" + count + ", false);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", true);");
			eval("setControl(document.res." + "ut" + count + ", true);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
<!-- lubricating oil, reactive gas, inert gas, water -->
		case "lub": case "krt": case "ktv": case "wtr":
			eval("setControl(document.res." + "cr" + count + ", true);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", true);");
			eval("setControl(document.res." + "ma" + count + ", true);");
			eval("setControl(document.res." + "pe" + count + ", true);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", true);");
			eval("setControl(document.res." + "ut" + count + ", true);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
<!-- polymer, fiberplast, evergreen wood, conifer wood, deciduos wood, animal bone, avian bone, bristely hide, leathery hide, scaley hide, wooly hide, horn -->
		case "pol": case "fib": case "ewd": case "cwd": case "dwd": case "abn": case "vbn": case "bhd": case "lhd": case "shd": case "whd": case "hrn":
			eval("setControl(document.res." + "cr" + count + ", true);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", true);");
			eval("setControl(document.res." + "ma" + count + ", false);");
			eval("setControl(document.res." + "pe" + count + ", true);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", false);");
			eval("setControl(document.res." + "ut" + count + ", false);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
<!-- flower fruit, berry fruit, fruit, fungus, tubers, beans, greens, wild wheat, domestic wheat, wild oats, domestic oats, wild rice, domestic rice, wild corn, domestic corn, carnivore meat, insect meat, domestic meat, herbivore meat, wild meat, fish meat, avian meat, reptile meat, mollusk meat, ?, egg, domestic milk, wild milk -->
		case "flr": case "ber": case "fts": case "fgs": case "tub": case "bns": case "grn": case "wwt": case "dwt": case "wot": case "dot": case "wrc": case "drc": case "wcn": case "dcn": case "cmt": case "imt": case "dmt": case "hmt": case "wmt": case "fmt": case "amt": case "rmt": case "mmt": case "tmt": case "egg": case "dmk": case "wmk":
			eval("setControl(document.res." + "cr" + count + ", true);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", false);");
			eval("setControl(document.res." + "hr" + count + ", true);");
			eval("setControl(document.res." + "ma" + count + ", true);");
			eval("setControl(document.res." + "pe" + count + ", false);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", true);");
			eval("setControl(document.res." + "ut" + count + ", true);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
<!-- wind energy, solar energy, geotherm energy -->
		case "weg": case "seg": case "geo":
			eval("setControl(document.res." + "cr" + count + ", true);");
			eval("setControl(document.res." + "cd" + count + ", true);");
			eval("setControl(document.res." + "dr" + count + ", true);");
			eval("setControl(document.res." + "fl" + count + ", true);");
			eval("setControl(document.res." + "hr" + count + ", true);");
			eval("setControl(document.res." + "ma" + count + ", true);");
			eval("setControl(document.res." + "pe" + count + ", false);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", true);");
			eval("setControl(document.res." + "ut" + count + ", true);");
			eval("setControl(document.res." + "er" + count + ", true);");
			break;
		default:
			eval("setControl(document.res." + "cr" + count + ", false);");
			eval("setControl(document.res." + "cd" + count + ", false);");
			eval("setControl(document.res." + "dr" + count + ", false);");
			eval("setControl(document.res." + "fl" + count + ", false);");
			eval("setControl(document.res." + "hr" + count + ", false);");
			eval("setControl(document.res." + "ma" + count + ", false);");
			eval("setControl(document.res." + "pe" + count + ", false);");
			eval("setControl(document.res." + "oq" + count + ", false);");
			eval("setControl(document.res." + "sr" + count + ", false);");
			eval("setControl(document.res." + "ut" + count + ", false);");
			eval("setControl(document.res." + "er" + count + ", false);");
			break;
	}
}

function setControl(control, disable) {

	control.disabled = disable; 
	control.readonly = disable;
	if(document.all || document.getElementById) {
		if(disable) {
			control.style.background  = '#555555';
			control.value = '0'; 
		} else {
			control.style.background  = '#cccccc';
			control.value = '';
		}
	}
}
<!-- End Add Resources 2 -->


<!-- Creature Calc -->
var HILIGHTCOL = '#cccccc';

function ResourceType(restype)
{
	HerbMeatDESC = document.getElementById('herbmeatdesc').style;
	HerbMeatROW = document.getElementById('herbmeatrow').style;
	OtherMeatDESC = document.getElementById('othermeatdesc').style;
	OtherMeatROW = document.getElementById('othermeatrow').style;
	HideBoneDESC = document.getElementById('hidebonedesc').style;
	HideBoneROW = document.getElementById('hidebonerow').style;
	if (restype == 'herbmeat')
	{
		document.basequal.qualmod.value = 1;
		HerbMeatDESC.backgroundColor=HILIGHTCOL;
		HerbMeatROW.backgroundColor=HILIGHTCOL;
		OtherMeatDESC.backgroundColor='';
		OtherMeatROW.backgroundColor='';
		HideBoneDESC.backgroundColor='';
		HideBoneROW.backgroundColor='';
		document.getElementById('PE_herb').disabled = "";
		document.getElementById('OQ_herb').disabled = "";
		document.getElementById('OQ_herb').disabled = "";
		document.getElementById('FL_meat').disabled = "disabled";
		document.getElementById('PE_meat').disabled = "disabled";
		document.getElementById('OQ_meat').disabled = "disabled";
		document.getElementById('BQ_meat').disabled = "disabled";
		document.getElementById('MA_hide').disabled = "disabled";
		document.getElementById('OQ_hide').disabled = "disabled";
		document.getElementById('SR_hide').disabled = "disabled";
		document.getElementById('UT_hide').disabled = "disabled";
		document.getElementById('BQ_hide').disabled = "disabled";
	}
	if (restype == 'othermeat')
	{
		document.basequal.qualmod.value = 1.25;
		HerbMeatDESC.backgroundColor='';
		HerbMeatROW.backgroundColor='';
		OtherMeatDESC.backgroundColor=HILIGHTCOL;
		OtherMeatROW.backgroundColor=HILIGHTCOL;
		HideBoneDESC.backgroundColor='';
		HideBoneROW.backgroundColor='';
		document.getElementById('PE_herb').disabled = "disabled";
		document.getElementById('OQ_herb').disabled = "disabled";
		document.getElementById('BQ_herb').disabled = "disabled";
		document.getElementById('FL_meat').disabled = "";
		document.getElementById('PE_meat').disabled = "";
		document.getElementById('OQ_meat').disabled = "";
		document.getElementById('BQ_meat').disabled = "";
		document.getElementById('MA_hide').disabled = "disabled";
		document.getElementById('OQ_hide').disabled = "disabled";
		document.getElementById('SR_hide').disabled = "disabled";
		document.getElementById('UT_hide').disabled = "disabled";
		document.getElementById('BQ_hide').disabled = "disabled";
	}
	if (restype == 'hidebone')
	{
		document.basequal.qualmod.value = 1.5;
		HerbMeatDESC.backgroundColor='';
		HerbMeatROW.backgroundColor='';
		OtherMeatDESC.backgroundColor='';
		OtherMeatROW.backgroundColor='';
		HideBoneDESC.backgroundColor=HILIGHTCOL;
		HideBoneROW.backgroundColor=HILIGHTCOL;
		document.getElementById('PE_herb').disabled = "disabled";
		document.getElementById('OQ_herb').disabled = "disabled";
		document.getElementById('BQ_herb').disabled = "disabled";
		document.getElementById('FL_meat').disabled = "disabled";
		document.getElementById('PE_meat').disabled = "disabled";
		document.getElementById('OQ_meat').disabled = "disabled";
		document.getElementById('BQ_meat').disabled = "disabled";
		document.getElementById('MA_hide').disabled = "";
		document.getElementById('OQ_hide').disabled = "";
		document.getElementById('SR_hide').disabled = "";
		document.getElementById('UT_hide').disabled = "";
		document.getElementById('BQ_hide').disabled = "";
	}
	if (restype == 'reset')
	{
		HerbMeatDESC.backgroundColor='';
		HerbMeatROW.backgroundColor='';
		OtherMeatDESC.backgroundColor='';
		OtherMeatROW.backgroundColor='';
		HideBoneDESC.backgroundColor='';
		HideBoneROW.backgroundColor='';
		document.getElementById('PE_herb').disabled = "";
		document.getElementById('OQ_herb').disabled = "";
		document.getElementById('BQ_herb').disabled = "";
		document.getElementById('FL_meat').disabled = "";
		document.getElementById('PE_meat').disabled = "";
		document.getElementById('OQ_meat').disabled = "";
		document.getElementById('BQ_meat').disabled = "";
		document.getElementById('MA_hide').disabled = "";
		document.getElementById('OQ_hide').disabled = "";
		document.getElementById('SR_hide').disabled = "";
		document.getElementById('UT_hide').disabled = "";
		document.getElementById('BQ_hide').disabled = "";
	}
}

function basetotals()
{
	var OQ_HERB = document.basequal.OQ_herb.value * 1;
	var PE_HERB = document.basequal.PE_herb.value * 1;
	
	var OQ_MEAT = document.basequal.OQ_meat.value * 1;
	var PE_MEAT = document.basequal.PE_meat.value * 1;
	var FL_MEAT = document.basequal.FL_meat.value * 1;
	
	var OQ_HIDE = document.basequal.OQ_hide.value * 1;
	var MA_HIDE = document.basequal.MA_hide.value * 1;
	var SR_HIDE = document.basequal.SR_hide.value * 1;
	var UT_HIDE = document.basequal.UT_hide.value * 1;

	var BQ_HERB = ((OQ_HERB * 2) + PE_HERB)/3;
	var BQ_MEAT = (OQ_MEAT + PE_MEAT + FL_MEAT)/3;
	var BQ_HIDE = ((OQ_HIDE * 7) + (MA_HIDE *3) + (SR_HIDE * 3) + UT_HIDE)/14;

	document.basequal.BQ_herb.value = BQ_HERB;
	document.basequal.BQ_meat.value = BQ_MEAT;
	document.basequal.BQ_hide.value = BQ_HIDE;

	averagequality(BQ_HERB,BQ_MEAT,BQ_HIDE);
}

function averagequality(qualherb,qualmeat,qualhide)
{
	var AVGQUAL = document.basequal.avgqual.value = Math.round( (qualherb + qualmeat + qualhide) *100)/100;	// Math.round(x/100)/100 = round to decimal places
	qualityrange(AVGQUAL);
}

function qualityrange(AVGQUAL)
{
	var QUALMOD = document.basequal.qualmod.value * 1;
	var QUANTITY = document.basequal.quantity.value * 1;
	
	// All CPU values rounded to 2 dp, to stop it all getting crazy
	var CPUPOO = document.basequal.cpupoo.value = 5;
	var CPUMED = document.basequal.cpumed.value = Math.round( ((AVGQUAL-200)/60) *100)/100;	// original before rounding = (AVGQUAL-200)/60
	var CPUHI = document.basequal.cpuhi.value = Math.round( ((AVGQUAL-700)/10) *100)/100;	// original before rounding = (AVGQUAL-700)/10
	var CPUEX = document.basequal.cpuex.value = Math.round( (((3 * AVGQUAL)-2500)/10) *100)/100;	// original before rounding = ((3 * AVGQUAL)-2500)/10
	
	// All totals rounded to no dp, cos who sells for a fraction of a credit??
	document.basequal.totpoo.value = CPUPOO * QUANTITY;
	document.basequal.totmed.value = Math.round( CPUMED * QUANTITY);
	document.basequal.tothi.value = Math.round( (AVGQUAL-700)/10  * QUANTITY);
	document.basequal.totex.value = Math.round( ((3 * AVGQUAL)-2500)/10 * QUANTITY);
	
	var CPUMODPOO = document.basequal.cpumodpoo.value = Math.round( (CPUPOO * QUALMOD) *100)/100;
	var CPUMODMED = document.basequal.cpumodmed.value = Math.round( ((AVGQUAL-200)/60 * QUALMOD) *100)/100;	// original before rounding = (AVGQUAL-200)/60 * QUALMOD
	var CPUMODHI = document.basequal.cpumodhi.value = Math.round( ((AVGQUAL-700)/10 * QUALMOD) *100)/100;	// original before rounding = (AVGQUAL-700)/10 * QUALMOD
	var CPUMODEX = document.basequal.cpumodex.value = Math.round( (((3 * AVGQUAL)-2500)/10 * QUALMOD) *100)/100;	// original before rounding = ((3 * AVGQUAL)-2500)/10 * QUALMOD
	
	document.basequal.totmodpoo.value = Math.round( CPUPOO * QUALMOD * QUANTITY);
	document.basequal.totmodmed.value = Math.round( (AVGQUAL-200)/60 * QUALMOD * QUANTITY);
	document.basequal.totmodhi.value = Math.round( (AVGQUAL-700)/10 * QUALMOD * QUANTITY);
	document.basequal.totmodex.value = Math.round( ((3 * AVGQUAL)-2500)/10 * QUALMOD * QUANTITY);
	priceshilite(AVGQUAL)
}

function qualmod()
{
	return 1;
}

function priceshilite(AVGQUAL)
{
	CpuPooCEL = document.getElementById('cpupoocel').style;
	CpuMedCEL = document.getElementById('cpumedcel').style;
	CpuHiCEL = document.getElementById('cpuhicel').style;
	CpuExCEL = document.getElementById('cpuexcel').style;
	
	TotPooCEL = document.getElementById('totpoocel').style;
	TotMedCEL = document.getElementById('totmedcel').style;
	TotHiCEL = document.getElementById('tothicel').style;
	TotExCEL = document.getElementById('totexcel').style;

	CpuModPooCEL = document.getElementById('cpumodpoocel').style;
	CpuModMedCEL = document.getElementById('cpumodmedcel').style;
	CpuModHiCEL = document.getElementById('cpumodhicel').style;
	CpuModExCEL = document.getElementById('cpumodexcel').style;
	
	TotModPooCEL = document.getElementById('totmodpoocel').style;
	TotModMedCEL = document.getElementById('totmodmedcel').style;
	TotModHiCEL = document.getElementById('totmodhicel').style;
	TotModExCEL = document.getElementById('totmodexcel').style;
	var QUALMOD;
	
	if (qualmod() == 1)
	{
		QUALMOD = 1;
	}
	else
	{
		QUALMOD = 0;
	}
	
	if (AVGQUAL < 500)
	{
		CpuPooCEL.backgroundColor=HILIGHTCOL;
		TotPooCEL.backgroundColor=HILIGHTCOL;
		CpuMedCEL.backgroundColor='';
		TotMedCEL.backgroundColor='';
		CpuHiCEL.backgroundColor='';
		TotHiCEL.backgroundColor='';
		CpuExCEL.backgroundColor='';
		TotExCEL.backgroundColor='';
	}
	else if (AVGQUAL < 800)
	{
		CpuPooCEL.backgroundColor='';
		TotPooCEL.backgroundColor='';
		CpuMedCEL.backgroundColor=HILIGHTCOL;
		TotMedCEL.backgroundColor=HILIGHTCOL;
		CpuHiCEL.backgroundColor='';
		TotHiCEL.backgroundColor='';
		CpuExCEL.backgroundColor='';
		TotExCEL.backgroundColor='';
	}
	else if (AVGQUAL <900)
	{
		CpuPooCEL.backgroundColor='';
		TotPooCEL.backgroundColor='';
		CpuMedCEL.backgroundColor='';
		TotMedCEL.backgroundColor='';
		CpuHiCEL.backgroundColor=HILIGHTCOL;
		TotHiCEL.backgroundColor=HILIGHTCOL;
		CpuExCEL.backgroundColor='';
		TotExCEL.backgroundColor='';
	}
	else
	{
		CpuPooCEL.backgroundColor='';
		TotPooCEL.backgroundColor='';
		CpuMedCEL.backgroundColor='';
		TotMedCEL.backgroundColor='';
		CpuHiCEL.backgroundColor='';
		TotHiCEL.backgroundColor='';
		CpuExCEL.backgroundColor=HILIGHTCOL;
		TotExCEL.backgroundColor=HILIGHTCOL;
	}

	if ((AVGQUAL < 500) && QUALMOD)
	{
		CpuModPooCEL.backgroundColor=HILIGHTCOL;
		TotModPooCEL.backgroundColor=HILIGHTCOL;
		CpuModMedCEL.backgroundColor='';
		TotModMedCEL.backgroundColor='';
		CpuModHiCEL.backgroundColor='';
		TotModHiCEL.backgroundColor='';
		CpuModExCEL.backgroundColor='';
		TotModExCEL.backgroundColor='';
	}
	else if ((AVGQUAL < 800) && QUALMOD)
	{
		CpuModPooCEL.backgroundColor='';
		TotModPooCEL.backgroundColor='';
		CpuModMedCEL.backgroundColor=HILIGHTCOL;
		TotModMedCEL.backgroundColor=HILIGHTCOL;
		CpuModHiCEL.backgroundColor='';
		TotModHiCEL.backgroundColor='';
		CpuModExCEL.backgroundColor='';
		TotModExCEL.backgroundColor='';
	}
	else if ((AVGQUAL <900) && QUALMOD)
	{
		CpuModPooCEL.backgroundColor='';
		TotModPooCEL.backgroundColor='';
		CpuModMedCEL.backgroundColor='';
		TotModMedCEL.backgroundColor='';
		CpuModHiCEL.backgroundColor=HILIGHTCOL;
		TotModHiCEL.backgroundColor=HILIGHTCOL;
		CpuModExCEL.backgroundColor='';
		TotModExCEL.backgroundColor='';
	}
	else if (QUALMOD)
	{
		CpuModPooCEL.backgroundColor='';
		TotModPooCEL.backgroundColor='';
		CpuModMedCEL.backgroundColor='';
		TotModMedCEL.backgroundColor='';
		CpuModHiCEL.backgroundColor='';
		TotModHiCEL.backgroundColor='';
		CpuModExCEL.backgroundColor=HILIGHTCOL;
		TotModExCEL.backgroundColor=HILIGHTCOL;
	}
}

function ResetForm()
{
	ResourceType('reset');
	document.getElementById('cpupoocel').style.backgroundColor='';
	document.getElementById('cpumedcel').style.backgroundColor='';
	document.getElementById('cpuhicel').style.backgroundColor='';
	document.getElementById('cpuexcel').style.backgroundColor='';
	
	TotPooCEL = document.getElementById('totpoocel').style.backgroundColor='';
	TotMedCEL = document.getElementById('totmedcel').style.backgroundColor='';
	TotHiCEL = document.getElementById('tothicel').style.backgroundColor='';
	TotExCEL = document.getElementById('totexcel').style.backgroundColor='';

	CpuModPooCEL = document.getElementById('cpumodpoocel').style.backgroundColor='';
	CpuModMedCEL = document.getElementById('cpumodmedcel').style.backgroundColor='';
	CpuModHiCEL = document.getElementById('cpumodhicel').style.backgroundColor='';
	CpuModExCEL = document.getElementById('cpumodexcel').style.backgroundColor='';
	
	TotModPooCEL = document.getElementById('totmodpoocel').style.backgroundColor='';
	TotModMedCEL = document.getElementById('totmodmedcel').style.backgroundColor='';
	TotModHiCEL = document.getElementById('totmodhicel').style.backgroundColor='';
	TotModExCEL = document.getElementById('totmodexcel').style.backgroundColor='';
	
	location.href = 'crea_tool.php#top';
}
<!-- End Creature Calc -->


<!-- Factory Tool Script -->
var powerPerHour = [50,50,50]; 
var maintPerHour = [60,60,60]; 
var timePerComplexity = [8,8,8]; 
function initialize() { 
document.facForm.factory.focus(); 
doChangeFactory(); 
} 
function selectFactory() { 
document.facForm.timePerComplexity.value = timePerComplexity[document.facForm.factory.options[document.facForm.factory.selectedIndex].value]; 
document.facForm.maintPerHour.value = maintPerHour[document.facForm.factory.options[document.facForm.factory.selectedIndex].value]; 
document.facForm.powerPerHour.value = powerPerHour[document.facForm.factory.options[document.facForm.factory.selectedIndex].value]; 
calcTimeAndCost(); 
} 
function calcTimeAndCost() { 
var f = document.facForm; 
f.productionTimeMinutes.value = (f.timePerComplexity.value * (f.complexity.value-0) * (f.items.value-0))/60; 
f.productionTimeHours.value = f.productionTimeMinutes.value / 60; 
f.maint.value = f.maintPerHour.value * f.productionTimeHours.value; 
f.power.value = f.powerPerHour.value * f.productionTimeHours.value; 
f.maintPerUnit.value = f.maint.value / (f.items.value-0); 
f.powerPerUnit.value = f.power.value / (f.items.value-0); 
f.resourceCost.value = (f.resourcesPerItem.value-0) * (f.items.value-0) * (f.resourceCPU.value-0); 
f.powerCost.value = (f.power.value-0) * (f.powerCPU.value-0); 
f.totalCost.value = (f.maint.value-0) + (f.resourceCost.value-0) + (f.powerCost.value-0); 
f.totalCostPerUnit.value = f.totalCost.value / (f.items.value-0); 
} 
function doChangeFactory() { 
document.facForm.changeTimePerComplexity.value = timePerComplexity[document.facForm.changeFactory.options[document.facForm.changeFactory.selectedIndex].value]; 
document.facForm.changeMaintPerHour.value = maintPerHour[document.facForm.changeFactory.options[document.facForm.changeFactory.selectedIndex].value]; 
document.facForm.changePowerPerHour.value = powerPerHour[document.facForm.changeFactory.options[document.facForm.changeFactory.selectedIndex].value]; 
selectFactory(); 
} 
function setComplexity() { 
timePerComplexity[document.facForm.changeFactory.options[document.facForm.changeFactory.selectedIndex].value] = (document.facForm.changeTimePerComplexity.value-0); 
selectFactory(); 
} 
function setMaintPerHour() { 
maintPerHour[document.facForm.changeFactory.options[document.facForm.changeFactory.selectedIndex].value] = (document.facForm.changeMaintPerHour.value-0); 
selectFactory(); 
} 
function setPowerPerHour() { 
powerPerHour[document.facForm.changeFactory.options[document.facForm.changeFactory.selectedIndex].value] = (document.facForm.changePowerPerHour.value-0); 
selectFactory(); 
} 
<!--End Factory Tool Script -->

<!-- Harvestor Tool Script -->
var maxPowerRates = [0, 5, 8, 13]; 
var maintPerHour = [0, 60, 60, 60]; 
var maxResourceRates = [2, 8, 13]; 
var resourceMaintPerHour = [30, 60, 90]; 
var resourcePowerPerHour = [25, 50, 75];

function initialize() { 
document.costForm.powerDensity.focus(); 
selectMaxPowerRate(); 
changeSelectMaxPowerRate(); 
changeSelectHarvester(); 
} 

function selectMaxPowerRate() { 
document.costForm.maxPowerRate.value = maxPowerRates[document.costForm.powerGenerator.options[document.costForm.powerGenerator.selectedIndex].value]; 
document.costForm.maintPerHour.value = maintPerHour[document.costForm.powerGenerator.options[document.costForm.powerGenerator.selectedIndex].value]; 
document.costForm.maintPerDay.value = document.costForm.maintPerHour.value * 24; 
calcActualPower(); 
} 

function calcActualPower() { 
	if(document.costForm.maxPowerRate.value == 0) { 
	document.costForm.actualPowerRate.value = 0; 
	document.costForm.productionPerHour.value = 0; 
	document.costForm.productionPerDay.value = 0; 
	document.costForm.costPerUnit.disabled = false; 
	document.costForm.costPerUnit.readOnly = false; 
	document.costForm.costPerUnit.value = 0; 
	document.costForm.powerDensity.value = 0; 
	document.costForm.powerDensity.disabled = true; 
	document.costForm.powerDensity.readOnly = true; 
	document.costForm.costPerUnit.focus(); 
	} else { 
	document.costForm.powerDensity.disabled = false; 
	document.costForm.powerDensity.readOnly = false; 
	document.costForm.costPerUnit.disabled = true; 
	document.costForm.costPerUnit.readOnly = true; 
	document.costForm.actualPowerRate.value = document.costForm.powerDensity.value * document.costForm.maxPowerRate.value / 100; 
	document.costForm.productionPerHour.value = document.costForm.actualPowerRate.value * 60; 
	document.costForm.productionPerDay.value = document.costForm.productionPerHour.value * 24; 
	document.costForm.costPerUnit.value = document.costForm.maintPerHour.value / document.costForm.productionPerHour.value; 
	document.costForm.powerDensity.focus(); 
	} 
selectHarvester(); 
} 

function selectHarvester() { 
document.costForm.maxResourceRate.value = maxResourceRates[document.costForm.harvester.options[document.costForm.harvester.selectedIndex].value]; 
document.costForm.resourceMaintPerHour.value = resourceMaintPerHour[document.costForm.harvester.options[document.costForm.harvester.selectedIndex].value]; 
document.costForm.resourceMaintPerDay.value = document.costForm.resourceMaintPerHour.value * 24; 
document.costForm.powerConsumptionPerHour.value = resourcePowerPerHour[document.costForm.harvester.options[document.costForm.harvester.selectedIndex].value]; 
document.costForm.powerConsumptionPerDay.value = document.costForm.powerConsumptionPerHour.value * 24; 
document.costForm.powerCostPerHour.value = document.costForm.powerConsumptionPerHour.value * document.costForm.costPerUnit.value; 
document.costForm.resourceCostPerHour.value = (document.costForm.resourceMaintPerHour.value - 0) + (document.costForm.powerCostPerHour.value - 0); 
document.costForm.resourceCostPerDay.value = document.costForm.resourceCostPerHour.value * 24; 
	if(document.costForm.maxPowerRate.value == 0) { 
	document.costForm.maxHarvesters.value = "N/A"; 
	} 
	else { 
	document.costForm.maxHarvesters.value = Math.floor(document.costForm.productionPerHour.value / document.costForm.powerConsumptionPerHour.value); 
	} 
calcActualResource(); 
}

function calcActualResource() { 
document.costForm.actualResourceRate.value = document.costForm.resourceDensity.value * document.costForm.maxResourceRate.value / 100; 
document.costForm.resourceProductionPerHour.value = document.costForm.actualResourceRate.value * 60; 
document.costForm.resourceProductionPerDay.value = document.costForm.resourceProductionPerHour.value * 24; 
document.costForm.breakEven.value = document.costForm.resourceCostPerHour.value / document.costForm.resourceProductionPerHour.value; 
/* 
document.costForm.breakEvenBurn.value = (document.costForm.resourceCostPerHour.value * 50) / 
(document.costForm.resourceProductionPerHour.value * 50 - 
document.costForm.resourceProductionPerHour.value * 50 * .505); 
*/ 
}

function changeSelectMaxPowerRate() { 
document.costForm.changeMaxPowerRate.value = maxPowerRates[document.costForm.changePowerGenerator.options[document.costForm.changePowerGenerator.selectedIndex].value]; 
document.costForm.changeMaintPerHour.value = maintPerHour[document.costForm.changePowerGenerator.options[document.costForm.changePowerGenerator.selectedIndex].value]; 
}

function setMaxPowerRate() { 
maxPowerRates[document.costForm.changePowerGenerator.options[document.costForm.changePowerGenerator.selectedIndex].value] = document.costForm.changeMaxPowerRate.value; 
selectMaxPowerRate(); 
} 

function setPowerMaintPerHour() { 
maintPerHour[document.costForm.changePowerGenerator.options[document.costForm.changePowerGenerator.selectedIndex].value] = document.costForm.changeMaintPerHour.value; 
selectMaxPowerRate(); 
}

function changeSelectHarvester() { 
document.costForm.changeMaxResourceRate.value = maxResourceRates[document.costForm.changeHarvester.options[document.costForm.changeHarvester.selectedIndex].value]; 
document.costForm.changeResourceMaintPerHour.value = resourceMaintPerHour[document.costForm.changeHarvester.options[document.costForm.changeHarvester.selectedIndex].value]; 
document.costForm.changePowerConsumptionPerHour.value = resourcePowerPerHour[document.costForm.changeHarvester.options[document.costForm.changeHarvester.selectedIndex].value]; 
}

function setMaxResourceRate() { 
maxResourceRates[document.costForm.harvester.options[document.costForm.harvester.selectedIndex].value] = document.costForm.changeMaxResourceRate.value; 
selectHarvester(); 
} 

function setResourceMaintPerHour() { 
resourceMaintPerHour[document.costForm.harvester.options[document.costForm.harvester.selectedIndex].value] = document.costForm.changeResourceMaintPerHour.value; 
selectHarvester(); 
}

function setPowerConsumptionPerHour() { 
resourcePowerPerHour[document.costForm.harvester.options[document.costForm.harvester.selectedIndex].value] = document.costForm.changePowerConsumptionPerHour.value; 
selectHarvester(); 
} 
<!-- End Harvestor Tool Script -->

<!--Production Cost Script -->
function initialize() { 
document.prForm.fixedCosts.focus(); 
} 
function calcBEP() { 
var f = document.prForm; 
f.bep.value = ((f.fixedCosts.value-0) + (f.variableCosts.value-0) * (f.maxProdPerDay.value-0)) / (f.maxProdPerDay.value - 0); 
} 
function calcBEV() { 
var f = document.prForm; 
f.bev.value = (f.fixedCosts.value-0) / ((f.priceToTest.value-0)-(f.variableCosts.value-0)); 
f.vdiff.value = f.bev.value - (f.maxProdPerDay.value-0); 
calcTRV(); 
calcEstProfit(); 
} 
function calcTRV() { 
var f = document.prForm; 
f.trv.value = (f.rpl.value-0) / ((f.priceToTest.value-0)-(f.variableCosts.value-0)) + (f.bev.value-0); 
f.trvdiff.value = f.trv.value - (f.volest.value-0); 
} 
function calcEstProfit() { 
var f = document.prForm; 
f.estProfit.value = ((f.volest.value-0)-(f.bev.value-0)) * ((f.priceToTest.value-0)-(f.variableCosts.value-0)); 
} 
<!-- End Production Cost Script-->

<!-- Resource Quality Script -->
function calc() { 
var theForm = document.resourceForm; 
theForm.valuea.value = theForm.attr1.value / 100 * theForm.quala1.value + 
theForm.attr2.value / 100 * theForm.quala2.value + 
theForm.attr3.value / 100 * theForm.quala3.value + 
theForm.attr4.value / 100 * theForm.quala4.value + 
theForm.attr5.value / 100 * theForm.quala5.value + 
theForm.attr6.value / 100 * theForm.quala6.value; 
theForm.valueb.value = theForm.attr1.value / 100 * theForm.qualb1.value + 
theForm.attr2.value / 100 * theForm.qualb2.value + 
theForm.attr3.value / 100 * theForm.qualb3.value + 
theForm.attr4.value / 100 * theForm.qualb4.value + 
theForm.attr5.value / 100 * theForm.qualb5.value + 
theForm.attr6.value / 100 * theForm.qualb6.value; 
theForm.valuec.value = theForm.attr1.value / 100 * theForm.qualc1.value + 
theForm.attr2.value / 100 * theForm.qualc2.value + 
theForm.attr3.value / 100 * theForm.qualc3.value + 
theForm.attr4.value / 100 * theForm.qualc4.value + 
theForm.attr5.value / 100 * theForm.qualc5.value + 
theForm.attr6.value / 100 * theForm.qualc6.value; 
theForm.valued.value = theForm.attr1.value / 100 * theForm.quald1.value + 
theForm.attr2.value / 100 * theForm.quald2.value + 
theForm.attr3.value / 100 * theForm.quald3.value + 
theForm.attr4.value / 100 * theForm.quald4.value + 
theForm.attr5.value / 100 * theForm.quald5.value + 
theForm.attr6.value / 100 * theForm.quald6.value; 
theForm.valuee.value = theForm.attr1.value / 100 * theForm.quale1.value + 
theForm.attr2.value / 100 * theForm.quale2.value + 
theForm.attr3.value / 100 * theForm.quale3.value + 
theForm.attr4.value / 100 * theForm.quale4.value + 
theForm.attr5.value / 100 * theForm.quale5.value + 
theForm.attr6.value / 100 * theForm.quale6.value; 
theForm.valuef.value = theForm.attr1.value / 100 * theForm.qualf1.value + 
theForm.attr2.value / 100 * theForm.qualf2.value + 
theForm.attr3.value / 100 * theForm.qualf3.value + 
theForm.attr4.value / 100 * theForm.qualf4.value + 
theForm.attr5.value / 100 * theForm.qualf5.value + 
theForm.attr6.value / 100 * theForm.qualf6.value; 
var bestResource = theForm.resourceA; 
var bestValue = theForm.valuea.value; 
if(theForm.valueb.value > bestValue) { 
bestValue = theForm.valueb.value; 
bestResource = theForm.resourceB; 
} 
if(theForm.valuec.value > bestValue) { 
bestValue = theForm.valuec.value; 
bestResource = theForm.resourceC; 
} 
if(theForm.valued.value > bestValue) { 
bestValue = theForm.valued.value; 
bestResource = theForm.resourceD; 
} 
if(theForm.valuee.value > bestValue) { 
bestValue = theForm.valuee.value; 
bestResource = theForm.resourceE; 
} 
if(theForm.valuef.value > bestValue) { 
bestValue = theForm.valuef.value; 
bestResource = theForm.resourceF; 
} 
if(bestResource.value == "") 
bestResource = bestResource.name; 
else 
bestResource = bestResource.value; 
theForm.bestResource.value = bestResource; 
} 
<!-- End Resource Quality Script -->

<!-- Begin Tissue Calc Script -->
function BECalc(num)
{
  var base;
  var mod;
  var quan;
  var quana;
  var quan1 = 1;
  var quan3 = 1;

  document.theSpreadsheet1.res1.value="Organic";

  if (num >= 1 && num <= 3)
    {
      document.theSpreadsheet1.res2.value="Flora Food";
      document.theSpreadsheet1.res3.value="Meat";
      mod = 30;

      if (num == 1)
        {
          document.theSpreadsheet1.tissue.value="Micronutrient Supplement (Light)";
          document.theSpreadsheet1.q1.value=20;
          document.theSpreadsheet1.q2.value=15;
          document.theSpreadsheet1.q3.value=15;
          base = 30;
        }
      else if (num == 2)
        {
          document.theSpreadsheet1.tissue.value="Broad Spectrum Nutrient (Medium)";
          document.theSpreadsheet1.q1.value=35;
          document.theSpreadsheet1.q2.value=25;
          document.theSpreadsheet1.q3.value=20;
          base = 60;
        }
      else if (num == 3)
        {
          document.theSpreadsheet1.tissue.value="Intelligent Nanonutrient (Heavy)";
          document.theSpreadsheet1.q1.value=55;
          document.theSpreadsheet1.q2.value=35;
          document.theSpreadsheet1.q3.value=20;
          base = 90;
        }
    }

  if (num >= 4 && num <= 6)
    {
      document.theSpreadsheet1.res2.value="Milk";
      document.theSpreadsheet1.res3.value="Flora Food";
      mod = 20;

      if (num == 4)
        {
          document.theSpreadsheet1.tissue.value="Multisaccharide Dimate (Light)";
          document.theSpreadsheet1.q1.value=20;
          document.theSpreadsheet1.q2.value=20;
          document.theSpreadsheet1.q3.value=25;
          base = 10;
        }
      else if (num == 5)
        {
          document.theSpreadsheet1.res1.value="Seeds";
          document.theSpreadsheet1.tissue.value="Multisaccharide Tetramate (Medium)";
          document.theSpreadsheet1.q1.value=35;
          document.theSpreadsheet1.q2.value=30;
          document.theSpreadsheet1.q3.value=30;
          base = 30;
        }
      else if (num == 6)
        {
          document.theSpreadsheet1.res1.value="Berries";
          document.theSpreadsheet1.tissue.value="Multisaccharide Pentamate (Heavy)";
          document.theSpreadsheet1.q1.value=35;
          document.theSpreadsheet1.q2.value=40;
          document.theSpreadsheet1.q3.value=45;
          base = 50;
        }
    }

  if (num >= 7 && num <= 9)
    {
      document.theSpreadsheet1.res2.value="Cereal";
      document.theSpreadsheet1.res3.value="Wild Meat";
      mod = 100;

      if (num == 7)
        {
          document.theSpreadsheet1.tissue.value="Hyper Yeast Additive (Light)";
          document.theSpreadsheet1.q1.value=20;
          document.theSpreadsheet1.q2.value=20;
          document.theSpreadsheet1.q3.value=20;
          base = 100;
        }
      else if (num == 8)
        {
          document.theSpreadsheet1.tissue.value="Hyper Yeast Concentrate (Medium)";
          document.theSpreadsheet1.q1.value=25;
          document.theSpreadsheet1.q2.value=20;
          document.theSpreadsheet1.q3.value=20;
          base = 200;
        }
      else if (num == 9)
        {
          document.theSpreadsheet1.res1.value="Vegetables";
          document.theSpreadsheet1.tissue.value="Edible Nano Constructors (Heavy)";
          document.theSpreadsheet1.q1.value=25;
          document.theSpreadsheet1.q2.value=40;
          document.theSpreadsheet1.q3.value=30;
          base = 300;
        }
    }

  if (num >= 10 && num <= 12)
    {
      document.theSpreadsheet1.res2.value="Wild Meat";
      document.theSpreadsheet1.res3.value="Domestic Meat";
      mod = 10;

      if (num == 10)
        {
          document.theSpreadsheet1.tissue.value="Carboreductive Catalyst (Light)";
          document.theSpreadsheet1.q1.value=20;
          document.theSpreadsheet1.q2.value=20;
          document.theSpreadsheet1.q3.value=20;
          base = 10;
        }
      else if (num == 11)
        {
          document.theSpreadsheet1.res1.value="Seeds";
          document.theSpreadsheet1.tissue.value="Caloric Conversion Supplement (Medium)";
          document.theSpreadsheet1.q1.value=35;
          document.theSpreadsheet1.q2.value=35;
          document.theSpreadsheet1.q3.value=30;
          base = 20;
        }
      else if (num == 12)
        {
          document.theSpreadsheet1.res1.value="Fruit";
          document.theSpreadsheet1.tissue.value="Carbocaloric Eliminator (Heavy)";
          document.theSpreadsheet1.q1.value=35;
          document.theSpreadsheet1.q2.value=45;
          document.theSpreadsheet1.q3.value=40;
          base = 30;
        }
    }


  if (document.theSpreadsheet1.pe1.value == 0)
    {
      quan1 = 0;
      document.theSpreadsheet1.aq1.value = Math.floor (document.theSpreadsheet1.oq1.value*1);
    }
  else
      document.theSpreadsheet1.aq1.value = Math.floor (document.theSpreadsheet1.oq1.value*0.5 + document.theSpreadsheet1.pe1.value*0.3 + document.theSpreadsheet1.fl1.value*0.2);

  document.theSpreadsheet1.aq2.value = Math.floor (document.theSpreadsheet1.oq2.value*0.5 + document.theSpreadsheet1.pe2.value*0.3 + document.theSpreadsheet1.fl2.value*0.2);

  if (document.theSpreadsheet1.pe3.value == 0)
    {
      quan3 = 0;
      document.theSpreadsheet1.aq3.value = Math.floor (document.theSpreadsheet1.oq3.value*1);
    }
  else
      document.theSpreadsheet1.aq3.value = Math.floor (document.theSpreadsheet1.oq3.value*0.5 + document.theSpreadsheet1.pe3.value*0.3 + document.theSpreadsheet1.fl3.value*0.2);

  quan = (document.theSpreadsheet1.q1.value*quan1) + (document.theSpreadsheet1.q2.value*1) + (document.theSpreadsheet1.q3.value*quan3);
  quana = (document.theSpreadsheet1.q1.value*1) + (document.theSpreadsheet1.q2.value*1) + (document.theSpreadsheet1.q3.value*1);

  document.theSpreadsheet1.aoq.value = Math.floor ((document.theSpreadsheet1.oq1.value*document.theSpreadsheet1.q1.value + document.theSpreadsheet1.oq2.value*document.theSpreadsheet1.q2.value + document.theSpreadsheet1.oq3.value*document.theSpreadsheet1.q3.value) / quana);
  document.theSpreadsheet1.ape.value = Math.floor ((document.theSpreadsheet1.pe1.value*document.theSpreadsheet1.q1.value + document.theSpreadsheet1.pe2.value*document.theSpreadsheet1.q2.value*1 + document.theSpreadsheet1.pe3.value*document.theSpreadsheet1.q3.value*quan3) / quan);
  document.theSpreadsheet1.afl.value = Math.floor ((document.theSpreadsheet1.fl1.value*document.theSpreadsheet1.q1.value + document.theSpreadsheet1.fl2.value*document.theSpreadsheet1.q2.value*1 + document.theSpreadsheet1.fl3.value*document.theSpreadsheet1.q3.value*quan3) / quan);

  document.theSpreadsheet1.aaq.value = Math.floor (document.theSpreadsheet1.aoq.value*0.5 + document.theSpreadsheet1.ape.value*0.3 + document.theSpreadsheet1.afl.value*0.2);

  document.theSpreadsheet1.bonus.value = Math.floor (base*1 + (document.theSpreadsheet1.aaq.value * mod) / 1000);

} // end of BECalc



function BEErase ()
  {
    document.theSpreadsheet1.res1.value="";
    document.theSpreadsheet1.res2.value="";
    document.theSpreadsheet1.res3.value="";

    document.theSpreadsheet1.oq1.value="";
    document.theSpreadsheet1.pe1.value="";
    document.theSpreadsheet1.fl1.value="";
    document.theSpreadsheet1.aq1.value="";

    document.theSpreadsheet1.oq2.value="";
    document.theSpreadsheet1.pe2.value="";
    document.theSpreadsheet1.fl2.value="";
    document.theSpreadsheet1.aq2.value="";

    document.theSpreadsheet1.oq3.value="";
    document.theSpreadsheet1.pe3.value="";
    document.theSpreadsheet1.fl3.value="";
    document.theSpreadsheet1.aq3.value="";

    document.theSpreadsheet1.aoq.value="";
    document.theSpreadsheet1.ape.value="";
    document.theSpreadsheet1.afl.value="";
    document.theSpreadsheet1.aaq.value="";

    document.theSpreadsheet1.q1.value="";
    document.theSpreadsheet1.q2.value="";
    document.theSpreadsheet1.q3.value="";

    document.theSpreadsheet1.tissue.value="";
    document.theSpreadsheet1.bonus.value="";

  } // BEErase


// Math functions:
// ** COPYRIGHT (c) 1999 STEFAN WANER & STEVEN R. COSTENOBLE **
// ****************** ALL RIGHTS RESERVED *******************

function roundSigDig(theNumber, numDigits) {
		numDigits = numDigits -1		// too accurate as written
	with (Math)
		{
		if (theNumber == 0) return(0);
		else if(abs(theNumber) < 0.000000000001) return(0);
// WARNING: ignores numbers less than 10^(-12)
		else
			{
			var k = floor(log(abs(theNumber))/log(10))-numDigits
			var k2 = shiftRight(round(shiftRight(abs(theNumber),-k)),k)
			if (theNumber > 0) return(k2);
			else return(-k2)
			} // end else
		}
	}

function shiftRight(theNumber, k) {
	if (k == 0) return (theNumber)
	else
		{
		var k2 = 1;
		var num = k;
		if (num < 0) num = -num;
		for (var i = 1; i <= num; i++)
			{
			k2 = k2*10
			}
		}
	if (k>0) 
		{return(k2*theNumber)}
	else 
		{return(theNumber/k2)}
	}
// END Math functions
<!-- End Tissue Calc Script -->

