function getHTTPObject () {
	var xhr = false;
	if ( window.XMLHttpRequest ) { xhr = new XMLHttpRequest (); }
	else if ( window.ActiveXObject ) {
		try { xhr = new ActiveXObject ( "Msxml2.XMLHTTP" ); }
		catch ( e ) {
			try { xhr = new ActiveXObject ( "Microsoft.XMLHTTP" ); }
			catch ( e ) { xhr = false; }
		}
	}
	return xhr;
}

function grabFile ( file, func ) {
	var req = getHTTPObject ();
	if ( req ) {
		req.onreadystatechange = function () { eval(func+"(req)"); };
		req.open ( "GET", file, true );
		req.send(null);
	}
}

function axOk ( req ) {	if ( req.readyState==4 && (req.status==200 || req.status==304) ) { return true; } else { return false; } }

function chkZsf ( zsfObj ) {
	zsfV=zsfObj.value; 
	var chk_in = 1;
	if ( zsfV.length>0 ) {
		if(document.getElementById("letter").checked == true)  chk_in  = 1;
		else  chk_in  = 2;
		grabFile ( "mailing_in.php?email="+zsfV+"&letter="+chk_in, 'rsltZsf' );
	}
	else {
		document.getElementById('emailfoot').focus();
	}
}

function rsltZsf ( req ) {
	if ( axOk(req) ) {
		zsfV = document.getElementById('emailfoot').value;
		rsltCls = "0"; 

		switch(req.responseText*1) {
			case 0:
			alert("이미 등록되어 있는 email입니다. email주소를 확인해 주세요.");
			document.getElementById('emailfoot').focus();
			break;

			case 1:
			rsltCls = "1";
			alert("뉴스레터 신청이 완료되었습니다.");
			break;

			case 2:
			alert("정확한 email을 입력해 주세요.");
			document.getElementById('emailfoot').focus();
			break;		
			
			case 3: 
			alert("입력하신 email에 대한 뉴스레터 구독을 취소했습니다.");
			break;	
			
			case 4:
			alert("체크박스를 선택하여 주세요.");
			document.getElementById('letter').focus();
			break;											

			default:		
		}
	}
}	