// Cookie Setting
function setCookie(name,value,expiredays){
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

// Cookie Getting
function getCookie(name){
	var tmp=document.cookie.split('; ');
	for (var i=0; i<tmp.length;i++){
		var c_name = tmp[i].split('=');
		if (c_name[0] == name) return unescape(c_name[1]);
	}
	return false;
}

// XMLHttpRequest »ý¼º
function createXMLHttpRequest() {
	try {
		xmlHttp = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				xmlHttp = false;
			}
		}
	}
	return xmlHttp;
}

// ÀÌ¹ÌÁöÆÄÀÏ Ã¼Å©
function checkImgFormat(imgPath){

 	if( imgPath == "" ||
       	imgPath.indexOf(".bmp") > 0   || imgPath.indexOf(".BMP") > 0  ||
        imgPath.indexOf(".jpg") > 0   || imgPath.indexOf(".JPG") > 0  ||
        imgPath.indexOf(".gif") > 0   || imgPath.indexOf(".GIF") > 0  ||
        imgPath.indexOf(".avi") > 0   || imgPath.indexOf(".AVI") > 0  ||
        imgPath.indexOf(".mov") > 0   || imgPath.indexOf(".MOV") > 0  ||
        imgPath.indexOf(".mpeg") > 0  || imgPath.indexOf(".MPEG") > 0 ||
        imgPath.indexOf(".asf") > 0   || imgPath.indexOf(".ASF") > 0  ||
        imgPath.indexOf(".rm") > 0    || imgPath.indexOf(".RM") > 0   ||
        imgPath.indexOf(".mpg") > 0   || imgPath.indexOf(".MPG") > 0  ||
        imgPath.indexOf(".wmv") > 0   || imgPath.indexOf(".WMV") > 0  ||
        imgPath.indexOf(".dat") > 0   || imgPath.indexOf(".DAT") > 0 ){
           return true;
	}else{
		return false;
    }
}

// ÀÌ¹ÌÁöÆÄÀÏ Ã¼Å©
function checkImgFormat2(imgPath){

 	if( imgPath == "" ||
       	imgPath.indexOf(".bmp") > 0   || imgPath.indexOf(".BMP") > 0  ||
        imgPath.indexOf(".jpg") > 0   || imgPath.indexOf(".JPG") > 0  ||
        imgPath.indexOf(".gif") > 0   || imgPath.indexOf(".GIF") > 0 ){
           return true;
	}else{
		return false;
    }
}

function scrollLayer(p_obj_name, p_gap_point){

	var start_point, end_point, timer;
	var obj_layer = document.getElementById(p_obj_name);

	if(obj_layer){
		start_point = parseInt(obj_layer.style.top, 10);

		if ( start_point < p_gap_point )    start_point = p_gap_point;

		end_point   = document.body.scrollTop + p_gap_point;
		limit_point = parseInt(window.document.body.scrollHeight) - parseInt(obj_layer.offsetHeight) -10;

		if ( end_point > limit_point )  end_point = limit_point;

		if ( start_point != end_point ) {
			scroll_amount = Math.ceil( Math.abs( end_point - start_point ) / 15 );
			obj_layer.style.top = parseInt(start_point, 10) + ( ( end_point < start_point ) ? -scroll_amount : scroll_amount );
		}

		timer = window.setTimeout ("scrollLayer('" + p_obj_name + "', " + p_gap_point + ");", 1);
	}
}

	// ¹®ÀÚ¿­ ¾ÕµÚ °ø¹é Á¦°Å
	function trim(str){
		return str.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "");
	}























/*----  ±âÁ¸ common.js ------------------*/





/*--------------------------------------------------------
* ÅëÇÕQ&A ÀÔ·ÂÆû È£Ãâ
*--------------------------------------------------------*/
	function  callQnaPopUp(sLclassId){
		//»õÃ¢ÀÇ Å©±â
		cw=586;
		ch=400;

		//½ºÅ©¸°ÀÇ Å©±â
		sw=screen.availWidth;
		sh=screen.availHeight;

		//¿­ Ã¢ÀÇ Æ÷Áö¼Ç
		px=(sw-cw)/2;
		py=(sh-ch)/2;
		Param = "/portal/qna_bod.ci?goTo=insert_form&strLclassId="+sLclassId+"&pop_flag=Y";
		Options	= "scrollbars=YES, status=no, resizable=no, width="+cw+", height="+ch+", top="+py+", left="+px;//589, 450
		window.open(Param, "QnA", Options);
	}
/*--------------------------------------------------------
* ÅëÇÕQ&A ÀÌµ¿
*--------------------------------------------------------*/
	function moveToMainQna() {//QnA ¸ÞÀÎ¸Þ´º·Î È­¸éÀÌµ¿

		var strLclass = "";
		var sUrl = "cc.ci?goTo=cc_sub_05"+strLclass; //cc_sub_05

		document.location.href= sUrl;
	}
/*--------------------------------------------------------
* ÅëÇÕ·Î±×ÀÎÈ­¸éÀ¸·Î ÀÌµ¿..
*--------------------------------------------------------*/
	//ÅëÇÕ SSO Login ÆäÀÌÁö·Î ÀÌµ¿ÇÏ°í ·Î±×ÀÎ ¼º°ø½Ã preURL ÆäÀÌÁö·Î ÀÌµ¿½ÃÅ²´Ù.
	function goSSOLogin() {

		var preURL = document.location;
			document.location.href=
			"/portal/publish_html/include/naMain_login/index_sso.jsp?preUrl="+preURL;
		}

/*--------------------------------------------------------
*  Live Poll js ÆÄÀÏºÎºÐ
*--------------------------------------------------------*/
function goPollVote()
{
	var thisForm = document.vote;

	for(i=0; i<thisForm.question.length; i++)
	{
		if(thisForm.question[i].checked==true)
		{
			thisForm.question.value = thisForm.question[i].value;
		}
	}

	if (thisForm.question.value == undefined)
	{
		alert("¼³¹®Ç×¸ñÀ» ¼±ÅÃÇÏ¿© ÁÖ¼¼¿ä!");
		return;
	}

    thisForm.method='post';
    thisForm.target = "livepolliframe";
    thisForm.action = '/portal/vs.ms?goTo=vs_livepoll_vote';
    thisForm.submit();
}

function viewPollResult(lclassId)
{
	var thisForm = document.vote;

	var pollid	= thisForm.pollid.value;

	if (lclassId == "10")
			parent.top.location.href = "/portal/ci/hc/hc_sub_06_3.jsp?lclassId="+lclassId+"&pollid="+pollid;
	else if (lclassId == "09")
			parent.top.location.href = "/portal/ci/am/am_sub_02_3.jsp?lclassId="+lclassId+"&pollid="+pollid;
	else
	{
		//»õÃ¢ÀÇ Å©±â
		cw=586;
		ch=400;

		//½ºÅ©¸°ÀÇ Å©±â
		sw=screen.availWidth;
		sh=screen.availHeight;

		//¿­ Ã¢ÀÇ Æ÷Áö¼Ç
		px=(sw-cw)/2;
		py=(sh-ch)/2;
		Param = "/portal/ms/vs/popLivePollResult.jsp?lclassId="+lclassId+"&pollid="+pollid;
		Options	= "scrollbars=YES, status=no, resizable=no, width="+cw+", height="+ch+", top="+py+", left="+px;
		window.open(Param, "pollReault", Options);
		/*
		thisForm.method='post';
	    thisForm.target = "_blank";
	    thisForm.action = '/portal/ms/vs/popLivePollResult.jsp';
	    thisForm.submit();
	    */
	}
}

/**
 * °Ë»ö ÆäÀÌÁö ÀÌµ¿
 */
function go_page(pg) {
	var fm = document.search_page;

	fm.pageNo.value = pg;
	fm.submit();
}
/**
 * °Ë»ö ÆäÀÌÁö ÀÌµ¿
 */
function bluring(){
 if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
 }
 document.onfocusin=bluring;
//-->


function boardIframeHeight(){
	if(document.getElementById('boardIframe') != null) {
		var the_height= document.getElementById('boardIframe').contentWindow.document.body.scrollHeight;
		document.getElementById('boardIframe').height = the_height;
	}
}