﻿//숫자만 입력가능
//onkeydown에서만 정상동작
//onkeydown="return keyCheckNum(event,["-"포함 bool],[탭이동 bool]);"
function keyCheckNum(isDash,isTab) 
{
    var e  = event;
	var n4 = (document.layers) ? true : false;
	var e4 = (document.all) ? true : false;
	if (n4) var keyValue = e.which;
	else if(e4) var keyValue = event.keyCode;	
	//event.returnValue = false;
	
	if(isTab && keyValue == 13)	AutoTab(window.event.srcElement,13);
	if(keyValue == 13 || keyValue == 9) return true; //9->TAB
	if(keyValue == 27 || keyValue == 35 || keyValue == 36) return true; //27->ESC, 36-> HOME, 35->END
	if(keyValue >= 37 && keyValue <= 40) return true; //화살표
	if(keyValue == 16 || keyValue == 8 || keyValue == 46) return true; //16->시프트, 8-> BS, 46->DEL
	if (keyValue >= 48 && keyValue <= 57)  return true; //숫자
	if (keyValue >= 96 && keyValue <= 105)  return true; //숫자키패드
	if(isDash) if(keyValue == 189 || keyValue == 109) return true; //109->키패드"-", 189-> "-"
	
	return false;
}

//onkeyup="keyRetNumFormat(this)"
function keyRetNumFormat(elem)
{
	var n4 = (document.layers) ? true : false;
	var e4 = (document.all) ? true : false;
	if (n4) var keyValue = e.which;
	else if(e4) var keyValue = event.keyCode;	
	
	if(keyValue >= 37 && keyValue <= 40) return true; //화살표
	if(keyValue == 13 || keyValue == 9) return true;
	elem.value = Number_Format(elem.value);
}
//영문/숫자 체크 
function isCharNum(str)
{
	sampleEx = /[^0-9a-zA-Z]/;
    if(sampleEx.test(str)){ return false; };
	return true;
}
//숫자만 입력되어 있는지 체크
function isOnlyNum(str)
{
	sampleEx = /[^0-9]/;
    if(sampleEx.test(str)){ return false; };
	return true;
}
//숫자와 - 이외 문자 제거
function makeDigiDash(str)
{
	newStr = String(str);
	newStr = newStr.replace(/[^0-9|-]/g,""); 
	return 	Number(newStr);
}

//숫자 이외 문자 제거
function makeDigi(str)
{
	newStr = String(str);
	newStr = newStr.replace(/[^0-9]/g,""); 
	return 	Number(newStr);
}

//숫자 이외 문자 제거후 천단위로 "," 찍기
function Number_Format(str)
{
	var NewStr = String(str);
	var preFix="";
	var sufFix="";
	var Re = /^-.+/; 
	
	if(NewStr.match(Re))	preFix = "-";
	
	//숫자 이외 문자 제거
	Re = /[^0-9\.]/g; 
	NewStr = NewStr.replace(Re,''); 
	
	var ReN = /^(-?[0-9]+)(\.[0-9]+)$/;
	if(NewStr.match(ReN))
	{
		sufFix = NewStr.replace(ReN, "$2");
		NewStr = NewStr.replace(ReN, "$1"); 
	}
	
	var ReN = /(-?[0-9]+)([0-9]{3})([^\.0-9]*)/;
	
	while (ReN.test(NewStr)) 
	{ 
		NewStr = NewStr.replace(ReN, "$1,$2$3"); 
	}
	return preFix + NewStr + sufFix;
}

//메일체크
function isValidEmailType(str)
{
	emailEx1 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z]+/;
    emailEx2 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;
	emailEx3 = /[^@]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z]+/;
    if(emailEx1.test(str)){ return true; };
	if(emailEx2.test(str)){ return true; };
    if(emailEx3.test(str)){ return true; };
	return false;
}
//날짜타입 체크
function isValidDateType(str)
{
	Ex1 = /^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/;
    if(Ex1.test(str)){ return true; }
	return false;
}

//에러 메세지
function errMsg(err, fo)
{
    alert(err);    
    if(!fo.disabled && fo.type != "hidden")
    {    	
    	if(fo.type=="text")  	fo.select();
    	fo.focus();
    }
    return false;
}


//-------------------탭 이동-----------------//
	//-- 지정된 element로 이동
function MoveNext(tElem,tKey) 
{
	var keyValue = event.keyCode;
		
	if (keyValue == tKey) 
	{
		tElem.focus();
		tElem.select();
		return true; 
	}
	else 
	{
		return true; 
	}
} 

	//--엔터치면 무조건 다음 TabInex로 이동
function MoveTab() 
{
	var cType = window.event.srcElement.type;	
	var cKey = window.event.keyCode;
	//if(cType == "select-one")
	if(cType == "text" || cType == "password")
	{
		AutoTab(window.event.srcElement,13);
	}
}

	//-- 타겟 미지정 자동으로 다음 TabInex로 이동
function AutoTab(cInput,tKey) 
{
	var keyValue = event.keyCode;
	
	if (keyValue == tKey) 
	{
		MoveNextElem(cInput);
		return true;
	}
	else 
	{
		return true;
	}
	
}
//사용방법  onKeyup="Format_String(this,'###-##-#####');"
function Format_String(elem, formatStr){
	var retV = "";
	var inpV;
	var pattern = /([0-9])/;
	var numVal;
	inpV = elem.value;
	
	k=0;
	for (i = 0; i < inpV.length; i++)	
	{
		cChar = inpV.substr(i,1);
		if(pattern.test(cChar)){
//						retV += cChar;
				for(var j = k; j < formatStr.length; j++){
					if(formatStr.substring(k,k+1) == "#"){
						retV += cChar;
						k++;
						break;
					}else{
						retV += formatStr.substring(k,k+1); 
						k++;
					}
				}
		}
	}
	elem.value = retV;
}
function Phone_Format(elem)
{	
	var inpV = String(elem.value);
	inpV = inpV.replace(/[^0-9]/g,""); 
	
	var fChar = inpV.substr(0,1);	
	var retV = "";
	if (fChar != 0 && fChar != 1 && fChar != "") //잘못된 입력
	{
		elem.value = "";
		return;
	}
	else if(fChar == 1) //1544등의 전화번호
	{
		retV = inpV.substr(0,8);
	}
	else
	{
		if(inpV.length>11) retV = inpV.substr(0,11);
		else retV=inpV;
	}

	var pattern = /^([0]{1}[0-9]{2})?([1-9]{1}[0-9]{2,3})?([0-9]{4})$/;
	if(retV.length >= 9){
		if(retV.substring(0,2)=="02")
		{
			pattern = /^([0]{1}[0-9]{1})?([1-9]{1}[0-9]{2,3})?([0-9]{4})$/;
		}
		else if(retV.substring(0,4)=='0505')
		{
			pattern = /^([0]{1}[0-9]{3})?([1-9]{1}[0-9]{2})?([0-9]{4})$/;
		}
		else
		{
			pattern = /^([0]{1}[0-9]{2})?([1-9]{1}[0-9]{2,3})?([0-9]{4})$/;
		}

		if (pattern.exec(retV)) 
		{
			if(RegExp.$1=="02" || RegExp.$1 == "010" || RegExp.$1 == "011" || RegExp.$1 == "013" || RegExp.$1 == "016" || RegExp.$1 == "017" || RegExp.$1 == "018" || RegExp.$1 == "019" || RegExp.$1=="031"  || RegExp.$1=="032"  || RegExp.$1=="033"  || RegExp.$1=="041"  || RegExp.$1=="042"  || RegExp.$1=="043"  || RegExp.$1=="051"  || RegExp.$1=="052"  || RegExp.$1=="053"  || RegExp.$1=="054"  || RegExp.$1=="055"  || RegExp.$1=="061"  || RegExp.$1=="062"  || RegExp.$1=="063"  || RegExp.$1=="064") {
				if(!elem.getAttribute("span")) retV = RegExp.$1 + "-" + RegExp.$2 + "-" + RegExp.$3;
			}
		}
	}
	else if(retV.length == 8 && fChar==1)
	{
		pattern = /^([1]{1}[0-9]{3})?([0-9]{4})$/;

		if (pattern.exec(retV)) {
			retV = RegExp.$1 + "-" + RegExp.$2;
		}
	}

	elem.value = retV;
}
function Date_Format(elem)
{	
	var inpV = String(elem.value);
	inpV = inpV.replace(/[^0-9]/g,""); 
	
	var fChar = inpV.substr(0,1);
	if (fChar != 1 && fChar != 2) //잘못된 입력
	{
		elem.value = "";
		return;
	}	
	var retV = "";
	if(inpV.length>8) retV = inpV.substr(0,8);
	else retV=inpV;

	var pattern = /^([1-9]{1}[0-9]{3})?([0-9]{1,2})?([0-9]{1,2})$/;
	if (pattern.exec(retV)) 
	{
	    if(parseInt(RegExp.$2) > 12 && inpV.length==7)
	    {
	        retV = RegExp.$1 + "-" + RegExp.$2.substr(0,1) + "-" + RegExp.$2.substr(1,1) + RegExp.$3;
	    }
		else if(RegExp.$1 !="" && RegExp.$2 !="" && !elem.getAttribute("span"))
		{
		    retV = RegExp.$1 + "-" + RegExp.$2 + "-" + RegExp.$3;
		}
	}

	elem.value = retV;
}
function MoveNextElem(cInput)
{
	var tIdx = (getindex(cInput)+1) % cInput.form.length;
		
	while(cInput.form[tIdx].disabled || cInput.form[tIdx].readOnly || cInput.form[tIdx].type == "hidden")
	{
		tIdx++;
		if(!cInput.form[tIdx])
		{
			tIdx--;
			break;
		}
	}
	try
	{
		if(cInput.form[tIdx]) cInput.form[tIdx].focus();
		if(cInput.form[tIdx].type=="text")	cInput.form[tIdx].select();
	}
	catch(E)
	{
		MoveNextElem(cInput.form[tIdx]);
	}
	return;
}
function AutoTabLen(input,len, e) 
{
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);

	var keycd = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	
	if(input.value.length >= len && !iscontain(filter, keycd))
	{
		input.value = input.value.slice(0, len);
		MoveNextElem(input);
		//input.form[(getindex(input)+1) % input.form.length].focus();
	}
}
function iscontain(filter, keycd) 
{
    var found = false;
    var index = 0;	
    while(!found && index < filter.length)	
    if(filter[index] == keycd) found = true;
    else index++;

    return found;
}
function getindex(input) 
{
    var index = -1;
    var i = 0;
    var found = false;

    while (i < input.form.length && index == -1)

    if (input.form[i] == input)index = i;
    else i++;

    return index;
    return true;
}
//-------------------탭 이동끝-----------------//

//창열기(전체화면)
function WinOpenFull(url)
{ 
	var w = screen.width * 0.8;
	var h = screen.height * 0.8;
	var l = screen.width * 0.1;
	newWin=window.open(url,"_blank","width="+w+",height="+h+",resizable=1,scrollbars=1,status=1,left="+l+",top=1,menubar =0,titlebar=0,toolbar =1");
	if (newWin !=null) {
			newWin.opener=self;
	}
	newWin.focus();
}


//창열기
function OpenWindow(url,windowname,w_size,h_size,w_left,w_top)
{ 
	w_left = parseInt(w_left) > 0  ? parseInt(w_left) : 50;
	w_top = parseInt(w_top) > 0  ? parseInt(w_top) : 50;
  	newWin=window.open(url,windowname,"width="+w_size+",height="+h_size+",resizable=no,scrollbars=yes,status=1,left="+w_left+",top="+w_top+"");
	if (newWin !=null) {
			newWin.opener=self;
	}
	newWin.focus();
}


//스크롤바 없는 창 열기
function OpenWindow_noscroll(url,windowname,w_size,h_size,w_left,w_top)
{ 
	w_left = parseInt(w_left) > 0  ? parseInt(w_left) : 50;
	w_top = parseInt(w_top) > 0  ? parseInt(w_top) : 50;
  	newWin=window.open(url,windowname,"width="+w_size+",height="+h_size+",resizable=no,scrollbars=no,status=1,left="+w_left+",top="+w_top+"");
	if (newWin !=null) 
	{
			newWin.opener=self;
	}
	newWin.focus();
}
//창열기리사이즈가능
function OpenWindowResize(url,windowname,w_size,h_size,w_left,w_top)
{ 
	w_left = parseInt(w_left) > 0  ? parseInt(w_left) : 50;
	w_top = parseInt(w_top) > 0  ? parseInt(w_top) : 50;
  	newWin=window.open(url,windowname,"width="+w_size+",height="+h_size+",resizable=yes,scrollbars=yes,status=1,left="+w_left+",top="+w_top+"");
	if (newWin !=null) {
			newWin.opener=self;
	}
	newWin.focus();
}

//모달 창열기
window.hasModal = false;
var modal = null;

function OpenWindowModal(url, w_size,h_size)
{
    window.hasModal = true;
	
	//오프너의 두번째 인자는 dialogArgumens 에 할당된다.
	
	var arg = OpenWindowModal.arguments;  	
	
  	if(arg.length > 3)
  	{
  		var modalArg = new Array();
  		
	  	for(i=3;i<arg.length;i++)
	  	{
	  		modalArg[i-3] = arg[i];	  			
	  	}
	}
	else
	{
		var modalArg = window;
	}
	
	var reVal = showModalDialog(url, modalArg,"dialogWidth="+w_size+"px; dialogHeight="+h_size+"px; status=yes; help=no;");	
    window.hasModal = false;
    return reVal;
}
function OpenWindowModalNoScroll(url, w_size,h_size)
{
    window.hasModal = true;
	
	//오프너의 두번째 인자는 dialogArgumens 에 할당된다.
	
	var arg = OpenWindowModalNoScroll.arguments;  	
	
  	if(arg.length > 3)
  	{
  		var modalArg = new Array();
  		
	  	for(i=3;i<arg.length;i++)
	  	{
	  		modalArg[i-3] = arg[i];	  			
	  	}
	}
	else
	{
		var modalArg = window;
	}
	
	var reVal = showModalDialog(url, modalArg,"dialogWidth="+w_size+"px; dialogHeight="+h_size+"px; status=yes; help=no;scroll=off;resizable=no;");
	//resizable:{ yes | no | 1 | 0 | on | off } Specifies whether the dialog window has fixed dimensions. The default is no. 
	//scroll:{ yes | no | 1 | 0 | on | off }	
    window.hasModal = false;
    return reVal;
}


window.closeModal = function()
{
    if(window.hasModal && modal != null)
        modal.closeDlg();
}


function DisableInputs() 
{
  	var arg = DisableInputs.arguments;  	
  	if(arg.length < 2) return false;
  	
  	for(i=1;i<arg.length;i++)
  	{
  		if(arg[i].type != undefined)
  		{
  			arg[i].disabled = arg[0];
  			
		   
		    var ty = arg[i].type.toLowerCase();
		    var tgName = arg[i].tagName.toLowerCase();
		    if(tgName=="select" || tgName=="textarea" || ty == "file" || ty == "password" || ty == "text")
            {    
                if(arg[0] == true)
  			    {	
                    arg[i].style.backgroundColor = "#DDDDDD";
                }
                else
                {
                    arg[i].style.backgroundColor = "#FFFFFF";
                }
            }            
  		}
  			
  	}  	
}


//주민번호 체크
function ChkRegNum(regNum1,regNum2)
{
	if(regNum1.length != 6 || regNum2.length != 7 || isNaN(regNum1) || isNaN(regNum2))
	{			
		return false;
	}
	
	var sum = 0;
	var j = 2;
	var resno = regNum1 + regNum2;
	for(var i = 0;i < 12;i++)
	{
		sum = sum + parseInt(resno.charAt(i)) * (j++);
		if(j == 10)				j = 2;
	}

	var re = 11 - sum % 11;
	if(re > 9 && (re - 10) != parseInt(resno.charAt(12)))
	{	
		return false;
	}	
	if(re < 9 && re != parseInt(resno.charAt(12)))
	{
		return false;
	}
	return true;
}

//한글포함 문자열 길이 체크
function HanStrLength(str) 
{
	var rCode = 0;
	var reLenth = 0;
	var rChar
	for (i=0; i<str.length; i++) 
	{
		rCode = parseInt(str.charCodeAt(i));
		rChar = str.substr(i,1).toUpperCase();
		if ((rChar < "0" || rChar > "9") && (rChar < "A" || rChar > "Z") && ((rCode > 255) || (rCode < 0))) 
		{
			reLenth = reLenth + 2;
		}
		else
		{
			reLenth = reLenth + 1;
		}
	}
	
	return reLenth;
}

function SelectRowsChange(elem)
{
	if(elem.checked==true)
	{
		allcheck(elem.form);
	}
	else
	{
		discheck(elem.form);
	}
}
//전체 선택
function allcheck(theForm)
{
	
	var check_box = new Array();
	check_box =theForm["chk[]"]; 	
	if(!check_box)
	{
		alert('값이 없습니다.');
	    return;
	}
	
	if(check_box.length == undefined)
	{
		if(check_box.checked == false)	check_box.checked = true;	
		return;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == false)	ele.checked = true;		
	}
	return;
}


//선택취소
function discheck(theForm)
{
	var check_box=theForm["chk[]"]; 	
	if(!check_box)
	{
		alert('값이 없습니다.');
	    return;
	}
	if(check_box.length == undefined)
	{
		check_box.checked = false;	
		return;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		ele.checked = false;	
	}	
	
	return;
}




//선택부분 반전
function invert_check(theForm)
{
	var check_box=theForm["chk[]"]; 	
	if(!check_box)
	{
		alert('값이 없습니다.');
	    	return;
	}
	if(check_box.length == undefined)
	{
		if(check_box.checked == false)	check_box.checked = true;	
		else check_box.checked = false;
		return;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == true)		ele.checked = false;
		else 	ele.checked = true;		
	}
	return;
}

function IsCheckedList(theForm)
{
	var check_box=theForm["chk[]"]; 
	if(!check_box)
	{
		alert('값이 없습니다.');
	    return false;
	}
	if(check_box.length == undefined)
	{
		if(check_box.checked == true)	return true;
		return false;
	}
	
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == true)	break;		
	}
	
	if(i==check_box.length) return false;
	
	return true;
}
function CheckedListCount(theForm,tName)
{
	if(tName==null || tName == undefined ||  tName=="")
	{
		tName = "chk[]";
	}
	var check_box=theForm[tName]; 
	if(!check_box)
	{
	    return 0;
	}
	if(check_box.length == undefined)
	{
		if(check_box.checked == true)	return 1;
		return 0;
	}
	var chkCount = 0;
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == true)	chkCount++;		
	}
	
	return chkCount;
}
function CheckIdString(strId)
{
    var pattern = /^[a-zA-Z]{1}[a-zA-Z0-9_]{3,11}$/;
	if(pattern.test(strId))
		return true;	
	else
		return false;
}
function CheckEmailIdString(strId)
{
    return isValidEmailType(strId);	
}

function isValidHangul(fld,checkFits) 
{ 
    if (!str_trim(fld)) return false;

    var pattern;
    var msg;
    if(checkFits) //자음 모음 조각(ㄱ,ㅏ 등)을 포함
    {
    	pattern = /([^가-힣ㄱ-ㅎㅏ-ㅣ\x20])/i; 
    }
    else
   	{
     	pattern = /([^가-힣\x20])/i; 
	}
    if (pattern.test(fld.value)) 
    {
    	return false;
    } 
    return true;
}

function str_trim(str) 
{ 
	str = this != window ? this : str; 
	return str.replace(/^\s+/g,'').replace(/\s+$/g,''); 
}

//TEXTAREA 크기 조정 => TextareaResize('content',10,'+')
function TextareaResize(tId,row,div)
{
    if(typeof tId == 'string')
    {
        tElem = $(tId);
    }
    else
    {
        tElem = tId;
    }
    
	if(div=="+")
	{
  		tElem.rows += row;
  	}
  	else if(div=="-")
  	{
  		if (tElem.rows - row > 0)
                tElem.rows -= row;
  	}
  	else
  	{	
  		tElem.rows = row;
	}
}

function isValidNick(str)
{
    var pattern = /[\$\@\\#%\&\`\=\!\<\>\'\"\?]/i;
	if (pattern.test(str)) 
    {
    	return false;
    }
    return true; 
}
function FindTable(obj)
{
	return obj.tagName == "TABLE" ? obj:FindTable(obj.parentElement);
}

function calculat_x(el)
{
	return el.offsetLeft+(el.offsetParent?calculat_x(el.offsetParent):0);
}

function calculat_y(el)
{
	return el.offsetTop+(el.offsetParent?calculat_y(el.offsetParent):0);
}
function FindChildTable(obj)
{
	return obj.tagName == "TABLE" ? obj:FindTable(obj.childElement);
}

function AddSelectedOption(tElem,tVal)
{
    tElem.value=tVal;
        
    if(tElem.value != tVal)
    {
	    SelectBoxAddOption(tElem, tVal, tVal);
	    tElem.selectedIndex = tElem.options.length -1;
	}
}

function SelectBoxAddOption(sel, val, txt) 
{
    /*
	oOption=document.createElement("OPTION");
	oOption.value=val;
	oOption.text=txt;
	sel.options.add(oOption);
	*/
	
   var opt = sel.form.ownerDocument.createElement("option");
   opt.setAttribute("value", val);
   var t = sel.form.ownerDocument.createTextNode(txt);
   opt.appendChild(t);
   sel.appendChild(opt);
}
function SelectBoxDelOption(sel, idx) 
{
   var opts = sel.getElementsByTagName("option");
   if (idx<0 || idx>(opts.length-1))
      return;
   sel.removeChild(opts[idx]);
}

function SelectBoxOptSel(elemId, val)
{
    var ele = document.getElementById(elemId);
    for(var i=0; i < ele.length;i++)
    {                    
        if(ele[i].value == val)
        {                 
            ele[i].selected = true;
            break;
        }                    
    }
}

function popZone(val)
{
    for(var i=1;i <= 7 ;i++)
    {
        if(i==val)
        {
            $("#popimg_0"+i).attr("src","/pub/img/main/popup_num0"+i+"_on.gif");
            $("#pop_0"+i).css("display","block");
        }else 
        {
            $("#popimg_0"+i).attr("src","/pub/img/main/popup_num0"+i+"_off.gif");
            $("#pop_0"+i).css("display","none");
        }
    }
}

var _C_FONT = 0;
function ZoomIn(val)
{   
    if(_C_FONT == 0) _C_FONT = "body" == val ? 0.75 : 1;
    _C_FONT = _C_FONT + 0.05;    
    if(val == "body") $(val).css("font-size",_C_FONT+"em");
    else $("#"+val).css("font-size",_C_FONT+"em");
}

function ZoomOut(val)
{
    if(_C_FONT == 0) _C_FONT = "body" == val ? 0.75 : 1;
    _C_FONT = _C_FONT - 0.05;
    if(val == "body") $(val).css("font-size",_C_FONT+"em");
    else $("#"+val).css("font-size",_C_FONT+"em");
}

function ZoomBase(val)
{   
    
    if(val == "body") $(val).css("font-size","0.75em");
    else $("#"+val).css("font-size","1em");
    _C_FONT = 0;
}

function contetnPrint(id){
    
	var formStr = "<form id=\"PrintForm\" method=\"post\" action=\"\">";
	formStr += "<input type=\"hidden\" id=\"PrintContent\" name=\"printContent\" value=\"\" />";
	formStr += "</form>";
	$('#PrintContiner').html(formStr);
	
	window.open("","printPage","toolbar=0, location=0, status=0, menubar=0, scrollbars=yes, resizable=0, top=80, left=120, width=800, height=700");
	var form = document.getElementById("PrintForm");
	form.action="/pub/etc/printpage.aspx";
	form.target = "printPage";
	form.method="post";
		
	var str = $('#'+id).html();		    		
	str = str.replace("class=bd_btn", " style=\"visibility:hidden\"");
    str = str.replace("id=prev", " style=\"visibility:hidden\"");
    str = str.replace("id=reply_satisfy", " style=\"visibility:hidden\"");
    if(str.indexOf("class=bd_btn>")) str = str.replace("class=bd_btn>", " style=\"visibility:hidden\">");
	$('#PrintContent').val(str);	
	form.submit();

	return false;
}	

function xload( xmlString ){
	var xdom = null;
	if(document.implementation.createDocument){	
		var parser = new DOMParser();
		xdom = parser.parseFromString( xmlString , "text/xml");
		if (xdom.documentElement.nodeName == "parsererror") { 		
			return;
		} 
	}else if( window.ActiveXObject){
		xdom = new ActiveXObject("Microsoft.XMLDOM");
		xdom.async = "false";
		xdom.loadXML(xmlString);
	    if (xdom.parseError.errorCode != 0) {
			return;
	    }        
	}	
	renderContent(xdom.documentElement);
}

function renderContent( xRoot){	
	var items = xRoot.getElementsByTagName("item");		
	if(items == null && items == "undifined"){
		return;
	}
	var str = "";
	for(var i = 0 ; i < 7 ;i++)
	{
		var item = items.item(i);
		var title = item.getElementsByTagName("title").item(0).firstChild.nodeValue;
        if (title.length > 22) title = title.substring(0,22);
		var link = item.getElementsByTagName("link").item(0).firstChild.nodeValue;
		var pubDate = item.getElementsByTagName("pubDate").item(0).firstChild.nodeValue;
		var tempSplit = pubDate.substring(2,10);		
		str += "<dl class='news_cont'>";
        str += "<dt class='news_con'><a href='"+link+"' title='"+title+"' target='_blank'>"+title+"</a></dt>";
        str += "<dd class='date'>"+tempSplit+"</dd>";
        str += "</dl>";
	}	
	$("#news_05").html(str);
}

jQuery.post("/etc/policeNotice.aspx" , {} , function(data){    
	xload(data);
});

function newDsp(val) {    
    for(var i=1; i <= 5;i++)
    {
        if( i == val )
        {           
           $("#newsimg_0"+i).attr("src","/pub/img/main/news0"+i+"_on.gif") ;         
           $("#news_0"+i).css("display","block");
        }else 
        {            
           $("#newsimg_0"+i).attr("src","/pub/img/main/news0"+i+"_off.gif") ;
           $("#news_0"+i).css("display","none");
        }
    }	
}

/* 청장 24시 실행 */
var sId = null;
function sListView()
{
    if(ListAry.length > 0 )
    {
        var temp = ListAry[sCnt];                        
        $("#d24date").html(temp.input_date);
        $("#d24Link").attr("href",temp.bbs_link_view.replace("&amp;","&"));
        $("#d24Link").attr("title",temp.subject);
        $("#d24Link").text(temp.subject);
        if(temp.imgsrc == "/pub/img/sub/noimg_photo.gif"){
            $("#d24ImgLink").attr("href",temp.bbs_link_view.replace("&amp;","&"));
            $("#d24ImgLink").attr("title",temp.subject); 
            
            $("#d24Img").attr("src","pub/img/sub/noimg_photo.gif");
            $("#d24Img").attr("alt","이미지없음");
            $("#d24Img").attr("title","temp.subject");
        }else {           
            $("#d24ImgLink").attr("href",temp.bbs_link_view.replace("&amp;","&"));
            $("#d24ImgLink").attr("title",temp.subject); 
            
            $("#d24Img").attr("src",temp.imgsrc);
            $("#d24Img").attr("alt",temp.subject);
            $("#d24Img").attr("title",temp.subject);            
        }
        sCnt++;
        if(sCnt == ListAry.length) sCnt = 0;
    }
}

function sListViewStop()
{    
    if(sId != null) {
        clearInterval(sId);
        sId = null;
    }
}

function sListViewStart()
{    
    if(sId == null) sId = setInterval("sListView()",4000);
}


/* 포토갤러리 및 동영상 */
var mId = null;
function mListView()
{    
    if(mListAry.length > 0 )
    {
        var temp = mListAry[mCnt];
        var str_img = "";        
        $("#m_link").attr("href",temp.bbs_link_list);
        $("#photoLink").attr("href",temp.bbs_link_view.replace("&amp;","&"));
        $("#photoLink").attr("title",temp.subject);
        $("#photoLink").text(temp.subject);
        $("#photoDate").html(temp.input_date);
        $("#photo_content").text(temp.content);
        if (temp.imgsrc == "/images/gbPs/noimage.gif") {
            $("#photoImgLink").attr("href",temp.bbs_link_view.replace("&amp;","&"));
            $("#photoImgLink").attr("title",temp.subject + " 페이지로 이동합니다.");
            $("#photImg").attr("src", "/images/gbPs/noimage.gif");
            $("#photImg").attr("alt","이미지없음");
            $("#photImg").attr("title", "이미지없음");            
        }else {
            $("#photoImgLink").attr("href",temp.bbs_link_view.replace("&amp;","&"));
            $("#photoImgLink").attr("title",temp.subject + " 페이지로 이동합니다.");
            $("#photImg").attr("src",temp.imgsrc);
            $("#photImg").attr("alt",temp.subject);
            $("#photImg").attr("title",temp.subject);                        
        }                               
        mCnt++;
        if(mCnt == mListAry.length) mCnt = 0;
    }
}

function mListViewStop()
{   
    if(mId != null) {
        clearInterval(mId);
        mId = null;
    }
}

function mListViewStart()
{    
    if(mId == null) mId = setInterval("mListView()",4000);    
}

/* g-pin open*/
function gpinAuth(bC, act, re_vars) {
    wWidth = 360;
    wHight = 120;
    
    wX = (window.screen.width - wWidth) / 2;
    wY = (window.screen.height - wHight) / 2;    
    // Request Page Call
    var w = window.open("/gpin/Sample-AuthRequest.aspx?bC="+bC+"&act="+act+"&re_vars="+re_vars, "gPinLoginWin", "directories=no,toolbar=no,left="+wX+",top="+wY+",width="+wWidth+",height="+wHight);
}

/* 만족도 */
function btnSatifyState()
{
    $("#isSatify").css("display","none");    

    $("#btnSatifyImg").hover(
      function () {        
        $("#btnSatifyImg").attr("src","/pub/img/common/btn_satisfy_on.gif");
      },
      function () {        
        $("#btnSatifyImg").attr("src","/pub/img/common/btn_satisfy.gif");
      }
    );
    
    $('#btnSatifyLink').focus(function(){        
        $("#btnSatifyImg").attr("src","/pub/img/common/btn_satisfy_on.gif");
    
    });
    
    $('#btnSatifyLink').blur(function(){        
        $("#btnSatifyImg").attr("src","/pub/img/common/btn_satisfy.gif");
    });    
}

var satPoint = 5;
function viewIsSatify(val)
{   
    if(val == "1") {
        if($("#isSatify").css("display") == "none")
        {
            $("#isSatify").css("display","block");
        }else {
            $("#isSatify").css("display","none");
        }
    }
}

function checkSatPoint(_id)
{
    sat_point = $("#"+_id).val();
}

function satifyFormSend()
{    
    var satComment = $("#satisfy_text").val();
    jQuery.post("/pub/satisfaction/satisfy_input.aspx" , {icode:$("#icode").val(),sat_point:satPoint,sat_comment:satComment} , function(data){
        if(data == "0")
        {
            alert("만족도 평가가 등록되었습니다.");            
            $("#satisfy_5").attr("checked","checked");
            $("#satisfy_text").val("");
            $("#isSatify").css("display","none");
        }else if(data == 100)
        {
            alert("만족도 평가는 하루에 1번 참여가능합니다.");
            $("#isSatify").css("display","none");
            return false;
        }
    });
}

/* 메인 팝업존*/
function popImgOpen(ele, imgPath, e)
{
    popImgBlur();
    var sWidth = document.body.clientWidth;    
    var _left = e.clientX;
    var _top = e.clientY; 
    if(sWidth > 1024) _left = _left - ((sWidth - 1000) / 2);
    $("#formdisplay").css("left" , _left + 10);
    $("#formdisplay").css("top" ,  _top + 12);
    $("#formdisplay").css("display" , "");     
    $("#popimgsrc").attr("src" , imgPath);
    $("#popimgsrc").attr("alt" , $("#"+ele.id).attr("title"));    
}

function popImgFocus(ele, imgPath)
{    
    popImgBlur();
    var dim=$(ele).offset();
    var _left = dim.left;
    var _top = dim.top; 
    var sWidth = document.body.clientWidth;    
    if(sWidth > 1024) _left = _left - ((sWidth - 1000) / 2);    
    
    $("#formdisplay").css("display" , "");
    $("#formdisplay").css("left" , _left + 10);
    $("#formdisplay").css("top" ,  _top + 12);         
    $("#popimgsrc").attr("src" , imgPath);
    $("#popimgsrc").attr("alt" , $("#"+ele.id).attr("title"));
}

function popImgBlur()
{
    $("#formdisplay").css("display" , "none");    
}

/* cms 적용 스크립트*/
// 100/72.ascx
function zoneBlank()
{   
    if($("#zoneSel").val() != "")
    {
        window.open($("#zoneSel").val());
    }
    return false;
}


/* RSS주소복사 스크립트 */
function f_UrlCopy(urlObj) {
    window.clipboardData.setData("Text", urlObj);
    alert('주소가 복사되었습니다.\n주소창에 Ctrl+V 하시면 복사된 주소가 붙여집니다.');
}

/**
* 쿠키 설정
* @param cookieName 쿠키명
* @param cookieValue 쿠키값
* @param expireDay 쿠키 유효날짜
*/
function setCookie(cookieName, cookieValue, expireDate) {
    var today = new Date();
    today.setDate(today.getDate() + parseInt(expireDate));
    document.cookie = cookieName + "=" + escape(cookieValue) + "; path=/; expires=" + today.toGMTString() + ";";
    //document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/;";
}


/**
* 쿠키값 추출
* @param cookieName 쿠키명
*/
function getCookie(cookieName) {
    var search = cookieName + "=";
    var cookie = document.cookie;

    // 현재 쿠키가 존재할 경우
    if (cookie.length > 0) {
        // 해당 쿠키명이 존재하는지 검색한 후 존재하면 위치를 리턴.
        startIndex = cookie.indexOf(cookieName);

        // 만약 존재한다면
        if (startIndex != -1) {
            // 값을 얻어내기 위해 시작 인덱스 조절
            startIndex += cookieName.length;

            // 값을 얻어내기 위해 종료 인덱스 추출
            endIndex = cookie.indexOf(";", startIndex);

            // 만약 종료 인덱스를 못찾게 되면 쿠키 전체길이로 설정
            if (endIndex == -1) endIndex = cookie.length;

            // 쿠키값을 추출하여 리턴
            return unescape(cookie.substring(startIndex + 1, endIndex));
        }
        else {
            // 쿠키 내에 해당 쿠키가 존재하지 않을 경우
            return false;
        }
    }
    else {
        // 쿠키 자체가 없을 경우
        return false;
    }
}


/**
* 쿠키 삭제
* @param cookieName 삭제할 쿠키명
*/
function deleteCookie(cookieName) {
    var expireDate = new Date();

    //어제 날짜를 쿠키 소멸 날짜로 설정한다.
    expireDate.setDate(expireDate.getDate() - 1);
    document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}


function MM_findObj(n, d) { //v3.0
    var p, i, x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    return x;
}

function MM_showHideLayers() { //v3.0
    var i, p, v, obj, args = MM_showHideLayers.arguments;
    for (i = 0; i < (args.length - 2); i += 3)
        if ((obj = MM_findObj(args[i])) != null) {
        v = args[i + 2];
        if (obj.style) {
            obj = obj.style;
            v = (v == 'show') ? 'visible' : (v = 'hide') ? 'hidden' : v;
        }
        obj.visibility = v;
    }
}

function doDown() {
    MM_showHideLayers('ifrmcal', '', 'hide');

}

function calendarBtn(form1) {    
    if ((obj = MM_findObj('ifrmcal')) != null) {
        if (obj.style) {
            obj = obj.style;
        }
        obj.left = x;
        obj.top = y;
    }
    
    calendarfrm.buttonmenu(form1);
    MM_showHideLayers('ifrmcal', '', 'show')
}	
