	row = 1;
	isIE = (document.all? true:false);
	
	var lastColumnTitle = new Array();
//			reduction['Energy'] = 'Carbon (CO<sub>2</sub>-e)<br>tonnes/yr';
//			reduction['Water'] = 'Water Savings (H<sub>2</sub>O)<br>litres/yr';
//			reduction['Finance'] = 'Carbon (CO<sub>2</sub>-e)<br>tonnes/yr';
//			reduction['Materials'] = 'Carbon (CO<sub>2</sub>-e)<br>tonnes/yr';
			lastColumnTitle["Energy"] = 'Carbon Reduction<br />(tonnes/yr)';
			lastColumnTitle["Water"] = 'Water Savings<br />(litres/yr)';
			lastColumnTitle["Finance"] = 'Carbon Reduction<br />(tonnes/yr)';
			lastColumnTitle["Recycling / Materials"] = 'Carbon Reduction<br />(tonnes)';
	
	
	var bgcolor = new Array();
			bgcolor['Energy'] = '#F2F2D3';
			bgcolor['Water'] = '#D3EAEA';
			bgcolor['Finance'] = '#DDEFD8';
			bgcolor['Recycling / Materials'] = '#EFE5DA';
	
	MyWishlist.prototype.elements = new Array();
	MyWishlist.prototype.tables = new Array();
	MyWishlist.prototype.group= new Array();
	MyWishlist.prototype.disables = new Array();
	MyWishlist.prototype.secdisables = new Array();
	MyWishlist.prototype.disableCount = new Array();

	
	function MyWishlist() { 
		this.add = function(elm, group, disables, secdisable) { 
			MyWishlist.prototype.elements[ MyWishlist.prototype.elements.length ] = elm;
			MyWishlist.prototype.group[ MyWishlist.prototype.elements.length ] = group;  
			MyWishlist.prototype.disables[ MyWishlist.prototype.elements.length ] = disables;
			MyWishlist.prototype.secdisables[ MyWishlist.prototype.elements.length ] = secdisable;
			MyWishlist.prototype.disableCount[ MyWishlist.prototype.elements.length ] = 0;
		}		
		this.count = function() { return MyWishlist.prototype.elements.length; }
		
		this.loadCookies = function() {
			var elements = MyWishlist.prototype.elements;
			var c = null;
			var loaded=0;
			
			for(i=1; i <= elements.length; i++) {
				c = readCookie('WishList2['+ i +']');
				
				if ( c != null && c != 0 ) { 
					setRadio( 'radio'+ i, 1 );
					el = c.split('%7C');
					setColumns(i, el[0] , 0);
					loaded++;
					if(loaded > elements.length) break;
				}
			}
			recalculate();
			return true;
		}
		
		this.clearAll = function() {
			var elements = MyWishlist.prototype.elements;
			var c = null;						
			// add 30 to length since length isn't actually right, it's a few too short. yeah, duct tape solutions for the win. -JT
			for(i=0; i <= elements.length+30; i++) {
				c = readCookie('WishList2['+ i +']');
				
				if(c) {
					el = c.split('%7C');
					toggleRadio( document.getElementById('radio'+  i));
					setColumns(i, el[0] , 1);
					if (wishlistForm.elements[i] != null )
					{
						if(wishlistForm.elements[i].selectedIndex>0){
							wishlistForm.elements[i].selectedIndex=-1;
						}
					}
					delCookie('WishList2['+ i +']');				
				}
				
			}

			recalculate();
			// and on the topic of duct-tape solutions. reload the sodding page to clear any leftover crap. sigh. i love IE.
			window.location.reload();
			
			return true;
		}
		
		this.display = function() {
		
			
			var elements = MyWishlist.prototype.elements;
			var groups = MyWishlist.prototype.group;
			var groupDisable = MyWishlist.prototype.disables;
			var lastCategory = "";
			for(i=0; i < elements.length; i++) {
				if( elements[i].category != lastCategory ) {
					
					if( lastCategory != "" ) printCategorySubTotal(lastCategory);
				 	
					MyWishlist.prototype.tables[ MyWishlist.prototype.tables.length ] = elements[i].category;
               	  	
					document.write('<form name=wishlistForm><table id="tbl'+ elements[i].category +'" width=880 border=0 cellspacing="0" cellpadding="6" bgcolor="#ebebea">'+
								   	'<tr align=left bgcolor='+ bgcolor[ elements[i].category ] +'>'+
											'<td width="30" style="border-bottom:2px dotted white;">&nbsp;</td>'+
											'<th style="width: 328px; border-bottom:2px dotted white;" class="orange">'+ elements[i].category +'</th>'+
											'<td style="border-bottom:2px dotted white;" width="75px" class="numbers">&nbsp;</td>'+
											'<td style="border-bottom:2px dotted white;" width="75px" class="numbers">&nbsp;</td>'+
											'<td style="border-bottom:2px dotted white;" width="75px" class="numbers">&nbsp;</td>'+
											'<td style="border-bottom:2px dotted white;" width="75px" class="numbers">&nbsp;</td>'+
											'<td align=center style="border-bottom:2px dotted white;" width="115" class="numbers orange">'+ lastColumnTitle[ elements[i].category ] +'</td>'+
									  '</tr>');
				}
				elements[i].display(i+1);
				
				lastCategory = elements[i].category;
			}
			printCategorySubTotal(lastCategory);
		}
		document.write('</form>');
	}
	/* ======================================================== */
	
	function printCategorySubTotal(cat) {
               	  		document.write('<tr align=left title="My '+ cat +' Sub-Total">'+
											'<td width="30" class="subtotalFields">&nbsp;</td>'+
											'<th class="subtotalFields">My '+ cat +' Sub-Total</th>'+
											'<td width="90" class="subtotalFields"><div id="subtotal'+ cat +'col1">&nbsp;</div></td>'+
											'<td width="75" class="subtotalFields"><div id="subtotal'+ cat +'col2">&nbsp;</div></td>'+
											'<td width="75" class="subtotalFields"><div id="subtotal'+ cat +'col3">&nbsp;</div></td>'+
											'<td width="75" class="subtotalFields"><div id="subtotal'+ cat +'col4">&nbsp;</div></td>'+
											'<td width="115" class="subtotalFields"><div id="subtotal'+ cat +'col5">&nbsp;</div></td>'+
									  '</tr></table>');	
	}
	/* ======================================================== */
	
	WishlistElement.prototype.elements = new Array();
	function getWishlistElement(id) { return WishlistElement.prototype.elements[id]; }
	
	function WishlistElement(_category, _name, _rebate, _oneYear, _tenYears, _twentyfiveYears, _reduction, _group, _nocalc) {
		category = name = rebate = oneYear = tenYears = twentyfiveYears = reduction = 0;
		group = -1;
		this.category = _category;
		this.name = _name;
		this.rebate = number_format(parseFloat(_rebate), 2, '.','');
		if((this.category == 'Finance') || (this.category == 'Water') || _nocalc == true){
			this.oneYear = number_format(parseFloat(_oneYear+_rebate), 2, '.','');
			if(_nocalc == true){
				this.oneYear = number_format(parseFloat(_oneYear), 2, '.','');
			}
			this.tenYears = number_format(parseFloat(_tenYears), 2, '.','');
			this.twentyfiveYears = number_format(parseFloat(_twentyfiveYears), 2, '.','');
		}else{
			this.oneYear = number_format(parseFloat(_oneYear+_rebate), 2, '.','');
			this.tenYears = number_format(parseFloat(_oneYear*10), 2, '.','');
			this.twentyfiveYears = number_format(parseFloat(_oneYear*25), 2, '.','');
		}
		this.reduction = number_format(parseFloat(_reduction), 2, '.','');
		
		this.group = _group;
		
		WishlistElement.prototype.elements[ WishlistElement.prototype.elements.length ] = this;
		this.ID = WishlistElement.prototype.elements.length-1;
		
		this.count = function() { return WishlistElement.prototype.elements.length; }
		
		this.display = function(myID) {
				document.write('<tr align=left id="row'+ row +'"	bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td class="group'+MyWishlist.prototype.group[myID]+'" width=30><img  src="images/radio_0.png" id="radio'+ row +'" state="0" title="radio'+ row +'" onClick="toggleRadio(this, '+myID+'); setColumns('+ row +', '+ this.ID +', 1 ); recalculate();"></td>'+
								'<td>'+ 
								'<img src="images/i.gif" border=0 title="Click here for more information!" style="float:right; cursor:pointer;" onClick="window.open(\'info.php?item='+ this.name +'\',\'\',\'width=800, height=600, status=no, toolbar=no, menu=no\');">'+
								this.name +
								'</td>'+
								'<td width="75" name="col1" class="numbers"><div id="row'+ row +'col1">&nbsp;</div></td>'+
								'<td width="75"name="col2" class="numbers"><div id="row'+ row +'col2">&nbsp;</div></td>'+
								'<td width="75" name="col3" class="numbers"><div id="row'+ row +'col3">&nbsp;</div></td>'+
								'<td width="75" name="col4" class="numbers"><div id="row'+ row +'col4">&nbsp;</div></td>'+
								'<td width="115" name="col5" class="numbers"><div id="row'+ row +'col5" tag="Not Set">&nbsp;</div></td>'+
						 		'</tr>');
				row++;
		}
				
	}
	/* ======================================================== */

	function WishlistElementText(_category, _name ) {
		category = name = 0;
		this.category = _category;
		this.name = _name;
		this.mode = 'text';
		
		WishlistElement.prototype.elements[ WishlistElement.prototype.elements.length ] = this;
		this.ID = WishlistElement.prototype.elements.length-1;
		
		this.count = function() { return WishlistElement.prototype.elements.length; }
		
		this.display = function(myID) {
			if(myID == 'materials'){
				document.write('<tr align=left id="row'+ row +'"	bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td width=30>&nbsp;</td>'+
								'<td colspan="1" style="font-size: 12px; text-align: center;">'+this.name+'</td>'+
								'<td colspan="1" style="font-size: 12px;">&nbsp;</td>'+
								

						 		'</tr>');				
			}else{
				document.write('<tr align=left id="row'+ row +'"	bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td width=30>&nbsp;</td>'+
								'<td colspan="1" style="font-size: 12px; text-align: center;">'+this.name+'</td>'+
								'<td colspan="1" style="font-size: 12px;">&nbsp;</td>'+
								'<td colspan="1" style="font-size: 12px;">&nbsp;</td>'+
								'<td colspan="1" style="font-size: 12px;">&nbsp;</td>'+
								'<td colspan="1" style="font-size: 12px;">&nbsp;</td>'+
								'<td colspan="1" style="font-size: 12px;">&nbsp;</td>'+
						 		'</tr>');
			}
				row++;
		}
				
	}
	
	function WishlistElementHeading(_category, _name ) {
		category = name = 0;
		this.category = _category;
		this.name = _name;
		this.mode = 'text';

		
		WishlistElement.prototype.elements[ WishlistElement.prototype.elements.length ] = this;
		this.ID = WishlistElement.prototype.elements.length-1;
		
		this.count = function() { return WishlistElement.prototype.elements.length; }
		
		this.display = function(myID, tL, tTL, tHTML) {
			if(myID == 'materials'){
				
var html = '<tr align=left id="row'+ row +'" bgcolor='+ bgcolor[ this.category ] +'>'+
									'<td  width=35></td>'+
							'<td style="color: orange; font-weight: bold; font-size: 12px;">'+
								'<img src="images/i.gif" border=0 title="Click here for more information!" style="float:right; cursor:pointer;" onClick="window.open(\'info.php?item='+ this.name +'\',\'\',\'width=600, height=800, status=no, toolbar=no, menu=no\');">'+
								this.name +
								
							'</td>'+	
							
							(tL==0? '<td width="300" colspan=4 rowspan='+ tTL +' align=center valign=center>'+ tHTML +'</td>':'')+							
'<td colspan="1" style="font-size: 12px;border-left: 1px solid white;">&nbsp;</td>'+
'</tr>';
				document.write(html);
				/*document.write('<tr align=left id="row'+ row +'"	bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td class="group'+MyWishlist.prototype.group[myID]+'" width=30>&nbsp;</td>'+
								'<td colspan="1" style="color: orange; font-weight: bold; font-size: 12px;">'+this.name+

								'<img src="images/i.gif" border=0 title="Click here for more information!" style="float:right; cursor:pointer;" onClick="window.open(\'info.php?item='+ this.name +'\',\'\',\'width=800, height=600, status=no, toolbar=no, menu=no\');">'+								
								'</td>'+
								'<td colspan="1" style="font-size: 12px;border-left: 1px solid white;">&nbsp;</td>'+
								

						 		'</tr>');		*/
				
			}else{
				document.write('<tr align=left id="row'+ row +'"	bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td class="group'+MyWishlist.prototype.group[myID]+'" width=30>&nbsp;</td>'+
								'<td colspan="6" style="color: orange; font-weight: bold; font-size: 12px;">'+this.name+'</td>'+
						 		'</tr>');
			}
				row++;
		}
				
	}


	/* ======================================================== */
	
	//WishlistElementList.prototype.elements = new Array();
	function WishlistElementList(_category, _name) {
		var category = name = "";
		this.elements = new Array();
		
		this.category = _category;
		this.name = _name;
		
		this.add = function(elm) { this.elements[ this.elements.length ] = elm; }
		
		this.display = function(myID) {
			var listElements = this.elements;
			
			var html = '<tr align=left  id="row'+ row +'" bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td class="group'+MyWishlist.prototype.group[myID]+'" width=30><img  src="images/radio_0.png" id="radio'+ row +'" state="0" onClick="setRadio(\'radio'+ row +'\', -1, '+myID+'); setColumns('+ row +', 0, 1); wishlistForm.slct'+row+'id.selectedIndex=0; recalculate();" ></td>'+
								'<td>'+
								'<img src="images/i.gif" border=0 title="Click here for more information!" style="float:right; cursor:pointer;" onClick="window.open(\'info.php?item='+ this.name +'\',\'\',\'width=800, height=600, status=no, toolbar=no, menu=no\');">'+
								'<select class="gsel'+MyWishlist.prototype.group[myID]+'" id="slct'+row+'id" size=1 onChange="setRadio(\'radio'+ row +'\', this.options[this.selectedIndex].value, '+myID+'); setColumns('+ row +', this.options[this.selectedIndex].value, 1); recalculate();" style="width:310px; float:left; border:none; background-color:'+ bgcolor[ this.category ] +'; color:black;">'+
								'<option value="-1" style=" border:none; background-color:'+ bgcolor[ this.category ] +'; color:black; font-weight:bold;" selected>'+ this.name +'</option>';
			
// onClick="setColumns('+ row +','+ elm.get() +');"
			for(l=0; l<listElements.length; l++) {
				var elm = listElements[l];
				html += '<option value="'+ elm.ID +'" style="border:none; background-color:#68c8ca; color:white;" >'+ elm.name +'</option>';
			}
		
				html += '</select></td>'+
						'<td width="75" name="col1" class="numbers"><div id="row'+ row +'col1">&nbsp;</div></td>'+
						'<td width="75" name="col2" class="numbers"><div id="row'+ row +'col2">&nbsp;</div></td>'+
						'<td width="75" name="col3" class="numbers"><div id="row'+ row +'col3">&nbsp;</div></td>'+
						'<td width="75" name="col4" class="numbers"><div id="row'+ row +'col4">&nbsp;</div></td>'+
						'<td width="115" name="col5" class="numbers"><div id="row'+ row +'col5" tag="Not Set">&nbsp;</div></td>'+
						'</tr>';
			document.write(html);
			row++;
		}
	}
	/* ======================================================== */
	
	function WishlistElementHollow(_category, _name, _html) {
		category = name = "";
		this.elements = new Array();
		this.category = _category;
		this.name = _name;
		this.group = new Array();
		this.disables = new Array();
		this.disableCount = new Array();
		
		this.add = function(elm, group, disables) { 
			this.elements[ this.elements.length ] = elm;
			this.group[ this.elements.length ] = group;  
			this.disables[ this.elements.length ] = disables;			
			this.disableCount[ this.elements.length ] = 0;
		}
		
		this.display = function(myID) {
			var listElements = this.elements;
			
			for(l=0; l<listElements.length; l++) {
				var elm = listElements[l];
				if(elm.mode=='text'){
					elm.display('materials', l, listElements.length, _html);
				}else{
					var html = '<tr align=left id="row'+ row +'" bgcolor='+ bgcolor[ this.category ] +'>'+
									'<td class="group'+this.group[elm.ID]+'"  width=30><img   src="images/radio_0.png" id="radio'+ row +'" state="0" title="radio'+ row +'" onClick="toggleRadio(this, '+elm.ID+'); setColumns('+ row +', '+ elm.ID +', 1 ); recalculate();"></td>'+
							'<td>'+
								'<img src="images/i.gif" border=0 title="Click here for more information!" style="float:right; cursor:pointer;" onClick="window.open(\'info.php?item='+ elm.name +'\',\'\',\'width=600, height=800, status=no, toolbar=no, menu=no\');">'+
								elm.name +
							'</td>'+					
							(l==0? '<td width="300" colspan=4 rowspan='+ listElements.length +' align=center valign=center>'+ _html +'</td>':'')+
							'<td width="115" name="col5" class="numbers"><div id="row'+ row +'col5" tag="Not Set">&nbsp;</div></td>'+
							'</tr>';
					document.write(html);
				}
				row++;
			}
			
		}
	}
	/* ======================================================== */

	function WishlistElementNote(_category, _html) {
		category = name = "";
		this.category = _category;
		this.note = _html;
		
		this.display = function() {
				var html = '<tr align=left id="row'+ row +'" bgcolor='+ bgcolor[ this.category ] +'>'+
								'<td style="padding:2px; padding-left:40px; border-top:2px dotted white; border-bottom:2px dotted white; font-size:11px; " colspan=7 align=left valign=top>'+ this.note +'</td>'+
							'</tr>';
				document.write(html);
				row++;
		}
	}
	/* ======================================================== */


	MyWishlist.prototype.className = "Wishlist";
	WishlistElement.prototype.className = "WishlistElement";
	WishlistElementHollow.prototype.className = "WishlistElementHollow";
	WishlistElementList.prototype.className = "WishlistElementList";
	WishlistElementNote.prototype.className = "WishlistElementNote";	
	/* ======================================================== */
	/* ======================================================== */

	
	function setColumns(row, elID, storeCookie) {
		if (storeCookie == '') storeCookie = 0;
		
		var el = getWishlistElement(elID);
		
		  if (isIE) {
		  	var radio = document.all('radio'+row);
		  } else {
		  	var radio = document.getElementById('radio'+row);
		  }
		  
		if ( !radio ) return false;
		
		if(el && radio.state=='1') {
			if(document.getElementById('row'+ row +'col1')) document.getElementById('row'+ row +'col1').innerHTML = number_format(parseFloat(el.rebate), 0, '.','');
			if(document.getElementById('row'+ row +'col2')) document.getElementById('row'+ row +'col2').innerHTML = number_format(parseFloat(el.oneYear), 0, '.','');
			if(document.getElementById('row'+ row +'col3')) document.getElementById('row'+ row +'col3').innerHTML = number_format(parseFloat(el.tenYears), 0, '.','');
			if(document.getElementById('row'+ row +'col4')) document.getElementById('row'+ row +'col4').innerHTML = number_format(parseFloat(el.twentyfiveYears), 0, '.','');
			if(document.getElementById('row'+ row +'col5')) document.getElementById('row'+ row +'col5').innerHTML = (el.reduction == "NaN.00"? "n/a" : number_format(parseFloat(el.reduction), (el.category == 'Water'? 0:2), '.','') );
			if(document.getElementById('row'+ row +'col5')) document.getElementById('row'+ row +'col5').tag = el.category;
			if (storeCookie > 0) setCookie('WishList2['+ row +']', el.ID +'|'+ el.category +'|'+ el.name +'|'+ el.rebate +'|'+ el.oneYear +'|'+ el.tenYears +'|'+ el.twentyfiveYears +'|'+ el.reduction);
		} else {
			if(document.getElementById('row'+ row +'col1')) document.getElementById('row'+ row +'col1').innerHTML = "&nbsp;";
			if(document.getElementById('row'+ row +'col2')) document.getElementById('row'+ row +'col2').innerHTML = "&nbsp;";
			if(document.getElementById('row'+ row +'col3')) document.getElementById('row'+ row +'col3').innerHTML = "&nbsp;";
			if(document.getElementById('row'+ row +'col4')) document.getElementById('row'+ row +'col4').innerHTML = "&nbsp;";
			if(document.getElementById('row'+ row +'col5')) document.getElementById('row'+ row +'col5').innerHTML = "&nbsp;";
			if(document.getElementById('row'+ row +'col5')) document.getElementById('row'+ row +'col5').tag = "Not Set";
			if (storeCookie > 0) setCookie('WishList2['+ row +']', "", -1);
		}		
		
	}
	/* ======================================================== */
	
	function recalculate() {
		
		var tables = MyWishlist.prototype.tables;
		total_rebate = total_oneYear = total_tenYears = total_twentyfiveYears = total_carbon = total_water = 0;
		
		for(var t=0; t<tables.length; t++) {
			if (isIE) {
				var tbl = document.all('tbl'+ tables[t]);
			} else {
				var tbl = document.getElementById('tbl'+ tables[t]);
			}
		
			var rows = tbl.getElementsByTagName('tr');
	
			_rebate = _oneYear = _tenYears = _twentyfiveYears = _carbon = _water = 0;
			
			for (var row=1; row<rows.length-1;row++) {
			
			  	var cols = rows[row].getElementsByTagName('td');
	
			  	var radio = cols[0].getElementsByTagName('img')[0]; 

				if (radio && radio.state == '1') {
					if( cols.length == 7 ) {
						
						_rebate += parseFloat( cols[2].getElementsByTagName('div')[0].innerHTML );
						_oneYear += parseFloat( cols[3].getElementsByTagName('div')[0].innerHTML );
						_tenYears += parseFloat( cols[4].getElementsByTagName('div')[0].innerHTML );
						_twentyfiveYears += parseFloat( cols[5].getElementsByTagName('div')[0].innerHTML );
						
						_lastColumn =  cols[6].getElementsByTagName('div')[0];
					} else {
						_lastColumn =  cols[2].getElementsByTagName('div')[0];
					}
					if(_lastColumn.tag){
						if (_lastColumn.tag == "Energy") {
							_carbon += parseFloat( (_lastColumn.innerHTML != 'n/a'? _lastColumn.innerHTML:0) );
						} else if (_lastColumn.tag == "Recycling / Materials") {
							_carbon += parseFloat( (_lastColumn.innerHTML != 'n/a'? _lastColumn.innerHTML:0) );
						} else if (_lastColumn.tag == "Finance") {
							_carbon += parseFloat( (_lastColumn.innerHTML != 'n/a'? _lastColumn.innerHTML:0) );
						} else if (_lastColumn.tag	 == "Water") {
							_water += parseFloat( (_lastColumn.innerHTML != 'n/a'? _lastColumn.innerHTML:0) );
						}
					}
			  	}
			  
			}

//			document.getElementById('subtotal'+ tables[t] +'col1').innerHTML = "$"+ number_format(parseFloat(_rebate), 0, '.','');
			document.getElementById('subtotal'+ tables[t] +'col2').innerHTML = "$"+ number_format(parseFloat(_oneYear), 0, '.',',');
			document.getElementById('subtotal'+ tables[t] +'col3').innerHTML = "$"+ number_format(parseFloat(_tenYears), 0, '.',',');
			document.getElementById('subtotal'+ tables[t] +'col4').innerHTML = "$"+ number_format(parseFloat(_twentyfiveYears), 0, '.',',');
//			document.getElementById('subtotal'+ tables[t] +'col5').innerHTML = number_format(parseFloat((_carbon? _carbon:_water)), 0, '.','');

			
			total_rebate += _rebate;
			total_oneYear += _oneYear;
			total_tenYears += _tenYears;
			total_twentyfiveYears += _twentyfiveYears;
			total_carbon += _carbon;
			total_water += _water;


		}

		if(document.getElementById('totalField1')) document.getElementById('totalField1').value = "$"+ number_format(parseFloat(total_oneYear), 0, '.',',');
		if(document.getElementById('totalField2')) document.getElementById('totalField2').value = "$"+ number_format(parseFloat(total_tenYears), 0, '.',',');
		if(document.getElementById('totalField3')) document.getElementById('totalField3').value = "$"+ number_format(parseFloat(total_twentyfiveYears), 0, '.',',');
		if(document.getElementById('totalField4')) document.getElementById('totalField4').value = number_format(parseFloat(total_carbon), 2, '.','');
		if(document.getElementById('totalField5')) document.getElementById('totalField5').value = number_format(parseFloat(total_water), 0, '.',',');
		
	}
	/* ======================================================== */

	function toggleRadio(el, myID) {
		el.state = (el.state != '1'? '1':'0');
		el.src = 'images/radio_'+ el.state +'.png';
		iDisable = MyWishlist.prototype.disables[myID]; 
		iAlsoDisable = MyWishlist.prototype.secdisables[myID]; 
		if(iDisable >=1 ){			
			if(el.state == 1){
				setStyleByClass('td', 'group'+iDisable, 'visibility', 'hidden');
				setOptionByClass('select', 'gsel'+iDisable, 'disabled', 'true');				
				MyWishlist.prototype.disableCount[iDisable]++;				
			}else{
				MyWishlist.prototype.disableCount[iDisable]--;	
				if(MyWishlist.prototype.disableCount[iDisable]==0){
					setStyleByClass('td', 'group'+iDisable, 'visibility', 'visible');
					setOptionByClass('select', 'gsel'+iDisable, 'disabled', 'false');
					
				}							
	
			}
			
		}
		if(iAlsoDisable >=1 ){			
			if(el.state == 1){
				setStyleByClass('td', 'group'+iAlsoDisable, 'visibility', 'hidden');
				setOptionByClass('select', 'gsel'+iAlsoDisable, 'disabled', 'true');
				//MyWishlist.prototype.disableCount[iAlsoDisable]++;				
			}else{
				//MyWishlist.prototype.disableCount[iAlsoDisable]--;	
				//if(MyWishlist.prototype.disableCount[iAlsoDisable]==0){
					setStyleByClass('td', 'group'+iAlsoDisable, 'visibility', 'visible');
					setOptionByClass('select', 'gsel'+iAlsoDisable, 'disabled', 'false');	
				//}							
	
			}
			
		}		
	}
	
	function setRadio(el, value, myID) {
		if(!document.getElementById(el)) return; 
		iDisable = MyWishlist.prototype.disables[myID];
		iAlsoDisable = MyWishlist.prototype.secdisables[myID]; 	
		
		document.getElementById(el).state = (value >= 0? 1:0);
		document.getElementById(el).src = 'images/radio_'+ (value >= 0? 1:0) +'.png';
		
		if(iDisable >=1 ){
			if(value >=0){
				MyWishlist.prototype.disableCount[iDisable]=1;
				setStyleByClass('td', 'group'+iDisable, 'visibility', 'hidden');
				setOptionByClass('select', 'gsel'+iDisable, 'disabled', 'true');
			}else{
				MyWishlist.prototype.disableCount[iDisable]=0;	
				if(MyWishlist.prototype.disableCount[iDisable]==0){
					setStyleByClass('td', 'group'+iDisable, 'visibility', 'visible');	
					setOptionByClass('select', 'gsel'+iDisable, 'disabled', 'false');
				}				

			}
		}
		if(iAlsoDisable >=1 ){		

			if(value >= 1){
				setStyleByClass('td', 'group'+iAlsoDisable, 'visibility', 'hidden');
				setOptionByClass('select', 'gsel'+iAlsoDisable, 'disabled', 'true');
				//MyWishlist.prototype.disableCount[iAlsoDisable]++;				
			}else{
				//MyWishlist.prototype.disableCount[iAlsoDisable]--;	
				//if(MyWishlist.prototype.disableCount[iAlsoDisable]==0){
					setStyleByClass('td', 'group'+iAlsoDisable, 'visibility', 'visible');
					setOptionByClass('select', 'gsel'+iAlsoDisable, 'disabled', 'false');
				//}							
	
			}
			
		}		
		
		
	}
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;

		elements = document.getElementsByTagName(t);

	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

function setOptionByClass(t,c,p,v){
	var elements;
		elements = document.getElementsByTagName(t);
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					if(v=='true'){
						eval('node.' + p + " = 'disabled'");
					}else{
					   eval('node.' + p + " = ''");	
					}
				}
			}
		}
	}
}

/* ======================================================== */

	function number_format(a, b, c, d) {
		a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
		e = a + '';
		f = e.split('.');
		if(!f[0]) f[0] = '0';
		if(!f[1]) f[1] = '';
		if(f[1].length < b) {
			g = f[1];
			for(i = f[1].length + 1; i <= b; i++) { g += '0'; }
			f[1] = g;
		}
		if(d != '' && f[0].length > 3) {
			h = f[0];
			f[0] = '';
			for(j = 3; j < h.length; j += 3) {
				i = h.slice(h.length - j, h.length - j + 3);
				f[0] = d + i + f[0] + '';
			}
			j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
			f[0] = j + f[0];
		}
		c = (b <= 0) ? '': c;
		return f[0] + c + f[1];
	}
	/* ======================================================== */

	function setCookie(name, value) {
		var exp = new Date();
		exp.setTime(exp.getTime() + (1000 * 60 * 60 * 7));  // current time + 1 week
		document.cookie = name + "=" + escape(value) + "; path=/" + ((exp == null) ? "" : "; expires=" + exp.toGMTString());
	} 
	
	function delCookie(name) {
		var value = "blah";
		var exp = new Date();
		exp.setTime(1);		
		document.cookie = name + "=" + escape(value) + "; path=/" + ((exp == null) ? "" : "; expires=" + exp.toGMTString());
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
