var ex_selected = 0;
var ex_sub_selected = 0;
var ex_dir_selected = 0;

// 통합검색로그 위한 변수
var log_accessPage='1501';

function doSubCategory(chID,id,chAllID)
{
	try{
		$('dir_'+ex_selected).className="noselect_item";
		$('dir_'+id).className="select_item";
		ex_selected=id;
		ex_sub_selected=0;
	}catch(e){;}

    openAjax.doDisplay("sub_dir", "sub_directory.jsp?ch=" + chID);
    openAjax.doDisplay("dir_content", "dir_content.jsp?ch1="+chAllID);
}

function doSubContent(theme,chID,id)
{
	var index = 2;

	if(theme=='B'){
		index = 3;
	}else if(theme=='C'){
		index = 4;
	}else if(theme=='D'){
		index = 5;
	}else if(theme=='E'){
		index = 6;
	}else if(theme=='f'){
		index = 7;
	}else if(theme=='G'){
		index = 8;
	}else if(theme=='H'){
		index = 9;
	}

	for(var i = 1; i < 10; i++){
		if(i==index){
			$('acrive_img_'+i).src='../include/images/oa_0'+i+'_tap_over.gif';
		}else {
			$('acrive_img_'+i).src='../include/images/oa_0'+i+'_tap.gif';
		}
	}

	try{
		$('subdir_'+ex_sub_selected).className="noselect_item";
		$('subdir_'+id).className="select_item";
		ex_sub_selected=id;
	}catch(e){;}
    openAjax.doDisplay("dir_content", "dir_content.jsp?sTheme="+theme+"&ch=" + chID);
}

function doValidRSS()
{
	if($('ARTICLE_WRITE').sChannelName.value==""){
		alert("채널명을 입렵해 주세요.");
		$('ARTICLE_WRITE').sChannelName.focus();
		return;
	}
	if($('ARTICLE_WRITE').sChannelAddr.value==""){
		alert("채널 주소를 선택하세요.");
		$('ARTICLE_WRITE').sChannelAddr.focus();
		return;
	}
	if($('ARTICLE_WRITE').cateCategory1.value==""){
		alert("rss 분류를 선택하세요");
		$('ARTICLE_WRITE').cateCategory1.focus();
		return;
	}

	var chID = $('ARTICLE_WRITE').sChannelAddr.value;

	$('WRITE_FORM').hide();
	$('vaild_btn').hide();
	$('ment').show();
    openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_rss_valid.jsp?ch=" + chID, ment);
}

function ment(resText){
	$('ment').hide();
	openAjax.setResult(resText,"valid_rss");
}

function displayMent(){
	$('ment').hide();
}

//=======================================================================================
// 아카이브 등록 팝업 띄우기
//=======================================================================================
function archivePopup(){
	var wOpt = ' width=520, ';
	var hOpt = ' height=480, ';
	var lOpt = ' left=100, ';
	var tOpt = ' top=100, ';
	var resizeOpt = ' resizable=no, ';
	var fullOpt = ' fullscreen=no, ';
	var menuOpt = ' menubar=no, ';
	var toolOpt = ' toolbar=no, ';
	var directoryOpt = ' directories=no, ';
	var scrollOpt = ' scrollbars=no, ';
	var statusOpt = ' status=no, ';
	var locOpt = 'location=no ';
	var popOption = wOpt + hOpt + lOpt + tOpt + resizeOpt + fullOpt + menuOpt + toolOpt + directoryOpt + scrollOpt + statusOpt + locOpt ;

	window.open('archive_article.jsp','archive',popOption);
}
//=======================================================================================
// 아카이브 탭 바꾸기
//=======================================================================================
function archiveTab(idNum){
	switch(idNum){
		case 'tab03':
			openAjax.doDisplay("POPUP_ARCHIVE_ARTIVLE","archive_article_write.jsp");
			break;
		case 'tab01':
			openAjax.doDisplay("POPUP_ARCHIVE_ARTIVLE","archive_article_blog.jsp");
			break;
		case 'tab02':
			openAjax.doDisplay("POPUP_ARCHIVE_ARTIVLE","archive_article_comm.jsp");
			break;
	}
}
//=======================================================================================
// 아카이브 직접올리기 파일 업로드 버튼
//=======================================================================================
function open_file(){
	$('ARTICLE_WRITE').file.click();
}
function setFile(){
	$('ARTICLE_WRITE').tempFile.value = $('ARTICLE_WRITE').file.value;
}
//=======================================================================================
// 아카이브 직접올리기 서브밋
//=======================================================================================
function writeSubmit(){
	if($('ARTICLE_WRITE').postTitle.value==""){
		alert("제목을 입력하세요");
		$('ARTICLE_WRITE').postTitle.focus();
		return;
	}
	if($('ARTICLE_WRITE').postCateId.value==""){
		alert("카테고리를 선택하세요.");
		$('ARTICLE_WRITE').postCateId.focus();
		return;
	}
	if($('ARTICLE_WRITE').cateCategory1.value==""){
		alert("OA 분류를 선택하세요");
		$('ARTICLE_WRITE').cateCategory1.focus();
		return;
	}
	if($('ARTICLE_WRITE').tempFile.value==""){
		alert("파일을 선택해 주세요");
		$('ARTICLE_WRITE').tempFile.focus();
		return;
	}
	//var file = $('ARTICLE_WRITE').tempFile.value;
	//if(file!=''){
	//	splitStr = file.split(".");
	//	var surfix = splitStr[splitStr.length-1].toLowerCase();
	//	if(!(surfix == 'pdf' || surfix =='hwp' || surfix == 'doc'|| surfix == 'ppt'|| surfix == 'xls')){
	//		alert('pdf, hwp, doc, ppt, xls 확장자의 파일을 올려주십시요.');
	//		return;
	//	}
	//}
	//$('ARTICLE_WRITE').submit();
	//alert(Form.serialize('ARTICLE_WRITE'));

	document.ARTICLE_WRITE.submit();
}
//=======================================================================================
// 사용자 rss 직접올리기 서브밋
//=======================================================================================
function writeSubmit(){
	if($('ARTICLE_WRITE').sChannelName.value==""){
		alert("채널명을 입렵해 주세요.");
		$('ARTICLE_WRITE').sChannelName.focus();
		return;
	}
	if($('ARTICLE_WRITE').sChannelAddr.value==""){
		alert("채널 주소를 선택하세요.");
		$('ARTICLE_WRITE').sChannelAddr.focus();
		return;
	}
	if($('ARTICLE_WRITE').cateCategory1.value==""){
		alert("rss 분류를 선택하세요");
		$('ARTICLE_WRITE').cateCategory1.focus();
		return;
	}

	document.ARTICLE_WRITE.submit();
}
//=======================================================================================
// 블로그 카테고리 셀렉트
//=======================================================================================
function changeBlogCate(cateid, nPage){
	byName('blogTag')[0].value="";
	if(cateid!=""){
		openAjax.doDisplay("ARTICLE_BLOGLIST","archive_article_bloglist.jsp?cateid="+cateid+"&nPage="+nPage);
	}
}
//=======================================================================================
// 블로그 표시순서 셀렉트
//=======================================================================================
function changeBlogOrder(orderText, nPage){
	if(byName('blogCate')[0].value==''){
		alert('카테고리를 먼저 선택해 주세요');
		byName('blogCate')[0].focus();
	}else{
		if(orderText!=""){
			openAjax.doDisplay("ARTICLE_BLOGLIST","archive_article_bloglist.jsp?orderText="+orderText+"&nPage="+nPage);
		}
	}
}
//=======================================================================================
// 아카이브 블로그 서브밋
//=======================================================================================
function blogSubmit(){
	if($('ARTICLE_BLOG').postIndex.value==""){
		alert("포스트를 선택하세요");
		return;
	}
	if($('ARTICLE_BLOG').cateCategory1.value==""){
		alert("OA 분류를 선택하세요");
		$('ARTICLE_BLOG').cateCategory1.focus();
		return;
	}
	$('ARTICLE_BLOG').submit();
}
//=======================================================================================
// 커뮤니티 셀렉트
//=======================================================================================
function changeCommCate(cateid, nPage){
	byName('commTag')[0].value="";

	$('ARTICLE_BEFORE').style.display='none';
	if(cateid!=""){
		openAjax.doDisplay("ARTICLE_COMMLIST","archive_article_commlist.jsp?cateid="+cateid+"&nPage="+nPage);
	}
}
//=======================================================================================
// 커뮤니티 태그 셀렉트
//=======================================================================================
function changeCommTag(tagid, nPage){
	byName('commCate')[0].value="";

	$('ARTICLE_BEFORE').style.display='none';
	if(tagid!=""){
		openAjax.doDisplay("ARTICLE_COMMLIST","archive_article_commlist_tag.jsp?tagid="+tagid+"&nPage="+nPage);
	}
}
//=======================================================================================
// 블로그 태그 셀렉트
//=======================================================================================
function changeBlogTag(tagid, nPage){
	//byName('blogTag')[0].value="";

	$('ARTICLE_BLOGBEFORE').style.display='none';
	if(tagid!=""){
		openAjax.doDisplay("ARTICLE_BLOGLIST","archive_article_bloglist_tag.jsp?tagid="+tagid+"&nPage="+nPage);
	}
}
//=======================================================================================
// 블로그 태그 셀렉트
//=======================================================================================
function changeOAList(value){
	if(value=='comm'){
		document.getElementById("img_comm").src=CONTEXT+'include/images/oa_01pop_tap_over.gif';
		document.getElementById("img_blog").src=CONTEXT+'include/images/oa_02pop_tap.gif';

		document.getElementById("comm_list").style.display='block';
		document.getElementById("blog_list").style.display='none';
	}else if(value=='blog'){
		document.getElementById("img_comm").src=CONTEXT+'include/images/oa_01pop_tap.gif';
		document.getElementById("img_blog").src=CONTEXT+'include/images/oa_02pop_tap_over.gif';

		document.getElementById("comm_list").style.display='none';
		document.getElementById("blog_list").style.display='block';
	}
}
//=======================================================================================
// 커뮤니티 표시순서 셀렉트
//=======================================================================================
function changeCommOrder(orderText, nPage){
	if(orderText!=""){
		openAjax.doDisplay("ARTICLE_COMMLIST","archive_article_commlist.jsp?orderText="+orderText+"&nPage="+nPage);
	}
}
//=======================================================================================
// 아카이브 커뮤니티 서브밋
//=======================================================================================
function commSubmit(){
	if($('ARTICLE_COMM').postIndex.value==""){
		alert("포스트를 선택하세요");
		return;
	}
	if($('ARTICLE_COMM').cateCategory1.value==""){
		alert("OA 분류를 선택하세요");
		$('ARTICLE_COMM').cateCategory1.focus();
		return;
	}
	$('ARTICLE_COMM').submit();
}
//=======================================================================================
// 블로그,커뮤니티  포스트 선택
//=======================================================================================
function clickImg(obj,idx){	// 포스트를 선택한다.
	var selectImg = $('POSTLIST').getElementsByTagName('img');

	$A(selectImg).each(function(value, index){
		value.src = value.src.replace("_select.gif","_noselect.gif");
	});
	obj.src = obj.src.replace("_noselect.gif","_select.gif");
	try{
		$('ARTICLE_BLOG').postIndex.value=idx;
	}catch(e){;}
	try{
		$('ARTICLE_COMM').postIndex.value=idx;
	}catch(e){;}
}

function clickMyImg(obj,idx){	// 포스트를 선택한다.
	var selectImg = $('POSTLIST').getElementsByTagName('img');

	$A(selectImg).each(function(value, index){
		value.src = value.src.replace("_select.gif","_noselect.gif");
	});

	obj.src = obj.src.replace("_noselect.gif","_select.gif");
	try{
		byName('postTempIndex')[0].value=idx;
	}catch(e){;}
}
//=======================================================================================
// 태그 관련 체크
//=======================================================================================
var CommTag =
{
	//유효한 태그명인지 확인.
	isTagname : function(tagname)
	{
		//[\\p{Punct}&&[^:/_@-]]
		re = /[\x21-\x2c\x2e\x3b-\x3f\x5b-\x5d\x60\x7b-\x7e ]/g
		var result = tagname.match(re)==null;
		return result;
	}
	,

	//태그 문자열을 유효하게 만든다.( 금지문자 제거, 연속되는 컴마 제거 )
	validateTagString : function(tagstring)
	{
		//[\\p{Punct}&&[^:/_@-]]
		re = /[\x21-\x2b\x2e\x3b-\x3f\x5b-\x5d\x60\x7b-\x7e ]/g;

		var ret = tagstring.replace(re, "");

		//콤마가 연속으로 있으면 하나로 만든다.
		re = /[\x2c]+/g;
		var ret = ret.replace(re, "\,");

		return ret;
	}
	,

	absoluteTagString : function(tagstring, maxcnt)
	{
		var valitags = CommTag.validateTagString(tagstring);

		var arraytag = valitags.split(",");

		var tagnames = "";

		var absolutecnt = arraytag.length;
		if(absolutecnt > maxcnt)
			absolutecnt = maxcnt;

		for(var i=0; i< absolutecnt; i++)
		{
			tagnames = tagnames + arraytag[i] + ",";
		}
		tagnames = CommTag.validateTagString(tagnames);

		tagnames = tagnames.substring(0, tagnames.length-1);

		return tagnames;
	}
	,

	//중복되는 태그를 없앤다.
	eliminateDuplicate : function(tagstring)
	{
		var valitags = CommTag.validateTagString(tagstring);

		var arraytag = valitags.split(",");

		var tagnames = "";

		for(var i=0; i<arraytag.length; i++)
		{
			for(var j=0; j<i; j++)
			{
				//이미 존재 하는 태그라면 없앰.
				if(arraytag[j]==arraytag[i])
				{
					arraytag[i]="";
				}
			}

			tagnames = tagnames + arraytag[i] + ",";

		}
		tagnames = CommTag.validateTagString(tagnames);

		tagnames = tagnames.substring(0, tagnames.length-1);

		return tagnames;

	}
	,

	//태그수 를 계산 한다.
	length : function(tagstring)
	{
		var arraytag = tagstring.split(",");

		return arraytag.length;
	}
	,

	//각 태그의 길이를 특정 크기 이하로 제한한다.
	validateTagLength : function(tagstring, maxlen)
	{
		var arraytag = tagstring.split(",");
		var tagnames = '';

		for(var i=0; i<arraytag.length; i++)
		{
			if(arraytag[i].length > maxlen)
			{
				arraytag[i] = arraytag[i].substring(0, maxlen);
			}
			tagnames = tagnames + arraytag[i] + ",";
		}

		tagnames = tagnames.substring(0, tagnames.length-1);

		tagnames = CommTag.eliminateDuplicate(tagnames);

		return tagnames;
	}
	,

	//각 태그의 길이가 유효한지 확인한다.
	isValidateTagLength : function(tagstring, maxlen)
	{
		var arraytag = tagstring.split(",");

		for(var i=0; i<arraytag.length; i++)
		{
			if(arraytag[i].length > maxlen)
			{
				return false;
			}
		}

		return true;
	}
}
var IE = false ;
if (window.navigator.appName.indexOf("Explorer") !=-1)
{
	IE = true;
}
function check_tagvalidate(aEvent, input)
{
	var keynum;
	if(typeof aEvent=="undefined") aEvent=window.event;
	if(IE)
	{
		keynum = aEvent.keyCode;
	}
	else
	{
		keynum = aEvent.which;
	}

	if(keynum == 111 )
	{
		input.value = CommTag.validateTagString(input.value);
	}
}

function check_tagsvalidate(input)
{
	input.value = CommTag.validateTagString(input.value);

	//중복되는 태그 제거
	input.value = CommTag.eliminateDuplicate(input.value);

	var tagcount = CommTag.length(input.value);
	//highlightMyTag();
	//태그 수 제한
	if(tagcount > 10)
	{
		alert("태그는 최대 10개 까지 입력이 가능합니다.");
		input.value = CommTag.absoluteTagString(input.value, 10);
		input.focus();
		return;
	}
}

function writeTagAdd(tagname, myTagSpan)
{
	var tagInput = document.getElementById("postTag");
	var tagSpan = document.getElementById(myTagSpan);
	var tagNames = tagInput.value;

	var elem = tagNames.split(",");
	for(var i=0; i < elem.length; i++){
		if(elem[i] == tagname) {
			alert("이미 입력된 태그입니다.");
			return;
		}
	}
	if(elem.length >= 10){
		alert("태그는 최대 10개까지 입력이 가능합니다.");
		return;
	}

	tagSpan.setAttribute("className","COMM_BODY_CONTENT_WRITE_POST_CONTENT_TAG_CLICK");
	if(tagNames != "") tagNames += ",";
	tagNames += tagname;
	tagInput.value = tagNames;
}
//=======================================================================================
// OA 분류
//=======================================================================================
function doCommunityCategory(){
	var tmp = "";
	try{
		tmp = $('ARTICLE_WRITE').cateCategory1.value;
	}catch(e){;}
	try{
		tmp = $('ARTICLE_BLOG').cateCategory1.value;
	}catch(e){;}
	try{
		tmp = $('ARTICLE_COMM').cateCategory1.value;
	}catch(e){;}
    tmp.substring(0,1);
    openAjax.doDisplay("CATEGORY_SECOND", "./action/comm_second_category.jsp?ch=" + tmp.substring(0,1));
}

function doMainCommunityCategory(th1){
	if(th1!=''){
		openAjax.doDisplay("CATEGORY_SECOND", "/archive/action/ajax_cate_info.jsp?ch=" + th1);
	}

    //openAjax.doDisplay("CATEGORY_SECOND", "./action/comm_main_second_category.jsp?ch=" + tmp.substring(0,1));
    //openAjax.doDisplay("SUBCATEGORY_SECOND", "./action/comm_sub_second_category.jsp?ch=" + tmp.substring(0,1));
}

function doSubCommunityCategory(){
	var tmp = "";
	try{
		tmp = byName('subCateCategory1')[0].value;
		byName('cateCategory1')[0].value = tmp;
	}catch(e){;}
    tmp.substring(0,1);

    openAjax.doDisplay("CATEGORY_SECOND", "./action/comm_main_second_category.jsp?ch=" + tmp.substring(0,1));
    openAjax.doDisplay("SUBCATEGORY_SECOND", "./action/comm_sub_second_category.jsp?ch=" + tmp.substring(0,1));
}

function doMainCommunityCategory2(){
	var tmp = "";
	try{
		tmp = byName('cateCategory2')[0].value;
		byName('subCateCategory2')[0].value = tmp;
	}catch(e){;}
}

function doSubCommunityCategory2(){
	var tmp = "";
	try{
		tmp = byName('subCateCategory2')[0].value;
		byName('cateCategory2')[0].value = tmp;
	}catch(e){;}
}
//=======================================================================================
// CCL 체크
//=======================================================================================
// ccl 적용 여부 체크
function cclChecking(chkResult){
	if(chkResult == '1'){
		$('CCL_SETTING').style.display  = 'block';
		if($('ARTICLE_WRITE')!=null)$('ARTICLE_WRITE').postIsCCL.value='1';
		else if($('ARTICLE_BLOG')!=null)$('ARTICLE_BLOG').postIsCCL.value='1';
		else if($('ARTICLE_COMM')!=null)$('ARTICLE_COMM').postIsCCL.value='1';
	}else{
		$('CCL_SETTING').style.display  = 'none';
		if($('ARTICLE_WRITE')!=null)$('ARTICLE_WRITE').postIsCCL.value='0';
		else if($('ARTICLE_BLOG')!=null)$('ARTICLE_BLOG').postIsCCL.value='0';
		else if($('ARTICLE_COMM')!=null)$('ARTICLE_COMM').postIsCCL.value='0';
	}
}
// ccl 적용 여부 체크 - 수정시
function cclCheckingModify(chkResult,chkValue){
	if(chkResult == '0'){
		$('CCL_SETTING').style.display  = 'none';
		try{
		$('FORM_POSTMODIFY').postIsCCL.value='0';
		}catch(e){;}
		try{
		$('POST_WRITE').postIsCCL.value='0';
		}catch(e){;}

	}else{
		$('CCL_SETTING').style.display  = 'block';
		try{
		$('FORM_POSTMODIFY').postIsCCL.value=chkValue;
		}catch(e){;}
		try{
		$('POST_WRITE').postIsCCL.value=chkValue;
		}catch(e){;}
	}
}
// ccl 적용 여부 체크
function cclCheckingBox(obj){
	if(obj.checked)$('ARTICLE_WRITE').postIsCCL.value='6';
	else $('ARTICLE_WRITE').postIsCCL.value='0';
}

function cclCheckingSubBox(obj){
	if(obj.checked)byName('postTempIsCCL')[0].value='6';
	else byName('postTempIsCCL')[0].value='0';
}
// ccl 라이센스 선택
function cclLicense(divID){
	var ccl1 = 1;

	if($('ARTICLE_WRITE')!=null)$ccl1=$('ARTICLE_WRITE').postIsCCL.value;
	else if($('ARTICLE_BLOG')!=null)ccl1=$('ARTICLE_BLOG').postIsCCL.value;
	else if($('ARTICLE_COMM')!=null)ccl1=$('ARTICLE_COMM').postIsCCL.value;

	var cclChk1 = parseInt(ccl1);
	if(divID == 'FORM_POSTMODIFY'){
		cclChk1 = 1;
	}
	var cclChk2 = 0;
	var cclObj02 = document.CCL_FORM.ccl02;

	var cclChk3 = 0;
	var cclObj03 = document.CCL_FORM.ccl03;

	for(var i = 0; i < cclObj02.length ; i++ ){
		if(cclObj02[i].checked){
			cclChk2 = parseInt(cclObj02[i].value);
		}
	}
	for(var i = 0; i < cclObj03.length ; i++ ){
		if(cclObj03[i].checked){
			cclChk3 = parseInt(cclObj03[i].value);
		}
	}
	var cclVal = parseInt(cclChk1) + parseInt(cclChk2) + parseInt(cclChk3);
	if($('ARTICLE_WRITE')!=null)$('ARTICLE_WRITE').postIsCCL.value=cclVal;
	else if($('ARTICLE_BLOG')!=null)$('ARTICLE_BLOG').postIsCCL.value=cclVal;
	else if($('ARTICLE_COMM')!=null)$('ARTICLE_COMM').postIsCCL.value=cclVal;

	$('CCL_SETTING').style.display  = 'none';
}

function downloadPDFConverter(){
	//PDF LINK
	location = CONTEXT+"common/file/PowerPDF_For_Personal.exe";
}

function downloadPDFPlugin(){
	location = "http://www.krm.or.kr/FRBR/coxsystem/files/coxgrd.7.0.3.9.exe";
}

function goPageMyOA(orderType,nPage){
	try{
	Element.hide('ARCHIVE_LOADING');
	}catch(e){;}

	try{
	Element.hide('ARCHIVE_VIEW');
	}catch(e){;}

	try{
	Element.hide('ARCHIVE_LIST');
	}catch(e){;}

	try{
	Element.show('OA_LOADING');
	}catch(e){;}

	openAjax.doDisplay("ARCHIVE_LIST",CONTEXT+"archive/sub_myoa_list.jsp?nPage="+nPage+"&orderType="+orderType);
}

function goPageFeed(channelIndex,nPage){
	if(nPage==null)nPage=1;
	try{
	$('loading').style.display='block';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	openAjax.doDisplayCall(CONTEXT+"archive/feed_content.jsp?channelIndex="+channelIndex+"&nPage="+nPage,doReadFeedCall);

	//openAjax.doDisplay("ARCHIVE_LIST",CONTEXT+"archive/feed_content_page.jsp?channelIndex="+channelIndex+"&nPage="+nPage);
}
//위에 goPageFeed와 동일하나 icon변경을 위한 nType파라미터만 추가 
//sky@anset.co.kr
function goPageOai(channelIndex,nPage){
	if(nPage==null)nPage=1;
	try{
	$('loading').style.display='block';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	openAjax.doDisplayCall(CONTEXT+"archive/feed_content.jsp?channelIndex="+channelIndex+"&nPage="+nPage+"&nType=4",doReadFeedCall);
}
function showLoadComm(){
	$('POPUP_ARCHIVE_ARTIVLE').show()
}

function hideLoadComm(){
	$('POPUP_ARCHIVE_ARTIVLE').hide()
}

function loadPost(){
	if(byName('postTempIndex')[0].value=="") {
		alert("가져올 포스트를 선택하세요");
		return;
	}
	var postIndex = byName('postTempIndex')[0].value;
	byName('postIndex')[0].value=postIndex;
	byName('postIsCCL')[0].value = byName('postTempIsCCL')[0].value;
	byName('postIsBLOG')[0].value = byName('postTempIsBLOG')[0].value;

	if(byName('postTempIsCCL')[0].value=="6"){
		byName('cclCheck')[0].checked=true;
	}

	byName('postTitle')[0].value = $('post_title_'+postIndex).innerHTML;
	byName('postContent')[0].value = byName('post_content_'+postIndex)[0].value;


	viewOaPop();
	//hideLoadComm();
}

function viewOaPop(){
	if($('myContentList').style.display == 'none') {
		$('myContentList').style.display = 'block'
	}else {
		$('myContentList').style.display = 'none'
	}
}

function myArchiveTab(idNum){
	switch(idNum){
		case 'tab02':
			openAjax.doDisplay("POPUP_ARCHIVE_ARTIVLE","archive_myarticle_blog.jsp");
			break;
		case 'tab01':
			openAjax.doDisplay("POPUP_ARCHIVE_ARTIVLE","archive_myarticle_comm.jsp");
			break;
	}
}

function readOA(postIndex,postType,nPage,orderType,linkID,id){
	try{
	Element.hide('ARCHIVE_LOADING');
	}catch(e){;}
	//Element.hide('ARCHIVE_LIST');
	try{
	Element.hide('ARCHIVE_VIEW');
	}catch(e){;}
	try{
	Element.hide('ARCHIVE_LIST');
	}catch(e){;}
	try{
	Element.show('OA_LOADING');
	}catch(e){;}

	try{
		if(id!=null){
			$('dir_con_'+ex_dir_selected).className="noselect_oaitem";
			$('dir_con_'+id).className="select_oaitem";
		}
		ex_dir_selected=id;
	}catch(e){;}

	if(postType=='1'){
			openAjax.doDisplay("ARCHIVE_VIEW","openarchive_blog_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID);
	}else if(postType=='2'){
			openAjax.doDisplay("ARCHIVE_VIEW","openarchive_comm_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID);
	}else if(postType=='3'){
			openAjax.doDisplay("ARCHIVE_VIEW","openarchive_forum_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID);
	}
}
function readFeed(channelIndex,nPage,id){
	if(nPage==null)nPage=1;

	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='block';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_LIST').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	try{
		if(id!=null){
			var tempClassName = $('dir_con_'+ex_dir_selected).className;
			tempClassName = tempClassName.replace("no","");

			$('dir_con_'+ex_dir_selected).className="no"+tempClassName;
			$('dir_con_'+id).className="select_feeditem";
		}
		ex_dir_selected=id;

	}catch(e){;}

	//document.location.href = "#ARCHIVE_FEED_READ";

	// rss 카테고리를 불러온다.
	//openAjax.doDisplay("archive2",CONTEXT+"archive/action/ajax_archive_category.jsp?sTheme=A");
	openAjax.doDisplayCall(CONTEXT+"archive/feed_content.jsp?channelIndex="+channelIndex+"&nPage="+nPage,doReadFeedCall);
}
//이 function은 OAI-PMH 호출 페이지로 방식은 바로 위에 있는 feedRead()와 동일하지만 마지막 openAjax부르는 부분에서
//nType를 주어 해당 채널이 rss인지 OAI-PMH인지 구별하는 function입니다. sky@asnet.co.kr
function readOai(channelIndex,nPage,id){
	if(nPage==null)nPage=1;
	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='block';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_LIST').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}
	try{
		if(id!=null){
			var tempClassName = $('dir_con_'+ex_dir_selected).className;
			tempClassName = tempClassName.replace("no","");

			$('dir_con_'+ex_dir_selected).className="no"+tempClassName;
			$('dir_con_'+id).className="select_oaiitem";
		}
		ex_dir_selected=id;
	}catch(e){;}
	openAjax.doDisplayCall(CONTEXT+"archive/feed_content.jsp?channelIndex="+channelIndex+"&nPage="+nPage+"&nType=4",doReadFeedCall);
}
function readFeedAll(channelIndex,nPage,id){
	if(nPage==null)nPage=1;

	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='block';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_LIST').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	try{
		if(id!=null){
			var tempClassName = $('dir_con_'+ex_dir_selected).className;
			tempClassName = tempClassName.replace("no","");

			$('dir_con_'+ex_dir_selected).className="no"+tempClassName;
			$('dir_con_'+id).className="select_feeditem";
		}
		ex_dir_selected=id;

	}catch(e){;}

	//document.location.href = "#ARCHIVE_FEED_READ";

	// rss 카테고리를 불러온다.
	openAjax.doDisplay("archive2",CONTEXT+"archive/action/ajax_archive_category.jsp?sTheme=A");
	openAjax.doDisplayCall(CONTEXT+"archive/feed_content.jsp?channelIndex="+channelIndex+"&nPage="+nPage,doReadFeedCall);
}

function readFeedSearchAll(channelIndex,nPage,id){
	if(nPage==null)nPage=1;

	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='none';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_LIST').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	try{
		if(id!=null){
			var tempClassName = $('dir_con_'+ex_dir_selected).className;
			tempClassName = tempClassName.replace("no","");

			$('dir_con_'+ex_dir_selected).className="no"+tempClassName;
			$('dir_con_'+id).className="select_feeditem";
		}
		ex_dir_selected=id;

	}catch(e){;}

	//document.location.href = "#ARCHIVE_FEED_READ";

	// rss 카테고리를 불러온다.
	//openAjax.doDisplay("archive2",CONTEXT+"archive/action/ajax_archive_category.jsp?sTheme=A");
	openAjax.doDisplayCall(CONTEXT+"archive/feed_content.jsp?channelIndex="+channelIndex+"&nPage="+nPage,doReadFeedCall);
}

function readOasAll(sTheme,postIndex,postType,nPage,orderType,linkID,id){
	if(nPage==null)nPage=1;

	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='block';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_LIST').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	try{
		if(id!=null){
			var tempClassName = $('dir_con_'+ex_dir_selected).className;
			tempClassName = tempClassName.replace("no","");

			$('dir_con_'+ex_dir_selected).className="no"+tempClassName;
			$('dir_con_'+id).className="select_feeditem";
		}
		ex_dir_selected=id;

	}catch(e){;}

	//document.location.href = "#ARCHIVE_FEED_READ";

	// rss 카테고리를 불러온다.
	openAjax.doDisplay("archive2",CONTEXT+"archive/action/ajax_archive_category.jsp?sTheme=A");

	if(postType=='1'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_blog_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doreadOasAllCall);
	}else if(postType=='2'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_comm_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doreadOasAllCall);
	}else if(postType=='3'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_forum_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doreadOasAllCall);
	}
}

function doreadOasAllCall (resText){
	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive3').style.display='block';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='none';
	}catch(e){;}

	openAjax.setResult(resText,"ARCHIVE_VIEW");
}

function readOAS(sTheme,postIndex,postType,nPage,orderType,linkID,id){
	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='none';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_LIST').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	if(postType=='1'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_blog_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doReadOASCall);
	}else if(postType=='2'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_comm_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doReadOASCall);
	}else if(postType=='3'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_forum_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doReadOASCall);
	}else if(postType=='5'){
		openAjax.doDisplayCall(CONTEXT+"archive/action/ajax_archive_result_view.jsp?sTheme="+sTheme+"&postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&orderType="+orderType+"&linkID="+linkID,doReadOASCall);
	}
}
function doReadOASCall(resText){
	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='block';
	}catch(e){;}

	openAjax.setResult(resText,"ARCHIVE_VIEW");
	try{
	$('loading').style.display='none';
	}catch(e){;}
	//document.location.href = "#ARCHIVE_POST_VIEW";
}
function doReadFeedCall (resText){
	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive3').style.display='block';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='none';
	}catch(e){;}

	openAjax.setResult(resText,"archive3");

	//document.location.href = "#ARCHIVE_POST_VIEW";
}
function readOAI(postIndex,postType,nPage,linkID){
	try{
	Element.hide('mykrmCenter');
	}catch(e){;}
	try{
	Element.hide('ARCHIVE_LOADING');
	}catch(e){;}
	try{
	Element.hide('OA_SEARCH_LOADING');
	}catch(e){;}
	try{
	Element.show('OA_LOADING');
	}catch(e){;}

	if(postType=='1'){
			openAjax.doDisplayCall(CONTEXT+"mykrm/my_oa_blog_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&linkID="+linkID,doReadOAICall);
	}else if(postType=='2'){
			openAjax.doDisplayCall(CONTEXT+"mykrm/my_oa_comm_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&linkID="+linkID,doReadOAICall);
	}else if(postType=='3'){
			openAjax.doDisplayCall(CONTEXT+"mykrm/my_oa_forum_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage+"&linkID="+linkID,doReadOAICall);
	}
}
function readBlog(postIndex,postType,nPage){
	try{
	Element.hide('ARCHIVE_LOADING');
	}catch(e){;}
	//Element.hide('ARCHIVE_LIST');
	try{
	Element.hide('ARCHIVE_VIEW');
	}catch(e){;}
	try{
	Element.hide('ARCHIVE_LIST');
	}catch(e){;}
	try{
	Element.show('OA_LOADING');
	}catch(e){;}
	openAjax.doDisplayCall(CONTEXT+"mypage/my_blog_view.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage="+nPage,doReadOAICall);
}
function doReadOAICall(resText){
	openAjax.setResult(resText,"mykrmCenter");
	Element.show('mykrmCenter');
	Element.hide('OA_LOADING');
}

function displayComment(){
	if($('commentID').style.display=='none'){
		Element.show('commentID');
	}else {
		Element.hide('commentID');
	}
}

function viewOAI(postIndex,postType,linkID,divID){
	//parent.location.href="../sub_mypage.jsp?nCmd=2&postIndex="+postIndex+"&postType="+postType+"&linkID="+linkID;
	location.href="my_openarchive.jsp?postIndex="+postIndex+"&postType="+postType+"&nPage=1"+"&linkID="+linkID;
}


//덧글작성
var replyIndex = "";
function doBlogPostReplyToggle(nPostIndex){
	replyIndex = nPostIndex;
	var b = $("COMMENT_" + nPostIndex);
    if(b.style.display=='none'){
    	b.style.display='block';
        openAjax.doDisplayCall(CONTEXT+'archive/ajax_blog_reply.jsp?nPostIndex='+nPostIndex,setDivComment);

    }else{
    	b.style.display='none'
    	$('COMMENT_'+ nPostIndex).innerHTML="";
		try{
			resizeFrame('IFRAME_MYPAGE');
		}catch(e){
			;
		}
    }
}

function setDivComment(resText){
	openAjax.setResult(resText,'COMMENT_'+ replyIndex);
	try{

		if($("COMMENT_COUNT_"+replyIndex)!=null){
			if($("replyCount"+replyIndex)!=null){
				$("COMMENT_COUNT_"+replyIndex).innerHTML = $("replyCount"+replyIndex).value;
			}
		}
	}catch(e){
		;
	}
	try{
		resizeFrame('IFRAME_MYPAGE');
	}catch(e){
		;
	}
}

function doBlogPostReplyToggle3(nPostIndex){
	replyIndex = nPostIndex;
    openAjax.doDisplayCall(CONTEXT+'archive/ajax_blog_reply.jsp?nPostIndex='+nPostIndex,setDivComment);
}

function doSubjectPostReplyToggle3(nPostIndex){
	replyIndex = nPostIndex;
    openAjax.doDisplayCall(CONTEXT+'archive/ajax_subject_reply.jsp?nPostIndex='+nPostIndex,setDivComment);
}

// 리플 -삭제
// replyIndex : 삭제할 리플의 고유 인덱스
function doBlogReplyDelete(replyIndex) {
		document.getElementById("tmp_div").src=CONTEXT+'archive/action/ajax_reply_delete.jsp?nReplyIndex='+replyIndex;
}

function doBlogReplyCheckSubmit(nPostIndex) {
    if( trim(eval( "document.replyWrite"+nPostIndex).replyContent.value).length < 1) {
        alert( "내용을 입력해 주세요" );
        eval( "document.replyWrite"+nPostIndex).replyContent.value="";
        eval( "document.replyWrite"+nPostIndex).replyContent.focus();
        return false;
    }
   return true;
}


//덕글작성
function doCommPostReplyToggle(nPostIndex){
	alert(CONTEXT);
	replyIndex = nPostIndex;
	var b = $("COMMENT_" + nPostIndex);
    if(b.style.display=='none'){
    	b.style.display='block';
        openAjax.doDisplayCall(CONTEXT+'archive/ajax_comm_reply.jsp?nPostIndex='+nPostIndex,setDivComment);

    }else{
    	b.style.display='none'
    	$('COMMENT_'+ nPostIndex).innerHTML="";
		try{
			resizeFrame('IFRAME_MYPAGE');
		}catch(e){
			;
		}
    }
}

function doCommPostReplyToggle3(nPostIndex){
	replyIndex = nPostIndex;
    openAjax.doDisplayCall(CONTEXT+'archive/ajax_comm_reply.jsp?nPostIndex='+nPostIndex,setDivComment);
}


// 리플 -삭제
// replyIndex : 삭제할 리플의 고유 인덱스
function doCommReplyDelete(replyIndex) {
	document.getElementById("tmp_div").src=CONTEXT+'archive/action/ajax_reply_comm_delete.jsp?nReplyIndex='+replyIndex;
}

function doCommReplyCheckSubmit(nPostIndex) {
    if( trim(eval( "document.replyWrite"+nPostIndex).replyContent.value).length < 1) {
        alert( "내용을 입력해 주세요" );
        eval( "document.replyWrite"+nPostIndex).replyContent.value="";
        eval( "document.replyWrite"+nPostIndex).replyContent.focus();
        return false;
    }
   return true;
}

function doFlashSearch(sSearchWord){
	$("search_form").searchword.value=sSearchWord;
	doSearchOA();
}

//검색
function doSearchOA(){

	var searchWord = document.getElementById("searchword").value;
	var oringinSearchWord = document.getElementById("originsearchword").value;
	if( searchWord.length < 1){
		alert("검색 키워드를 입력해주세요.");
		$("search_form").searchword.focus();
	}else{
		$("SEARCHBUTTON").innerHTML = "<img src=\"../include/images/btn_search.gif\"  alt=\"검색\">";

	    try{
		$('archive').style.display='none';
		}catch(e){;}
		try{
		$('archive2').style.display='none';
		}catch(e){;}
		try{
		$('archive3').style.display='none';
		}catch(e){;}
		try{
		$('ARCHIVE_VIEW').style.display='none';
		}catch(e){;}
		try{
		$('loading').style.display='none';
		}catch(e){;}
		try{
		$('search_loading').style.display='block';
		}catch(e){;}

		if(oringinSearchWord != searchWord){
			document.getElementById("nPage").value = 1;
		}

		if(document.getElementById("searchMode").value != document.getElementById("originsearchmode").value){
			document.getElementById("nPage").value = 1;
		}
		// rss 카테고리를 불러온다.
	    //openAjax.doDisplay("archive2",CONTEXT+"archive/action/ajax_archive_category.jsp?sTheme=A");

	    // 검색 결과 리스트 페이지를 불러온다.
	    openAjax.doActionCall(CONTEXT+"archive/action/ajax_archive_word_search.jsp" ,"search_form", doSearchOACall);
	}

}

function doSearchOACall(resText)
{
	$("archive3").innerHTML = resText;
	$("SEARCHBUTTON").innerHTML = "<a href=\"javascript:doSearchOA();\"><img src=\"../include/images/btn_search.gif\"></a>";
	$("search_form").searchword.readOnly=false;
	document.location.href = "#ARCHIVE_LIST1";
	try{
	$('search_loading').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='none';
	}catch(e){;}
	try{
	$('archive3').style.display='block';
	}catch(e){;}
	document.getElementById("originsearchword").value = document.getElementById("searchword").value;
	document.getElementById("originsearchmode").value = document.getElementById("searchMode").value;
}

function doKeySearchOA(){
	if (event.keyCode==13) {
		//$("search_form").searchword.readOnly=true;
		//$("search_form").searchword.blur();
		doSearchOA();
	}
}

//검색
function doTestSearchOA()
{
	var searchWord = $("search_form").searchword.value;

	if( searchWord.length < 2)
	{
		alert("검색 키워드를 입력해주세요.");
		$("search_form").searchword.focus();
	}
	else
	{
		$("SEARCHBUTTON").innerHTML = "<img src=\"../include/images/btn_search.gif\">";
	    //openAjax.doAction("ARCHIVE_LIST", "sub_archive_search.jsp" ,"search_form");
	    Element.hide('ARCHIVE_LOADING');
		//Element.hide('ARCHIVE_LIST');
		Element.hide('ARCHIVE_VIEW');
	    Element.hide('OA_LOADING');
	    Element.show('OA_SEARCH_LOADING');
	    openAjax.doActionCall("test_search.jsp" ,"search_form", doSearchOACall);
	}

}

function doTestKeySearchOA(){
	if (event.keyCode==13) {
		$("search_form").searchword.readOnly=true;
		$("search_form").searchword.blur();
		doSearchOA();
	}
}

//검색 페이징
function goPageSearchOA(nPage){
	openAjax.doAction("ARCHIVE_LIST", "sub_archive_search.jsp?nPage="+nPage ,"search_form");
}
//Main 검색 페이징
function goPageMainSearchOA(nPage){
	document.getElementById("nPage").value = nPage;
	if(document.getElementById("searchword").value != document.getElementById("originsearchword").value){
		document.getElementById("nPage").value = 1;
	}
	if(document.getElementById("searchMode").value != document.getElementById("originsearchmode").value){
		document.getElementById("nPage").value = 1;
	}
	openAjax.doActionCall(CONTEXT+"archive/action/ajax_archive_word_search.jsp" ,"search_form", doSearchOACall);
}
//검색조건이 변경되면 nPage 1로 변경
function changeSearchForm(){
	document.getElementById("nPage").value = 1;
}

function doPopularKeyword(strKeyword)
{
	$("search_form").searchword.value = strKeyword;
	doSearchOA();
}

function filedownload_blog(nIndex){
	document.location = "/archive/action/download_blog.jsp?nIndex="+nIndex;
}

function filedownload_comm(nIndex){
	document.location = "/archive/action/download_comm.jsp?nIndex="+nIndex;
}

function pdf_down_blog(nIndex){
	document.location = "/archive/action/pdf_download_blog.jsp?nIndex="+nIndex;
}
function pdf_down_comm(nIndex){
	document.location = "/archive/action/pdf_download_comm.jsp?nIndex="+nIndex;
}
function nouser_script(){
	alert("로그인 후 이용하실 수 있습니다.");
}


function CenterWindow(href,WinName,w,h,scroll,resize) {
	var PosLeft;
	var PosTop;

	PosLeft = (window.screen.width/2) - (w/2 + 10);
	PosTop = (window.screen.height/2) - (h/2 + 50);

//	scroll = 0;

	if(window.screen.width<w+10){
		PosLeft = 0;
		w = window.screen.width - 10;
		scroll = 1;
	}

	if(window.screen.height<h+60){
		PosTop = 0;
		if(window.screen.width>w+10){
			w +=15;
		}

		h = window.screen.height - 60;
		scroll = 1;
	}
	return window.open(href,WinName,"status=no, height=" + h + ",width=" + w + ", scrollbars=" + scroll + ",resizable=" + resize + ",left=" + PosLeft + ",top=" + PosTop + ",screenX=" + PosLeft + ",screenY=" + PosTop );
}
function viewImage(nImageNumber ) {
    var imageWin = CenterWindow("../view_image.jsp?sPath="+nImageNumber, "imageWin", 500, 500, "yes", "yes" );
    imageWin.focus();
}
function view_detailimage(sImagePath, width, height,url) {
	if(url==null){
    var imageWin = CenterWindow(CONTEXT+"archive/view_image.jsp?sPath="+escape(sImagePath), "imageWin",
                               width, height, "yes", "yes" );
                               imageWin.focus();
	}else{
	var imageWin = CenterWindow(url, "imageWin",
                               width, height, "yes", "yes" );
                               imageWin.focus();
	}
}
function view_detailimage_blog(sImagePath, width, height,url) {
	if(url==null){
    var imageWin = CenterWindow(CONTEXT+"archive/view_image_blog.jsp?sPath="+escape(sImagePath), "imageWin",
                               width, height, "yes", "yes" );
                               imageWin.focus();
	}else{
	var imageWin = CenterWindow(url, "imageWin",
                               width, height, "yes", "yes" );
                               imageWin.focus();
	}
}
function view_detailimage_comm(sImagePath, width, height,url) {
	if(url==null){
    var imageWin = CenterWindow(CONTEXT+"archive/view_image_comm.jsp?sPath="+escape(sImagePath), "imageWin",
                               width, height, "yes", "yes" );
                               imageWin.focus();
	}else{
	var imageWin = CenterWindow(url, "imageWin",
                               width, height, "yes", "yes" );
                               imageWin.focus();
	}
}
/*
function filedownload_blog(nIndex){
	document.location = "/blog/download.jsp?nIndex="+nIndex;
}

function filedownload_comm(nIndex){
	document.location = "/opencomm/download.jsp?nIndex="+nIndex;
}
*/

//
function cancelOA(postIndex,postType){
	openAjax.doDisplayCall(CONTEXT+"archive/action/action_article_cancel.jsp?postIndex="+postIndex+"&postType="+postType,doEmpty);
}
function cancelOARe(postIndex,postType){
	openAjax.doDisplayCall(CONTEXT+"archive/action/action_article_cancel_re.jsp?postIndex="+postIndex+"&postType="+postType,doEmpty);
}
function deleteMyOA(postIndex,postType){
	if(confirm("삭제하시겠습니까?")){
		openAjax.doDisplayCall(CONTEXT+"archive/action/action_article_delete.jsp?postIndex="+postIndex+"&postType="+postType,doEmpty);
	}
}

function doEmpty(resTxt){
	location.reload();;
}

var scrapIndex = null;
var scrapType=null;

function doMyScrap(postIndex,postType){
	//1:blog
	//2:community
	//3:forum
	//4:notice
	//5:Q&A
	//6:rss

	scrapIndex = postIndex;
	scrapType = postType;

	if(scrapType=='1'){
		openAjax.doDisplay("POPUP_ARCHIVE_SCRAP", CONTEXT+"archive/scrap_blog.jsp?postIndex="+scrapIndex);
	}if(scrapType=='6'){
		openAjax.doActionCall(CONTEXT+"archive/scrap_rss.jsp",scrapIndex,doMyScrapFocus);
	}else if(scrapType=='7'){
		openAjax.doDisplayCall(CONTEXT+"archive/scrap_channel.jsp?postIndex="+scrapIndex,doMyScrapFocus);
	}
}

function copyToClipboard(sUrl){
	alert('퍼가기 주소가 클립보드로 복사되었습니다.');
	window.clipboardData.setData('Text',sUrl);
}

function doMyScrapShow(){
	if(scrapType=='1'){
		openAjax.doDisplay("POPUP_ARCHIVE_SCRAP", CONTEXT+"archive/scrap_blog.jsp?postIndex="+scrapIndex);
	}else if(scrapType=='2'){
		openAjax.doDisplayCall(CONTEXT+"archive/scrap_comunity.jsp?postIndex="+scrapIndex,doMyScrapFocus);
	}else if(scrapType=='3'){
		openAjax.doDisplayCall(CONTEXT+"archive/scrap_forum.jsp?postIndex="+scrapIndex,doMyScrapFocus);
	}else if(scrapType=='4'){
		openAjax.doDisplayCall(CONTEXT+"archive/scrap_notice.jsp?postIndex="+scrapIndex,doMyScrapFocus);
	}else if(scrapType=='5'){
		openAjax.doDisplayCall(CONTEXT+"archive/scrap_qna.jsp?postIndex="+scrapIndex,doMyScrapFocus);
	}else if(scrapType=='6'){
		openAjax.doActionCall(CONTEXT+"archive/scrap_rss.jsp",scrapIndex,doMyScrapFocus);
	}else if(scrapType=='7'){
		openAjax.doDisplayCall(CONTEXT+"archive/scrap_channel.jsp?postIndex="+scrapIndex,doMyScrapFocus);
	}
}

function checkLogin(){

	openAjax.doDisplayCall(CONTEXT+"common/login/check_login.jsp",doCheckLogin);
}

function doCheckLogin(resText){
	var data = resText;
	var data = eval("(" + data + ")");

	if(data.code=="S"){
		doMyScrapShow();
	}else{
		alert("로그인 후 스크랩하실 수 있습니다.");
	}
}
function doMyScrapFocus(resText){
	//openAjax.setResult(resText,"POPUP_ARCHIVE_SCRAP");
	$('POPUP_ARCHIVE_SCRAP').innerHTML=resText;
	$('POPUP_ARCHIVE_SCRAP').style.display='block';
}

function doMyScrapBlog(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_blog.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}

function doMyScrapComm(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_community.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}

function doMyScrapForum(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_forum.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}
function doMyScrapNotice(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_notice.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}
function doMyScrapQna(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_qna.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}

function doMyScrapRSS(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_rss.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}

function doMyScrapChannel(){
	$("POPUP_ARCHIVE_SCRAP_PRE").hide();
	openAjax.doActionCall(CONTEXT+"archive/action/action_scrap_channel.jsp","MY_SCRAP_FORM",doMyScrapEnd);
}

function doMyScrapEnd(){
	$("POPUP_ARCHIVE_SCRAP_END").show();
	 document.location.href = "#POPUP_ARCHIVE_SCRAP_A";
}

function goMyScrapPage(){
	location = CONTEXT+"sub_mypage.jsp?nCmd=6";
}

function goMyChannelScrapPage(){
	location = CONTEXT+"sub_mypage.jsp?nCmd=5";
}

function blogChange(sID){
	if(sID=='blog'){
		$('img_blog').src='../include/images/btn_oa_itemtab01_over.gif';
		$('img_blogpost').src='../include/images/btn_oa_itemtab02.gif';

		$('list_blog').style.display='block';
		$('list_blogpost').style.display='none';
	}else {
		$('img_blog').src='../include/images/btn_oa_itemtab01.gif';
		$('img_blogpost').src='../include/images/btn_oa_itemtab02_over.gif';

		$('list_blog').style.display='none';
		$('list_blogpost').style.display='block';
	}
}

function commChange(sID){
	if(sID=='comm'){
		$('img_comm').src='../include/images/btn_oa_itemtab05_over_n.gif';
		$('img_commpost').src='../include/images/btn_oa_itemtab06_n.gif';

		$('list_comm').style.display='block';
		$('list_commpost').style.display='none';
	}else {
		$('img_comm').src='../include/images/btn_oa_itemtab05_n.gif';
		$('img_commpost').src='../include/images/btn_oa_itemtab06_over_n.gif';

		$('list_comm').style.display='none';
		$('list_commpost').style.display='block';
	}
}

function rssChange(sID){
	if(sID=='rss'){
		$('img_rss').src='../include/images/btn_oa_itemtab03_over.gif';
		$('img_rsspost').src='../include/images/btn_oa_itemtab04.gif';

		$('list_rss').style.display='block';
		$('list_rsspost').style.display='none';
	}else {
		$('img_rss').src='../include/images/btn_oa_itemtab03.gif';
		$('img_rsspost').src='../include/images/btn_oa_itemtab04_over.gif';

		$('list_rss').style.display='none';
		$('list_rsspost').style.display='block';
	}
}

function doDisplayCategory(index, sTheme)
{
	$("SEARCHBUTTON").innerHTML = "<a href=\"javascript:doSearchOA();\"><img src=\"../include/images/btn_search.gif\"></a>";

	for(var i = 1; i < 10; i++){
		if(i==index){
			$('acrive_img_'+i).src='../include/images/oa_0'+i+'_tap_over.gif';
		}else {
			$('acrive_img_'+i).src='../include/images/oa_0'+i+'_tap.gif';
		}
	}

	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='none';
	}catch(e){;}
	try{
	$('archive3').style.display='none';
	}catch(e){;}
	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}
	try{
	$('search_loading').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	if(sTheme){
		ex_sub_selected=0;
    	openAjax.doDisplayCall("action/ajax_archive_search.jsp?sTheme=" + sTheme, setResultSearch);
    }else {
    	openAjax.doDisplayCall("action/ajax_archive_section.jsp", setResultCategory);
    }
}

function goPageOA(sTheme,orderType,nPage)
{
	try{
	$('archive').style.display='none';
	}catch(e){;}
	try{
	$('archive2').style.display='none';
	}catch(e){;}
	try{
	$('loading').style.display='block';
	}catch(e){;}

	openAjax.doDisplayCall("action/ajax_archive_search.jsp?sTheme=" + sTheme + "&nPage="+nPage+"&orderType="+orderType, setResultCategory);

    //openAjax.doDisplay("ARCHIVE_LIST", "action/ajax_archive_section.jsp?nPage=" + nPage+(best==1?"&best=1":"")+"&orderType="+orderType);
}
function setResultCategory(resText)
{
	var divID = 'archive';

	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}

	if($(divID)!=null){
		$(divID).innerHTML=resText;
		$(divID).show();
		$('loading').style.display='none';
	}
	openAjax.setLocation();
}

function setResultSearch(resText)
{
	var divID = 'archive2';

	try{
	$('ARCHIVE_VIEW').style.display='none';
	}catch(e){;}

	if($(divID)!=null){
		$(divID).innerHTML=resText;
		$(divID).show();
		$('loading').style.display='none';
	}
	openAjax.setLocation();
}

// 아카이브 -> 연구자 블로그 메뉴. 이미지 자동변경 스크립트
function changeArchiveImg(){
	var nIdx = parseInt(document.getElementById("roopImg").value)+1;

	if(nIdx==4){
		nIdx=1;
	}
	document.getElementById("roopImg").value = nIdx;
	for(var i=1;i<4;i++){
		if(i==nIdx){
			document.getElementById("blogImg"+i).src=CONTEXT+"include/images/img_blog_0"+i+"_over.gif";
		}else {
			document.getElementById("blogImg"+i).src=CONTEXT+"include/images/img_blog_0"+i+".gif";
		}
	}

	document.getElementById("blogMainImg").src=CONTEXT+"include/images/img_blog_guide0"+nIdx+".gif";
}

// 아카이브 -> 연구자 블로그 메뉴. 이미지 마우스 오버시 발생 스크립트.
function displayArchiveImg(nIdx){
	document.getElementById("blogMainImg").src=CONTEXT+"include/images/img_blog_guide0"+nIdx+".gif";
	for(var i=1;i<4;i++){
		if(i==nIdx){
			document.getElementById("blogImg"+i).src=CONTEXT+"include/images/img_blog_0"+i+"_over.gif";
		}else {
			document.getElementById("blogImg"+i).src=CONTEXT+"include/images/img_blog_0"+i+".gif";
		}
	}
}
