/*==========================================================
	ÆÄÀÏ¸í		:common.js
	ÆÄÀÏ¼³¸í		:ajax¿¡¼­ »ç¿ëµÇ´Â °øÅëÇÔ¼öµé
	Á¦  ÀÛ		:¹é½ÂÇö(gazerkr)
==========================================================*/

/***********************************************************
	ÇÔ¼ö¸í		:func_paging(ÃÑ°Ô½Ã¹°¼ö)
	Ã³¸®³»¿ë		:ÆäÀÌÂ¡¿ë ÇÔ¼ö
***********************************************************/
function func_paging(totalcnt){
	var totpages = Math.ceil(totalcnt/LISTUNIT); //ÃÑÆäÀÌÁö¼ö
	var thisblock = Math.ceil(THISPAGE/PAGEUNIT); //ÇöÀç ÆäÀÌÂ¡ºí·°
	var startpage, endpage;
	var ret_HTML = "";
	
	// ÇöÀç ÆäÀÌÁöºí·°ÀÇ ½ÃÀÛÆäÀÌÁö¹øÈ£
	if(thisblock > 1){
		startpage = (thisblock-1)*PAGEUNIT+1;
	}else{
		startpage = 1;
	}
	
	// ÇöÀç ÆäÀÌÁöºí·°ÀÇ ³¡ÆäÀÌÁö¹øÈ£
	if( (thisblock*PAGEUNIT) >= totpages ){
		endpage = totpages;
	}else{
		endpage = thisblock*PAGEUNIT;
	}
	
	ret_HTML = "<TR>";
	ret_HTML += "  <TD align='center' colspan='5'><div class='paging'>";
	if(THISPAGE > 1){
		ret_HTML += "  <A onclick='act_search(1);' style='cursor:hand;'><img src='../m_board/img/icon_05.gif' width='8' height='5' align='absmiddle' border='0'></A>"; // ¸ÇÃ³À½À¸·Î °¡±â
		ret_HTML += "  <A onclick='act_search("+(THISPAGE-1)+");' style='cursor:hand;'><img src='../m_board/img/icon_03.gif' width='4' height='5' align='absmiddle' border='0'></A>"; // ÇöÀçºí·°ÀÇ ÀüÆäÀÌÁö
	}
	for(i=startpage; i<=endpage; i++){
		if(i!=THISPAGE){
			ret_HTML += " &nbsp;<A onclick='act_search("+i+");' onmouseover=\"this.className='over'\" onmouseout=\"this.className=''\" style='padding:7px' style='cursor:hand;'>"+i+"</A>";
		}else{
			ret_HTML += " &nbsp;<strong>"+i+"</strong>";
		}
	}
	
	if(THISPAGE != totpages){
		ret_HTML += "  <A onclick='act_search("+(THISPAGE+1)+");' style='cursor:hand;'><img src='../m_board/img/icon_04.gif' width='4' height='5' align='absmiddle' border='0'></A>"; // ÇöÀçºí·°ÀÇ ´ÙÀ½ÆäÀÌÁö
		ret_HTML += "  <A onclick='act_search("+totpages+");' style='cursor:hand;'><img src='../m_board/img/icon_06.gif' width='8' height='5' align='absmiddle' border='0'></A>"; // ¸Ç ¸¶Áö¸·ÆäÀÌÁö
	}
	ret_HTML += "  </div></TD>";
	ret_HTML += "</TR>";
	
	return ret_HTML;
}

/***********************************************************
	ÇÔ¼ö¸í		:newXMLHttpRequest()
	Ã³¸®³»¿ë		:¿äÃ»°´Ã¼¸¦ »ý¼ºÈÄ ¹ÝÈ¯
***********************************************************/
// function from http://www-128.ibm.com/developerworks/kr/library/j-ajax1/index.html
function newXMLHttpRequest() {
	var xmlreq = false;
	if (window.XMLHttpRequest) {
		// Create XMLHttpRequest object in non-Microsoft browsers
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		// Create XMLHttpRequest via MS ActiveX
		try {
			// Try to create XMLHttpRequest in later versions
			// of Internet Explorer
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			// Failed to create required ActiveXObject
			try {
				// Try version supported by older versions
				// of Internet Explorer
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				// Unable to create an XMLHttpRequest with ActiveX
			}
		}
	}
	return xmlreq;
}

