var AJAX = {
     XmlHttp: null,
     create: function () {
           try {
                if (window.XMLHttpRequest) {
                     AJAX.XmlHttp = new XMLHttpRequest();
                     // ÀÏºÎÀÇ ¸ðÁú¶ó ¹öÀüÀ»Àº readyState property, onreadystate event
                     // ¸¦ Áö¿øÇÏÁö ¾ÊÀ¸¹Ç·Î. - from xmlextrs
                     if (this.XmlHttp.readyState == null) {
                           this.XmlHttp.readyState = 1;
                           this.XmlHttp.addEventListener("load", function () {
                                this.XmlHttp.readyState = 4;
                                if (typeof this.XmlHttp.onreadystatechange == "function")
                                     tmpXmlHtp.onreadystatechange();
                           }, false);
                     }
                } else {
                     AJAX.XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
           }
           catch (e) {
                alert("Your browser does not support XmlHttp objects");
                //throw new Error("Your browser does not support XmlHttp objects");
           }
     }
}

AJAX.openXML = function (method, url, async, uname, pswd) {
     if (AJAX.XmlHttp != null) {
           if (uname == undefined) {
                AJAX.XmlHttp.open(method, url, async, uname, pswd);
           } else {
                AJAX.XmlHttp.open(method, url, async);
           }
           AJAX.XmlHttp.onreadystatechange = function () {				
                if (AJAX.XmlHttp.readyState == 4) {
                     if (AJAX.XmlHttp.status == 200) { // 200 Àº HTTP¿¡¼­ ¼º°ø i.e) 404 : not found
                           AJAX.statusSuccessHandler(AJAX.XmlHttp.responseXML);
                     } else {
                           AJAX.statusErrorHandler();						   
                           alert('Error while loading!');
                     }
                }
           }
     } else {
           alert ("need to create xmlhttp object");
     }
}

AJAX.openText = function (method, url, async, uname, pswd) {
     if (AJAX.XmlHttp != null) {
           if (uname == undefined) {
                AJAX.XmlHttp.open(method, url, async, uname, pswd);
           } else {
                AJAX.XmlHttp.open(method, url, async);
           }
           AJAX.XmlHttp.onreadystatechange = function () {
                if (AJAX.XmlHttp.readyState == 4) {
                     if (AJAX.XmlHttp.status == 200) { // 200 Àº HTTP¿¡¼­ ¼º°ø i.e) 404 : not found
                           AJAX.statusSuccessHandler(AJAX.XmlHttp.responseText);
                     } else {
                           AJAX.statusErrorHandler();
                           alert('Error while loading!');
                     }
                }
           }
     } else {
           alert ("need to create xmlhttp object");
     }
}

AJAX.send = function (content) {
           if (content == undefined)
                AJAX.XmlHttp.send(null);
           else
                AJAX.XmlHttp.send(content);
}

AJAX.setOnReadyStateChange = function (funcname) {
           if (AJAX.XmlHttp) {
                AJAX.XmlHttp.onreadystatechange = funcname;
           } else {
                alert ("need to create xmlhttp object");
           }
}

// status 200 ÀÏ ¶§ Ã³¸® ÇÔ¼ö

AJAX.statusSuccessHandler = function (data) {
           alert(data);
}

AJAX.setStatusSuccessHandler = function (funcname) {
           AJAX.statusSuccessHandler = funcname;
}
     // status 200 ÀÏ ¶§ ±âº» Ã³¸® ÇÔ¼ö
     // setStatusSuccessHandler() ·Î ´ëÃ¼ °¡´É
	 
AJAX.statusErrorHandler = function (status) {
           AJAX.rtnText = AJAX.XmlHttp.responseText;
}

AJAX.setStatusSuccessHandler = function (funcname) {
           AJAX.statusSuccessHandler = funcname
}

AJAX.setStatusErrorHandler = function (funcname) {
           AJAX.statusErrorHandler = funcname
}

AJAX.setRequestHeader = function (label, value)
{
     AJAX.XmlHttp.setRequestHeader(label, value);
}



var getNowScroll = function(){
	var de = document.documentElement;
	var b = document.body;
	var now = {};

	now.X = document.all ? (!de.scrollLeft ? b.scrollLeft : de.scrollLeft) : (window.pageXOffset ? window.pageXOffset : window.scrollX);
	now.Y = document.all ? (!de.scrollTop ? b.scrollTop : de.scrollTop) : (window.pageYOffset ? window.pageYOffset : window.scrollY);

	return now;
}

var msgNowScroll = function(){
	nowScroll = getNowScroll();
	alert([nowScroll.X, nowScroll.Y]);
}


function ShowStateImg(){
	msg = "<img src='image/process.gif'>";
	nowScroll = getNowScroll();
	var left = document.body.clientWidth / 2 - 100;
	var top = document.body.clientHeight / 2;
	left = left + document.body.scrollLeft;
	$("state_img").style.display = "block";	
	$("state_img").style.left = left;
	$("state_img").style.top = top;
	$("state_img").style.width = "100px";
	$("state_img").innerHTML = msg;
}

function HideStateImg(){
	try{
		parent.$("state_img").style.display = "none";
	}catch(e){
		$("state_img").style.display = "none";
	}
}


function ShowStateMsg(msg){
	msg = "<font color=white><b>" + msg + "</b></font>";
	nowScroll = getNowScroll();
	var left = document.body.clientWidth - 68;
	var top = nowScroll.Y;
	left = left + document.body.scrollLeft;
	$("state").style.display = "block";	
	$("state").style.left = document.body.clientWidth - 100;
	$("state").style.top = top;
	$("state").style.width = "100px";
	$("state").innerHTML = msg;


}

function HideStateMsg(){
	try{
		parent.$("state").style.display = "none";
	}catch(e){
		$("state").style.display = "none";
	}
}

document.write("<div id='state' style='display:none;position:absolute;background:#CA1710;width=66px;z-index:100'></div>");
document.write("<div id='state_img' style='display:none;position:absolute;background:#FFFFFF;width=66px;z-index:100'></div>");




/*** ÆË¾÷À» ·¹ÀÌ¾î·Î ¶ç¿ì±â ***/

function PopupLayer(target,wid,hei,scroll)
{
	wid = parseInt(wid);
	hei = parseInt(hei);

	if(!wid) wid = 650;
	if(!hei) hei = 480;

	var pixelBorder = 3;
	var titleHeight = 20;
	wid = wid + pixelBorder * 2;
	hei = hei + pixelBorder * 2 + titleHeight;
	

	var BodyWidth = screen.width;
	var BodyHeight = screen.height;
	/*
	var BodyWidth = document.body.scrollWidth;
	var BodyHeight = document.body.scrollHeight;
	*/

	//var posX = (BodyWidth - wid) / 2;
	//var posY = (BodyHeight - hei) / 2;
	var posX = 0;
	var posY = 0;

	/*** ¹é±×¶ó¿îµå ·¹ÀÌ¾î ***/
	var Obj = document.createElement("div");
	with (Obj.style){
		position = "absolute";
		left = 0;
		top = 0;
		//width = "100%";
		width = document.body.scrollWidth;
		if(screen.height>document.body.scrollHeight) height = "100%";
		else height = document.body.scrollHeight;
		backgroundColor = "#000000";
		filter = "Alpha(Opacity=30)";
	}
	Obj.id = "ObjBackGroud";
	document.body.appendChild(Obj);

	/*** Content Frame ***/
	var Obj = document.createElement("div");
	with (Obj.style){
		position = "absolute";
		left = posX + document.body.scrollLeft;
		top = posY + document.body.scrollTop;
		top = posY;
		width = wid;
		height = hei;
		zIndex = 1000;
		border = "3px solid #000000";
	}
	Obj.id = "ObjLayer";
	document.body.appendChild(Obj);

	/*** TITLE VAR ***/
	var bottom = document.createElement("div");
	with (bottom.style){
		position = "absolute";
		width = wid;
		height = titleHeight;
		left = 0;
		top = hei - titleHeight - pixelBorder * 3;
		padding = "5px 0 5 0";
		textAlign = "right";
		backgroundColor = "#38340F";
	}
	bottom.innerHTML = "<a href='javascript:CloseLayer()'><img src='../img/popup_close.gif' border='0'></a>";
	Obj.appendChild(bottom);




	/*** IFRAME ***/
	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = wid;
		height = hei - pixelBorder * 2 - titleHeight - 3;
	}

	ifrm.frameBorder = 0;
	ifrm.src = target;
	ifrm.scrolling = scroll;
	var obj_ret = Obj.appendChild(ifrm);
	



	try{
		var ret = verNumIE();
		if(ret<7) pauseWithModal(1000);
	}catch(e){
		alert(e.description);
	}
}
var navName = navigator.appName; //ºê¶ó¿ìÁ® ÀÌ¸§...
var brVer = navigator.userAgent;//ºê¶ó¿ìÁ® Á¤º¸

function verNumIE(){
	var brVerId = brVer.indexOf('MSIE');//ºê¶ó¿ìÁ® Á¤º¸¿¡¼­ 'MSIE'¶ó´Â ºÎºÐÀÇ ¹®ÀÚ¿­
	brNum = brVer.substr(brVerId,8);//ºê¶ó¿ìÁ® ¹öÀü('MSIE' Æ÷ÇÔ..)..
	brNum2 = brNum.substr(5,3)//ºê¶ó¿ìÁ® ¹ö¹ø. ¼ýÀÚ¸¸...

	return parseInt(brNum2);
}


function pause(numberMillis) {
     var now = new Date();
     var exitTime = now.getTime() + numberMillis;

     while (true) {
          now = new Date();
          if (now.getTime() > exitTime)
              return;
     }
}

 

// ¸ð´ÞÃ¢ ¶ç¿ì¸é¼­ n millis µ¿¾È ¸ØÃß±â

function pauseWithModal(numberMillis) {
        var dialogScript = 
           'window.setTimeout(' +
           ' function () { window.close(); }, ' + numberMillis + ');';

         window.showModalDialog('javascript:document.writeln(' + '"<script>' + dialogScript + '<' + '/script>")');

        // NN
        /* openDialog(
           'javascript:document.writeln(' +
            '"<script>' + dialogScript + '<' + '/script>Àá½Ã¸¸ ±â´Ù·Á ÁÖ¼¼¿ä"',
           'pauseDialog', 'modal=1,width=10,height=10');
        */
}


function PopupLayer2(target,id)
{
	if(!id) {
		//alert('[¾Ë¸²] È¸¿ø¸¸ »ç¿ë °¡´ÉÇÕ´Ï´Ù');
		//return false;
	}
	var scroll = "yes";
	wid = screen.width-36;
	//hei = screen.height-185;
	//wid = document.body.clientWidth
	hei = document.body.clientHeight;

	var pixelBorder = 3;
	var titleHeight = 20;

	var BodyWidth = document.body.clientWidth;
	var BodyHeight = document.body.clientHeight;

	var posX = (BodyWidth - wid) / 2;
	var posY = (BodyHeight - hei) / 2;

	posX=posY=0;

	/*** ¹é±×¶ó¿îµå ·¹ÀÌ¾î ***/
	var Obj = document.createElement("div");
	with (Obj.style){
		position = "absolute";
		left = 0;
		top = 0;
		//width = "100%";
		width = document.body.scrollWidth;
		if(screen.height>document.body.scrollHeight) height = "100%";
		else height = document.body.scrollHeight;
		backgroundColor = "#000000";
		filter = "Alpha(Opacity=30)";
	}
	Obj.id = "ObjBackGroud";
	document.body.appendChild(Obj);

	/*** Content Frame ***/
	var Obj = document.createElement("div");
	with (Obj.style){
		position = "absolute";
		left = posX + document.body.scrollLeft;
		top = posY + document.body.scrollTop;
		width = wid;
		height = hei;
		border = "3px solid #000000";
	}
	Obj.id = "ObjLayer";
	document.body.appendChild(Obj);

	/*** TITLE VAR ***/
	var bottom = document.createElement("div");
	with (bottom.style){
		position = "absolute";
		width = wid;
		height = titleHeight;
		left = 0;
		top = hei - titleHeight - pixelBorder * 3;
		padding = "5px 0 5 0";
		textAlign = "right";
		backgroundColor = "#000000";
	}
	bottom.innerHTML = "<a href='javascript:CloseLayer()'><img src='image/btn_close.gif' border='0'></a>";
	Obj.appendChild(bottom);





	/*** IFRAME ***/
	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = wid;
		height = hei - pixelBorder * 2 - titleHeight - 3;
	}

	ifrm.frameBorder = 0;
	ifrm.src = target;
	ifrm.scrolling = scroll;
	//ifrm.className = "scroll";
	Obj.appendChild(ifrm);
}

function CloseLayer()
{
	document.getElementById('ObjLayer').removeNode(true);
	document.getElementById('ObjBackGroud').removeNode(true);
}

function inputCheckSpecial(f){
	re = /[~!@\#$%^&*\()\-=;\\+_'"]/gi;
	if(re.test(f.value)){
		alert("Æ¯¼ö¹®ÀÚ´Â ÀÔ·ÂÇÏ½Ç¼ö ¾ø½À´Ï´Ù");
		f.value=f.value.replace(re,"");
	}
}