/**
  ³»  ¿ë : Ajax »ç¿ë½Ã ÁøÇà»óÅÂ Ç¥½Ã°ü·Ã ÇÁ·ÎÅäÅ¸ÀÔ ¼±¾ð
  Âü  °í : javascript prototype 1.4 ¸Þ´º¾ó ÂüÁ¶
           http://www.sergiopereira.com/articles/prototype.js.html   (¿µ¹®»çÀÌÆ®)
		   http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html (ÇÑ±Û»çÀÌÆ®)
		   À§ÀÇ »çÀÌÆ®¿¡¼­ ¹èÆ÷ÇÏ´Â prototype.js ¸¦ ±âº»À¸·Î ·Îµå ÇØÁØÈÄ ¾Æ·¡ÀÇ ÇÁ·ÎÅäÅ¸ÀÔÀ» »ç¿ëÇØ¾ßÇÑ´Ù

  ÀÛ¼ºÀÚ : ±èÁ¾Áø
  ÀÛ¼ºÀÏ : 2007-04-11
**/


function AjaxStatMsg()
{
}//end function AjaxStatMsg

AjaxStatMsg.prototype = {

	/**
	 ±â  ´É : Ajax »ç¿ë½Ã ÁøÇà»óÅÂ ·¹ÀÌ¾î »ý¼º
	 ÇÔ¼ö¸í : _setLayerProcess
	 ÀÛ¼ºÀÚ : ±èÁ¾Áø
	 ÀÛ¼ºÀÏ : 2007-07-19
	 ÀÎ  ÀÚ : 1. nDpLayer :[String] ³»¿ëÀÌ º¸¿©Áú ·¹ÀÌ¾î id
	                       °ªÀÌ ¾ø¾îµµ µÈ´Ù
	 ¸®ÅÏ°ª : ¾øÀ½
	 Âü  °í :
			var oASM = new AjaxStatMsg();		//°´Ã¤»ý¼º
			cASM._setLayerProcess(nDpLayer);	//»óÅÂÇ¥½Ã ·¹ÀÌ¾î »ý¼º
	**/
	_setLayerProcess: function(nDpLayer)
	{
		var nMsgStr, obj, chObj, nPLeft, nPTop, newElem;

		//±âÁ¸ »ý¼ºµÇ¾î »ç¶óÁöÁö ¾ÊÀº »óÅÂ ·¹ÀÌ¾î »èÁ¦
		chObj = document.getElementById("systemWorking");
		if(chObj)
		{
			chObj.parentNode.removeChild(chObj);
		}

		obj = document.getElementById(nDpLayer);

		nPLeft = document.body.clientWidth - 80; //ºê¶ó¿ìÁ® °¡·Î Æ÷Áö¼Ç

		if(document.body.scrollTop > 0)
		{
			nPTop = document.body.scrollTop + 5;  //ºê¶ó¿ìÁ® ¼¼·Î Æ÷Áö¼Ç
		}else{
			nPTop = document.documentElement.scrollTop + 5;  //ºê¶ó¿ìÁ® ¼¼·Î Æ÷Áö¼Ç
		}//end if

		newElem = document.createElement("div");
		newElem.id = "systemWorking";
		newElem.innerHTML = "Loading...";
		with(newElem.style)
		{
			position = "absolute";
			display = "none";
			top = nPTop+"px";
			left = nPLeft+"px";
			width = "60px";
			textAlign = "center";
			backgroundColor = "#ff0000";
			color = "#ffffff";
			fontSize = "12px";
			padding = "5px";
			zIndex = "10000";
		}

		if(!obj)
		{
			document.body.appendChild(newElem);
		}else{
			obj.appendChild(newElem);
		}//end if

	},


	/**
	 ±â  ´É : Ajax State °á°ú¿¡µû¸¥ »óÅÂÇ¥½Ã ·¹ÀÌ¾î º¸¿©ÁÖ±â¹× ¼Ò¸ê
	 ÇÔ¼ö¸í : _setShowProcess
	 ÀÛ¼ºÀÚ : ±èÁ¾Áø
	 ÀÛ¼ºÀÏ : 2007-07-19
	 ÀÎ  ÀÚ : 1. nDpLayer :[String] ³»¿ëÀÌ º¸¿©Áú ·¹ÀÌ¾î id
	 ¸®ÅÏ°ª : ¾øÀ½
	 Âü  °í :
			var oASM = new AjaxStatMsg();		//°´Ã¤»ý¼º
			cASM._setLayerProcess(nDpLayer);	//»óÅÂÇ¥½Ã ·¹ÀÌ¾î »ý¼º
			cASM._setShowProcess();		//Ajax State °á°ú¿¡µû¸¥ »óÅÂÇ¥½Ã ·¹ÀÌ¾î º¸¿©ÁÖ±â¹× ¼Ò¸ê
	**/
	_setShowProcess: function()
	{
		var myGlobalHandlers = {
			onCreate: function()
			{
				Element.show('systemWorking');
			},

			onComplete: function()
			{
				if(Ajax.activeRequestCount == 0)
				{
					Element.remove('systemWorking');
				}//end if
			}
		};

		Ajax.Responders.register(myGlobalHandlers);
	}
}//end AjaxStatMsg.prototype

var asm = new AjaxStatMsg();
