
//카운터
function FuncAjaxModPlugin_Search_Func_ListCounter(){
      var AjaxModPluginLayout_Search_LoadTotal = document.getElementsByName("TxtAjaxModPlugin_Search_Total")[0].value;
      var totpages  = Math.ceil(AjaxModPluginLayout_Search_LoadTotal/AjaxModPluginLayout_Search_ListUnit); //총페이지수
      var thisblock = Math.ceil(AjaxModPluginLayout_Search_ThisNo/AjaxModPluginLayout_Search_PageUnit); //현재 페이징블럭
      var startpage, endpage;
      var tag  = "";
      // 현재 페이지블럭의 시작페이지번호
      if(thisblock > 1){
        startpage = (thisblock-1)*AjaxModPluginLayout_Search_PageUnit+1;
      }else{
        startpage = 1;
      }
      // 현재 페이지블럭의 끝페이지번호
      if( (thisblock*AjaxModPluginLayout_Search_PageUnit) >= totpages ){
        endpage = totpages;
      }else{
        endpage = thisblock*AjaxModPluginLayout_Search_PageUnit;
      }
      tag += "<table border='0' align='center' cellspacing='0' cellpadding='0'>";
         tag += "<tr>";
            if(AjaxModPluginLayout_Search_ThisNo > 1 && AjaxModPluginLayout_Search_LoadTotal > 0 ){
               tag += "<td JqueryRollOver='Y' style='background-color:#FFFFFF;border:1px solid #DBDBDB;padding:0.3em 0.5em 0.3em 0.5em;text-align:center;' onclick='FuncAjaxModPlugin_Search_Func_AjaxPageMove(1);'>처음</td>";
               tag += "<td style='width:3px'></td>";
               tag += "<td JqueryRollOver='Y' style='background-color:#FFFFFF;border:1px solid #DBDBDB;padding:0.3em 0.5em 0.3em 0.5em;text-align:center;' onclick='FuncAjaxModPlugin_Search_Func_AjaxPageMove("+(Number(AjaxModPluginLayout_Search_ThisNo)-1)+");'>이전</td>";
               tag += "<td style='width:5px'></td>";
            }
            for(i=startpage; i<=endpage; i++){
               if(i != AjaxModPluginLayout_Search_ThisNo){
                  tag += "<td JqueryRollOver='Y' style='background-color:#FFFFFF;border:1px solid #DBDBDB;padding:0.3em 0.5em 0.3em 0.5em;text-align:center;' onclick='FuncAjaxModPlugin_Search_Func_AjaxPageMove("+i+");'>"+i+"</td>";
                  tag += "<td style='width:3px'></td>";
               }else{
                  tag += "<td style='border:1px solid #495bd7;padding:0.3em 0.5em 0.3em 0.5em;font-size:8pt;text-align:center;font-weight:bold;color:#495bd7'>"+i+"</td>";
                  tag += "<td style='width:3px'></td>";
               }
            }
            if(AjaxModPluginLayout_Search_ThisNo != totpages && AjaxModPluginLayout_Search_LoadTotal > 0 ){
               tag += "<td style='width:5px'></td>";
               tag += "<td JqueryRollOver='Y' style='background-color:#FFFFFF;border:1px solid #DBDBDB;padding:0.3em 0.5em 0.3em 0.5em;text-align:center;' onclick='FuncAjaxModPlugin_Search_Func_AjaxPageMove("+(Number(AjaxModPluginLayout_Search_ThisNo)+1)+");'>다음</td>";
               tag += "<td style='width:3px'></td>";
               tag += "<td JqueryRollOver='Y' style='background-color:#FFFFFF;border:1px solid #DBDBDB;padding:0.3em 0.5em 0.3em 0.5em;text-align:center;' onclick='FuncAjaxModPlugin_Search_Func_AjaxPageMove("+totpages+");'>끝</td>";
            }
         tag += "</tr>";
      tag += "</table>";
      return tag;
}





//웹검색 -> 서브메뉴 이동
function FuncAjaxModPlugin_Search_Func_SubMenu(menu){
   if(!menu){
      window.alert("더보기에 필요한 메뉴값이 없습니다");
      return false;
   }
   AjaxModPluginLayout_Search_ThisNo = 1;
   RootFormSearch.stPAGE.value = AjaxModPluginLayout_Search_ThisNo;
   RootFormSearch.SEARCH_MENU.value = menu;

   RootFormSearch.SEARCH_SUB.value = "Y";
   if(AjaxModPluginLayout_Search_AjaxYn == "Y"){         //Ajax실행 유무
      FuncAjaxModPlugin_Search_Action_Search();
   }else{
      RootFormSearch.submit();
   }
}


//웹검색 -> 페이지 번호 이동
function FuncAjaxModPlugin_Search_Func_AjaxPageMove(page){
   if(page){
      AjaxModPluginLayout_Search_ThisNo = page;
   }
   RootFormSearch.SEARCH_SUB.value = "Y";
   FuncAjaxModPlugin_Search_Action_Search();
}



//웹검색 스위치
function FuncAjaxModPlugin_Search_Switch_Search(){
   if(!document.getElementsByName("SelectAjaxModPluginLayout_Search_Type")[0].value){
      window.alert("검색 방법이 없습니다");
      document.getElementsByName("SelectAjaxModPluginLayout_Search_Type")[0].focus();
      return false;
   }
   if(!document.getElementsByName("SelectAjaxModPluginLayout_Search_keyword")[0].value){
      window.alert("검색 키워드가 없습니다");
      document.getElementsByName("SelectAjaxModPluginLayout_Search_keyword")[0].focus();
      return false;
   }
   if(document.getElementsByName("SelectAjaxModPluginLayout_Search_Type")[0]){
      RootFormSearch.SEARCH_TYPE.value = document.getElementsByName("SelectAjaxModPluginLayout_Search_Type")[0].value;
   }
   if(document.getElementsByName("SelectAjaxModPluginLayout_Search_keyword")[0]){
      RootFormSearch.SEARCH_DATA.value = document.getElementsByName("SelectAjaxModPluginLayout_Search_keyword")[0].value;
   }
   RootFormSearch.SEARCH_SUB.value = "N";
   if(AjaxModPluginLayout_Search_AjaxYn == "Y"){         //Ajax실행 유무
      FuncAjaxModPlugin_Search_Action_Search();
   }else{
      RootFormSearch.submit();
   }
}


//검색어 링크 처리
function FuncAjaxModPlugin_Search_Action_Direct(string){
   if(string){
      //SEARCH_DATA
      document.getElementsByName("SelectAjaxModPluginLayout_Search_keyword")[0].value = decodeURIComponent(FucRepaceScript("+"," ",string));
      AjaxModPluginLayout_Search_ThisNo = 1;
      FuncAjaxModPlugin_Search_Switch_Search();
   }
}


//웹검색 ACTION
function FuncAjaxModPlugin_Search_Action_Search(){
   RootFormSearch.stPAGE.value = AjaxModPluginLayout_Search_ThisNo;

   var string = $("form[name='RootFormSearch']").serialize();
   string += "&SkinPath="+AjaxModPluginLayout_Search_SkinPath;
   string += "&TableSize="+AjaxModPluginLayout_Search_TableSize;

   FuncDftAjaxProcessWaitingTag(1);       //Ajax 실행중 출력문
   //jqeury -> Ajax 실행
   $.ajax({
      type:"POST",
      url:""+AjaxModPluginLayout_Search_SkinPath+"act/action.php",
      data:string,
      success:function(html){
         FuncDftAjaxProcessWaitingTag(2);       //Ajax 실행중 출력문
         $("#"+AjaxModPluginLayout_Search_InnerDivName).html(html);
         if(document.getElementById("DivAjaxSearchLayout_Counter")){
            var count = FuncAjaxModPlugin_Search_Func_ListCounter();
            $("#DivAjaxSearchLayout_Counter").html(count);
            $("#DivAjaxSearchLayout_Counter2").html(count);
         }
         document.body.scrollTop = 0;                       //페이지 상위로
         FuncJqueryToAjaxDefaultReadySetting(); //jQuery -> Ajax 기본 설정적용
      }
   });
}

//Ajax 가 아닌 POST방식 검색 레이아웃으로 이동
function FuncAjaxModPlugin_Search_Func_GetCount(link,page){
   RootFormSearch.action            = link;
   RootFormSearch.stPAGE.value      = page;
   RootFormSearch.SEARCH_PAGE.value = "Y";
   RootFormSearch.SEARCH_SUB.value  = "Y";
   RootFormSearch.submit();
}

//검색어 제거
function FuncAjaxModPlugin_Search_SearchClear(){
   $("input[name=SelectAjaxModPluginLayout_Search_keyword]").val("").focus();
}
