//問卷開新視窗=======================
 function openwin(u) {
         x=650;
         y=600;
         newwin=open(u,'prd','width='+x+',height='+y+',scrollbars=yes,top=0,left=0');
         newwin.focus(); 
         newwin.moveTo((screen.width-x)/2,(screen.height-y-20)/2);
}

//圖片(共用)========================================================================================================

  function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  }
  
  function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
      var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  }
  
  function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
  }
  
  function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
     if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  }
  
  function pathOnly (InString)  {
    LastSlash=InString.lastIndexOf ('/', InString.length-1)
    OutString=InString.substring  (0, LastSlash+1)
    return (OutString);	
  }

  function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  }

  function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  }

  function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
  }

  function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  }
//圖層========================================================================================================
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//Banner 功能Menu====================================================================================================
/*
function mmLoadMenus() {
  if (window.mm_menu_1004175724_0) return;
    window.mm_menu_1004175724_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,10,false,false);
    mm_menu_1004175724_0.addMenuItem("最新消息","location='index.php?page=news_list&type=1'");
    mm_menu_1004175724_0.addMenuItem("活動計劃公告","location='index.php?page=news_list&type=2'");
    mm_menu_1004175724_0.addMenuItem("好人好事","location='index.php?page=news_list&type=3'");
    mm_menu_1004175724_0.hideOnMouseOut=true;
    mm_menu_1004175724_0.bgColor='#E6E6E6';
    mm_menu_1004175724_0.menuBorder=1;
    mm_menu_1004175724_0.menuLiteBgColor='#E6E6E6';
    mm_menu_1004175724_0.menuBorderBgColor='#CBDCED';

    window.mm_menu_1004180847_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,10,false,false);
    mm_menu_1004180847_0.addMenuItem("署長","location='index.php?page=sir_add&type=1'");
	mm_menu_1004180847_0.addMenuItem("副署長之一","location='index.php?page=sir_add&type=2'");
	mm_menu_1004180847_0.addMenuItem("副署長之二","location='index.php?page=sir_add&type=3'");
	mm_menu_1004180847_0.addMenuItem("副署長之三","location='index.php?page=sir_add&type=4'");
	//mm_menu_1004180847_0.addMenuItem("副署長之四","location='index.php?page=sir_add&type=5'");
    mm_menu_1004180847_0.addMenuItem("局長簡介","location='index.php?page=sir_add&type=6'");
    mm_menu_1004180847_0.addMenuItem("副局長簡介","location='index.php?page=sir_add&type=7'");
    mm_menu_1004180847_0.hideOnMouseOut=true;
    mm_menu_1004180847_0.bgColor='#E6E6E6';
    mm_menu_1004180847_0.menuBorder=1;
    mm_menu_1004180847_0.menuLiteBgColor='#E6E6E6';
    mm_menu_1004180847_0.menuBorderBgColor='#CBDCED';

    window.mm_menu_1004181828_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,10,false,false);
    mm_menu_1004181828_0.addMenuItem("下載專區","location='index.php?page=down_list'");
    mm_menu_1004181828_0.hideOnMouseOut=true;
    mm_menu_1004181828_0.bgColor='#E6E6E6';
    mm_menu_1004181828_0.menuBorder=1;
    mm_menu_1004181828_0.menuLiteBgColor='#E6E6E6';
    mm_menu_1004181828_0.menuBorderBgColor='#CBDCED';
      window.mm_menu_1004181935_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,10,false,false);
  mm_menu_1004181935_0.addMenuItem("常見問答","location='index.php?page=qan_list'");
  //mm_menu_1004181935_0.addMenuItem("留言專區","location='index.php?page=phorum'");
   mm_menu_1004181935_0.hideOnMouseOut=true;
   mm_menu_1004181935_0.bgColor='#E6E6E6';
   mm_menu_1004181935_0.menuBorder=1;
   mm_menu_1004181935_0.menuLiteBgColor='#E6E6E6';
   mm_menu_1004181935_0.menuBorderBgColor='#CBDCED';

        window.mm_menu_1005112606_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","center","middle",3,0,1000,-5,7,true,true,true,10,false,false);
  mm_menu_1005112606_0.addMenuItem("");
   mm_menu_1005112606_0.hideOnMouseOut=true;
   mm_menu_1005112606_0.bgColor='#E6E6E6';
   mm_menu_1005112606_0.menuBorder=1;
   mm_menu_1005112606_0.menuLiteBgColor='#E6E6E6';
   mm_menu_1005112606_0.menuBorderBgColor='#CBDCED';

    window.mm_menu_1024172727_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","center","middle",3,0,1000,-5,7,true,true,true,10,false,false);
  mm_menu_1024172727_0.addMenuItem("相關連結","location='index.php?page=href_list'");
   mm_menu_1024172727_0.hideOnMouseOut=true;
   mm_menu_1024172727_0.bgColor='#E6E6E6';
   mm_menu_1024172727_0.menuBorder=1;
   mm_menu_1024172727_0.menuLiteBgColor='#E6E6E6';
   mm_menu_1024172727_0.menuBorderBgColor='#CBDCED';
window.mm_menu_1024172755_0 = new Menu("root",88,20,"",12,"#000000","#000000","#CBDCED","#FFFFFF","center","middle",3,0,1000,-5,7,true,true,true,10,false,false);
  mm_menu_1024172755_0.addMenuItem("採購公告","location='index.php?page=purchase_list'");
   mm_menu_1024172755_0.hideOnMouseOut=true;
   mm_menu_1024172755_0.bgColor='#E6E6E6';
   mm_menu_1024172755_0.menuBorder=1;
   mm_menu_1024172755_0.menuLiteBgColor='#E6E6E6';
   mm_menu_1024172755_0.menuBorderBgColor='#CBDCED';

mm_menu_1024172755_0.writeMenus();
} // mmLoadMenus()

function MM_showMenu(menu, x, y, child, imgname) {
	if (!window.mmWroteMenu) return;
	MM_clearTimeout();
	if (menu) {
		var obj = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
		x = moveXbySlicePos (x, obj);
		y = moveYbySlicePos (y, obj);
	}
	if (document.layers) {
		if (menu) {
			var l = menu.menuLayer || menu;
			l.top = l.left = 1;
			hideActiveMenus();
			if (this.visibility) l = this;
			window.ActiveMenu = l;
		} else {
			var l = child;
		}
		if (!l) return;
		for (var i=0; i<l.layers.length; i++) { 			   
			if (!l.layers[i].isHilite) l.layers[i].visibility = "inherit";
			if (l.layers[i].document.layers.length > 0) MM_showMenu(null, "relative", "relative", l.layers[i]);
		}
		if (l.parentLayer) {
			if (x != "relative") l.parentLayer.left = x || window.pageX || 0;
			if (l.parentLayer.left + l.clip.width > window.innerWidth) l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
			if (y != "relative") l.parentLayer.top = y || window.pageY || 0;
			if (l.parentLayer.isContainer) {
				l.Menu.xOffset = window.pageXOffset;
				l.Menu.yOffset = window.pageYOffset;
				l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
				l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
				if (l.parentLayer.menuContainerBgColor && l.Menu.menuBgOpaque ) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
			}
		}
		l.visibility = "inherit";
		if (l.Menu) l.Menu.container.visibility = "inherit";
	} else if (FIND("menuItem0")) {
		var l = menu.menuLayer || menu;	
		hideActiveMenus();
		if (typeof(l) == "string") l = FIND(l);
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") {
			s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
			s.left = s.pixelLeft + 'px';
		}
		if (y != "relative") {
			s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
			s.top = s.pixelTop + 'px';
		}
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) window.activeMenus[window.activeMenus.length] = l;
	MM_clearTimeout();
}
*/
//資料刪除===================================================================================================
//(共用)
function Expand() {
 if (""!=event.srcElement.id) {
    var ch=event.srcElement.id + "child" 
    var el=document.all[ch]
    if (null!=el) el.style.display = "none" == el.style.display ? "" : "none"
    event.returnValue=false
 }
}
function pathOnly (InString)  {
  LastSlash=InString.lastIndexOf ('/', InString.length-1)
  OutString=InString.substring  (0, LastSlash+1)
  return (OutString);	
}

function delQanConfirm(id){
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=qan_h&action=Del&id="+id;}
}
function delDownConfirm(id){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=down_h&action=Del&id="+id;}
}
function clrIpConfirm(id,field)
{
	var choice=confirm('確定清除?')
	if(choice)
	{
		window.location=pathOnly(location.href)+"index.php?page=down_h&id="+id+"&field="+field+"&action=clrIp"
	}
}
function delPurchaseConfirm(id){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=purchase_h&action=Del&id="+id;}
}
function delHrefConfirm(id){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=href_h&action=Del&id="+id;}
}
function delNewsConfirm(id,type){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=news_h&action=Del&id="+id+"&type="+type;}
}
function delHrefTypeConfirmOpen(id,action){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"hreftype_index.php?page=hreftype_h&actionOpen=Del&id="+id+"&action="+action;}
}
function delSearchTypeConfirmOpen(sid,id,action,type){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"searchtype_index.php?page=searchtype_h&actionOpen=Del&id="+id+"&action="+action+"&sid="+sid+"&type="+type;}
}
function delDownTypeConfirmOpen(id,action){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"downtype_index.php?page=downtype_h&actionOpen=Del&id="+id+"&action="+action;}
}

function delPurchaseTypeConfirmOpen(id,action){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"purchasetype_index.php?page=purchasetype_h&actionOpen=Del&id="+id+"&action="+action;}
}
function Phorumdelconfirm(p_id){  
  var aaa;
  aaa=confirm("確定要刪除此回覆?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=phorum_h&action=Del&p_id="+p_id;}
}
function PhorumReydelconfirm(prid,pid){  
  var aaa;
  aaa=confirm("確定要刪除此回覆?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=phorum_h&action=pr_del&pr_id="+prid+"&p_id="+pid;}
}

function PhoruserReydelconfirm(puid,pid){  
  var aaa;
  aaa=confirm("確定要刪除此民眾回覆?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=phorum_h&action=pu_del&pu_id="+puid+"&p_id="+pid;}
}

function Admdelconfirm(id){
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=admin_h&action=Del&id="+id;}
}

function delOpenTypeConfirmOpen(id,action){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"opentype_index.php?page=opentype_h&actionOpen=Del&b_id="+id+"&action="+action;}
}



//全文檢索
function chk_search()
{
 var pass = true;
 while (true)
 {
 	if( document.searchf.sv.value == "" )
 	{
 		alert("請輸入搜尋關鍵字!!!");
 		document.searchf.sv.focus();
 		pass = false;
 		break;
 	}
	if (document.searchf.sv.value == "請輸入查詢字串")
	{
		alert("請輸入搜尋關鍵字!!!");
 		document.searchf.sv.focus();
 		pass = false;
 		break;
	}
 	break;
 }
 if ( pass ) {
 	document.searchf.submit();
 }
}

function chk_login()
{
  if(document.ad_login.login_name.value == "")
  {
    alert("請輸入帳號");    
	document.ad_login.login_name.focus();
    return false;
  }
  if(document.ad_login.login_pwd.value == "")
  {
    alert("請輸入密碼");    
	document.ad_login.login_pwd.focus();
    return false;
  }  
  return true;
}
//
function downTypecheckdata(){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.dt_title.value =="")
  {
     alert("請輸入類別名稱。");
     document.form1.dt_title.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}
function purchaseTypecheckdata(){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.pt_title.value =="")
  {
     alert("請輸入類別名稱。");
     document.form1.pt_title.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}
//民意論壇
function Phorcheckdata(){
 var pass = true;
  while (true) 
  { 

  if(document.form1.p_name.value =="")
  {
     alert("請輸入姓名。");
     document.form1.p_name.focus();
     pass = false;
	 break;
  }
  if(document.form1.p_title.value =="")
  {
     alert("請輸入留言主題。");
     document.form1.p_title.focus();
     pass = false;
	 break;
  }
  if(document.form1.p_content.value =="")
  {
     alert("請輸入留言內容。");
     document.form1.p_content.focus();
     pass = false;
	 break;
  }
  
    if ( document.form1.p_mail.value != "") {
    if ( document.form1.p_mail.value.indexOf('@',0) == -1 || document.form1.p_mail.value.indexOf('.',0) == -1 )
    {
	alert("輸入的電子郵件格式不正確！");
	document.form1.p_mail.focus();
	pass = false;
	 break;
	}  
}  
  
   if(document.form1.q1_imgcode.value =="")
  {
     alert("請輸入驗證碼。");
     document.form1.q1_imgcode.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();
  }	
}

//民意論壇回覆
function Phorreplycheckdata(){
 var pass = true;
  while (true) 
  { 

  if(document.form1.pu_name.value =="")
  {
     alert("請輸入姓名。");
     document.form1.pu_name.focus();
     pass = false;
	 break;
  }

  if(document.form1.pu_content.value =="")
  {
     alert("請輸入回覆內容。");
     document.form1.pu_content.focus();
     pass = false;
	 break;
  }
  
    if ( document.form1.pu_mail.value != "") {
    if ( document.form1.pu_mail.value.indexOf('@',0) == -1 || document.form1.pu_mail.value.indexOf('.',0) == -1 )
    {
	alert("輸入的電子郵件格式不正確！");
	document.form1.pu_mail.focus();
	pass = false;
	 break;
	}  
}  
   if(document.form1.q1_imgcode.value =="")
  {
     alert("請輸入驗證碼。");
     document.form1.q1_imgcode.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();
  }	
}

function PArticalRecheckdata(){
	 document.form1.submit();
}


function newsCheckData(){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.news_title.value =="")
  {
     alert("請輸入標題。");
     document.form1.news_title.focus();
     pass = false;
	 break;
  }

  if(document.form1.n_document1==undefined)								//如果附件一存在，送出表單前檢查索引欄
  {
  	 if((document.form1.chkFileExit1.value.length>0)&&(document.form1.p_s_1.value==""))
 				{
 					alert('請輸入關鍵字索引_1')
 					pass=false
 					break
 				}
  }
  else
  	{
  		 if((document.form1.n_document1.value.length>0)&&(document.form1.p_s_1.value==""))
  				{
  		  		alert('請輸入關鍵字索引_1!')
  					pass=false
  					break
  				}
  	}
  if(document.form1.n_document2==undefined)									//如果附件二存在，送出表單前檢查索引欄
  {
  	 if((document.form1.chkFileExit2.value.length>0)&&(document.form1.p_s_2.value==""))
 				{
 					alert('請輸入關鍵字索引_2')
 					pass=false
 					break
 				}
  }
  else
  	{
  		 if((document.form1.n_document2.value.length>0)&&(document.form1.p_s_2.value==""))
  				{
  		  		alert('請輸入關鍵字索引_2!')
  					pass=false
  					break
  				}
  	}

  if(document.form1.n_document3==undefined)									 //如果附件三存在，送出表單前檢查索引欄
  	{
  	 if((document.form1.chkFileExit3.value.length>0)&&(document.form1.p_s_3.value==""))
 			{
 				alert('請輸入關鍵字索引_3')
 				pass=false
 				break
 			}
  	}
 	else
 		{
 			if((document.form1.n_document3.value.length>0)&&(document.form1.p_s_3.value==""))
  			{
  				alert('請輸入關鍵字索引_3!')
  				pass=false
  				break
  			}
 		}
  	break
	}
if (pass) {
      document.form1.submit();
  }	
}
//
function hrefTypecheckdata(){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.ht_title.value =="")
  {
     alert("請輸入類別名稱。");
     document.form1.ht_title.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

function hrefCheckData(){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.h_title.value =="")
  {
     alert("請輸入連結標題。");
     document.form1.h_title.focus();
     pass = false;
	 break;
  }
  if(document.form1.h_www.value =="")
  {
     alert("請輸入連結網址。");
     document.form1.h_www.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

function qanCheckData(){
 var pass = true;
  while (true) 
  {   
  if(document.form1.q_title.value =="")
  {
     alert("請輸入標題。");
     document.form1.q_title.focus();
     pass = false;
	 break;
  }
  if(document.form1.q_content.value =="")
  {
     alert("請輸入問題。");
     document.form1.q_content.focus();
     pass = false;
	 break;
  }
  if(document.form1.q_ans.value =="")
  {
     alert("請輸入回答。");
     document.form1.q_ans.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}
//------------------------------------
function downCheckData(chkColEmpty){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.d_title.value =="")
  {
     alert("請輸入標題。");
     document.form1.d_title.focus();
     pass = false;
	 break;
  }
 
  if (chkColEmpty=='0')
  {
  
  if(document.form1.d_file_1.value =="")
  {
     alert("請選擇上傳檔案。");
     document.form1.d_file_1.focus();
     pass = false;
	 break;
  }
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}
function purchaseCheckData(chkColEmpty){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.p_title.value =="")
  {
     alert("請輸入標題。");
     document.form1.p_title.focus();
     pass = false;
	 break;
  }
 
  if (chkColEmpty=='0')
  {
  
  if(document.form1.p_document1.value =="")
  {
     alert("請選擇上傳檔案。");
     document.form1.p_document1.focus();
     pass = false;
	 break;
  }
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

function sirCheckData(chkColEmpty){
 var pass = true;
  while (true) 
  { 
  
  if(document.form1.sir_name.value =="")
  {
     alert("請輸入姓名。");
     document.form1.sir_name.focus();
     pass = false;
	 break;
  }
  if(document.form1.sir_back.value =="")
  {
     alert("請輸入學歷。");
     document.form1.sir_back.focus();
     pass = false;
	 break;
  }
  if(document.form1.sir_job.value =="")
  {
     alert("請輸入現職。");
     document.form1.sir_job.focus();
     pass = false;
	 break;
  }
  if(document.form1.sir_career.value =="")
  {
     alert("請輸入經歷。");
     document.form1.sir_career.focus();
     pass = false;
	 break;
  }
  if (chkColEmpty=='0')
  {
  
  if(document.form1.sir_photo.value =="")
  {
     alert("請選擇上傳照片。");
     document.form1.sir_photo.focus();
     pass = false;
	 break;
  }
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}
function checkdata(){
var pass = true;
 while (true) 
  { 
    if(document.form1.name.value == "")
    {
     alert("請輸入姓名");    
	 document.form1.name.focus();
     pass = false;
	 break;
    }
    if(document.form1.count.value == "")
    {
     alert("請輸入帳號");    
	 document.form1.count.focus();
     pass = false;
	 break;
    } 
	if(document.form1.pass.value == "")
    {
     alert("請輸入密碼");    
	 document.form1.pass.focus();
     pass = false;
	 break;
    } 	
   break;
  }
  if (pass) {
      document.form1.submit();
  }	
}

function sm1Check(){
var pass = true;
 while (true) 
  { 
   break;
  }
  if (pass) {
      document.form1.submit();
  }	
}
//
function searchTypecheck(){
 var pass = true;
  while (true) 
  { 
  if(document.form1.sm2_number.value =="")
  {
     alert("請輸入類別代碼。");
     document.form1.sm2_number.focus();
     pass = false;
	 break;
  }
  if(document.form1.sm2_name.value =="")
  {
     alert("請輸入類別名稱。");
     document.form1.sm2_name.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

/*----------------------------------------開啟各檔案被下載之ip列表--------------------------------------------*/
function showDownloadedIP(obj)
{
	if(obj.options[obj.selectedIndex].value != 0)
	{
		selectedIdx = (obj.options[obj.selectedIndex].value);
		f_id=selectedIdx.substr(0,2);
	
		if(selectedIdx.substr(2,1) == 'f')
		 	field = 1;
		else
			field = 2;
	
		window.open("showip.php?f_id="+f_id+"&field="+field,'',config='height=800,width=600,toolbar=no,menubar=no');	
	}
	
}
//開新視窗.......................................................................................
//連結類別
function hrefTypeAddOpen(page,action,id){
  window.open(unescape("href/hreftype_index.php?page="+page+"&action="+action+"&hid="+id) ,"aa"," width=550,height=500,top=100,left=300,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,cannelmode=no,fullscreen=no")
}
function downTypeAddOpen(page,action,id){
  window.open(unescape("down/downtype_index.php?page="+page+"&action="+action+"&did="+id) ,"aa"," width=550,height=500,top=100,left=300,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,cannelmode=no,fullscreen=no")
}
function purchaseTypeAddOpen(page,action,id){
  window.open(unescape("purchase/purchasetype_index.php?page="+page+"&action="+action+"&pid="+id) ,"aa"," width=550,height=500,top=100,left=300,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,cannelmode=no,fullscreen=no")
}
function searchDepOpen(page,action,id,type,SearchID){
  window.open(unescape("search/searchtype_index.php?page="+page+"&action="+action+"&sm2_id="+id+"&type="+type+"&SearchID="+SearchID) ,"aa"," width=600,height=130,top=100,left=300,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,cannelmode=no,fullscreen=no")
}

function searchTypeAddOpen(page,action,id,type){
  window.open(unescape("search/searchtype_index.php?page="+page+"&action="+action+"&sid="+id+"&type="+type) ,"aa"," width=550,height=500,top=100,left=300,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,cannelmode=no,fullscreen=no")
}

function openTypeAddOpen(page,action,id){
  window.open(unescape("open/opentype_index.php?page="+page+"&action="+action+"&b_id="+id) ,"aa"," width=550,height=500,top=100,left=300,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,cannelmode=no,fullscreen=no")
}
//文件刪除======================================================================================================

function Filedelconfirm(foldername,type,filename,id){  
  var aaa;
  aaa=confirm("確定要刪除該檔案嗎?");
  if(aaa){window.location=pathOnly(location.href)+foldername+"/del_file.php?id="+id+"&foldername="+foldername+"&type="+type+"&filename="+filename;}
}

//==========================================
function chk_epaper()
{
 var pass = true;
 while (true) 
  { 
    if(document.form1.ep_name.value == "")
    {
     alert("請輸入本期標題內容");    
	 document.form1.ep_name.focus();
     pass = false;
	 break;
    }
   break;
  }
  if (pass) {
      document.form1.submit();
  }	
}

//======================================
function delEpaperconfirm(page_fun,id)
{  
   var aaa;
   aaa=confirm("確定要刪除該筆資料嗎?");
   if(aaa)
   {window.location=pathOnly(location.href)+"index.php?page="+page_fun+"&id="+id+"&action=Del";}
}
//======================================
 function epaperMaildelconfirm(id,mail_addr)
{  
   var aaa;
   aaa=confirm("確定要刪除 " + mail_addr + " mail帳號嗎?");
   if(aaa) 
   {window.location=pathOnly(location.href)+"index.php?page=epaper_h&id="+id+"&action=mailDel";}
  
}
//======================================
function chk_EpaperMailAdd(){
 var pass = true;
  while (true) 
  {   
  if(document.form1.epaper_mail.value =="")
  {
     alert("請輸入電子郵件。");
     document.form1.epaper_mail.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();

  }	
}


//======================================
 function DelQuestionnaireConfirm(page_fun,id)
{  
   var aaa;
   aaa=confirm("確定要刪除該筆資料嗎?");
   if(aaa)
   {window.location=pathOnly(location.href)+"index.php?page="+page_fun+"&QID="+id+"&action=Del";}
}


//--------------------------------------
function chk_questionnaire(){
 var pass = true;
  while (true) 
  {   
  if(document.form1.QTitle.value =="")
  {
     alert("請輸入標題。");
     document.form1.QTitle.focus();
     pass = false;
	 break;
  }
  if(document.form1.QEndDate.value =="")
  {
     alert("請輸入結束時間。");
     document.form1.QEndDate.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

//--問卷小題------------------------------------
function chk_questionnaire2(){
 var pass = true;
  while (true) 
  {   
  if(document.form1.Q2Subject.value =="")
  {
     alert("請輸入問卷題目內容。");
     document.form1.Q2Subject.focus();
     pass = false;
	 break;
  }
  if(document.form1.Answer_num.value =="")
  {
     alert("請輸入答案數。");
     document.form1.Answer_num.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

//--問卷答案------------------------------------
function chk_questionnaire3(num){
 var pass = true;
 var result;
 var str="document.form1.Q3Answer";
 for(i=1;i<=num;i++){
 result=eval(str+i)
  while(true){ 
	  if(result.value==""){
		 alert("請輸入答案"+i+"的內容。");
		 result.focus();
		 pass = false;
		 break;
	  }	 
   break;
  }
 }
  if (pass) {
      document.form1.submit();
  }	
}


//--首頁看板------------------------------------
function chk_advertise(){
 var pass = true;
  while (true) 
  {   
  if(document.form1.ad_Title.value =="")
  {
     alert("請輸入標題。");
     document.form1.ad_Title.focus();
     pass = false;
	 break;
  }
  if(document.form1.ad_Content.value =="")
  {
     alert("請輸入內容。");
     document.form1.ad_Content.focus();
     pass = false;
	 break;
  }
  if(document.form1.ad_Pic.value =="")
  {
     alert("請輸入檔案來源。");
     document.form1.ad_Pic.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

//--首頁看板修改------------------------------------
function chk_advertise_modify(){
 var pass = true;
  while (true) 
  {   
  if(document.form1.ad_Title.value =="")
  {
     alert("請輸入標題。");
     document.form1.ad_Title.focus();
     pass = false;
	 break;
  }
  if(document.form1.ad_Content.value =="")
  {
     alert("請輸入內容。");
     document.form1.ad_Content.focus();
     pass = false;
	 break;
  }
 
 break;
}
if (pass) {
      document.form1.submit();

  }	
}


///=======================
 function DeladvertiseConfirm(page_fun,id)
{  
   var aaa;
   aaa=confirm("確定要刪除該筆資料嗎?");
   if(aaa)
   {window.location=pathOnly(location.href)+"index.php?page="+page_fun+"&ad_ID="+id+"&action=Del";}
}

///政府資訊公開刪除=======================
function delOpenConfirm(id){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=open_h&action=Del&o_id="+id;}
}
///刪除分類檢索=======================
 function DelsearchConfirm(page_fun,id)
{  
   var aaa;
   aaa=confirm("確定要刪除該筆資料嗎?");
   if(aaa)
   {window.location=pathOnly(location.href)+"index.php?page="+page_fun+"&SearchID="+id+"&action=Del";}
}


//--分類檢索------------------------------------
function chk_search1(){
 var pass = true;
  while (true) 
  {
  if(document.form1.Title.value =="")
  {
     alert("請輸入標題。");
     document.form1.Title.focus();
     pass = false;
	 break;
  }	
  if(document.form1.URL.value =="")
  {
     alert("請輸入網址。");
     document.form1.URL.focus();
     pass = false;
	 break;
  }	
  //判斷是否有select bar
 if(document.form1.theme!=null&&document.form1.cake!=null&&document.form1.service!=null){
  if(document.form1.theme.value =="")
  {
     alert("請選擇第二層主題分類。");
     document.form1.theme.focus();
     pass = false;
	 break;
  }
  if(document.form1.cake.value =="")
  {
     alert("請選擇第二層施政分類。");
     document.form1.cake.focus();
     pass = false;
	 break;
  }
  if(document.form1.service.value =="")
  {
     alert("請選擇第二層服務分類。");
     document.form1.service.focus();
     pass = false;
	 break;
  }
 }//-
 break;
}
if (pass) {
      document.form1.submit();

  }	
}

//--分類檢索下拉選單1------------------------------------
function chk_searchdep1(){
 var pass = true;
  while (true) 
  {
  if(document.form1.theme.value =="")
  {
     alert("請選擇第二層主題分類。");
     document.form1.theme.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();
  }	
}

//--分類檢索下拉選單2------------------------------------
function chk_searchdep2(){
 var pass = true;
  while (true) 
  {
  if(document.form1.cake.value =="")
  {
     alert("請選擇第二層施政分類。");
     document.form1.cake.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();
  }	
}

//--分類檢索下拉選單3------------------------------------
function chk_searchdep3(){
 var pass = true;
  while (true) 
  {
  if(document.form1.service.value =="")
  {
     alert("請選擇第二層服務分類。");
     document.form1.service.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();
  }	
}

//--公開資訊目錄------------------------------------
function CheckBillData(){
 var pass = true;
  while (true) 
  {
  if(document.form1.b_title.value =="")
  {
     alert("請輸入類別名稱。");
     document.form1.b_title.focus();
     pass = false;
	 break;
  }
  
 break;
}
if (pass) {
      document.form1.submit();
  }	
}

//--公開資訊------------------------------------
function CheckOpenData(){
 var pass = true;
  while (true) 
  {
  if(document.form1.b_id.value =="")
  {
     alert("請選擇公開資訊類別。");
     document.form1.b_id.focus();
     pass = false;
	 break;
  }
  if(document.form1.o_title.value =="")
  {
     alert("請輸入公開資訊標題。");
     document.form1.o_title.focus();
     pass = false;
	 break;
  }
   if((document.form1.o_www.value =="") && (document.form1.o_file.value =="") )
  {
     alert("請選擇上傳網頁或是上傳檔案。");
     //document.form1.o_title.focus();
     pass = false;
	 break;
  }
 break;
}
if (pass) {
      document.form1.submit();
  }	
}
//--政府公開資訊檔案刪除

function OpenFiledel(action,id){  
  var aaa;
  aaa=confirm("確定要刪除該筆資料嗎?");
  if(aaa){window.location=pathOnly(location.href)+"index.php?page=open_delfile&action="+action+"&o_id="+id;}
}

/*-----------------------進階搜尋check----------------------------------*/

//------------------------資料搜尋------------------------
function strSearchChk(control)
{
	var pass=true
	re=/^\s*$/
	if(re.test(document.form1.textfield.value))
	  {
		alert("請輸入欲查詢字彙")
		document.form1.textfield.focus()
		pass=false
	  }
	else if(!(document.form1.purchase.checked)&&!(document.form1.service.checked)&&!(document.form1.hyperlink.checked)&&!(document.form1.board.checked)&&!(document.form1.canServ.checked)&&!(document.form1.unitIntro.checked))
	 {
		alert('沒有選取搜尋分類!')
		pass=false
	 }
	 else
	 {
		 if(!re.test(document.form1.textfield.value))
		 {
		 	ltrimStr= lTrim(document.form1.textfield.value)
			document.form1.textfield.value=rTrim(ltrimStr)
		 }
		 if(!re.test(document.form1.textfield2.value))
		 {
			ltrimStr= lTrim(document.form1.textfield2.value)
			document.form1.textfield2.value=rTrim(ltrimStr)
		 }
	 }
	if(pass)
		document.form1.submit()
}

//------------------------檔案搜尋-------------------------
function fSearchChk()
{
	var pass = true
	re=/^\s*$/
	if(re.test(document.form2.fName.value))
	{
			alert("請輸入檔案名稱!")
			document.form2.fName.focus()
			pass=false
	}
	else
		{
			if(!re.test(document.form2.fName.value))
			{
				ltrimStr=lTrim(document.form2.fName.value)
				document.form2.fName.value=rTrim(ltrimStr)
			}
		}
	if(pass)
		document.form2.submit()
}

//------------------------網頁搜尋-------------------------
function webSearchChk()
{
	var pass=true
	re=/^\s*$/
	if(re.test(document.form3.textfield3.value))
	  {
		alert("請輸入欲查詢字彙")
		document.form3.textfield3.focus()
		pass=false
	  }
	if(!(document.form3.unitIntro.checked)&&!(document.form3.film.checked)&&!(document.form3.canServ.checked))
	{
		alert('沒有選取搜尋分類!')
		pass=false
	}
	else
		{
			if(!re.test(document.form3.textfield3.value))
		 	{
		 		ltrimStr= lTrim(document.form3.textfield3.value)
				document.form3.textfield3.value=rTrim(ltrimStr)
		 	}
		 		if(!re.test(document.form3.textfield4.value))
		 	{
				ltrimStr= lTrim(document.form3.textfield4.value)
				document.form3.textfield4.value=rTrim(ltrimStr)
		 	}
		}
	if(pass)
		document.form3.submit()
}

//--------------------去除字串左邊空白-----------------------

function lTrim(str)
{
	sCounter=0
		for(i=0;i<str.length;i++)
		{
			if(str.charAt(i)==" ")
			{
				 sCounter++
			}
			else
			break
		}
	return str.substr(sCounter,str.length)
}

//--------------------去除字串右邊空白------------------------
function rTrim(str)
{
	sCounter=0
		for(i=str.length;i>=0;i--)
		{
			if(str.charAt(i-1)==" ")
			{
			  sCounter++;
			}
			else
			break
		}
    return	str.substr(0,str.length-sCounter)
}