//--------------- 논문 검색 ----------------
function Journal_Frm(vol,num)
{
	theForm = document.Journal_form;
	if(!theForm.mod.value)
	{
		if(theForm.year1.value !="" && theForm.year2.value !="")
		{
			if(theForm.year1.value > theForm.year2.value)
			{
				alert("발행년도가 잘못지정되었습니다!");
				theForm.year1.focus();
				return false;
			}
		}
	}
	else
	{
		theForm.Vol.value = vol;
		theForm.Num.value = num;
	}
/*
	if(!theForm.sub_box.checked && !theForm.aut_box.checked && !theForm.sos_box.checked && !theForm.key_box.checked && !theForm.pub_box.checked && !theForm.abs_box.checked)
	{
		alert("출력결과를 적어도 한가지는 선택하셔야 합니다!");
		theForm.sub_box.focus();
		return false;
	}
	if(!radioCheck(theForm.sort))
	{
		alert("정렬기준을 선택하셔야 합니다!");
		theForm.sort[0].focus();
		return false;
	}
*/
	// 권호수 검색과 같은 모듈을 사용하므로 권호수검색은 따로 뺸다.
	if(theForm.mod.value != "vol") {
		if (theForm.at[0].checked == true) {
			// 내부검색
			theForm.action = "list.html";
			theForm.submit();
		} else {
			// pubmed일때는 term 에 pubmed형식 쿼리문을 생성해야 한다.
			var term_tmp = theForm.term.value; // 기본 쿼리문 Journal of Veterinary Science [Journal Name]
			var key = theForm.key.value;
			var key_word =  theForm.key_word.value;
			var query_word;

			switch (key) {
				case "all" : query_word = key_word + " [ALL]"; break;
				case "title" : query_word = key_word + " [TI]"; break;
				case "author" : query_word = key_word + " [AU]"; break;
				case "keywords" : query_word = key_word + " [MA]"; break;
				case "abstract" : query_word = key_word + " [TIAB]"; break;
				default : query_word = ""; break;
			}

			// 년도
			if (theForm.year1.value && theForm.year2.value) {
				year_word = theForm.year1.value + ":"+ theForm.year2.value +" [dp]";
				if (key_word == "") query_word = "";
			} else if (theForm.year1.value) {
				year_word = theForm.year1.value +" [dp]";
				if (key_word == "") query_word = "";
			} else {
				year_word = "";
			}
			// 권수
			if (theForm.Vol.value) {
				vol_word = theForm.Vol.value +" [VI]";
				if (key_word == "") query_word = "";
			} else {
				vol_word = "";
			}
			// 호수
			if (theForm.Num.value) {
				num_word = theForm.Num.value +" [IP]";
				if (key_word == "") query_word = "";
			} else {
				num_word = "";
			}

			if (theForm.at[2].checked == true) {
				// pubmed 전체 - 기본 수의학회 쿼리는 제외
				term_tmp = query_word + year_word + vol_word + num_word;
			} else {
				// pubmed 기본 수의학회 쿼리
				term_tmp += " and (" + query_word + year_word + vol_word + num_word + ")";
			}

			theForm.term.value = term_tmp;
			theForm.action = "http://www.ncbi.nlm.nih.gov/sites/entrez";
			theForm.submit();
		}
	} else {
			theForm.action = "list.html";
			theForm.submit();
	}
}

//--------------- 권호수별 검색 ----------------
function Vol_Frm()
{
	window.location = "main.html?mod=vol";
}

//--------------- 전체 선택 ----------------
function Allcheck()
{
	theForm = document.Journal_form;
	for( var i=0; i < theForm.elements.length; i++)
	{
		var check = theForm.elements[i];
		check.checked = true;
	}
	return;
}

//--------------- 전체 선택 취소 ----------------
function Allnocheck()
{
	theForm = document.Journal_form;
	for( var i=0; i < theForm.elements.length; i++)
	{
		var check = theForm.elements[i];
		check.checked = false;
	}
	return;
}

//--------------- 선택 항목 보기 ----------------
function Select_check()
{
	var check_nums = document.Journal_form.elements.length;
	for(var i = 0; i < check_nums; i++)
	{
		var checkbox_obj = eval("document.Journal_form.elements[" + i + "]");
		if(checkbox_obj.checked == true)
		{
			 break;
		}
	}

	if(i == check_nums)
	{
		alert("No Select.");
		return;
	}
	else
	{
		document.Journal_form.action="view.html";
		document.Journal_form.submit();
	}
}

//--------------- 한개 보기 ----------------
function View(no)
{
//	document.Journal_form.uid.value = no;
//	document.Journal_form.action="view.html";
//	document.Journal_form.submit();
	var box = eval("document.getElementById('multi_' + no)");
	box.checked = true;
	document.Journal_form.action="view.html";
	document.Journal_form.submit();
}

//--------------- 검색시 여러 권의 논문리스트일때 각 권,호수를 가져가게 한다 2005.2.16 신호정----------------
function View2(no,vol,num)
{
	document.Journal_form.Vol.value = vol;
	document.Journal_form.Num.value = num;
	document.Journal_form.uid.value = no;
	document.Journal_form.action="view.html";
	document.Journal_form.submit();
}

//--------------- 리스트 페이지로 이동 ----------------
function List_go()
{
//	if(document.Journal_form.sflag.value=="Y"){
//		document.Journal_form.Vol.value="";
//		document.Journal_form.Num.value="";
//	}
	document.Journal_form.action="list.html";
	document.Journal_form.submit();
}

//--------------- 검색 메인 페이지로 이동 ----------------
function Main_go()
{
	document.Journal_form.action="main.html";
	document.Journal_form.submit();
}
function radioCheck(oN){
	for(i=0;i<oN.length;i++){
		if(oN[i].checked){ return true; }
	}
	return false;
}

//--------------- 로그인 체크 ----------------
function session_err()
{
	alert("회원전용 공간입니다.");
	return;
}

// ------------- 엔터키 체크 -------------------
function chkEnterKey() {
	var f = document.Journal_form;
	if (event.keyCode=='13') {
		Journal_Frm();
	}
}


// 컨펌메세지 출력 후 이동
function conf_url(msg,murl) {
	if(confirm(msg)) window.location = murl;
}

// 팝업창 띄우기
var _pop //create global variable without assigning a value so that its value is null
function popen(url,name,w,h,scroll,pos,res) { // (경로,이름,가로,세로,스크롤유무,위치,리사이즈)

	if (!scroll) scroll = 1;
	if (!pos) pos = "center";
	if (!res) res = 0;

	switch (pos) {
		case 'center' :
			LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100;
			TopPosition = (screen.height) ? (screen.height - h - 100) / 2 : 100;
			break;
		case "random" :
			LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100;
			TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100;
			break;
		default :
			LeftPosition=0;
			TopPosition=0;
			break;
	}

	var settings = 'width=' + w + ', height=' + h + ', top=' + TopPosition + ', left=' + LeftPosition + ', scrollbars=' + scroll;
	settings += ', location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=' + res;

	if(_pop!=null && !_pop.closed) {
		_pop.close();
	}

	pop = window.open(url, name, settings);
	pop.focus();
}

