// ÄÁÅÙÃ÷ ±¸ºÐ //////////////////////////////////////////////////////
//¸®Äí¸£Æ® ¸®Æ÷Æ®		= 0
//ÀÌ·Â¼­ Å¬¸®´Ð			= 1
//¾ç½Ä ´Ù¿î·Îµå			= 2
//½ÅÀÔ»ç¿øAtoZ			= 8
//Ãë¾÷´º½ºÅ¬¸®ÇÎ		= 30
//¾Æ¸£¹ÙÀÌÆ® Ã¤¿ë Á¤º¸	= 98
//¸®Äí¸£Æ® Ã¤¿ëÁ¤º¸		= 99
//°ø¸ðÀü				= 100
//¸éÁ¢Á·º¸				= 101
//Àü¹®°¡ ÀÎÅÍºä			= 102

// ¼­ºêÄÁÅÙÃ÷ ±¸ºÐ : Ãë¾÷´º½º Å¬¸®ÇÎ°ú °ø¸ðÀü¿¡¼­ °°ÀÌ »ç¿ëµÊ
//[Ãë¾÷, ¹®È­¿¹¼ú]		= 1
//[±â¾÷/°æÁ¦, ±â¾÷]		= 2
//[ÀÚ°ÝÁõ/Á÷¾÷,°ø°ø±â°ü]= 3
//»çÈ¸/³ëµ¿				= 4
//±³À°/´ëÇÐ				= 5

// AJAX°ü·Ã//////////////////////////////////////////////////////////
var Data = {};
Data.init= {};
Data.param = {};
Data.init.LineImg			= null;		// tr ¶óÀÎ ÀÌ¹ÌÁö
Data.init.PrevImg			= null;		// ÀÌÀü ÆäÀÌÁö ÀÌ¹ÌÁö
Data.init.NextImg			= null;		// ´ÙÀ½ ÆäÀÌÁö ÀÌ¹ÌÁö
Data.init.PageSize			= null;		// ÆäÀÌÁö »çÀÌÁî
Data.init.LoaderObj			= null;		// ·Îµù Object
Data.init.spConObj			= null;		// ·ÎµùµÉ¶§ disabled ? true : false µÉ Object
Data.init.nowPage			= 1;		// ÇöÀç ÆäÀÌÁö
Data.init.strCode			= null;		// ÄÁÅÙÃ÷ ±¸ºÐÄÚµå
Data.init.strSubCode		= null;		// ÄÁÅÙÃ÷ ±¸ºÐ ¼­ºêÄÚµå
Data.init.ListObj			= null;		// µ¥ÀÌÅÍ°¡ Ã¤¿öÁú ¿µ¿ª
Data.init.PageObj			= null;		// ÆäÀÌÂ¡ÀÌ Ã¤¿öÁú ¿µ¿ª
Data.init.BoderColor		= null;		// °Ô½ÃÆÇ ÇüÅÂ°¡ 1ÀÏ °æ¿ì Å×ÀÌºí BorderColor °ª
Data.init.BgColor			= null;		// °Ô½ÃÆÇ ÇüÅÂ°¡ 1ÀÏ°æ¿ì »óÀ§ Á¦¸ñ ¹è°æ »ö °ª
Data.init.RecordObj			= null;		// °Ô½Ã¹° ¼ö°¡ Ã¤¿öÁú Object
Data.init.TotalRecord		= 0;		// ÃÑ °Ô½Ã¹° ¼ö
Data.init.ListType			= 0;		// ¸®½ºÆ® Ãâ·Â ÇüÅÂ 0 : ÀÏ¹Ý °Ô½ÃÆÇ, 1 : ¹æ¸í·Ï ÇüÅÂ
Data.init.PageBlock			= 10;		// ÆäÀÌÂ¡ »çÀÌÁî
Data.init.ListIcon			= null;		// ¸ÞÀÎ Ãë¾÷, ¸®Äí¸£Æ®, ¾Æ¸£¹ÙÀÌÆ® µ¥ÀÌÅÍ ¾Õ¸Ó¸® ¾ÆÀÌÄÜ
Data.init.MaxLength			= null;		// º¸¿©ÁÙ Á¦¸ñ ¹®ÀÚ¿­ ±æÀÌ 
Data.init.LinkClassName		= null;		// ¸µÅ© class

Data.xhr = {};
Data.xhr.HttpUrl = "/ajax/contents.bridge.asp";
Data.xhr.Request = function(param, callback, method) {
	this.url = Data.xhr.HttpUrl;
    this.param = param;
    this.callback = callback;
    this.method = method;        
    this.send();
}

Data.xhr.Request.prototype = {
	CreateXMLHttp : function() { 
	 		if (window.XMLHttpRequest) 
			{ 
				return new XMLHttpRequest(); 
			} 
			else if (window.ActiveXObject) 
			{ 
				var aVersions = [ "MSXML2.XMLHttp.5.0" 
			      ,"MSXML2.XMLHttp.4.0" 
			      ,"MSXML2.XMLHttp.3.0" 
			      ,"MSXML2.XMLHttp" 
			      ,"Microsoft.XMLHttp" 
			      ]; 
			
			    for (var i = 0; i < aVersions.length; i++) 
			    { 
			      try 
			      { 
			        var oXmlHttp = new ActiveXObject(aVersions[i]); 
			        return oXmlHttp; 
			      } 
			      catch (oError) 
			      {     
			      } 
			    } 
		   } 
	},

	send : function() {
        this.req = this.CreateXMLHttp();
        var httpMethod = this.method ? this.method : 'GET';
        if(httpMethod != 'GET' && httpMethod != 'POST') {
            httpMethod = 'GET';
        }
        
        var httpParams = (this.param == null || this.param == '') ? null : this.param;
        var httpUrl = this.url;
        if(httpMethod == 'GET' && httpParams != null) {
            httpUrl = httpUrl + "?" + httpParams;
        }
        
        this.req.open(httpMethod, httpUrl, true);
        this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        var request = this;
        this.req.onreadystatechange = function() {
            request.onStateChange.call(request);
        }
        this.req.send(httpMethod == 'POST' ? httpParams : null);
    },
    
    onStateChange : function() {
        this.callback(this.req);
    }
}

// ÆäÀÌÁö º¯È¯½Ã ±âÁ¸ ¾ÆÀÌÅÛ »èÁ¦
Data.xhr.setControlDel = function(obj, delVal) {
	try {
		while(obj.childNodes.length > delVal) {
			obj.removeChild(obj.childNodes[0]);
		}
	} catch(e1) {}
}

// ·Îµù ÀÌ¹ÌÁö val = true ? none : ''
// ¸®½ºÆ® ÆäÀÌÁö disable
Data.xhr.ToggleLoader = function(val) {
	this.val1 = (val) ? 'none'	: '';
	this.val2 = (val) ? false	: true;	

	this.setLoader();
}
Data.xhr.ToggleLoader.prototype = {
	setLoader : function() {
		if(Data.init.LoaderObj) {
			Data.init.LoaderObj.style.display = this.val1;
			if(Data.init.spConObj) { Data.init.spConObj.disabled = this.val2; }
		}
	}
}

// ÆäÀÌÂ¡ ¼³Á¤
Data.xhr.doCreatePaging = function(obj, pcount) {
	this.obj		= obj;
	this.Pcount		= parseInt(pcount);
	this.Page		= parseInt(Data.init.nowPage);
	this.PageBlock	= parseInt(Data.init.PageBlock);
	this.PrevImg	= Data.init.PrevImg;
	this.NextImg	= Data.init.NextImg;
	this.strCode	= Data.init.strCode;
	this.strSubCode = Data.init.strSubCode;

	this.sPage = parseInt(this.Page / this.PageBlock) + 1;
	this.sPage = ((this.Page % this.PageBlock) == 0) ? this.sPage - 1 : this.sPage;
	this.sPage = (this.sPage - 1) * this.PageBlock + 1;
	this.ePage = (this.sPage + this.PageBlock) -1;
	this.ePage = (this.ePage > this.Pcount) ? this.Pcount : this.ePage;

	this.setPaging();
}
Data.xhr.doCreatePaging.prototype = {
	setPaging : function() {
		var row = this.obj.insertRow();
		row.align="center"
		var cell = row.insertCell();

		var html	= "";
		var tmpNum	= "";

		html += (this.sPage > 1) 
			? "<a href='' onclick=\"doLoader('"+ parseInt(this.sPage - this.PageBlock) +"', '"+ this.strCode +"', '"+ this.strSubCode +"');return false;\"><img src='"+ this.PrevImg +"' align='absmiddle' border='0' hspace='5'></a>"
			: ""; 

		for(var i=this.sPage; i<=this.ePage; i++) {
			tmpNum = (this.Page ==  i) ? "<span class='b'>"+ i +"</span>" : i;
			html += "<a href='' onclick=\"javascript:doLoader('"+ i +"', '"+ this.strCode +"', '"+ this.strSubCode +"');return false;\">"+ tmpNum +"</a>";
			if(i < this.ePage) {
				html += " | ";
			}
		}
		html += (this.sPage + this.PageBlock > this.Pcount) 
			? "" 
			: "<a href='' onclick=\"doLoader('"+ parseInt(this.sPage + this.PageBlock) +"', '"+ this.strCode +"', '"+ this.strSubCode +"');return false;\"><img src='"+ this.NextImg +"' align='absmiddle' border='0' hspace='5'></a>";
		cell.innerHTML = html;
	}
}

Data.xhr.getObject = function(name) {
	return eval("document.getElementById('"+ name +"')");
}