/*-------------------------------------------------- 
*   ÆÄÀÏ¸í     :   com_page.js
*   µî·ÏÀÚ     :   ÀÌ±â¼ø |   2004.8.3
*   ¼öÁ¤ÀÚ     :            
*   ³»   ¿ë   :   ÆäÀÌÁö °ü·Ã ½ºÅ©¸³Æ® Á¤¸®
*--------------------------------------------------*/ 

//--------------------------------------------------
//  °Ë»öÃ³¸®
//--------------------------------------------------
var cioPath = "/jsp"

function gfn_fgoPage(page) {
    var dst = "";
	var	str = self.location.toString(); 
    with(document.vJobForm){
	    try {
	    	dst = replaceStr(str,"sPage",page);
			location.href = dst;
		} catch (e){
		}   
    } 
}   


//--------------------------------------------------
// ÆäÀÌÂ¡Ã³¸®¿¡¼­ spage Ä¡È¯Ã³¸®
//--------------------------------------------------
function replaceStr(str, fromStr, page){
    if (str=="") return str;
    if (!str.substring) return str;
    var idx = str.indexOf(fromStr);
    var idx2 = str.indexOf("?");
    if (idx>=0){
		str = str.substring(0,idx)+"sPage="+page;
    } else {
    	if (idx2>=0){
	    	str = str + "&sPage="+page;
    	} else {
    		str = str + "?sPage="+page;
    	}
    }
    return str;
}

//--------------------------------------------------
//  Æú´õ¸íº¯°æ

//--------------------------------------------------
function gfn_fnList(page) { 
    gfn_fgoPage(page); 
}   

//--------------------------------------------------
//  ÆäÀÌÁö¸¦ È­¸é¿¡ Ãâ·Â
//--------------------------------------------------
function gfn_printPageNum(totalCount,printNum,rowNum,curPage){ 
    if (totalCount==0){ 
      document.all['total'].innerHTML = " (ÃÑ <b><font color='#FF9900'>0</font></b> ÆäÀÌÁö ,ÃÑ <font color='#84BDDA'>0</font> °Ç)"; 
    } else { 
      var totalPageCnt = Math.ceil(totalCount / rowNum); 
      var sHtml = gfn_getPageNav(totalPageCnt,printNum,curPage); 
      document.all['total'].innerHTML = "(ÃÑ <b><font color='#FF9900'>"+totalPageCnt+"</font></b> ÆäÀÌÁö ,ÃÑ <font color='#84BDDA'>"+ totalCount +"</font> °Ç)";
      document.all['pages'].innerHTML = sHtml;    
    } 
}

//--------------------------------------------------
//  Æú´õ¸íº¯°æ
//--------------------------------------------------
function gfn_getPageNav(totalPageCnt,printNum,curPage) {  

    var iStart= curPage - Math.ceil(printNum / 2)+1; 
    var iEnd = curPage + Math.ceil(printNum / 2)-1; 
  
    if (iStart  < 1) { 
        iStart = 1; 
        iEnd  = printNum; 
    } 
  
    if (iEnd  > totalPageCnt) { 
        iEnd = totalPageCnt; 
        iStart = ((iEnd - printNum+1) < 1 ) ? 1 : iEnd - printNum+1; 
    } 
 
    var sHtml = ""; 
    if ((iStart != 1) && (totalPageCnt>=iEnd)) { 
        var ibefore = iStart - 1 ;
        if (ibefore < 1) ibefore = 1;
        sHtml += "<a href='javascript:gfn_fnList(1)'><img src='"+cioPath+"/common/img/icon/icon_first_page.gif' width='55' height='20' align='absmiddle' title='The First' border=0></a>&nbsp;";   
        sHtml += "<a href='javascript:gfn_fnList(" + ibefore + ")'><img src='"+cioPath+"/common/img/icon/icon_prev_page.gif'  width='55' height='20' align='absmiddle' title='The Previous' border=0></a>";      
    } 
    for(var i=iStart; i<= iEnd; i++) { 
        if(curPage== i) { 
            sHtml += "<b><font color='#FF0066'>[" + i + "]</font> </b>|"; 
        } else { 
            sHtml += "<a href='javascript:gfn_fnList(" + i + ")'><font>[" + i + "]</font></a>|"; 
        } 
    } 
    if ((iEnd != totalPageCnt) && (totalPageCnt>iEnd)) { 
        var inext = iEnd + 1 ;
        if (inext > totalPageCnt) ibefore = totalPageCnt;
        sHtml += "<a href='javascript:gfn_fnList(" + inext + ")'><img src='"+cioPath+"/common/img/icon/icon_next_page.gif'  width='55' height='20' align='absmiddle' title='The Next' border=0></a>&nbsp;";    
        sHtml += "<a href='javascript:gfn_fnList(" + totalPageCnt + ")'><img src='"+cioPath+"/common/img/icon/icon_last_page.gif'  width='55' height='20' align='absmiddle' title='The Last' border=0></a>";  
    } 
    return sHtml; 
}



/*-------------------------------------------------- 
* End
*--------------------------------------------------*/ 