//	snis="["+"[";
//	snie="]"+"]";
	//func_name="Ditto"
	//parmlist="ditto_base,id,language,format,config,debug,phx,save,removeChunk,parents,documents,depth,dateFormat,display,total,showPublishedOnly,showInMenuOnly,hideFolders,hidePrivate,seeThruUnpub,sortDir,sortBy,randomize,start,dateSource,keywords,queryLimit,where,noResults,hiddenFields,paginate,paginateAlwaysShowLinks,paginateSplitterCharacter"
	//p_list=parmlist.split(",");

function initialized()
{
	document.fm1.reset();
	p_list=parmlist.split(",");
	
	//alert(func_name);
}
function GetParm()
{
	//alert("getparm in");
	//alert("p_list.length->"+p_list.length);
	//parmstr_e=document.getElementsByName("base");
	parmstr=document.getElementsByName("base")[0].value;
	snityperb=document.getElementsByName("snitype");
	//alert(parmstr.substring(0,2));
	switch(parmstr.substring(0,2))
	{
		case "[[":
			//alert("[[判定");
			snis="[[";
			snie="]]";
			snityperb[0].checked=true;
			break;
		case "[[":
			//alert("[[判定");
			snis="[[";
			snie="]]";
			snityperb[1].checked=true;
			break;
	}
	//alert(parmstr.indexOf("&",0)+"-"+parmstr.indexOf("]]",0));
	//alert(parmstr.substring(parmstr.indexOf("&",0),parmstr.indexOf("]]",0)));
	//alert(snie+"->"+parmstr.indexOf(snie,0));
	dmystr=parmstr.substring(parmstr.indexOf("&",0),parmstr.indexOf(snie,0));
	parmarr=dmystr.split(" ");
	parmstr="";
	for(x=0;x<parmarr.length;x++)
	//for(x in parmarr)
	{
		//target_str=parmarr[x];
		opname=parmarr[x].substring(parmarr[x].indexOf("&",0)+1,parmarr[x].indexOf("=",0));
		opvalue=parmarr[x].substring(parmarr[x].indexOf("`",0)+1,parmarr[x].indexOf("`",parmarr[x].indexOf("`",0)+1));
		if(parmlist.indexOf(opname,0)>0)
		{
			elements = document.getElementsByName(opname);
			//alert("arr: "+opname+" / value: "+opvalue+" / type: "+elements[0].type);
			for(z=0;z<p_list.length;z++)
			{
			//alert("p_list[z]->"+p_list[z]+" / opname->"+opname);
				if(p_list[z]==opname)
				{
					p_list[z]=opname+"=`"+opvalue+"`";
					parmstr=parmstr+" &"+p_list[z];
				}
			}
			//alert("parmstr->"+parmstr);
			switch(elements[0].type)
			{
				case "select-one":
					for(i=0;i<elements[0].options.length;i++)
					{
						if(elements[0].options[i].value == opvalue)
						{
							elements[0].options[i].selected=true;
						}
					}
					break;
				case "text":
					elements[0].value = opvalue;
					break;
				case "checkbox":
					elements[0].checked=true;
					break;
			}
		}else{
			parmstr=parmstr+" "+parmarr[x];
			//alert(parmstr);
		}
	}
	//alert("len:"+parmarr.length);
	
	output_code();
	//output_area=document.getElementsByName("output");
	//output_area[0].value=snis+func_name+"?"+parmstr+snie;
}
function chgparm(chgparm)
{
	//alert("chgparm in");
	parmstr="";
	snityperb=document.getElementsByName("snitype");
	iparm=document.getElementsByName(chgparm);
	switch(iparm[0].type)
	{
		case "select-one":
			//alert("selected: "+iparm[0].options[iparm[0].selectedIndex].text);
			//alert("index: "+iparm[0].selectedIndex);
			if(iparm[0].selectedIndex==0)
			{
				ivalue="";
			}else{
				ivalue=iparm[0].options[iparm[0].selectedIndex].value;
			}
			break;
		case "text":
			ivalue=iparm[0].value;
			break;
		case "checkbox":
			ivalue=iparm[0];
			break;
	}
	//alert("ivalue: "+ivalue);
	for(z=0;z<p_list.length;z++)
	{
		if(p_list[z].indexOf("=",0)>0)
		{
			//alert("114/"+p_list[z]);
			parm_dmy=p_list[z].substring(0,p_list[z].indexOf("=",0));
			//alert("parm_dmy: "+parm_dmy);
		}else{
			parm_dmy=p_list[z];
		}
		if(parm_dmy==chgparm)
		{
			//alert("parm_dmy==chgparm");
			if(ivalue=="")
			{
				p_list[z]=chgparm;
			}else{
				p_list[z]=chgparm+"=`"+ivalue+"`";
			}
		}
	}
	for(z=0;z<p_list.length;z++)
	{
		if(p_list[z].indexOf("=",0)>0)
		{
			parmstr=parmstr+" &"+p_list[z];
		}
	}
	
	output_code();
	//output_area=document.getElementsByName("output");
	//output_area[0].value=snis+func_name+"?"+parmstr+snie;
}
function output_code()
{
	//alert("output_code in");
	switch(snityperb[0].checked)
	//if(snityperb[0].checked==true)
	{
		case true:
			snis="["+"[";
			snie="]"+"]";
			break;
	//}else{
		case false:
			snis="["+"!";
			snie="!"+"]";
			break;
	}
	output_area=document.getElementsByName("output");
	output_area[0].value=snis+func_name+"?"+parmstr+snie;
}
function chgover(tparm)
{
	//alert("chgover in");
	coelements=document.getElementsByName("co_"+tparm);
	taelements=document.getElementsByName(tparm);
	if(coelements[0].checked==true)
	{
		swapvalue=taelements[0].value;
		taelements[0].value=coelements[0].title;
		taelements[0].disabled=true;
	}else{
		taelements[0].value=swapvalue;
		taelements[0].disabled=false;
	}
	chgparm(tparm);
}
