var CONTEXT = "/";

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(CONTEXT+"/bin/webeditor/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+"/bin/system/textediter/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 filedownload(nIndex){
	document.location = CONTEXT+"/download.jsp?nIndex="+nIndex;
}
function downloadPDFPlugin(){
	location = "http://www.krm.or.kr/FRBR/coxsystem/files/coxgrd.7.0.3.9.exe";
}
function pdf_down(nIndex){
	document.location = CONTEXT+"/pdf_download_comm.jsp?nIndex="+nIndex;
}
function nouser_script(){
	alert("로그인 후 이용하실 수 있습니다.");
}

function user_infoWin(UR_ID) {
if(parent.document.getElementById("INFO_USER") ){
	    document.getElementById("INFO_USER").style.display = 'block';
	    document.getElementById("INFO_USER").style.pixelLeft = document.body.scrollLeft + event.clientX - 30;
	    document.getElementById("INFO_USER").style.pixelTop = document.body.scrollTop + event.clientY - 50;
	    document.getElementById("INFO_USER").src = CONTEXT+"/bin/community/ifpopup_userinfo.jsp?sUserID="+UR_ID;
	}else{
	    document.getElementById("INFO_USER").style.display = 'block';
	    document.getElementById("INFO_USER").style.pixelLeft = document.body.scrollLeft + event.clientX - 30;
	    document.getElementById("INFO_USER").style.pixelTop = document.body.scrollTop + event.clientY - 50;
	    document.getElementById("INFO_USER").src = CONTEXT+"/bin/community/ipopup_userinfo.jsp?sUserID="+UR_ID;
	}
}


// Functions for Processing Reply Emoticon

function selectEm(em) {
    document.all['reply_emoticon'].style.display='none';
	if( em < 10 ) em_number = "0" + em;
	else em_number = "" + em;
	eval( "document.replyWrite" + _GlobalPostIndex ).replyIcon.value = em;
	eval( "document.all.replyEmo" + _GlobalPostIndex ).src = CONTEXT+"/bin/system/images/emoticon/reply_icon_" + em_number + ".gif";
}

var _GlobalPostIndex = -1;


function showEmoticon(nPostIndex) {
	_GlobalPostIndex = nPostIndex;
    document.all['reply_emoticon'].style.display='block';
    document.all['reply_emoticon'].style.pixelLeft = document.body.scrollLeft + event.clientX + 10;
    document.all['reply_emoticon'].style.pixelTop = document.body.scrollTop + event.clientY - 10;
}


function go_ScrapSource(sURL) {
	top.location = sURL;
}



function selectReply(nPostIndex){
	document.location =CONTEXT+'/bin/community/index.jsp?sCmd=post_view&isReply=1&postIndex='+nPostIndex;
}


function selectGuestBook(sCmd, sMenuID, nPostIndex){
	this.location = CONTEXT+"/bin/community/index.jsp?sCmd="+sCmd+"&sMenuID="+sMenuID+"&postIndex="+nPostIndex+"&isReply=1";
}



function print_post(index) {
    var printWin = CenterWindow(CONTEXT+"/bin/post/post/popup_print_post.jsp?postIndex="+index, "printWin", 650, 500, "yes", "yes" );
    printWin.focus();
}


function toggle_rightlist(listName) {
	var obj = document.getElementById(listName);
	var img = document.getElementById(listName+"_btn");
	if( obj!= null ) {
		if(obj.style.display != 'none' ) {
			obj.style.display = 'none';
			img.src = CONTEXT+"/bin/system/images/button/btn_showmore.gif"
		} else {
			obj.style.display = 'block';
			img.src = CONTEXT+"/bin/system/images/button/btn_showless.gif"
		}

	}
}


function copyRSSAddress(chID) {
    var rssWin = CenterWindow("comm_body_left_rss.jsp?chID="+chID, "rssWin", 600, 500, "yes", "yes");
    rssWin.focus();
}

function getHeight(h) {
	appname = navigator.appName
	useragent = navigator.userAgent;

	if(appname == "Microsoft Internet Explorer") appname = "IE";
	win2000 = (useragent.indexOf('NT 5.0')>0);  //윈도우 2000 버전
	winxp = (useragent.indexOf('NT 5.1')>0);     //윈도우 xp 버전

	if(appname=="IE" && win2000){
		return h;
	}else if (appname=="IE" && winxp){
		return h+50;
	}else{
		return h;
	}
}
