﻿			var list = ['hey','haha'];
			var nIndex = 4;
			var maxrow = 10;


			function Send()
			{
				var param = "";
				for(mindex = 1 ; mindex < nIndex; mindex++)
				{
					param = param + "i" + mindex + "=" +  escape($F("txtName" + mindex)) + "&";
				}
				
				param = param + "i" + mindex + "=" +  escape($F("txtName" + mindex));
				
				location.href = "send.php?" + param;
				
                        return false;
			}

			function CreateNewRow()
			{

				nIndex++;

				newitem = document.createElement("DIV");
				newitem.setAttribute("id", "roboitem"+nIndex);
				newitem.className = "roboitem";

				//################################################
				newindex = document.createElement("DIV");
				newindex.setAttribute("id", "roboitemindex"+nIndex);
				newindex.className = "roboitemindex";

				currenttext=document.createTextNode(nIndex+"...");
				newindex.appendChild(currenttext);
				//################################################

				newname = document.createElement("DIV");
				newname.setAttribute("id", "roboitemname"+nIndex);
				newname.className = "roboitemname";

				newtxtdiv = document.createElement("DIV");
				newtxtdiv.className = "Names";

				newtxtname = document.createElement("input");
				newtxtname.setAttribute("id", "txtName"+nIndex);
				newtxtname.setAttribute("type", "text");
				newtxtname.setAttribute("name", "i["+(nIndex-1)+"]");

				newtxtname.className="text1m";
				newtxtname.onblur= function(){

				setResult($('txtName'+this.id.substr(7)).value,'result'+this.id.substr(7));};

				//setAttribute("onblur", "setResult($('txtName1').value,'result1');");

				

				//##########


				//suggest用改行
				newbrdiv = document.createElement("DIV");
				newbrdiv.appendChild(newtxtname);

				newtxtdiv.appendChild(newbrdiv);
				newname.appendChild(newtxtdiv);
				//################################################
				newsug = document.createElement("DIV");
				newsug.setAttribute("id", "suggest"+nIndex);
				newsug.className ="suggest"+nIndex;

				newtxtdiv.appendChild(newsug);
				//#################################################

				newtxtdiv2 = document.createElement("DIV");
				newtxtdiv2.className = "Nums";

				newtxtname2 = document.createElement("input");
				newtxtname2.setAttribute("id", "txtNums"+nIndex);
				newtxtname2.setAttribute("type", "text");
				newtxtname2.setAttribute("name", "n["+(nIndex-1)+"]");

				newtxtname2.className="text1s";

				newtxtdiv2.appendChild(newtxtname2);
				newname.appendChild(newtxtdiv2);

				//##########
				newtxtdiv3 = document.createElement("DIV");
				newtxtdiv3.setAttribute("id", "result"+nIndex);
				newtxtdiv3.className = "unitresult";

				newname.appendChild(newtxtdiv3);


				//################################################
				//newnum = document.createElement("DIV");
				//newnum.setAttribute("id", "roboitemnum"+nIndex);
				//newnum.className = "roboitemnum";
				//currenttext=document.createTextNode("手順"+nIndex);
				//newnum.appendChild(currenttext);

				//################################################

				newitem.appendChild(newindex);
				newitem.appendChild(newname);
				//newitem.appendChild(newnum);

				newdiv4  = document.createElement("DIV");
				newdiv4.setAttribute("style","clear:both");

				newitem.appendChild(newdiv4);

				return newitem;
			}

			function AddData()
			{
				var mystep = $('my_steps');
				mystep.appendChild(CreateNewRow());
				new Suggest.Local("txtName"+nIndex, "suggest"+nIndex, list,{prefix: true});

			}

			function DelData()
			{
				var mystep = $('my_steps');
				var delitem = $('roboitem'+nIndex);

				mystep.removeChild(delitem);
				nIndex--;
			}

			function insertAfter(newChild,refChild)
			//Post condition: if childNodes[n] is refChild, than childNodes[n+1] is newChild.
			{
				var parent=refChild.parentNode;
				if(parent.lastChild==refChild) return parent.appendChild(newChild);
					else return parent.insertBefore(newChild,refChild.nextSibling);
			}

			window.onload= function hoge(){
				
				var defaultbox = new Suggest.Local("txtName1", "suggest1", list,{prefix: true});

			      	window.addEventListener ?
			        	window.addEventListener('load', defaultbox, false) :
			        	window.attachEvent('onload', defaultbox);

				var mystep = $('my_steps');
  				new Suggest.Local("txtName2", "suggest2", list, {prefix: true});
				new Suggest.Local("txtName3", "suggest3", list, {prefix: true});
				new Suggest.Local("txtName4", "suggest4", list, {prefix: true});
			}

