function confirmDelete( x )
{
	var ans = window.confirm("Are you sure you want to delete this " + x + "?\nThis action can not be undone.");
	return ans;
}

function addSet( setname, fields, i )
{
	myCntr = document.getElementById( setname + "num" );
	if ( myCntr.value == i )
	{
		myTable = document.getElementById( setname );
		
		iCntr = parseInt( myCntr.value ) + 1;
		
		myCode = "var iCntr = " + (iCntr)
		var onkeypressfunction = new Function( "addSet( '" + setname + "', " + (fields) + ", " + (iCntr) + ")");
		
		var row = myTable.insertRow( myTable.rows.length );
		
		cell = row.insertCell(0);
		cell.width = 4;
		cell.innerHTML = "&nbsp;";
		
		for ( indx = 1; indx <= fields; indx++ )
		{
			cell = row.insertCell( indx );
			var namefield = document.createElement("input");
		    namefield.setAttribute("type", "text");
		    namefield.setAttribute("id", setname + "_" + (indx) + "_" + (iCntr));
		    namefield.setAttribute("name", setname + "_" + (indx) + "_" + (iCntr));
		    namefield.setAttribute("size", "30");
		    if ( indx == fields )
		    	namefield.onkeypress = onkeypressfunction;
			cell.appendChild(namefield);
		}
		myCntr.value = iCntr;	
	}
}

function addShopSet( i )
{
	myCntr = document.getElementById("shnumitems");
	if ( myCntr.value == i )
	{
		myTable = document.getElementById("shop");
		
		iCntr = parseInt(myCntr.value) + 1;
		
		myCode = "var iCntr = " + (iCntr)
		var onkeypressfunction = new Function("addShopSet(" + (iCntr) + ")");
		
		var row = myTable.insertRow(myTable.rows.length);
		
		cell = row.insertCell(0);
		cell.width = 4;
		cell.innerHTML = "&nbsp;";
		
		cell = row.insertCell(1);
		var namefield = document.createElement("input");
	    namefield.setAttribute("type", "text");
	    namefield.setAttribute("id", "shop_" + (iCntr));
	    namefield.setAttribute("name", "shop_" + (iCntr));
	    namefield.setAttribute("size", "40");
	    namefield.onkeypress = onkeypressfunction;
		cell.appendChild(namefield);
		
		myCntr.value = iCntr;
	}
} 

function addUtilitySet( i )
{
	myCntr = document.getElementById("utilnumitems");
	if ( myCntr.value == i )
	{
		myTable = document.getElementById("utility");
		
		iCntr = parseInt(myCntr.value) + 1;
		
		myCode = "var iCntr = " + (iCntr)
		var onkeypressfunction = new Function("addUtilitySet(" + (iCntr) + ")");
		
		var row = myTable.insertRow(myTable.rows.length);
		
		cell = row.insertCell(0);
		cell.width = 4;
		cell.innerHTML = "&nbsp;";
		
		cell = row.insertCell(1);
		var namefield = document.createElement("input");
	    namefield.setAttribute("type", "text");
	    namefield.setAttribute("id", "utility_" + (iCntr));
	    namefield.setAttribute("name", "utility_" + (iCntr));
	    namefield.setAttribute("size", "40");
	    namefield.onkeypress = onkeypressfunction;
		cell.appendChild(namefield);
		
		myCntr.value = iCntr;
	}
} 
