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="treeSpecies"+spanNumber;
	theArray[1]=document.getElementById(theId).selectedIndex;
	theId="treeHeight"+spanNumber;
	for (i=0;i<document.RegTree[theId].length;i++)
	{
		if(document.RegTree[theId][i].checked)
		{
			theArray[2]=document.RegTree[theId][i].id;	
		}
	}
	theId="treeQuantity"+spanNumber;
	theArray[3]=document.getElementById(theId).value;	
	theId="Where Did You Get Your Tree "+spanNumber;
	for (i=0;i<document.RegTree[theId].length;i++)
	{
		if(document.RegTree[theId][i].checked)
		{
			theArray[4]=document.RegTree[theId][i].id;	
		}
	}
	theId="Where Did You Get Your Tree - Local Nursery "+spanNumber;
	theArray[5]=document.getElementById(theId).value;
	theId="Where Did You Get Your Tree - Other "+spanNumber;
	theArray[6]=document.getElementById(theId).value;
	return(theArray);
}
function restoreData(storedData){
	for(var i=0;i<storedData.length;i++)
	{
		var spanNumber=storedData[i][0];
		var theId="treeSpecies"+spanNumber;
		document.getElementById(theId).selectedIndex=storedData[i][1];
		theId=storedData[i][2];
		if (theId != undefined){			
			document.RegTree[theId].checked=true;
		}
		theId="treeQuantity"+spanNumber;
		document.getElementById(theId).value=storedData[i][3];
		theId=storedData[i][4];
		if (theId != undefined){
			document.RegTree[theId].checked=true;
		}
		theId="Where Did You Get Your Tree - Local Nursery "+spanNumber;
		document.getElementById(theId).value=storedData[i][5];
		theId="Where Did You Get Your Tree - Other "+spanNumber;
		document.getElementById(theId).value=storedData[i][6];
	}
}
function getTreeTypeSpan(typeNumber){
	var displayTypeNum = typeNumber-1
	var theSpan='<span id="tree'+typeNumber+'"><p class="headline">Species '+ displayTypeNum+'</p>';
	
	theSpan=theSpan+'<table><tbody><tr><td class="contactLabel"><span class="red_bold">*</span>What kind of tree did you plant?</td>';
	theSpan=theSpan+'<td class="contactField"><select id="treeSpecies'+typeNumber+'" name="Tree Species '+typeNumber+'"><option selected value="">Plese select the appropriate species</option>';
	theSpan=theSpan+'<option value="Amelanchier canadensis/Serviceberry">Amelanchier canadensis/Serviceberry</option>';
	theSpan=theSpan+'<option value="Amelanchier Grandiflora/Apple serviceberry">Amelanchier Grandiflora/Apple serviceberry</option>';
	theSpan=theSpan+'<option value="Amelanchier laevis cumulus/Allegheny service berry">Amelanchier laevis cumulus/Allegheny service berry</option>';
	theSpan=theSpan+'<option value="Carpinus betulus (fastigiata)/European hornbeam (columnar)">Carpinus betulus (fastigiata)/European hornbeam (columnar)</option>';
	theSpan=theSpan+'<option value="Carpinus caroliniana/American Hornbeam)">Carpinus caroliniana/American Hornbeam</option>';
	theSpan=theSpan+'<option value="Catalpa spp./Cigar Tree">Catalpa spp./Cigar Tree</option>';
	theSpan=theSpan+'<option value="Cedrus atlantica/Blue Atlas Cedar">Cedrus atlantica / Blue Atlas Cedar</option>';
	theSpan=theSpan+'<option value="Celtis occidentalis/Hackberry">Celtis occidentalis/Hackberry</option>';
	theSpan=theSpan+'<option value="Cercidiphyllum japonicum/Katsura Tree">Cercidiphyllum japonicum/Katsura Tree</option>';
	theSpan=theSpan+'<option value="Cercis canadensis/Eastern Redbud">Cercis canadensis/Eastern Redbud</option>';
	theSpan=theSpan+'<option value="Cercis reniformis/Oklahoma redbud">Cercis reniformis/Oklahoma redbud</option>';
	theSpan=theSpan+'<option value="Chamaecyparis obtusa/Hinoke Cypress">Chamaecyparis obtusa/Hinoke Cypress </option>';
	theSpan=theSpan+'<option value="Chionanthus retusus/Japanese Fringe Tree">Chionanthus retusus/Japanese Fringe Tree</option>';
	theSpan=theSpan+'<option value="Cladastris lutea/Yellowwood">Cladastris lutea/Yellowwood</option>';
	theSpan=theSpan+'<option value="Cladrastis kentuckea/American Yellowood">Cladrastis kentuckea/American Yellowood</option>';
	theSpan=theSpan+'<option value="Cornus spp./Dogwood">Cornus spp./Dogwood</option>';
	theSpan=theSpan+'<option value="Corylus colurna/Turkish Filbert">Corylus colurna/Turkish Filbert</option>';
	theSpan=theSpan+'<option value="Creatgus spp./Hawthorn">Creatgus spp./Hawthorn</option>';
	theSpan=theSpan+'<option value="Eucommia ulmoides/Hardy Rubber Tree">Eucommia ulmoides/Hardy Rubber Tree</option>';
	theSpan=theSpan+'<option value="Evodia danielli/Evodia">Evodia danielli/Evodia</option>';
	theSpan=theSpan+'<option value="Fagus sylvatica/Purple Beach">Fagus sylvatica/Purple Beach</option>';
	theSpan=theSpan+'<option value="Ginkgo biloba/Ginkgo">Ginkgo biloba/Ginkgo</option>';
	theSpan=theSpan+'<option value="Gleditsia triacanthose var. inermis/Honeylocust">Gleditsia triacanthose var. inermis/Honeylocust</option>';
	theSpan=theSpan+'<option value="Gymnocladus dioicus/Kentucky Coffee tree">Gymnocladus dioicus/Kentucky Coffee tree</option>';
	theSpan=theSpan+'<option value="Halesia carolina/Carolina Silverbell">Halesia carolina/Carolina Silverbell</option>';
	theSpan=theSpan+'<option value="Hamamelis virginiana/Common Witchhazel">Hamamelis virginiana/Common Witchhazel</option>';
	theSpan=theSpan+'<option value="Juniperus virginiana/Eastern Redcedar">Juniperus virginiana/Eastern Redcedar</option>';
	theSpan=theSpan+'<option value="Koelreuteria paniculata/Golden Rain Tree">Koelreuteria paniculata/Golden Rain Tree</option>';
	theSpan=theSpan+'<option value="Laburnum vossi/Golden Chain Tree">Laburnum vossi/Golden Chain Tree</option>';
	theSpan=theSpan+'<option value="Liquidambar styraciflua/Sweetgum">Liquidambar styraciflua/Sweetgum</option>';
	theSpan=theSpan+'<option value="Liriodendron tulipifera/Tulip tree">Liriodendron tulipifera/Tulip tree</option>';
	theSpan=theSpan+'<option value="Maackia amurensis/Amur Maackia">Maackia amurensis/Amur Maackia</option>';
	theSpan=theSpan+'<option value="Magnolia stellata/Star Magnolia">Magnolia stellata/Star Magnolia</option>';
	theSpan=theSpan+'<option value="Malus spp./various crab apples">Malus spp./various crab apples</option>';
	theSpan=theSpan+'<option value="Metasequoia glyptostroboides/Dawn Redwood">Metasequoia glyptostroboides/Dawn Redwood</option>';
	theSpan=theSpan+'<option value="Nyssa sylvatica/Black Gum">Nyssa sylvatica/Black Gum</option>';
	theSpan=theSpan+'<option value="Ostrya virginiana/American Hophornbeam">Ostrya virginiana/American Hophornbeam</option>';
	theSpan=theSpan+'<option value="Parrotia persica/ Persian Perotia">Parrotia persica/ Persian Perotia</option>';
	theSpan=theSpan+'<option value="Platanus acerifolia/London Planetree">Platanus acerifolia/London Planetree</option>';
	theSpan=theSpan+'<option value="Prunus cerasifera/Purpleleaf Plum">Prunus cerasifera/Purpleleaf Plum</option>';
	theSpan=theSpan+'<option value="Prunus cerasus \'Montmorency\'/Montmorency Cherry">Prunus cerasus \'Montmorency\'/Montmorency Cherry</option>';
	theSpan=theSpan+'<option value="Prunus domestica \'stanley\'/Stanley Plum">Prunus domestica \'stanley\'/Stanley Plum</option>';
	theSpan=theSpan+'<option value="Prunus okame/Okame Cherry">Prunus okame/Okame Cherry</option>';
	theSpan=theSpan+'<option value="Prunus Persica/Peach">Prunus Persica/Peach</option>';
	theSpan=theSpan+'<option value="Prunus serrulata (Kwanzan)/Japanese Flowering Cherry">Prunus serrulata (Kwanzan)/Japanese Flowering Cherry</option>';
	theSpan=theSpan+'<option value="Prunus \'snow fountain\'/Weeping Cherry">Prunus \'snow fountain\'/Weeping Cherry</option>';
	theSpan=theSpan+'<option value="Prunus virginiana/Canada Red Chokecherry">Prunus virginiana/Canada Red Chokecherry</option>';
	theSpan=theSpan+'<option value="Prunus yedoensis/Yoshino Cherry">Prunus yedoensis/Yoshino Cherry</option>';
	theSpan=theSpan+'<option value="Pyrus bartlett/Bartlett Pear">Pyrus bartlett/Bartlett Pear</option>';
	theSpan=theSpan+'<option value="Pyrus calleriana/Pear Tree">Pyrus calleriana/Pear Tree</option>';
	theSpan=theSpan+'<option value="Quercus accutisima/Sawtooth Oak">Quercus accutisima/Sawtooth Oak</option>';
	theSpan=theSpan+'<option value="Quercus alba/White Oak">Quercus alba/White Oak</option>';
	theSpan=theSpan+'<option value="Quercus bicolor/Swamp White Oak">Quercus bicolor/Swamp White Oak</option>';
	theSpan=theSpan+'<option value="Quercus coccinea/Scarlet Oak">Quercus coccinea/Scarlet Oak</option>';
	theSpan=theSpan+'<option value="Quercus imbricaria/Shingle Oak">Quercus imbricaria/Shingle Oak</option>';
	theSpan=theSpan+'<option value="Quercus lyrata/Overcup Oak">Quercus lyrata/Overcup Oak</option>';
	theSpan=theSpan+'<option value="Quercus macrocarpa/Burr Oak">Quercus macrocarpa/Burr Oak</option>';
	theSpan=theSpan+'<option value="Quercus nutalli/Nutall Oak">Quercus nutalli/Nutall Oak</option>';
	theSpan=theSpan+'<option value="Quercus palustris columnar/Columnar Pin Oak">Quercus palustris columnar/Columnar Pin Oak</option>';
	theSpan=theSpan+'<option value="Quercus palustris/Pin Oak">Quercus palustris/Pin Oak</option>';
	theSpan=theSpan+'<option value="Quercus phellos/Willow Oak">Quercus phellos/Willow Oak</option>';
	theSpan=theSpan+'<option value="Quercus robur (fastigiata)/English Oak (columnar)">Quercus robur (fastigiata)/English Oak (columnar)</option>';
	theSpan=theSpan+'<option value="Quercus rubra/Red Oak">Quercus rubra/Red Oak</option>';
	theSpan=theSpan+'<option value="Quercus shumardii/Shumardii Oak">Quercus shumardii/Shumardii Oak</option>';
	theSpan=theSpan+'<option value="Robinia Pseudoacacia/Black Locust">Robinia Pseudoacacia/Black Locust</option>';
	theSpan=theSpan+'<option value="Styphnolobium japonicum/Scholar Tree">Styphnolobium  japonicum/Scholar Tree(Liriodendron)</option>';
	theSpan=theSpan+'<option value="Syringa reticulata/Japanese Tree Lilac">Syringa reticulata/Japanese Tree Lilac</option>';
	theSpan=theSpan+'<option value="Taxodium Acsendens Nutans/Pond Cypress">Taxodium Acsendens Nutans/Pond Cypress</option>';
	theSpan=theSpan+'<option value="Taxodium distichum/Baldcypress">Taxodium distichum/Baldcypress</option>';
	theSpan=theSpan+'<option value="Tilia americana/American Linden">Tilia americana/American Linden</option>';
	theSpan=theSpan+'<option value="Tilia cordata/Littleleaf Linden">Tilia cordata/Littleleaf Linden</option>';
	theSpan=theSpan+'<option value="Tilia euchlora/Crimean Linden">Tilia euchlora/Crimean Linden</option>';
	theSpan=theSpan+'<option value="Tilia tomentosa/Silver Linden">Tilia tomentosa/Silver Linden</option>';
	theSpan=theSpan+'<option value="Ulmus americana/American Elm">Ulmus americana/American Elm</option>';
	theSpan=theSpan+'<option value="Zelkova musashino/ Musachino Zelkova">Zelkova musashino/ Musachino Zelkova</option>';
	theSpan=theSpan+'<option value="Zelkova serrata/Japanese Zelkova">Zelkova serrata/Japanese Zelkova</option>';
	theSpan=theSpan+'<option value="Unkown">Unkown</option></select></td>';
	theSpan=theSpan+'<tr><td colspan="2"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="484" height="3"></td></tr>';
	theSpan=theSpan+'<tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0" width="0"><tbody><tr><td colspan="5"><span class="red_bold">*</span>Please specify tree height at time of planting - see graphic below:</td></tr><tr><td colspan="5"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="484" height="3"></td></tr>';
	theSpan=theSpan+'<tr><td onclick="document.getElementById(\'Tree'+typeNumber+'_2-3\').checked=true;" align="middle"><img border="0" alt="2-3 ft." src="http://www.milliontreesnyc.org/images/misc/2-3.gif" width="99" height="133"><br><input id="Tree'+typeNumber+'_2-3" value="2-3 ft." type="radio" name="treeHeight'+typeNumber+'"> 2-3 ft.</td><td background="../../includes/site_images/misc/vert_dots.gif" width="1"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="1" height="155"></td>';
	theSpan=theSpan+'<td onclick="document.getElementById(\'Tree'+typeNumber+'_4-5\').checked=true;" align="middle"><img border="0" alt="4-5 ft." src="http://www.milliontreesnyc.org/images/misc/4-5.gif" width="99" height="133"><br><input id="Tree'+typeNumber+'_4-5" value="4-5 ft." type="radio" name="treeHeight'+typeNumber+'"> 4-5 ft.</td><td background="../../includes/site_images/misc/vert_dots.gif" width="1"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="1" height="155"></td>';
	theSpan=theSpan+'<td onclick="document.getElementById(\'Tree'+typeNumber+'1_6up\').checked=true;" align="middle"><img border="0" alt="6 ft. &amp; up" src="http://www.milliontreesnyc.org/images/misc/6up.gif" width="99" height="133"><br><input id="Tree'+typeNumber+'_6up" value="6ft. &amp; up" type="radio" name="treeHeight'+typeNumber+'"> 6 ft. &amp; up</td></tr>';
	theSpan=theSpan+'<tr><td colspan="5"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="484" height="3"></td></tr><tr><td colspan="5"><p>REMEMBER: MillionTreesNYC is not counting trees planted in planter boxes, shrubs or seedlings (trees less than&#160;2 feet tall).</p></td></tr></tbody></table></td></tr>';
	theSpan=theSpan+'<tr><td colspan="2"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="484" height="3"></td></tr><tr><td class="contactLabel"><span class="red_bold">*</span>How many of the selected species did you plant?</td><td class="contactField"><input id="treeQuantity'+typeNumber+'" maxlength="10" size="10" name="Tree Quantity '+typeNumber+'"></td></tr>';
	theSpan=theSpan+'<tr><td colspan="2"><img border="0" alt="" src="../../includes/site_images/spacers/spacer.gif" width="484" height="3"></td></tr><tr><td class="contactLabel"><span class="red_bold">*</span>Where Did You Get Your Tree(s)?</td><td class="contactField"><input value="Local Nursery" type="radio" id="Tree'+typeNumber+'_LocalNursery" name="Where Did You Get Your Tree '+typeNumber+'">Local Nursery, please specify:<br><input style="WIDTH: 283px; HEIGHT: 22px" maxlength="50" size="41" name="Where Did You Get Your Tree - Local Nursery '+typeNumber+'" id="Where Did You Get Your Tree - Local Nursery '+typeNumber+'"><br><input value="Tree Giveaway" id="Tree'+typeNumber+'_TreeGiveaway" type="radio" name="Where Did You Get Your Tree '+typeNumber+'">MillionsTreesNYC Tree Giveaway<br><input value="Retail Location" id="Tree'+typeNumber+'_RetailLocation" type="radio" name="Where Did You Get Your Tree '+typeNumber+'">Retail Location<br><input value="Other" id="Tree'+typeNumber+'_Other" type="radio" name="Where Did You Get Your Tree '+typeNumber+'">Other, please specify:<br><input style="WIDTH: 283px; HEIGHT: 22px" maxlength="50" size="41" name="Where Did You Get Your Tree - Other '+typeNumber+'" id="Where Did You Get Your Tree - Other '+typeNumber+'"> </td></tr>';
	
	theSpan=theSpan+'</tbody></table>';
	if (typeNumber != 2){
		theSpan=theSpan+'<p align="right"><a href="javascript:removeTreeType('+typeNumber+')">Remove This Tree</a></p>';
	}
	theSpan=theSpan+'</span><!--end span tree'+typeNumber+'-->';
	return(theSpan);
}
function removeTreeType(typeNumber){
	var theSpanName="tree"+typeNumber;
	var theSpan=document.getElementById(theSpanName);
	theSpan.innerHTML="";
}