﻿
        function changePage(pIndex){
            document.getElementById('pageIndexHidden').value=pIndex;
            ajaxQuery();
        }
         
			function ajaxQuery(){
                    var strCityID='-1';
                    var strClientType=document.getElementById('ddlClientType').value;                    
                    
                    var strRegionIDList='';
                    for (var intI = 0 ; intI < document.form1.length ; intI++) {
                            if (document.form1.elements[intI].type == 'checkbox') {
                                var strCheckID=document.form1.elements[intI].id ;
                                if (strCheckID.indexOf('chkRegion_',0) != '-1'){
                                    if (document.getElementById (strCheckID).checked==true){
                                        var arrTmp=strCheckID.split("_");
                                        if(strRegionIDList!=''){strRegionIDList+='_';}
                                        strRegionIDList += arrTmp[2];
                                    }
                                }
                            }
                      }
                    if (strRegionIDList==''){
                        for (var intI = 0 ; intI < document.form1.length ; intI++) {
                                if (document.form1.elements[intI].type == 'checkbox') {
                                    var strCheckID=document.form1.elements[intI].id ;
                                    if (strCheckID.indexOf('chkRegion_',0) != '-1'){
                                            var arrTmp=strCheckID.split("_");
                                            if(strRegionIDList!=''){strRegionIDList+='_';}
                                            strRegionIDList += arrTmp[2];
                                    }
                                }
                          }
                    }
                    
                    var strPageIndex=document.getElementById('pageIndexHidden').value;
                    document.getElementById('divPopUpMsg').style.display='block';
                    setPopUpPosition('divPopUpMsg');
                    $.ajax({
                      type:'post',
                      url:'ajax/Agency_AJAX.aspx',
                      data:{strCityID:strCityID, strClientType:strClientType, strRegionIDList:strRegionIDList, strPageIndex:strPageIndex, strOtherPara:''},
                      error: function(xhr) {
//                          alert(xhr.responseText);
                          alert('系統錯誤');
                          document.getElementById('divPopUpMsg').style.display='none';
                      },
                    success: function(response) {
                        var aryreturn=response.split("******")
                        $('#divList').html(aryreturn[0]);
                        $('#divList').fadeIn();
                        $('#divPageContainer_Up').html(aryreturn[1]);
                        $('#divPageContainer_Up').fadeIn();
                        $('#divPageContainer_Down').html(aryreturn[1]);
                        $('#divPageContainer_Down').fadeIn();
                        document.getElementById('divPopUpMsg').style.display='none';
                    }
                  });
			}
    
