
//var ajax_domain = "http://www.itms.co.kr";

//alert(document.location.href);

// 첨부파일 정보 출력
function xmlhttpFile(ggubun,gidx,gflag,gsize,garr) {
   var xmlHttpReqFile = false;
    var self = this;
    // Mozilla/Safari
    if (window.xmlHttpRequest) {
        self.xmlHttpReqFile = new xmlHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReqFile = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReqFile.open('POST', '/inc/loadfiles.asp?gubun='+ggubun+'&mstidx='+gidx+'&flag='+gflag+'&fwidth='+gsize+'&arrfile='+garr, true);
    self.xmlHttpReqFile.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReqFile.onreadystatechange = function() {
        if (self.xmlHttpReqFile.readyState == 4) {
            updatepage("divFiles",self.xmlHttpReqFile.responseText);
        }
    }
    self.xmlHttpReqFile.send(null);
}
//-----------------------------------------------------------------------------------------------------------


// 첨부파일 삭제
function xmlhttpFileDelete(ggubun,gidx,fidx,gpath,gfile,gsize) {
//alert(gsize+' '+gidx+' '+fidx+' '+gpath+' '+gfile); return;
    var xmlhttpFileDel = false;
    var self = this;
    // Mozilla/Safari
    if (window.xmlHttpReqFolderuest) {
        self.xmlhttpFileDel = new xmlHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlhttpFileDel = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlhttpFileDel.open('POST', '/inc/deletefiles.asp?gubun='+ggubun+'&mstidx='+gidx+'&afidx='+fidx+'&delpath='+escape(gpath)+'&delfile='+escape(gfile), true);
    self.xmlhttpFileDel.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlhttpFileDel.onreadystatechange = function() {
        if (self.xmlhttpFileDel.readyState == 4) {
			xmlhttpFile(ggubun,gidx,'EDIT',gsize,'');
        }
    }
    self.xmlhttpFileDel.send(null);
}
//-----------------------------------------------------------------------------------------------------------



// 게시물 비밀번호 확인
function xmlhttpPassCheck(gflag,gidx,gpass,gurl) {
   var xmlHttpReqFilePassCheck = false;
    var self = this;
    // Mozilla/Safari
    if (window.xmlHttpRequest) {
        self.xmlHttpReqFilePassCheck = new xmlHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReqFilePassCheck = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReqFilePassCheck.open('POST', '/inc/divpop/checkpass.asp?flag='+gflag+'&idx='+gidx+'&pass='+gpass, true);
    self.xmlHttpReqFilePassCheck.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReqFilePassCheck.onreadystatechange = function() {
        if (self.xmlHttpReqFilePassCheck.readyState == 4) {
			if(self.xmlHttpReqFilePassCheck.responseText=="Y"){
				parent.onView(gflag,gurl,gidx);
			} else{
				alert("비밀번호가 일치하지 않습니다.");
			}
        }
    }
    self.xmlHttpReqFilePassCheck.send(null);
}
//-----------------------------------------------------------------------------------------------------------


// Default Ajax
function xmlhttpResult(gpath,gdivname) {
   var xmlHttpReqResult = false;
    var self = this;
    // Mozilla/Safari
    if (window.xmlHttpRequest) {
        self.xmlHttpReqResult = new xmlHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReqResult = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReqResult.open('POST', ''+gpath, true);
    self.xmlHttpReqResult.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReqResult.onreadystatechange = function() {
        if (self.xmlHttpReqResult.readyState == 4) {
            updatepage(gdivname,self.xmlHttpReqResult.responseText);
        }
    }
    self.xmlHttpReqResult.send(null);
}
//-----------------------------------------------------------------------------------------------------------



// Default Ajax Class
function Ajax_Code() 
{
    this.xmlhttpResult = xmlhttpResult;

	function xmlhttpResult(gpath,gdivname) {
	   var xmlHttpReqResult = false;
		var self = this;
		// Mozilla/Safari
		if (window.xmlHttpRequest) {
			self.xmlHttpReqResult = new xmlHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReqResult = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReqResult.open('POST', ''+gpath, true);
		self.xmlHttpReqResult.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReqResult.onreadystatechange = function() {
			if (self.xmlHttpReqResult.readyState == 4) {
				updatepage(gdivname,self.xmlHttpReqResult.responseText);
			}
		}
		self.xmlHttpReqResult.send(null);
	}

	function updatepage(gobj,str){
	//	alert(gobj);
		document.getElementById(gobj).innerHTML = str;
	}
}
//-----------------------------------------------------------------------------------------------------------


// DIV에 ResponseText Insert
function updatepage(gobj,str){
//	alert(gobj);
    document.getElementById(gobj).innerHTML = str;
}
//-----------------------------------------------------------------------------------------------------------

