// JavaScript Document
function RemoveDefault( field )  {
	field.value = "";	
}

function MoveSprite(num) {
	navObj = document.getElementById( 'topNav' );
	vertOffset = num * 34;
	navObj.style.backgroundPosition = '0 -' + vertOffset + 'px';
}

function addVariety(event) {
	varietyNum = $('numberOfVarieties').value;
	varietyNum = Number(varietyNum) + 1;
	$('numberOfVarieties').value= varietyNum;
	html = '<tr>\n' 
	+ '<th>Variety ' + varietyNum + ' Name:</th>\n'
	+ '<td><input type="text" name="variety' + varietyNum + '" /></td>\n'
	+ '</tr>\n';
	html += '<tr>\n'
	+ '<th>Variety ' + varietyNum + ' Description:</th>\n'
	+ '<td><textarea name="varietyDescription' + varietyNum + '"></textarea></td>\n'
	+ '</tr>\n';
	$('varietyTable').insert({ bottom: html} );		
}

function addPest(event) {
	pestNum = $('numberOfPests').value;
	pestNum = Number(pestNum) + 1;
	$('numberOfPests').value= pestNum;
	html = '<tr>\n' 
	+ '<th>pest ' + pestNum + ' Name:</th>\n'
	+ '<td><input type="text" name="pest' + pestNum + '" /></td>\n'
	+ '</tr>\n';
	html += '<tr>\n'
	+ '<th>pest ' + pestNum + ' Description:</th>\n'
	+ '<td><textarea name="pestDescription' + pestNum + '"></textarea></td>\n'
	+ '</tr>\n';
	html += '<tr>\n'
	+ '<th>pest ' + pestNum + ' Link:</th>\n'
	+ '<td><input type="text" name="pestLink' + pestNum + '" /></td>\n'
	+ '</tr>\n';
	$('pestTable').insert({ bottom: html} );		
}

function addRecipe(event) {
	recipeNum = $('numberOfRecipes').value;
	recipeNum = Number(recipeNum) + 1;
	$('numberOfRecipes').value= recipeNum;
	html = '<tr>\n' 
	+ '<th>Recipe ' + recipeNum + ' Name:</th>\n'
	+ '<td><input type="text" name="recipe' + recipeNum + '" /></td>\n'
	+ '</tr>\n';
	html += '<tr>\n'
	+ '<th>Recipe ' + recipeNum + ' Link:</th>\n'
	+ '<td><input type="text" name="recipeLink' + recipeNum + '" /></td>\n'
	+ '</tr>\n';
	$('recipeTable').insert({ bottom: html} );		
}


document.observe('dom:loaded',function(){
if($('addVariety')) {
	$('addVariety').observe('click',addVariety);
	$('addPest').observe('click',addPest);
	$('addRecipe').observe('click',addRecipe);
}


});
