function sessionCheck(userid){
	if(userid==""){
		document.location="./login.yp?targetpage=login_main_01";
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	PopupWindow = window.open(theURL,winName,features);
}
function myinfoheader(){
	makeRequest("get", "/servlet/usermyinfo?targetpage=user_pop_login_01", fLoginCheckajax);//
}
function fLoginCheckajax(req_obj){
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		if(userid==0){
			MM_openBrWindow("/login.yp?targetpage=login_pop_01&pageflag=myinfo",'login_pop','width=596,height=320');
		}else{
			document.location="/user_myInfo.yp";
		}
	}
}

//로그 아웃.
function fLogout(){
	makeRequest("get", "/servlet/usermyinfo?targetpage=user_logout_01", fLogoutajax1);//
}
function fLogoutajax1(req_obj){
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		if(userid==0){
			document.location="/kor_index.yp";
		}
	}
}
function fLoginCheck(){
	makeRequest("get", "/servlet/usermyinfo?targetpage=user_pop_login_01", fLoginCheckajax1);//관심분야
}
function fLoginCheckajax1(req_obj){
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		if(userid==0){
			MM_openBrWindow("/login.yp?targetpage=login_pop_01",'login_pop','width=596,height=320');
		}
	}
}
function fLoginCheck02(){
	makeRequest("get", "/servlet/usermyinfo?targetpage=user_pop_login_01", fLoginCheckajax2);//관심분야
}
function fLoginCheckajax2(req_obj){
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		var userdiv =lists.getElementsByTagName("userdiv")[0].firstChild.nodeValue;
		if(userid==0){
			MM_openBrWindow("/login.yp?targetpage=login_pop_02",'login_pop','width=596,height=405');
		}else{
			if(userdiv=="C0"){  //기업 소속 회원,마스터 회원 서로 뒤바껴서 리스트 나오는 오류 수정 2010.05.03 김성은
				document.location="/user_myInfo.yp";
			}else if(userdiv=="00"){
				document.location="/user_myInfo.yp?targetpage=usermyinfo_commaster_order_search_list";
			}else {
			 	document.location="/user_myInfo.yp?targetpage=user_order_list";
			}
		}
	}
}
///////////////////내서재/////////////////////////////
function fUserLibraryRegist(value){
window.name="livraryfrom";
		makeRequest("get", "/servlet/usermyinfo?targetpage=fUserLibraryRegist&bookcd="+value, fUserLibraryRegistajax);//내서재
}
function fUserLibraryRegistajax(req_obj){
//alert(req_obj.responseXML.xml);
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		var bookcd =lists.getElementsByTagName("bookcd")[0].firstChild.nodeValue;
		if(userid==0){
			MM_openBrWindow("/login.yp?targetpage=login_pop_01&pageflag=livrary",'login_pop','width=596,height=320');
		}else{
			makeRequest("get", "/servlet/usermyinfo?targetpage=usermyinfo_library&pageflag=usermyinfo_library&bookcd="+bookcd, getUserLibrary);//내서재
		}
	}
}
function getUserLibrary(req_obj){
//alert(req_obj.responseXML.xml);
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var booklist = lists.getElementsByTagName("flag")[0].firstChild.nodeValue;
		if(booklist==0){
			if(confirm('내서재에 등록되었습니다.\n내서재로 이동하시 겠습니까?')){
				document.location="/user_myInfo.yp?targetpage=usermyinfo_library";
			}
		}else if(booklist==1){
			if(confirm('이미 내서재에 등록된 도서 입니다.\n내서재로 이동하시 겠습니까?')){
				document.location="/user_myInfo.yp?targetpage=usermyinfo_library";
			}
		}else{
			alert("내서재 등록에 실패하였습니다.");
		}
	}
}
//////////////////////////////////////////////////
///////////////////주문예약도서//////////////////////


function fUserReservationRegist(value){
window.name="Reservationfrom";
		makeRequest("get", "/servlet/usermyinfo?targetpage=fUserReservationRegist&bookcd="+value, fUserReservationRegistajax);//주문예약도서
}
function fUserReservationRegistajax(req_obj){
//alert(req_obj.responseXML.xml);
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		var bookcd =lists.getElementsByTagName("bookcd")[0].firstChild.nodeValue;
		if(userid==0){
			MM_openBrWindow("/login.yp?targetpage=login_pop_01&pageflag=reservation",'login_pop','width=596,height=320');
		}else{
			makeRequest("get", "/servlet/usermyinfo?targetpage=usermyinfo_reservation&pageflag=usermyinfo_reservation&bookcd="+bookcd, getUserReservation);//내서재
		}
	}
}
function getUserReservation(req_obj){
//alert(req_obj.responseXML.xml);
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var booklist = lists.getElementsByTagName("flag")[0].firstChild.nodeValue;
		if(booklist==0){
			if(confirm('주문예약서재에 등록되었습니다.\n주문예약서재로 이동하시 겠습니까?')){
				document.location="/user_myInfo.yp?targetpage=usermyinfo_reservation";
			}
		}else if(booklist==1){
			if(confirm('이미 주문예약서재에 등록된 도서 입니다.\n주문예약서재로 이동하시 겠습니까?')){
				document.location="/user_myInfo.yp?targetpage=usermyinfo_reservation";
			}
		}else{
			alert("주문예약서재 등록에 실패하였습니다.");
		}
	}
}

///////////////////////////////////////////////////////
function fLibraryLoginCheck(){
	makeRequest("get", "/servlet/usermyinfo?targetpage=user_pop_login_01", fLibraryLoginCheckajax1);//관심분야
}
function fLibraryLoginCheckajax1(req_obj){
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var userid =lists.getElementsByTagName("userid")[0].firstChild.nodeValue;
		if(userid==0){
			MM_openBrWindow("/login.yp?targetpage=login_pop_library&pageflag=userlivrary",'login_pop','width=596,height=320');
		}else{
			document.location="/user_myInfo.yp?targetpage=usermyinfo_library";
		}
	}
}


function fCouponDown(value,userdiv){
	var udiv = userdiv;
	if(udiv=="00" || udiv=="C0"){
		alert("쿠폰은 북클럽 회원만 다운로드 받을 수 있습니다.");
		return;
	}
	if(udiv.length==0){
		alert("로그인을 하셔야 쿠폰을 다운로드 받을수 있습니다.");
		MM_openBrWindow("/login.yp?targetpage=login_pop_01&pageflag=eachlist",'login_pop','width=596,height=320');
	}else{
		makeRequest("get", "/servlet/eventlist?targetpage=event_couponDownload&couponcd="+value, getCouponDown);//쿠폰 다운로드
	}
}

function getCouponDown(req_obj){
//alert(req_obj.responseXML.xml);
	var lists = req_obj.responseXML.getElementsByTagName("lists")[0];
	if (lists){
		var couponcd		= lists.getElementsByTagName("couponcd")[0].firstChild.nodeValue;
		var count			= lists.getElementsByTagName("count")[0].firstChild.nodeValue;
	}
	if(count!=0){
		alert("이미 다운로드된 쿠폰입니다.\n마이영풍에서 쿠폰을 확인하십시오.");
	}else{
		alert("쿠폰을 다운받으셨습니다.\n마이영풍에서 쿠폰을 확인하십시오.");
	}
}