/**
 * @(#)koreafocus.js
 *
 * 코리아 포커스
 *	@author		Triple_H
 *	@version $Revision$ $Date$
 */

var pageLoad = new PageLoad();

function kfw_init() {
	pageLoad.process();
	family_site_reset();
}

// Family site selection --
function family_site_reset() {
}

function family_site_go(s) {
	window.open(s, "", "");

}

function getStyleDir(volume_id) {
		var styleDir;
		if (volume_id < 58) {
			styleDir = "design1"; 
		} else if (volume_id >= 58) {
			styleDir = "design2";
		}
		return styleDir;
}
// 플래시 네비 링크
function goURL(category, volume_id) {
		var styleDir;
		styleDir = getStyleDir(volume_id);
		switch (category) {
		case	0:
			document.location.href = "/" + styleDir + "/?volume_id=" + volume_id;
			break;
		case	1:
			document.location.href = "/" + styleDir + "/politics/list.asp?volume_id=" + volume_id  + "&category=A";
			break;
		case	2:
			document.location.href = "/" + styleDir + "/economy/list.asp?volume_id=" + volume_id  + "&category=B";
			break;
		case	3:
			document.location.href = "/" + styleDir + "/society/list.asp?volume_id=" + volume_id  + "&category=D";
			break;
		case	4:
			document.location.href = "/" + styleDir + "/culture/list.asp?volume_id=" + volume_id  + "&category=C";
			break;
		case	5:
			document.location.href = "/" + styleDir + "/essays/list.asp?volume_id=" + volume_id  + "&category=G";
			break;	
		case	6:
			document.location.href = "/" + styleDir + "/features/list.asp?volume_id=" + volume_id  + "&category=H";
			break;		
		case	7:
			document.location.href = "/" + styleDir + "/bookreview/list.asp?volume_id=" + volume_id  + "&category=I";
			break;		
		case	8:
			document.location.href = "/" + styleDir + "/interview/list.asp?volume_id=" + volume_id  + "&category=J";
			break;		
		}
}

// Session 확인 Ajax 요청
function sessionCheckAjax() {
	var execUrl = "/login/login_proc.asp";
	var params = "mode=check";
	var opts = { method : "post",
			    parameters : params,
			    onComplete : get_sessionCheckAjax
			  };
	var req = new Ajax.Request(execUrl, opts);
	return false;	
}

// Session 확인 Ajax 응답
function get_sessionCheckAjax(oreq){
	if (oreq.responseText == "True") {alert("로그인 세션이 종료되었습니다.\n\n다시 로그인 하세요."); location.reload();}
	else if  (oreq.responseText == "False") { alert('서버에러.\n\n서버 관리자에게 문의 하세요.');}
}

// 통합검색 확인
//
// @param f 검색객체
//
function go_search(f) {	
	var styleDir;
	styleDir = getStyleDir(f.volume_id.value);
	if (f.searchText.value.replace(/\s/gi, "" ) == "" ) {alert("Enter search keyword."); return false; }
}

// 이메일 뉴스레터 팝업 _FAQ용
function go_signUp(volume_id) {	
	var styleDir;
	styleDir = getStyleDir(volume_id);
	var email = document.getElementById("sign").value;
	email = (email == "E-mail Address")? "" : email
	popupCenterWindow("/" + styleDir + "/joinus/signup.asp?email=" + email, "newsletter", "500", "400");
}

// 볼륨 변경
//
// @param volume_id 볼륨아이디
//
function go_chnvolume(volume_id){
		if (volume_id != "") 	{
				document.location.href = "/?volume_id=" + volume_id;
		}		
}

// 이메일 뉴스레터 팝업 _main용
function go_signUpMain(volume_id) {
	var styleDir;
	styleDir = getStyleDir(volume_id);
	var email = document.getElementById("sign").value;
	email = (email == "E-mail Address")? "" : email
	if (email_check(email)) {
			popupCenterWindow("/" + styleDir + "/joinus/joinus_proc.asp?mode=check&email=" + email, "newsletter", "500", "400");
	} 
	return;
	
}	

// 이메일 확인
function email_check(email) {
	var rgEmail = /^[\w_-]+(\.[\w_-]+)*@[\w_-]+(\.[\w_-]+)*\.\w{2,3}$/i
	if (email == "" ) { alert("Complete your email messages."); return false; }
	if (!rgEmail.test(email)) { alert("Email format is incorrect."); return false; }
	return true;
}

// 투표결과 팝업
function go_voteResult(volume_id) {		
	var styleDir;
	styleDir = getStyleDir(volume_id);
	popupCenterWindow("/" + styleDir + "/vote/vote_result.asp?volume_id="+volume_id, "voteResult", "500", "400");
}
// 투표
function vote(f) {
	var vote_id = "";
	for (var i = 0 ; i < f.answer.length ; i++) {
		if (f.answer[i].checked){
				vote_id = f.answer[i].value;
				break;
		}
	}
	if (vote_id == "") 	{return false; }
	var execUrl = "/design1/vote/vote_proc.asp";
	var params = "vote_answer_id=" + vote_id;
	var opts = { method : "post",
			    parameters : params,
			    onComplete : get_resultVote
			  };
	var req = new Ajax.Request(execUrl, opts);
	return false;	
}

//투표결과
function get_resultVote(oreq) {
		if (oreq.responseText == "True" ) {
			alert("Successfully voted.");
		}
		else {
			alert("Voting failed");
		}
}
//원본보기
function imgOrg_Popup(img_org_name) {
		
		var url = "/design1/layout/content_imgOrg.asp?img_org_name=" + img_org_name ;
		window.open(url, "imgOrg", "top=0, left=0");
}







// EOF
