function func(state,index)
{
	if (state=="add")
	{
		window.open("add.asp","","width=520,height=375,top=10,left=150,menubar=0,toolbar=0,scrollbars=1,resizable=1");
	}
	else if (state=="update")
	{
		window.open("","update","width=520,height=425,top=10,left=150,menubar=0,toolbar=0,scrollbars=1,resizable=1");
		document.all("IndexKey").value=index;
		document.forms[0].target = "update";
		document.forms[0].action = "update.asp";
		document.forms[0].submit();
	}
	else if (state=="delete")
	{
		window.open("","delete","width=520,height=425,top=10,left=150,menubar=0,toolbar=0,scrollbars=1,resizable=1");
		document.all("IndexKey").value=index;
		document.forms[0].target = "delete";
		document.forms[0].action = "delete.asp";
		document.forms[0].submit();
	}
	else if (state=="search")
	{
		if (document.getElementById('qvalue'))
			document.getElementById('qvalueNEW').value = document.getElementById('qvalue').value;
		if (document.getElementById('qvalue2'))
			document.getElementById('qvalue2NEW').value = document.getElementById('qvalue2').value;
		if (document.getElementById('AMYear'))
			document.getElementById('AMYearNEW').value = document.getElementById('AMYear').value;
		document.forms[0].target = "bottom";
		document.forms[0].action = "dealdata.asp";
		document.forms[0].submit();
	}
}

function changeto(obj){
  var innerObj = document.all("innerInput");
    innerObj.innerHTML="";
  var innerObj2 = document.all("innerInput2");
    innerObj2.innerHTML="";
  switch (obj.value.toUpperCase()){
	case "POSTYEARCLASS":
		innerObj.innerHTML="民國&nbsp;<select name='AMYear' id='AMYear' class='search_select_style'></select>&nbsp;年" ;
		var dd = new Date(); //預設今天日期
		document.all("AMYear").length = ( dd.getFullYear()+3 - 80 -1911) ;
		for(var i = 0 ; i <=( dd.getFullYear()+3 - 80-1911-1 ) ; i++)
		{
		  document.all("AMYear").options[i].value = i +80;
		  document.all("AMYear").options[i].text = i +80;
		}
		document.all("AMYear").value = dd.getFullYear()-1911 ;
		innerObj2.innerHTML="大類：<select name='qvalue' id='qvalue' class=text><option value=0>全部</option><option value=1>中央法令</option><option value=2>高雄市法令</option><option value=3>其他縣市法令</option></select> 小類：<select name='qvalue2' id='qvalue2' class=text><option value=0>全部</option><option value=A>A類：建築法規</option><option value=B>B類：都市計畫法規</option><option value=C>C類：法規技術會報</option><option value=D>D類：區域計畫法規</option><option value=E>E類：水電消防法規</option><option value=F>F類：建築(技)師法規</option><option value=G>G類：其他相關法規</option></select>";
	break;
	case "POSTYEAR":
		innerObj.innerHTML="民國&nbsp;<select name='AMYear' id='AMYear' class='search_select_style'></select>&nbsp;年" ;
		var dd = new Date(); //預設今天日期
		document.all("AMYear").length = ( dd.getFullYear()+3 - 80 -1911) ;
		for(var i = 0 ; i <=( dd.getFullYear()+3 - 80-1911-1 ) ; i++)
		{
		  document.all("AMYear").options[i].value = i +80;
		  document.all("AMYear").options[i].text = i +80;
		}
		document.all("AMYear").value = dd.getFullYear()-1911 ; 
	break;
		case "BIGCLASS":
			innerObj.innerHTML="大類：<select name='qvalue' id='qvalue' class=text><option value=0>全部</option><option value=1>中央法令</option><option value=2>高雄市法令</option><option value=3>其他縣市法令</option></select> 小類：<select name='qvalue2' id='qvalue2' class=text><option value=0>全部</option><option value=A>A類：建築法規</option><option value=B>B類：都市計畫法規</option><option value=C>C類：法規技術會報</option><option value=D>D類：區域計畫法規</option><option value=E>E類：水電消防法規</option><option value=F>F類：建築(技)師法規</option><option value=G>G類：其他相關法規</option></select>";
		break;
		case "POSTNUMBER":
		   innerObj.innerHTML="<input name='qvalue' id='qvalue' type='text' size='20' class='search_Input_Style'>";
		break;
		case "TITLE":
		   innerObj.innerHTML="<input name='qvalue' id='qvalue' type='text' size='50' class='search_Input_Style'>";
		break;
   }
}

function init(state){
	if (state=="add")
	{
		window.parent.document.forms[0].action="";
		window.parent.document.forms[0].target="_self";
		window.parent.document.forms[0].submit();
	}
	else if (state=="update")
	{
		window.parent.document.forms[0].action="";
		window.parent.document.forms[0].target="_self";
		window.parent.document.forms[0].submit();
	}
	else if (state=="delete")
	{
		window.parent.document.forms[0].action="";
		window.parent.document.forms[0].target="_self";
		window.parent.document.forms[0].submit();
	}
	else if (state=="search")
	{
		document.forms[0].submit();
	}
}

function check(form)
{
	//var checkform = new CheckForm();
	form.target = "self";	
	window.close();
	return true;
}