/*--------------------------------------------------|

| dTree 2.05 | www.destroydrop.com/javascript/tree/ |

|---------------------------------------------------|

| Copyright (c) 2002-2003 Geir Landrö               |

|                                                   |

| This script can be used freely as long as all     |

| copyright messages are intact.                    |

|                                                   |

| Updated: 17.04.2003                               |

|--------------------------------------------------*/



// Node object

function Node(id, pid, name, url, title, target, icon, iconOpen, open) {

	this.id = id;

	this.pid = pid;

	this.name = name;

	this.url = url;

	this.title = title;

	this.target = target;

	this.icon = icon;

	this.iconOpen = iconOpen;

	this._io = open || false;

	this._is = false;

	this._ls = false;

	this._hc = false;

	this._ai = 0;

	this._p;

};



// Tree object

function dTree(objName) {

	this.config = {

		target					: null,

		folderLinks			: true,

		useSelection		: true,

		useCookies			: true,

		useLines				: true,

		useIcons				: true,

		useStatusText		: false,

		closeSameLevel	: false,

		inOrder					: false,
		
		width				: 0,
		
		indent				: 0

	}

	this.icon = {

		root				: 'graphics/tree_img/base.gif',

		folder			: 'graphics/tree_img/folder.gif',

		folderOpen	: 'graphics/tree_img/folderopen.gif',

		node				: 'graphics/tree_img/page.gif',

		empty				: 'graphics/tree_img/empty.gif',

		line				: 'graphics/tree_img/line.gif',

		join				: 'graphics/tree_img/join.gif',

		joinBottom	: 'graphics/tree_img/joinbottom.gif',

		plus				: 'graphics/tree_img/plus.gif',

		plusBottom	: 'graphics/tree_img/plusbottom.gif',

		minus				: 'graphics/tree_img/minus.gif',

		minusBottom	: 'graphics/tree_img/minusbottom.gif',

		nlPlus			: 'graphics/tree_img/nolines_plus.gif',

		nlMinus			: 'graphics/tree_img/nolines_minus.gif'

	};

	this.obj = objName;

	this.aNodes = [];

	this.aIndent = [];

	this.root = new Node(-1);

	this.selectedNode = null;

	this.selectedFound = false;

	this.completed = false;

};



// Adds a new node to the node array

dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {

	this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);

};



// Open/close all nodes

dTree.prototype.openAll = function() {

	this.oAll(true);

};

dTree.prototype.closeAll = function() {

	this.oAll(false);

};



// Outputs the tree to the page

dTree.prototype.toString = function() {

	var str = '<div class="dtree" style="width: '+this.config.width+'px;" align="right">\n';

	if (document.getElementById) {

		if (this.config.useCookies) this.selectedNode = this.getSelected();

		str += this.addNode(this.root);

	} else str += 'Browser not supported.';

	str += '</div>';

	if (!this.selectedFound) this.selectedNode = null;

	this.completed = true;

	return str;

};



// Creates the tree structure

dTree.prototype.addNode = function(pNode) {

	var str = '';

	var n=0;

	if (this.config.inOrder) n = pNode._ai;

	for (n; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == pNode.id) {

			var cn = this.aNodes[n];

			cn._p = pNode;

			cn._ai = n;

			this.setCS(cn);

			if (!cn.target && this.config.target) cn.target = this.config.target;

			if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);

			if (!this.config.folderLinks && cn._hc) cn.url = null;

			if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {

					cn._is = true;

					this.selectedNode = n;

					this.selectedFound = true;

			}

			str += this.node(cn, n);

			if (cn._ls) break;

		}

	}

	return str;

};



// Creates the node icon, url and text

dTree.prototype.node = function(node, nodeId) {

	var depth = -1;
	
	var lpNode = node; //lpNode is a loop variable hence the lp
	
	while(lpNode.pid != -1)
	{
		depth++;
		for(var i=0; i<this.aNodes.length; i++)
		{
			if(lpNode.pid==this.aNodes[i].id)
			{
				lpNode=this.aNodes[i];
				break;
			}
		}
	}  //lpNode should be the root node at end of loop
	
	if(lpNode.id==node.id)
	{
		depth=0;
	}
	
	var str = '';
	if(node.pid==lpNode.id || node.pid==-1)
	{
		str += '<div class="dTreeNode" style="width: '+(this.config.width - (depth * this.config.indent))+'px;" align="left">' + this.indent(node, nodeId);
	}
	else
	{
		str += '<div class="dTreeNode" style="width: '+(this.config.width - (depth * this.config.indent))+'px; padding-bottom: .33em;" align="left">' + this.indent(node, nodeId);
	}

	if (this.config.useIcons) {

		if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);

		if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;

		if (this.root.id == node.pid) {

			node.icon = this.icon.root;

			node.iconOpen = this.icon.root;

		}

		str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';

	}

	if (node.url) {

		str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';

		if (node.title)
		{
			str += ' title="' + node.title + '"';
		}

		if (node.target)
		{
			str += ' target="' + node.target + '"';
		}

		if (this.config.useStatusText)
		{
			str += ' onmouseover="window.status=\'' + node.name + '\'; this.style.color=\'#CCCCFF\'; return true;" onmouseout="window.status=\'\'; this.style.color=\'#FFFFFF\'; return true;" ';
		}
		else
		{
			str += ' onMouseOver="this.style.color=\'#CCCCFF\';" onMouseOut="this.style.color=\'#FFFFFF\';" ';
		}

		if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
		{
			str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + '); ' + this.obj + '.o(' + nodeId + ');"';
		}
		else
		{
			str += ' onclick="javascript: ' + this.obj + '.o(' + nodeId + ');"';
		}
		str += '>';

	}

	else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)

		str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node" onMouseOver="this.style.color=\'#CCCCFF\';" onMouseOut="this.style.color=\'#FFFFFF\';">';

	str += node.name;

	if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';

	str += '</div>';
	
	if (node.pid==lpNode.id)
	{
		str += '<span style="font-size: 6px;"><br /></span>';	
	}

	if (node._hc) {

		str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';

		str += this.addNode(node);

		str += '<span style="font-size: 6px;"><br /></span></div>';

	}

	this.aIndent.pop();

	return str;

};



// Adds the empty and line icons

dTree.prototype.indent = function(node, nodeId) {

	var str = '';

	if (this.root.id != node.pid) {

		for (var n=0; n<this.aIndent.length; n++)

			//str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';

		(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);

		if (node._hc) {

			str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';

			if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;

			else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );

			str += '" alt="" align="left" /></a>';

		}// else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';

	}

	return str;

};



// Checks if a node has any children and if it is the last sibling

dTree.prototype.setCS = function(node) {

	var lastId;

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == node.id) node._hc = true;

		if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;

	}

	if (lastId==node.id) node._ls = true;

};



// Returns the selected node

dTree.prototype.getSelected = function() {

	var sn = this.getCookie('cs' + this.obj);

	return (sn) ? sn : null;

};



// Highlights the selected node

dTree.prototype.s = function(id) {

	if (!this.config.useSelection) return;

	var cn = this.aNodes[id];

	if (cn._hc && !this.config.folderLinks) return;

	if (this.selectedNode != id) {

		if (this.selectedNode || this.selectedNode==0) {

			eOld = document.getElementById("s" + this.obj + this.selectedNode);

			eOld.className = "node";

		}

		eNew = document.getElementById("s" + this.obj + id);

		eNew.className = "nodeSel";

		this.selectedNode = id;

		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);

	}

};

// Highlights the node identified by id until the page is reloaded

dTree.prototype.highlight = function(id) {

		document.getElementById("s" + this.obj + id).className="highlight";

};


// Toggle Open or close

dTree.prototype.o = function(id) {

	var cn = this.aNodes[id];

	this.nodeStatus(!cn._io, id, cn._ls);

	cn._io = !cn._io;

	if (this.config.closeSameLevel) this.closeLevel(cn);

	if (this.config.useCookies) this.updateCookie();

};

// Open one node

dTree.prototype.oOne = function(id) {

	var cn = this.aNodes[id];

	this.nodeStatus(open, id, cn._ls);

	cn._io = open;

	if (this.config.closeSameLevel) this.closeLevel(cn);

	if (this.config.useCookies) this.updateCookie();

};

// Open or close all nodes

dTree.prototype.oAll = function(status) {

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {

			this.nodeStatus(status, n, this.aNodes[n]._ls)

			this.aNodes[n]._io = status;

		}

	}

	if (this.config.useCookies) this.updateCookie();

};



// Opens the tree to a specific node

dTree.prototype.openTo = function(nId, bSelect, bFirst) {

	if (!bFirst) {

		for (var n=0; n<this.aNodes.length; n++) {

			if (this.aNodes[n].id == nId) {

				nId=n;

				break;

			}

		}

	}

	var cn=this.aNodes[nId];

	if (cn.pid==this.root.id || !cn._p) return;

	cn._io = true;

	cn._is = bSelect;

	if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);

	if (this.completed && bSelect) this.s(cn._ai);

	else if (bSelect) this._sn=cn._ai;

	this.openTo(cn._p._ai, false, true);

};



// Closes all nodes on the same level as certain node

dTree.prototype.closeLevel = function(node) {

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {

			this.nodeStatus(false, n, this.aNodes[n]._ls);

			this.aNodes[n]._io = false;

			this.closeAllChildren(this.aNodes[n]);

		}

	}

}



// Closes all children of a node

dTree.prototype.closeAllChildren = function(node) {

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {

			if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);

			this.aNodes[n]._io = false;

			this.closeAllChildren(this.aNodes[n]);		

		}

	}

}



// Change the status of a node(open or closed)

dTree.prototype.nodeStatus = function(status, id, bottom) {

	eDiv	= document.getElementById('d' + this.obj + id);

	eJoin	= document.getElementById('j' + this.obj + id);

	if (this.config.useIcons) {

		eIcon	= document.getElementById('i' + this.obj + id);

		eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;

	}

	eJoin.src = (this.config.useLines)?

	((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):

	((status)?this.icon.nlMinus:this.icon.nlPlus);

	eDiv.style.display = (status) ? 'block': 'none';

};





// [Cookie] Clears a cookie

dTree.prototype.clearCookie = function() {

	var now = new Date();

	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);

	this.setCookie('co'+this.obj, 'cookieValue', yesterday);

	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);

};



// [Cookie] Sets value in a cookie

dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {

	document.cookie =

		escape(cookieName) + '=' + escape(cookieValue)

		+ (expires ? '; expires=' + expires.toGMTString() : '')

		+ (path ? '; path=' + path : '')

		+ (domain ? '; domain=' + domain : '')

		+ (secure ? '; secure' : '');

};



// [Cookie] Gets a value from a cookie

dTree.prototype.getCookie = function(cookieName) {

	var cookieValue = '';

	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {

		var posValue = posName + (escape(cookieName) + '=').length;

		var endPos = document.cookie.indexOf(';', posValue);

		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));

		else cookieValue = unescape(document.cookie.substring(posValue));

	}

	return (cookieValue);

};



// [Cookie] Returns ids of open nodes as a string

dTree.prototype.updateCookie = function() {

	var str = '';

	for (var n=0; n<this.aNodes.length; n++) {

		if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {

			if (str) str += '.';

			str += this.aNodes[n].id;

		}

	}

	this.setCookie('co' + this.obj, str);

};



// [Cookie] Checks if a node id is in a cookie

dTree.prototype.isOpen = function(id) {

	var aOpen = this.getCookie('co' + this.obj).split('.');

	for (var n=0; n<aOpen.length; n++)

		if (aOpen[n] == id) return true;

	return false;

};



// If Push and pop is not implemented by the browser

if (!Array.prototype.push) {

	Array.prototype.push = function array_push() {

		for(var i=0;i<arguments.length;i++)

			this[this.length]=arguments[i];

		return this.length;

	}

};

if (!Array.prototype.pop) {

	Array.prototype.pop = function array_pop() {

		lastElement = this[this.length-1];

		this.length = Math.max(this.length-1,0);

		return lastElement;

	}

};


/* ///////////////////////////////////////////////////////////////////////// */
/* ///////////////////////////////////////////////////////////////////////// */
/* ///////////////////////////////////////////////////////////////////////// */

function buildUSCmenu()
{

	d = new dTree('d');
	d.config.useLines=0;
	d.config.useIcons=0;
	d.config.useSelection=0;
	d.config.width=115;
	d.config.indent=20;
	d.add(0,-1,'Home', './index.php?l=front', 'USC, LLC', '');
	d.add(1,0,'Company Overview','./index.php?l=aboutUs', 'Company Overview', '');
	d.add(2,0,'Products','./index.php?l=prods', 'Products', '');
/*	d.add(3,0,'Testamonials','./index.php?l=servs', 'Testamonials', '');	*/
	d.add(4,0,'Sales','./index.php?l=sales', 'Sales', '');
	d.add(5,0,'Service','./index.php?l=supp', 'Support', '');
	d.add(6,0,'Events','./index.php?l=events', 'Events', '');
	d.add(7,0,'Find a Dealer','./index.php?l=Dealers', 'Find a Dealer', '');
	d.add(8,0,'Dealers Only*','./index.php?l=DealersOnly', 'Dealers Only', '');
	d.add(9,0,'Careers','./index.php?l=careers', 'Careers', '');
	d.add(10,0,'Location','./index.php?l=location', 'Our Location and Directions', '');
	d.add(11,0,'Links','./index.php?l=links', 'Links', '');
	d.add(12,0,'Contact Us','./index.php?l=contact2', 'Contact Us', '');
/*	d.add(13,1,'Personnel','./index.php?l=hist', 'USC LLC\'s Company Personnel', ''); */
	d.add(14,2,'On the farm','./index.php?l=farm', 'Farm Treaters', '');
	d.add(15,2,'Ag Retail','./index.php?l=treaters', 'Ag Retail', '');
	d.add(16,2,'Commmercial','./index.php?l=comm', 'Commercial', '');
/*	d.add(17,2,'ATV Crossover','./index.php?l=atv', 'ATV Crossover', ''); */
	d.add(18,2,'Treater Accessories','./index.php?l=acc', 'Treater Accessories', '');
	d.add(19,2,'Flxtor','./index.php?l=flxtor2', 'flxtor', '');
	d.add(20,4,'Product Catalogs', './index.php?l=cats', 'Product Catalogs', ''); 
	d.add(21,4,'Leasing Programs', './index.php?l=lease', 'Leasing Programs', ''); 
	d.add(22,5,'Equipment Manuals*','./index.php?l=manual', 'Downloadable Manuals (requires login)', '');
	d.add(23,5,'Technical Information','./index.php?l=tech', 'Technical Information', '');
/*	d.add(24,4,'Used Treaters','./index.php?l=trade', 'Treater Trading Post (requires login)', '');	*/

	if ( logon_status=='0' )
	{ d.add(30,0,'Login','./index.php?l=login','Login',''); }
	else
	{ d.add(30,0,'Logout','./logout.php','Logout',''); }

	d.add(31,0,'* - Requires Login','','','');
	
	document.write(d);

}

/* ///////////////////////////////////////////////////////////////////////// */
/* ///////////////////////////////////////////////////////////////////////// */
/* ///////////////////////////////////////////////////////////////////////// */

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function e_mail(to)
{
	if(to=='sales')
	{
		document.write('<a href="mailto:sales-team@uscllc.com">sales-team@uscllc.com</a>');
	}
	else if(to=='web')
	{
		document.write('<a href="mailto:webadmin@uscllc.com">webadmin@uscllc.com</a>');
	}
	else if(to=='hr')
	{
		document.write('<a href="mailto:jenniferpoe@uscllc.com">jenniferpoe@uscllc.com</a>');	
	}
	else if(to=='saleMan')
	{
		document.write('<a href="mailto:chuckchiles@uscllc.com">chuckchiles@uscllc.com</a>');	
	}
	else if(to=='servMan')
	{
		document.write('<a href="mailto:glennsander@uscllc.com">glennsander@uscllc.com</a>');
	}
	else if(to=='repJN')
	{
		document.write('<a href="mailto:jakeniehues@uscllc.com">jakeniehues@uscllc.com</a>');
	}
	else if(to=='repCW')
	{
		document.write('<a href="mailto:craigwiebe@uscllc.com">craigwiebe@uscllc.com</a>');
	}
	else if(to=='repBM')
	{
		document.write('<a href="mailto:billmichaelsen@uscllc.com">billmichaelsen@uscllc.com</a>');
	}
	else if(to=='repDW')
	{
		document.write('<a href="mailto:davidwilson@uscllc.com">davidwilson@uscllc.com</a>');
	}
	else if(to=='gm')
	{
		document.write('<a href="mailto:jimrenyer@uscllc.com">jimrenyer@uscllc.com</a>');	
	}
	
	return;
}

function phone(numb)
{
	if(numb=='voice')
	{
		document.write('785.284.0048');
	}
	else if(numb=='fax')
	{
		document.write('785.284.0032');
	}
	else if(numb=='saleMan')
	{
		document.write('913.728.2790');	
	}
	else if(numb=='saleManm')
	{
		document.write('913.707.1088');	
	}
	else if(numb=='repJNm')
	{
		document.write('785.285.1717');	
	}
	else if(numb=='repCWm')
	{
		document.write('785.285.0275');	
	}
	return;
}

function writeFrontFlash(id)
{
	document.getElementById(id).innerHTML ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="1024" height="400" id="topBarSplash" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" /><param name="movie" value="topBarSplash.swf" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="topBarSplash.swf" loop="false" quality="high" bgcolor="#ffffff" width="1024" height="400" name="topBarSplash" align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
}

function seedsOver(img)
{
	document.getElementById(img.id.substring(3)).style.display='block';
	document.getElementById(img.id).style.zIndex='45';
	
	if(img.id=='imgPinkCorn')
	{
		document.getElementById('imgGreenCorn').style.opacity='.40';
		document.getElementById('imgRedSoy').style.opacity='.40';
		document.getElementById('imgGreenSoy').style.opacity='.40';
		document.getElementById('imgOrangeSoy').style.opacity='.40';
		document.getElementById('imgRedWheat').style.opacity='.40';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgGreenCorn')
	{
		document.getElementById('imgPinkCorn').style.opacity='.40';
		document.getElementById('imgRedSoy').style.opacity='.40';
		document.getElementById('imgGreenSoy').style.opacity='.40';
		document.getElementById('imgOrangeSoy').style.opacity='.40';
		document.getElementById('imgRedWheat').style.opacity='.40';
		
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgRedSoy')
	{
		document.getElementById('imgGreenCorn').style.opacity='.40';
		document.getElementById('imgPinkCorn').style.opacity='.40';
		document.getElementById('imgGreenSoy').style.opacity='.40';
		document.getElementById('imgOrangeSoy').style.opacity='.40';
		document.getElementById('imgRedWheat').style.opacity='.40';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgGreenSoy')
	{
		document.getElementById('imgGreenCorn').style.opacity='.40';
		document.getElementById('imgRedSoy').style.opacity='.40';
		document.getElementById('imgPinkCorn').style.opacity='.40';
		document.getElementById('imgOrangeSoy').style.opacity='.40';
		document.getElementById('imgRedWheat').style.opacity='.40';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgOrangeSoy')
	{
		document.getElementById('imgGreenCorn').style.opacity='.40';
		document.getElementById('imgRedSoy').style.opacity='.40';
		document.getElementById('imgGreenSoy').style.opacity='.40';
		document.getElementById('imgPinkCorn').style.opacity='.40';
		document.getElementById('imgRedWheat').style.opacity='.40';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgRedWheat')
	{
		document.getElementById('imgGreenCorn').style.opacity='.40';
		document.getElementById('imgRedSoy').style.opacity='.40';
		document.getElementById('imgGreenSoy').style.opacity='.40';
		document.getElementById('imgOrangeSoy').style.opacity='.40';
		document.getElementById('imgPinkCorn').style.opacity='.40';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=40)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=40)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=40)';
	}
}

function seedsOut(img)
{
	document.getElementById(img.id.substring(3)).style.display='none';
	document.getElementById(img.id).style.zIndex='40';
	
	if(img.id=='imgPinkCorn')
	{
		document.getElementById('imgGreenCorn').style.opacity='1';
		document.getElementById('imgRedSoy').style.opacity='1';
		document.getElementById('imgGreenSoy').style.opacity='1';
		document.getElementById('imgOrangeSoy').style.opacity='1';
		document.getElementById('imgRedWheat').style.opacity='1';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgGreenCorn')
	{	
		document.getElementById('imgPinkCorn').style.opacity='1';
		document.getElementById('imgRedSoy').style.opacity='1';
		document.getElementById('imgGreenSoy').style.opacity='1';
		document.getElementById('imgOrangeSoy').style.opacity='1';
		document.getElementById('imgRedWheat').style.opacity='1';
		
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgRedSoy')
	{
		document.getElementById('imgGreenCorn').style.opacity='1';
		document.getElementById('imgPinkCorn').style.opacity='1';
		document.getElementById('imgGreenSoy').style.opacity='1';
		document.getElementById('imgOrangeSoy').style.opacity='1';
		document.getElementById('imgRedWheat').style.opacity='1';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgGreenSoy')
	{
		document.getElementById('imgGreenCorn').style.opacity='1';
		document.getElementById('imgRedSoy').style.opacity='1';
		document.getElementById('imgPinkCorn').style.opacity='1';
		document.getElementById('imgOrangeSoy').style.opacity='1';
		document.getElementById('imgRedWheat').style.opacity='1';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgOrangeSoy')
	{
		document.getElementById('imgGreenCorn').style.opacity='1';
		document.getElementById('imgRedSoy').style.opacity='1';
		document.getElementById('imgGreenSoy').style.opacity='1';
		document.getElementById('imgPinkCorn').style.opacity='1';
		document.getElementById('imgRedWheat').style.opacity='1';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedWheat').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgRedWheat')
	{
		document.getElementById('imgGreenCorn').style.opacity='1';
		document.getElementById('imgRedSoy').style.opacity='1';
		document.getElementById('imgGreenSoy').style.opacity='1';
		document.getElementById('imgOrangeSoy').style.opacity='1';
		document.getElementById('imgPinkCorn').style.opacity='1';
		
		document.getElementById('imgGreenCorn').style.filter='alpha(opacity=100)';
		document.getElementById('imgRedSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgGreenSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgOrangeSoy').style.filter='alpha(opacity=100)';
		document.getElementById('imgPinkCorn').style.filter='alpha(opacity=100)';
	}
}

function seedsArrow()
{
	document.getElementById('imgPinkCorn').style.display='none';
	document.getElementById('imgGreenCorn').style.display='none';
	document.getElementById('imgRedSoy').style.display='none';
	document.getElementById('imgGreenSoy').style.display='none';
	document.getElementById('imgOrangeSoy').style.display='none';
	document.getElementById('imgRedWheat').style.display='none';
	document.getElementById('imgRightArrow').style.display='none';
	
	document.getElementById('imgUncoatedRound').style.display='block';
	document.getElementById('img8liq_1dig_Y').style.display='block';
	document.getElementById('img4liq_14dig').style.display='block';
	document.getElementById('img12liq_3dig').style.display='block';
	document.getElementById('imgWhiteRock').style.display='block';
	document.getElementById('imgBlueRock').style.display='block';
	document.getElementById('imgPurpleRock').style.display='block';
	document.getElementById('imgLeftArrow').style.display='block';
	
	//document.getElementById('seedDescContainer').style.top='-5px';
}

function foodsOver(img)
{
	document.getElementById(img.id.substring(3)).style.display='block';
	document.getElementById(img.id).style.zIndex='45';
	
	if(img.id=='imgUncoatedRound')
	{		
		document.getElementById('img8liq_1dig_Y').style.opacity='.4';
		document.getElementById('img4liq_14dig').style.opacity='.4';
		document.getElementById('img12liq_3dig').style.opacity='.4';
		document.getElementById('imgWhiteRock').style.opacity='.4';
		document.getElementById('imgBlueRock').style.opacity='.4';
		document.getElementById('imgPurpleRock').style.opacity='.4';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=40)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=40)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='img8liq_1dig_Y')
	{	
		document.getElementById('imgUncoatedRound').style.opacity='.4';
		document.getElementById('img4liq_14dig').style.opacity='.4';
		document.getElementById('img12liq_3dig').style.opacity='.4';
		document.getElementById('imgWhiteRock').style.opacity='.4';
		document.getElementById('imgBlueRock').style.opacity='.4';
		document.getElementById('imgPurpleRock').style.opacity='.4';
		
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=40)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=40)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='img4liq_14dig')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='.4';
		document.getElementById('imgUncoatedRound').style.opacity='.4';
		document.getElementById('img12liq_3dig').style.opacity='.4';
		document.getElementById('imgWhiteRock').style.opacity='.4';
		document.getElementById('imgBlueRock').style.opacity='.4';
		document.getElementById('imgPurpleRock').style.opacity='.4';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=40)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=40)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='img12liq_3dig')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='.4';
		document.getElementById('img4liq_14dig').style.opacity='.4';
		document.getElementById('imgUncoatedRound').style.opacity='.4';
		document.getElementById('imgWhiteRock').style.opacity='.4';
		document.getElementById('imgBlueRock').style.opacity='.4';
		document.getElementById('imgPurpleRock').style.opacity='.4';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=40)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=40)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgWhiteRock')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='.4';
		document.getElementById('img4liq_14dig').style.opacity='.4';
		document.getElementById('img12liq_3dig').style.opacity='.4';
		document.getElementById('imgUncoatedRound').style.opacity='.4';
		document.getElementById('imgBlueRock').style.opacity='.4';
		document.getElementById('imgPurpleRock').style.opacity='.4';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=40)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=40)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=40)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgBlueRock')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='.4';
		document.getElementById('img4liq_14dig').style.opacity='.4';
		document.getElementById('img12liq_3dig').style.opacity='.4';
		document.getElementById('imgWhiteRock').style.opacity='.4';
		document.getElementById('imgUncoatedRound').style.opacity='.4';
		document.getElementById('imgPurpleRock').style.opacity='.4';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=40)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=40)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=40)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=40)';
	}
	else if(img.id=='imgPurpleRock')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='.4';
		document.getElementById('img4liq_14dig').style.opacity='.4';
		document.getElementById('img12liq_3dig').style.opacity='.4';
		document.getElementById('imgWhiteRock').style.opacity='.4';
		document.getElementById('imgBlueRock').style.opacity='.4';
		document.getElementById('imgUncoatedRound').style.opacity='.4';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=40)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=40)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=40)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=40)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=40)';	
	}
}

function foodsOut(img)
{
	document.getElementById(img.id.substring(3)).style.display='none';
	document.getElementById(img.id).style.zIndex='40';
	
	if(img.id=='imgUncoatedRound')
	{		
		document.getElementById('img8liq_1dig_Y').style.opacity='1';
		document.getElementById('img4liq_14dig').style.opacity='1';
		document.getElementById('img12liq_3dig').style.opacity='1';
		document.getElementById('imgWhiteRock').style.opacity='1';
		document.getElementById('imgBlueRock').style.opacity='1';
		document.getElementById('imgPurpleRock').style.opacity='1';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=100)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=100)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='img8liq_1dig_Y')
	{	
		document.getElementById('imgUncoatedRound').style.opacity='1';
		document.getElementById('img4liq_14dig').style.opacity='1';
		document.getElementById('img12liq_3dig').style.opacity='1';
		document.getElementById('imgWhiteRock').style.opacity='1';
		document.getElementById('imgBlueRock').style.opacity='1';
		document.getElementById('imgPurpleRock').style.opacity='1';
		
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=100)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=100)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='img4liq_14dig')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='1';
		document.getElementById('imgUncoatedRound').style.opacity='1';
		document.getElementById('img12liq_3dig').style.opacity='1';
		document.getElementById('imgWhiteRock').style.opacity='1';
		document.getElementById('imgBlueRock').style.opacity='1';
		document.getElementById('imgPurpleRock').style.opacity='1';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=100)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=100)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='img12liq_3dig')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='1';
		document.getElementById('img4liq_14dig').style.opacity='1';
		document.getElementById('imgUncoatedRound').style.opacity='1';
		document.getElementById('imgWhiteRock').style.opacity='1';
		document.getElementById('imgBlueRock').style.opacity='1';
		document.getElementById('imgPurpleRock').style.opacity='1';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=100)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=100)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgWhiteRock')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='1';
		document.getElementById('img4liq_14dig').style.opacity='1';
		document.getElementById('img12liq_3dig').style.opacity='1';
		document.getElementById('imgUncoatedRound').style.opacity='1';
		document.getElementById('imgBlueRock').style.opacity='1';
		document.getElementById('imgPurpleRock').style.opacity='1';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=100)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=100)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=100)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgBlueRock')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='1';
		document.getElementById('img4liq_14dig').style.opacity='1';
		document.getElementById('img12liq_3dig').style.opacity='1';
		document.getElementById('imgWhiteRock').style.opacity='1';
		document.getElementById('imgUncoatedRound').style.opacity='1';
		document.getElementById('imgPurpleRock').style.opacity='1';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=100)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=100)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=100)';
		document.getElementById('imgPurpleRock').style.filter='alpha(opacity=100)';
	}
	else if(img.id=='imgPurpleRock')
	{
		document.getElementById('img8liq_1dig_Y').style.opacity='1';
		document.getElementById('img4liq_14dig').style.opacity='1';
		document.getElementById('img12liq_3dig').style.opacity='1';
		document.getElementById('imgWhiteRock').style.opacity='1';
		document.getElementById('imgBlueRock').style.opacity='1';
		document.getElementById('imgUncoatedRound').style.opacity='1';
		
		document.getElementById('img8liq_1dig_Y').style.filter='alpha(opacity=100)';
		document.getElementById('img4liq_14dig').style.filter='alpha(opacity=100)';
		document.getElementById('img12liq_3dig').style.filter='alpha(opacity=100)';
		document.getElementById('imgWhiteRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgBlueRock').style.filter='alpha(opacity=100)';
		document.getElementById('imgUncoatedRound').style.filter='alpha(opacity=100)';	
	}
}

function foodsArrow()
{
	document.getElementById('imgPinkCorn').style.display='block';
	document.getElementById('imgGreenCorn').style.display='block';
	document.getElementById('imgRedSoy').style.display='block';
	document.getElementById('imgGreenSoy').style.display='block';
	document.getElementById('imgOrangeSoy').style.display='block';
	document.getElementById('imgRedWheat').style.display='block';
	document.getElementById('imgRightArrow').style.display='block';
	
	document.getElementById('imgUncoatedRound').style.display='none';
	document.getElementById('img8liq_1dig_Y').style.display='none';
	document.getElementById('img4liq_14dig').style.display='none';
	document.getElementById('img12liq_3dig').style.display='none';
	document.getElementById('imgWhiteRock').style.display='none';
	document.getElementById('imgBlueRock').style.display='none';
	document.getElementById('imgPurpleRock').style.display='none';
	document.getElementById('imgLeftArrow').style.display='none';
	
	//document.getElementById('seedDescContainer').style.top='120px';
}

function leaseCalc(leaseFrm, e)
{
	var key;
	
	if(window.event)
	{
		key = window.event.keyCode;
	}
	else if(e)
	{
		key = e.which;
	}
	
	if(parseFloat(leaseFrm.leaseIn.value)>=1000000)
	{
		leaseFrm.leaseIn.value='999999.99';
	}
	
	if((key<48 || key>57) && (leaseFrm.leaseIn.value=='' || leaseFrm.leaseIn.value=='.'))
	{
		return true;
	}
	else
	{
		if(leaseFrm.leaseIn.value<10000)
		{
				switch (leaseFrm.leasePrg.value)
				{
					case 'One':
						document.getElementById('lease1').style.display='block';
						document.getElementById('lease2').style.display='none';
						document.getElementById('lease0').style.display='none';
					
						leaseFrm.lease1One24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04778).toFixed(2);
						leaseFrm.lease1One36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03412).toFixed(2);
						leaseFrm.lease1One48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02761).toFixed(2);
						leaseFrm.lease1One60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02375).toFixed(2);
						
						leaseFrm.lease1Fair24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04493).toFixed(2);
						leaseFrm.lease1Fair36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03302).toFixed(2);
						leaseFrm.lease1Fair48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02716).toFixed(2);
						leaseFrm.lease1Fair60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02353).toFixed(2);
						
						break;
					case 'Two':
						document.getElementById('lease1').style.display='none';
						document.getElementById('lease2').style.display='block';
						document.getElementById('lease0').style.display='none';
						
						leaseFrm.lease2One24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04723).toFixed(2);
						leaseFrm.lease2One36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03372).toFixed(2);
						leaseFrm.lease2One48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02727).toFixed(2);
						leaseFrm.lease2One60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02357).toFixed(2);
						
						leaseFrm.lease2Fair24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04493).toFixed(2);
						leaseFrm.lease2Fair36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03302).toFixed(2);
						leaseFrm.lease2Fair48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02716).toFixed(2);
						leaseFrm.lease2Fair60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02353).toFixed(2);
						
						break;
					case 'No':
						document.getElementById('lease1').style.display='none';
						document.getElementById('lease2').style.display='none';
						document.getElementById('lease0').style.display='block';
						
						leaseFrm.lease0One24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04837).toFixed(2);
						leaseFrm.lease0One36.value=(parseFloat(leaseFrm.leaseIn.value)*0.04837).toFixed(2);
						leaseFrm.lease0One48.value=(parseFloat(leaseFrm.leaseIn.value)*0.04837).toFixed(2);
						leaseFrm.lease0One60.value=(parseFloat(leaseFrm.leaseIn.value)*0.04837).toFixed(2);
						
						leaseFrm.lease0Fair24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04548).toFixed(2);
						leaseFrm.lease0Fair36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03343).toFixed(2);
						leaseFrm.lease0Fair48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02750).toFixed(2);
						leaseFrm.lease0Fair60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02383).toFixed(2);
						
						break;
				}
		}
		else
		{
			switch (leaseFrm.leasePrg.value)
			{
				case 'One':
					document.getElementById('lease1').style.display='block';
					document.getElementById('lease2').style.display='none';
					document.getElementById('lease0').style.display='none';
				
					leaseFrm.lease1One24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04735).toFixed(2);
					leaseFrm.lease1One36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03367).toFixed(2);
					leaseFrm.lease1One48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02713).toFixed(2);
					leaseFrm.lease1One60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02325).toFixed(2);
					
					leaseFrm.lease1Fair24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04447).toFixed(2);
					leaseFrm.lease1Fair36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03255).toFixed(2);
					leaseFrm.lease1Fair48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02667).toFixed(2);
					leaseFrm.lease1Fair60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02302).toFixed(2);
					
					break;
				case 'Two':
					document.getElementById('lease1').style.display='none';
					document.getElementById('lease2').style.display='block';
					document.getElementById('lease0').style.display='none';
					
					leaseFrm.lease2One24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04684).toFixed(2);
					leaseFrm.lease2One36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03330).toFixed(2);
					leaseFrm.lease2One48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02682).toFixed(2);
					leaseFrm.lease2One60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02309).toFixed(2);
					
					leaseFrm.lease2Fair24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04447).toFixed(2);
					leaseFrm.lease2Fair36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03255).toFixed(2);
					leaseFrm.lease2Fair48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02667).toFixed(2);
					leaseFrm.lease2Fair60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02302).toFixed(2);
					
					break;
				case 'No':
					document.getElementById('lease1').style.display='none';
					document.getElementById('lease2').style.display='none';
					document.getElementById('lease0').style.display='block';
					
					leaseFrm.lease0One24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04789).toFixed(2);
					leaseFrm.lease0One36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03406).toFixed(2);
					leaseFrm.lease0One48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02745).toFixed(2);
					leaseFrm.lease0One60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02365).toFixed(2);
					
					leaseFrm.lease0Fair24.value=(parseFloat(leaseFrm.leaseIn.value)*0.04498).toFixed(2);
					leaseFrm.lease0Fair36.value=(parseFloat(leaseFrm.leaseIn.value)*0.03293).toFixed(2);
					leaseFrm.lease0Fair48.value=(parseFloat(leaseFrm.leaseIn.value)*0.02698).toFixed(2);
					leaseFrm.lease0Fair60.value=(parseFloat(leaseFrm.leaseIn.value)*0.02330).toFixed(2);
					
					break;
			}
		}
		leaseFrm.monthlyRentUCL.value='$'+(parseFloat(leaseFrm.leaseIn.value)*0.03155).toFixed(2);
		leaseFrm.monthlyRentOL.value='$'+(parseFloat(leaseFrm.leaseIn.value)*0.02997).toFixed(2);
		leaseFrm.monthlyRentUCS.value=(parseFloat(leaseFrm.monthlyRentOL.value.substr(1))-parseFloat(leaseFrm.monthlyRentUCL.value.substr(1))).toFixed(2);
		
		leaseFrm.interimRentOL.value='$'+(parseFloat(leaseFrm.monthlyRentOL.value.substr(1))*0.5).toFixed(2);
		leaseFrm.interimRentUCS.value=leaseFrm.interimRentOL.value;
		
		leaseFrm.totalMonthlyUCL.value='$'+(parseFloat(leaseFrm.monthlyRentUCL.value.substr(1))*36).toFixed(2);
		leaseFrm.totalMonthlyOL.value='$'+(parseFloat(leaseFrm.monthlyRentOL.value.substr(1))*36).toFixed(2);
		leaseFrm.totalMonthlyUCS.value=(parseFloat(leaseFrm.totalMonthlyOL.value.substr(1))-parseFloat(leaseFrm.totalMonthlyUCL.value.substr(1))).toFixed(2);
		
		leaseFrm.forcedInsuranceOL.value='$'+(.001*parseFloat(leaseFrm.leaseIn.value)*36).toFixed(2);
		leaseFrm.forcedInsuranceUCS.value=leaseFrm.forcedInsuranceOL.value;
	
		leaseFrm.ptaxFeesOL.value='$'+((parseFloat(leaseFrm.leaseIn.value)*0.25*0.084687*3)+(75*3)).toFixed(2);
		leaseFrm.ptaxFeesUCS.value=leaseFrm.ptaxFeesOL.value;
		
		leaseFrm.autoRenewOL.value='$'+(parseFloat(leaseFrm.monthlyRentOL.value.substr(1))*2).toFixed(2);
		leaseFrm.autoRenewUCS.value=leaseFrm.autoRenewOL.value;
		
		leaseFrm.returnOL.value='$'+(parseFloat(leaseFrm.leaseIn.value)*0.05).toFixed(2);
		leaseFrm.returnUCS.value=leaseFrm.returnOL.value;
		
		leaseFrm.lateOL.value='$'+((parseFloat(leaseFrm.interimRentOL.value.substr(1))*0.1)*17).toFixed(2);
		leaseFrm.lateUCS.value=leaseFrm.lateOL.value;
		
		leaseFrm.totalUCL.value='$'+(parseFloat(leaseFrm.totalMonthlyUCL.value.substr(1))+95).toFixed(2);
		leaseFrm.totalOL.value='$'+(parseFloat(leaseFrm.interimRentOL.value.substr(1))+parseFloat(leaseFrm.totalMonthlyOL.value.substr(1))+parseFloat(leaseFrm.forcedInsuranceOL.value.substr(1))+95+parseFloat(leaseFrm.ptaxFeesOL.value.substr(1))+parseFloat(leaseFrm.autoRenewOL.value.substr(1))+parseFloat(leaseFrm.returnOL.value.substr(1))+parseFloat(leaseFrm.lateOL.value.substr(1))).toFixed(2);
		leaseFrm.totalUCS.value='$'+(parseFloat(leaseFrm.totalOL.value.substr(1))-parseFloat(leaseFrm.totalUCL.value.substr(1))).toFixed(2);
	}
}

function profit(field, e)
{
	var key;
	var frm = field.form;
	var otherFrm;
	var revFrm = document.getElementById('threeRevFrm');
	var roiFrm = document.getElementById('roiFrm');
	
	if(frm.name=='apronFrm')
	{
		otherFrm=document.getElementById('cruiserFrm');	
	}
	else if(frm.name=='cruiserFrm')
	{
		otherFrm=document.getElementById('apronFrm');
	}
	else if(frm.name=='roiFrm')
	{
		frm = document.getElementById('apronFrm');
		otherFrm = document.getElementById('cruiserFrm');
	}
	
	if(window.event)
	{
		key = window.event.keyCode;
	}
	else if(e)
	{
		key = e.which;
	}
	
	//Max value checks
	if(field.name.lastIndexOf('CostUnit')!=(-1) && parseFloat(field.value)>=1000)
	{
		field.value='999.99';
	}
	else if((field.name=='y1unit' || field.name=='y2unit' || field.name=='y3unit') && parseFloat(field.value)>=10000000)
	{
		field.value='9999999';
	}
	else if(field.name=='treatCost' && parseFloat(field.value)>=1000000)
	{
		field.value='999999.99';
	}
	
	//Do not calculate when NaN would result
	if((key<48 || key>57) && (field.value=='' || field.value=='.'))
	{
		return true;
	}
	else
	{
		frm.grossCostUnit.value=(parseFloat(frm.growerCostUnit.value)-parseFloat(frm.estCostUnit.value)).toFixed(2);
		frm.y1rev.value=(parseFloat(frm.grossCostUnit.value)*parseFloat(frm.y1unit.value)).toFixed(2);
		frm.y2rev.value=(parseFloat(frm.grossCostUnit.value)*parseFloat(frm.y2unit.value)).toFixed(2);
		frm.y3rev.value=(parseFloat(frm.grossCostUnit.value)*parseFloat(frm.y3unit.value)).toFixed(2);
		
		frm.totUnit.value=(parseFloat(frm.y1unit.value)+parseFloat(frm.y2unit.value)+parseFloat(frm.y3unit.value)).toFixed(2);
		frm.totRev.value=(parseFloat(frm.y1rev.value)+parseFloat(frm.y2rev.value)+parseFloat(frm.y3rev.value)).toFixed(2);
		
		revFrm.threeRev.value=(parseFloat(frm.totRev.value)+parseFloat(otherFrm.totRev.value)).toFixed(2);
		
		roiFrm.treatFin.value=((parseFloat(roiFrm.treatCost.value)*0.0333)*12).toFixed(2);
		if(parseFloat(roiFrm.treatCost.value)>0)
		{
			roiFrm.y1CostRoi.value=(((parseFloat(frm.y1rev.value)+parseFloat(otherFrm.y1rev.value))/parseFloat(roiFrm.treatCost.value))*100).toFixed(2);
			roiFrm.y2CostRoi.value=(((parseFloat(frm.y2rev.value)+parseFloat(otherFrm.y2rev.value))/parseFloat(roiFrm.treatCost.value))*100).toFixed(2);
			roiFrm.y3CostRoi.value=(((parseFloat(frm.y3rev.value)+parseFloat(otherFrm.y3rev.value))/parseFloat(roiFrm.treatCost.value))*100).toFixed(2);
			roiFrm.y1FinRoi.value=(((parseFloat(frm.y1rev.value)+parseFloat(otherFrm.y1rev.value))/parseFloat(roiFrm.treatFin.value))*100).toFixed(2);
			roiFrm.y2FinRoi.value=(((parseFloat(frm.y2rev.value)+parseFloat(otherFrm.y2rev.value))/parseFloat(roiFrm.treatFin.value))*100).toFixed(2);
			roiFrm.y3FinRoi.value=(((parseFloat(frm.y3rev.value)+parseFloat(otherFrm.y3rev.value))/parseFloat(roiFrm.treatFin.value))*100).toFixed(2);
		}
		else
		{
			roiFrm.y1CostRoi.value=0;
			roiFrm.y2CostRoi.value=0;
			roiFrm.y3CostRoi.value=0;
			roiFrm.y1FinRoi.value=0;
			roiFrm.y2FinRoi.value=0;
			roiFrm.y3FinRoi.value=0;
		}
	}
}

function onlyDigits(e, str)
{
	var key;
	
	if(window.event)
	{
		key = window.event.keyCode;
	}
	else if(e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	//alert(str.lastIndexOf('.')+'  '+key);
	
	if(key!=8 && key!=37 && key!=39 && key!=46 && key!=110 && key!=190 && (key<48 || key>57))
	{
		return false;
	}
	else if((key==190 || key==110 || key==46) && (str.lastIndexOf('.')!=(-1) || str.lastIndexOf('.')!=(-1)))
	{
		return false;
	}
	else
	{
		return true;
	}
}
