var addNumTrees=1;
var treeTypes=1;

function addAnotherTreeType(){
	var treeTypesSpan=document.getElementById("treeTypes");
	var typesInnerHtml=treeTypesSpan.innerHTML;
	var storeCurrentData=storeCurrent();
	treeTypes=treeTypes+1;
	var theNewInnerHTML=typesInnerHtml+getTreeTypeSpan(treeTypes);
	treeTypesSpan.innerHTML=theNewInnerHTML;
	restoreData(storeCurrentData);
}
function storeCurrent(){
	var current=new Array();
	for(var i=1;i<=treeTypes;i++){
		var spanName="tree"+i;
		if(document.getElementById(spanName).innerHTML.length>0){
			current[current.length]=getCurrent(i);
		}
	}
	return(current);
}
function getCurrent(spanNumber){
	var theArray=new Array();
	theArray[0]=spanNumber;
	var theId="qty"+spanNumber;
	theArray[1]=document.getElementById(theId).value;
	theId="treeSpecies"+spanNumber;
	theArray[2]=document.getElementById(theId).selectedIndex;
	theId="size"+spanNumber;
	theArray[3]=document.getElementById(theId).selectedIndex;
	theId="year"+spanNumber;
	theArray[4]=document.getElementById(theId).selectedIndex;
	theId="season"+spanNumber;
	theArray[5]=document.getElementById(theId).selectedIndex;
	theId="property_name"+spanNumber;
	theArray[6]=document.getElementById(theId).value;
	theId="property_type"+spanNumber;
	theArray[7]=document.getElementById(theId).selectedIndex;
	theId="borough"+spanNumber;
	theArray[8]=document.getElementById(theId).selectedIndex;
	theId="zip"+spanNumber;
	theArray[9]=document.getElementById(theId).value;
	return(theArray);
}
function restoreData(storedData){
	for(var i=0;i<storedData.length;i++){
		var spanNumber=storedData[i][0];
		var theId="qty"+spanNumber;
		document.getElementById(theId).value=storedData[i][1];
		theId="treeSpecies"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][2];
		theId="size"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][3];
		theId="year"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][4];
		theId="season"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][5];
		theId="property_name"+spanNumber;
		document.getElementById(theId).value=storedData[i][6];
		theId="property_type"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][7];
		theId="borough"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][8];
		theId="zip"+spanNumber;
		document.getElementById(theId).value=storedData[i][9];
	}
}
function getTreeTypeSpan(typeNumber){
	var theSpan='<span id="tree'+typeNumber+'"><div id="section">';
	if(typeNumber==1){
		theSpan=theSpan+'<p><strong>What Did You Plant?</strong></p>';
	}
	theSpan=theSpan+'<table><tr><td><span id="red">*</span>Qty</td><td><span id="red">*</span>Tree Type</td><td><span id="red">*</span>Size</td><td><span id="red">*</span>Year</td><td><span id="red">*</span>Season</td></tr>';
	theSpan=theSpan+'<tr><td><input maxlength="3" name="Qty '+typeNumber+'" size="3" style="WIDTH: 40px; HEIGHT: 22px" id="qty'+typeNumber+'"></td>';
	theSpan=theSpan+'<td><select name="Tree Type '+typeNumber+'" id="treeSpecies'+typeNumber+'" style="WIDTH: 208px"><option value="" selected></option>';
	theSpan=theSpan+'<option value="Arborvitae (Thuja)">Arborvitae (Thuja)</option>';
	theSpan=theSpan+'<option value="Ash (Fraxinus)">Ash (Fraxinus)</option>';
	theSpan=theSpan+'<option value="Beech (Fagus)">Beech (Fagus)</option>';
	theSpan=theSpan+'<option value="Birch (Betula)">Birch (Betula)</option>';
	theSpan=theSpan+'<option value="Catalpa (Catalpa)">Catalpa (Catalpa)</option>';
	theSpan=theSpan+'<option value="Cedar (Cedrus)">Cedar (Cedrus)</option>';
	theSpan=theSpan+'<option value="Cedar, Atlantic White (Chamaecyparis)">Cedar, Atlantic White (Chamaecyparis)</option>';
	theSpan=theSpan+'<option value="Cherry (Prunus)">Cherry (Prunus)</option>';
	theSpan=theSpan+'<option value="Coffee Tree, Kentucky (Gymnocladus)">Coffee Tree, Kentucky (Gymnocladus)</option>';
	theSpan=theSpan+'<option value="Cornelian Cherry (Cornus)">Cornelian Cherry (Cornus)</option>';
	theSpan=theSpan+'<option value="Crabapple (Malus)">Crabapple (Malus)</option>';
	theSpan=theSpan+'<option value="Crepe myrtle (Lagerstroemia)">Crepe myrtle (Lagerstroemia)</option>';
	theSpan=theSpan+'<option value="Cryptomeria (Cryptomeria)">Cryptomeria (Cryptomeria)</option>';
	theSpan=theSpan+'<option value="Cypress (Taxodium)">Cypress (Taxodium)</option>';
	theSpan=theSpan+'<option value="Cypress (Chamaecyparis)">Cypress (Chamaecyparis)</option>';
	theSpan=theSpan+'<option value="Dogwood (Cornus)">Dogwood (Cornus)</option>';
	theSpan=theSpan+'<option value="Dovetree (Davidia)">Dovetree (Davidia)</option>';
	theSpan=theSpan+'<option value="Elm (Ulmus)">Elm (Ulmus)</option>';
	theSpan=theSpan+'<option value="Fig (Ficus)">Fig (Ficus)</option>';
	theSpan=theSpan+'<option value="Filbert (Corylus)">Filbert (Corylus)</option>';
	theSpan=theSpan+'<option value="Fir (Abies)">Fir (Abies)</option>';
	theSpan=theSpan+'<option value="Fringetree (Chionanthus)">Fringetree (Chionanthus)</option>';
	theSpan=theSpan+'<option value="Ginkgo (Ginkgo)">Ginkgo (Ginkgo)</option>';
	theSpan=theSpan+'<option value="Goldenchain tree (Laburnum)">Goldenchain tree (Laburnum)</option>';
	theSpan=theSpan+'<option value="Goldenraintree (Koelreuteria)">Goldenraintree (Koelreuteria)</option>';
	theSpan=theSpan+'<option value="Hackberry (Celtis)">Hackberry (Celtis)</option>';
	theSpan=theSpan+'<option value="Hawthorn (Crataegus)">Hawthorn (Crataegus)</option>';
	theSpan=theSpan+'<option value="Hickory (Carya)">Hickory (Carya)</option>';
	theSpan=theSpan+'<option value="Holly (Ilex)">Holly (Ilex)</option>';
	theSpan=theSpan+'<option value="Honeylocust (Gleditsia)">Honeylocust (Gleditsia)</option>';
	theSpan=theSpan+'<option value="Hophornbeam (Ostrya)">Hophornbeam (Ostrya)</option>';
	theSpan=theSpan+'<option value="Hornbeam (Carpinus)">Hornbeam (Carpinus)</option>';
	theSpan=theSpan+'<option value="Horsechestnut (Aesculus)">Horsechestnut (Aesculus)</option>';
	theSpan=theSpan+'<option value="Japanese lilac tree (Syringa)">Japanese lilac tree (Syringa)</option>';
	theSpan=theSpan+'<option value="Juniper (Juniperus)">Juniper (Juniperus)</option>';
	theSpan=theSpan+'<option value="Kasturatree (Cercidiphyllum)">Kasturatree (Cercidiphyllum)</option>';
	theSpan=theSpan+'<option value="Larch (Larix)">Larch (Larix)</option>';
	theSpan=theSpan+'<option value="Linden (Tilia)">Linden (Tilia)</option>';
	theSpan=theSpan+'<option value="Locust (Robinia)">Locust (Robinia)</option>';
	theSpan=theSpan+'<option value="Maackia (Maackia)">Maackia (Maackia)</option>';
	theSpan=theSpan+'<option value="Magnolia (Magnolia)">Magnolia (Magnolia)</option>';
	theSpan=theSpan+'<option value="Maple (Acer)">Maple (Acer)</option>';
	theSpan=theSpan+'<option value="Mountain ash (Sorbus)">Mountain ash (Sorbus)</option>';
	theSpan=theSpan+'<option value="Oak (Quercus)">Oak (Quercus)</option>';
	theSpan=theSpan+'<option value="Olive (Elaeagnus)">Olive (Elaeagnus)</option>';
	theSpan=theSpan+'<option value="Pagodatree (Styphnolobium)">Pagodatree (Styphnolobium)</option>';
	theSpan=theSpan+'<option value="Parrotia (Parrotia)">Parrotia (Parrotia)</option>';
	theSpan=theSpan+'<option value="Pear (Pyrus)">Pear (Pyrus)</option>';
	theSpan=theSpan+'<option value="Pine (Pinus)">Pine (Pinus)</option>';
	theSpan=theSpan+'<option value="Planetree (Platanus x acerifolia)">Planetree (Platanus x acerifolia)</option>';
	theSpan=theSpan+'<option value="Plum (Prunus cerasifera)">Plum (Prunus cerasifera)</option>';
	theSpan=theSpan+'<option value="Popular (Populus)">Popular (Populus)</option>';
	theSpan=theSpan+'<option value="Redbud (Cercis)">Redbud (Cercis)</option>';
	theSpan=theSpan+'<option value="Redcedar (Juniperus)">Redcedar (Juniperus)</option>';
	theSpan=theSpan+'<option value="Redwood (Metasequoia)">Redwood (Metasequoia)</option>';
	theSpan=theSpan+'<option value="Rubber tree (Eucommia)">Rubber tree (Eucommia)</option>';
	theSpan=theSpan+'<option value="Serviceberry (Amelanchier)">Serviceberry (Amelanchier)</option>';
	theSpan=theSpan+'<option value="Silverbell (Halesia)">Silverbell (Halesia)</option>';
	theSpan=theSpan+'<option value="Smoke tree (Cotinus)">Smoke tree (Cotinus)</option>';
	theSpan=theSpan+'<option value="Snowbell (Styrax)">Snowbell (Styrax)</option>';
	theSpan=theSpan+'<option value="Sourwood (Oxydendron)">Sourwood (Oxydendron)</option>';
	theSpan=theSpan+'<option value="Spruce (Picea)">Spruce (Picea)</option>';
	theSpan=theSpan+'<option value="Stewartia (Stewartia)">Stewartia (Stewartia)</option>';
	theSpan=theSpan+'<option value="Sweetgum (Liquidambar)">Sweetgum (Liquidambar)</option>';
	theSpan=theSpan+'<option value="Sycamore (Platanus)">Sycamore (Platanus)</option>';
	theSpan=theSpan+'<option value="Tuliptree (Liriodendron)">Tuliptree (Liriodendron)</option>';
	theSpan=theSpan+'<option value="Tupelo (Nyssa)">Tupelo (Nyssa)</option>';
	theSpan=theSpan+'<option value="Walnut (Juglans)">Walnut (Juglans)</option>';
	theSpan=theSpan+'<option value="Willow (Salix)">Willow (Salix)</option>';
	theSpan=theSpan+'<option value="Witchhazel (Hamamellis)">Witchhazel (Hamamellis)</option>';
	theSpan=theSpan+'<option value="Yellowwood (Cladrastis)">Yellowwood (Cladrastis)</option>';
	theSpan=theSpan+'<option value="Zelkova (Zelkova)">Zelkova (Zelkova)</option>';
	theSpan=theSpan+'<option value="Unkown">Unkown</option>';
	theSpan=theSpan+'<option value="Other">Other</option></select></td>';
	theSpan=theSpan+'<td><select name="Tree Size '+typeNumber+'" style="WIDTH: 105px" id="size'+typeNumber+'">';
	theSpan=theSpan+'<option value="" selected></option><option value="2 - 3 ft">2 - 3 ft</option>';
	theSpan=theSpan+'<option value="4 - 5 ft">4 - 5 ft</option><option value="6 ft &amp; Up">6 ft &amp; Up</option></select></td>';
	theSpan=theSpan+'<td><select name="Year '+typeNumber+'" style="WIDTH: 55px" id="year'+typeNumber+'"><option value="" selected></option>';
	theSpan=theSpan+'<option value="2007">2007</option><option value="2008">2008</option><option value="2008">2009</option>';
	theSpan=theSpan+'<option value="2008">2010</option><option value="2008">2011</option><option value="2008">2012</option>';
	theSpan=theSpan+'<option value="2008">2013</option><option value="2008">2014</option><option value="2008">2015</option>';
	theSpan=theSpan+'<option value="2008">2016</option><option value="2008">2017</option></select></td>';
	theSpan=theSpan+'<td><select name="Season '+typeNumber+'" style="WIDTH: 65px" id="season'+typeNumber+'"><option value="" selected></option>';
	theSpan=theSpan+'<option value="Spring">Spring</option><option value="Summer">Summer</option><option value="Fall">Fall</option>';
	theSpan=theSpan+'<option value="Winter">Winter</option></select></td></tr></table>';
	theSpan=theSpan+'<table><tr><td>Property Name</td><td><span id="red">*</span>Property Type</td><td><span id="red">*</span>Borough</td><td><span id="red">*</span>Zip</td></tr>';
	theSpan=theSpan+'<tr><td><input maxlength="50" name="Property Name '+typeNumber+'" size="21" style="WIDTH: 167px; HEIGHT: 22px" id="property_name'+typeNumber+'"></td>';
	theSpan=theSpan+'<td><select name="Property Type '+typeNumber+'" style="WIDTH: 143px" id="property_type'+typeNumber+'"><option value="" selected></option>';
	theSpan=theSpan+'<option value="Residential">Residential</option><option value="Hospital">Hospital</option>';
	theSpan=theSpan+'<option value="Faith-based">Faith-based</option><option value="Commercial/Industrial">Commercial/Industrial</option>';
	theSpan=theSpan+'<option value="Academic Facility">Academic Facility</option><option value="Parking Lot">Parking Lot</option>';
	theSpan=theSpan+'<option value="Other (Private)">Other (Private)</option><option value="Parkland">Parkland</option>';
	theSpan=theSpan+'<option value="Academic Facility">Academic Facility</option><option value="NYCHA">NYCHA</option>';
	theSpan=theSpan+'<option value="Community Garden">Community Garden</option><option value="Roadway">Roadway</option>';
	theSpan=theSpan+'<option value="Other (Public)">Other (Public)</option></select></td>';
	theSpan=theSpan+'<td><select name="Borough '+typeNumber+'" id="borough'+typeNumber+'"><option value="" selected></option>';
	theSpan=theSpan+'<option value="Bronx">Bronx</option><option value="Brooklyn">Brooklyn</option>';
	theSpan=theSpan+'<option value="Manhattan">Manhattan</option><option value="Queens">Queens</option>';
	theSpan=theSpan+'<option value="Staten Island">Staten Island</option></select></td><td><input maxlength="10" name="Zip '+typeNumber+'" id="zip'+typeNumber+'" size="6" style="WIDTH: 65px; HEIGHT: 22px"></td>';
	theSpan=theSpan+'</tr></table><p align="right"><a href="javascript:removeTreeType('+typeNumber+')">Remove This Tree</a></p></div></span>';
	return(theSpan);
}
function removeTreeType(typeNumber){
	var theSpanName="tree"+typeNumber;
	var theSpan=document.getElementById(theSpanName);
	theSpan.innerHTML="";
}