//전역변수
var resultEdit = null;

// 데이터 송수신 
function openSendStatus(LBcode, filename, MouseMode, MenuNum) {
    var xmlHttp = newXMLHttpRequest();           //XMLHttpRequest 생성
    var thisGubun;
	xmlHttp.open("GET", "/main_branch/"+filename, false);    //송신방법,URL,통신방법(동기:false,비동기:true)

//alert("1");
	if(MouseMode == "over"){
		for(i=1;i<=7;i++){
		//	if(i != 12){
				thisBranch = document.getElementById("menu_LBcode" + i);
				result = thisBranch.style.visibility
				if(result == "visible"){
					thisGubun = "yes";
					break;
				}else{
					thisGubun = "no";
				}
		//	}
		}
	}
	
thisGubun = "yes"; 

	if(thisGubun == "yes" || MouseMode == "click"){
	    xmlHttp.onreadystatechange = function() {    //처리상태 변경 발생

	        if (xmlHttp.readyState == 4) {           //서버 처리 완료
        	    if (xmlHttp.status == 200) {         //파일 수신 성공
			MM_swapImgRestore();
//			MM_swapImage('menu'+MenuNum,'','/main_img/2009/header_menu'+MenuNum+'_on.gif',MenuNum);
			
               		mainControl(xmlHttp,LBcode,MouseMode);     //메인 처리
	            }
        	    if (xmlHttp.status == 404) {         //404 예외처리
                	exceptionControl(xmlHttp,LBcode);       
	            }	
        	}
		}
	}

    xmlHttp.send("");                            //처리 데이터 송신
}

//메인 처리
function mainControl(xmlHttp,LBcode,MouseMode) {
	resultEdit = xmlHttp.responseText;
    	thisBranch = document.getElementById("menu_LBcode"+LBcode);
	thisBranch.innerHTML = resultEdit;
	thisBranch.style.visibility="visible";

	for(i=1;i<=7;i++){
	//	if(i != 12){
			if(LBcode != i){
				thisBranch = document.getElementById("menu_LBcode" + i);
				thisBranch.style.visibility = "hidden";
			}
	//	}
	}
}

//예외 처리
function exceptionControl(xmlHttp,LBcode) {
    document.getElementById("menu_LBcode"+LBcode).innerHTML = "해당 파일이 존재하지 않습니다.";
}