var responseHttpObj; //XMLHttpRequest객체를 저장할 변수를 전역변수로 선언
var Xwidth; // 레이어 width 전역선연
var Xheight; // 레이어 width 전역선연
var Xmode; //레이어 X Mode 선언

function createXHR(){ //XMLHttpRequest객체를 생성하는 메소드
	  if(window.ActiveXObject){ //웹 브라우저가 IE5.0, IE6.0인 경우
	     responseHttpObj = new ActiveXObject("Microsoft.XMLHTTP"); //XMLHttpRequest객체 생성
	  }else if(window.XMLHttpRequest){ //웹 브라우저가 IE7.0, 파이어폭스, 사파리, 오페라등의 경우
         responseHttpObj = new XMLHttpRequest(); //XMLHttpRequest객체 생성
	  }
}

function startMethod(xSrc,wid,hei,Mode){//클라이언트로부터 이벤트가 발생시 실행되는 메소드
	  var xmlParam="";
	  createXHR(); //createXHR()메소드 호출
	  responseHttpObj.onreadystatechange = resultProcess; //응답결과를 처리메소드인 resultProcess()메소드 설정
      responseHttpObj.open("Post", xSrc, "true");//서버의 요청설정 - requestGet.xml페이지를 요청할 준비
	  responseHttpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8;');
    xmlParam        = makeParam(wid,hei,Mode);
	  responseHttpObj.send(xmlParam);//서버로 요청을 보냄
}

function resultProcess(){//응답결과가 오면 자동으로 실행
	  if(responseHttpObj.readyState == 4){ //요청객체의 상태가 모든 데이터를 받을 수 있는 상태로 완료된 경우
//      alert('resultProcess:4, status:'+responseHttpObj.status);
	    if(responseHttpObj.status == 200){ //서버로부터 응답받는 HTTP상태가 정상인 경우 수행
//        alert('resultProcess:200');
        AjaxProcess();
		  }
      else
      {
          alert('Error');
      }
	  }
}

function AjaxProcess(){
  //alert(responseHttpObj.responseText);
  var XHtml = responseHttpObj.responseText;
  XLayerOn('XLayer',XHtml,Xwidth,Xheight,Xmode);
}

//전역변수 사용 (전송파라미터로 이용가능)
function makeParam(info1,info2,info3){
  var xmlsendParam
  Xwidth = info1;
  Xheight = info2;
  Xmode = info3;
  return xmlsendParam;
}



