//객체 생성
function getXMLHttpRequest() {
	var xmlHttp = false;
	
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
	else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
	}
	
	return xmlHttp;	
}

//Get 방식
//httpRequest.open("GET","/test.txt?id=XXX&pw=***",true);
//httpRequest.send(null);

//Post 방식
//httpRequest.open("POST","/test.txt", true);
//httpRequest.send("id=XXX&pw=***");


var httpRequest = null;

function load(method, url, header, syn) 
{
	if (method = "GET")
	{
		url = url + "?" + header;
		header = null;
	}
	else if(method = "POST")
	{
		//httpRequest.open(method,url,syn);
		//httpRequest.send(header);
	}
	else
	{
		alert("잘못된 방식으로 전송하려고 합니다. 다시 확인바랍니다.");
		return null;
	}

	httpRequest = getXMLHttpRequest();		//객체 생성
	httpRequest.onreadystatechange = callbackResult;		//callback 시
	httpRequest.open(method,url,syn);
	httpRequest.send(header);  //동기 방식일 경우 결과를 기다린다.(브자우저 방식에 따라 처리불능 가능성)
										//비동기 방식일 경우 다음 명령 바로 처리.(크로스 브라우저 추천)

	
}

//.readyState (상태)에 따라 처리
//페이지 미존재시 오페라 3으로 변경 안함,  파이어폭스 3으로 변경됨
//크로스 브라우저 : 1 과 4만 사용 추천

//.status (결과상태)
// 200 : OK								성공
// 403 : Forbidden					접근거부
// 404 : Not Found					페이지 없음
// 500 : Internal Server Error		서버 오류 발생

//.statusText (결과 상태 영문 문장)
// 위 영문 설명 문자열
// 크로스 브라우저 : 오페라 8.51 이전 버전 지원 안함



function callbackResult() //callback 함수
{
	if (httpRequest.readyState == 0)	
	{
		//UNINITIALIZED 객체만 생성 미초기화 
	}
	else if (httpRequest.readyState == 1)	
	{
		//LOADING open 호출 이후 send 호출 이전
	}
	else if (httpRequest.readyState == 2)	
	{
		//LOADED send 호출 이후 status와 헤더 도착이전 상태
	}
	else if (httpRequest.readyState == 3)	
	{
		//INTERACTIVE 일부 데이터 수신 상태
	}
	else if (httpRequest.readyState == 4)
	{
		//COMPLETED 데이터 완전 수신 상태
		if (httpRequest.status == 200)
		{
			// 200 : OK	성공
			// httpRequest.ResponseText 를 가지고 처리
			process();  //처리시 
		}
		else if (httpRequest.status == 403)
		{
			//403 : Forbidden					접근거부
			alert("Error 403 : 접근이 거부되었습니다.");
		}
		else if (httpRequest.status == 404)
		{
			// 404 : Not Found					페이지 없음
			alert("Error 404 : 파일이 존재 하지 않습니다.");
		}
		else if (httpRequest.status == 500)
		{
			// 500 : Internal Server Error		서버 오류 발생
			alert("Error 500 : 오류가 발생 하였습니다.");
		}
	}
}



function process() //처리 함수
{
	eval(httpRequest.responseText);
}


function appwmanprofss_onchange(obj) {	
	load("GET", "wmansprofssDBStep2.kw", "profssCd=" + obj.value, true);
	
}
