var ie=document.all; var ns=document.layers; var ns6=document.getElementById&&!document.all;
// ÀÔ·ÂÆû °Ë»ç¿¡ »ç¿ëÇÏ´Â ½ºÅ©¸³Æ®
function isNumeric(el){var pattern=/^(-{0,1})([0-9]+)$/;return (pattern.test(el.value)) ? true : doError(el,"¼ýÀÚÇü½ÄÀ» ÀÔ·ÂÇÏ¼¼¿ä.");}
function isEnglish(el){var pattern=/^([a-zA-Z ]+)$/;return (pattern.test(el.value)) ? true : doError(el,"¿µ¹®ÀÚ¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");}
function isNotNull(el,msg){return (el.value.replace(/ /g, "").length>0) ? true : doError(el,msg);}
function isGoodID(el){var pattern=/^[a-zA-Z]{1}[_a-zA-Z0-9-]{3,}$/;return (pattern.test(el.value)) ? true : doError(el,"¾ÆÀÌµð´Â ¿µ¹®ÀÚ·Î ½ÃÀÛÇÏ°í ¿µ¼ýÀÚ, ÇÏÀÌÇÂ(-), ¾ð´õ¹Ù(_)¸¦ Á¶ÇÕÇÏ¿© 4ÀÚÀÌ»óÀ¸·Î ÀÔ·ÂÇÏ¼¼¿ä.");}
function isGoodPass(el){var pattern=/^[_a-zA-Z0-9!#$%&()*+\.:;<=>?@{|}~-]{4,}$/;return (pattern.test(el.value)) ? true : doError(el,"ºñ¹Ð¹øÈ£´Â ¿µ¼ýÀÚ¿Í Æ¯¼ö¹®ÀÚ(!#$%&()*+-.:;<=>?@^_{|}~)¸¦ Á¶ÇÕÇÏ¿© 4ÀÚÀÌ»óÀ¸·Î ÀÔ·ÂÇÏ¼¼¿ä.");}
function isEmail(el){var pattern=/^[_a-zA-Z0-9-\.]+@[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;return (pattern.test(el.value)) ? true : doError(el,"¿Ã¹Ù¸¥ ¸ÞÀÏÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");}
function isDomain(el){var pattern=/^(http:\/\/)?(www\.)?([_°¡-Èþa-zA-Z0-9-]+\.)+[a-zA-Z]{2,3}(\/[_°¡-Èþa-zA-Z0-9-]+)*/i;return (pattern.test(el.value)) ? true : doError(el,"¿Ã¹Ù¸¥ URLÀ» ÀÔ·ÂÇÏ¼¼¿ä.");}
function isPhone(el, value){var pattern=/^([0]{1}[0-9]{1,3})-?([1-9]{1}[0-9]{2,3})-?([0-9]{4})$/; var num=value?value:el.value;if(pattern.test(num)){return true;}else{return doError(el,"¿Ã¹Ù¸¥ ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");}}

function doError(el,msg){alert(msg);el.value="";el.focus();return false;}
function numOnly(){ if((event.keyCode<48)||(event.keyCode>57)) event.returnValue=false;}
function nextInput(e1,e2,m){if(e1.value.length==m) e2.focus();}

function isJumin(el,value){var pattern=/^([0-9]{6})-?([0-9]{7})$/;var num=value?value:el.value;
if(!pattern.test(num)) return doError(el,"¿Ã¹Ù¸¥ ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");num=RegExp.$1+RegExp.$2;var sum=0;var last=num.charCodeAt(12)-0x30;var bases="234567892345";
for(var i=0;i<12;i++){if(isNaN(num.substring(i,i+1))) return doError(el,"¿Ã¹Ù¸¥ ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");sum+=(num.charCodeAt(i)-0x30)*(bases.charCodeAt(i)-0x30);}
var mod=sum%11;return ((11-mod)%10==last) ? true : doError(el,"¿Ã¹Ù¸¥ ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");}
function checkJumin(e1,e2){if(e1.value.length>0 && e2.value.length>0){if(!isJumin(e1,e1.value+e2.value)){e2.value="";return false;}}}

// ÀÌ¹ÌÁö »çÀÌÁî Á¶Á¤
function imgSize(el,maxWidth,maxHeight){var width=el.width;var height=el.height;
if(maxWidth<0)maxWidth=0;if(maxHeight<0)maxHeight=0;if(maxWidth==0&&maxHeight>0&&height>maxHeight){height=height/maxHeight;width=width/(height/maxHeight);}
else if(maxHeight==0&&maxWidth>0&&width>maxWidth){width=width/maxWidth;height=height/(width/maxWidth);}
else if(maxWidth>0&&maxHeight>0){if(width>maxWidth){height=height/(width/maxWidth);width=maxWidth;}
if(height>maxHeight){width=width/(height/maxHeight);height=maxHeight;}}el.width=width;el.height=height;}

// ÀÌ¹ÌÁö »õÃ¢À¸·Î ¿­±â
function openImageWin(imageRef,title){var x,y,w,h,loadingMsg;w=300;h=100;x=Math.floor((screen.availWidth-(w+12))/2);y=Math.floor((screen.availHeight-(h+30))/2);
loadingMsg="<table width=100% height=100%><tr><td valign=center align=center><font size='2' color='#ff6600' face='termanal'>NOW LODDING...</font></td></tr></table>";
with(window.open("","",'height='+h+',width='+w+',top='+y+',left='+x+',scrollbars=yes,resizable=yes')){
document.write("<body topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'>",loadingMsg,"<img src=\""+imageRef+"\" style=\"cursor:Hand\" hspace=0 vspace=0 border=0 onmousedown=\"window.close();\" onload=\"document.title=':: "+title+"';document.body.removeChild(document.body.children[0]);window.resizeTo(this.width+30,this.height+40);window.moveTo(Math.floor( (screen.availWidth-this.width)/2),Math.floor( (screen.availHeight-this.height)/2 ));\">","</body>"); focus(); }}

// window Áß¾Ó¹èÄ¡
function wResize(dWidth,dHeight){window.moveTo((screen.width-dWidth)/2,(screen.Height-dHeight)/3);window.resizeTo(dWidth,dHeight);}

// Æ÷Ä¿½º Ã³¸®
//function inputIn(){oSrc=event.srcElement;if(oSrc && (oSrc.tagName=="INPUT" || oSrc.tagName=="TEXTAREA")) oSrc.style.backgroundColor="#F0F0DF";}
//function inputOut(){oSrc=event.srcElement;if(oSrc && (oSrc.tagName=="INPUT" || oSrc.tagName=="TEXTAREA")) oSrc.style.backgroundColor="#FFFFFF";}
//document.onfocusin = inputIn; document.onfocusout = inputOut;
// °Ô½Ã±Û ÀÔ·ÂÇ×¸ñ °Ë»ç
function regBoardSubmit(f,needMobile,needPhone,needEmail,needAddr,needHome,cnt,allowExt,allowEditor){
	if(!isNotNull(f.user_nm,"ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä")) return false;
	if(f.passwd && !isNotNull(f.passwd,"ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä")) return false;

	if( f.mobile1 && (needMobile || f.mobile1.value.length>0 || f.mobile1.value.length>0 || f.mobile1.value.length>0) && !isPhone(f.mobile1, f.mobile1.value+"-"+f.mobile2.value+"-"+f.mobile3.value)){
		f.mobile2.value='';
		f.mobile3.value='';
		f.mobile1.focus();
		return false;
	}
	
	if( f.tel1 && (needPhone || f.tel1.value.length>0 || f.tel2.value.length>0 || f.tel3.value.length>0) && !isPhone(f.tel1, f.tel1.value+"-"+f.tel2.value+"-"+f.tel3.value)){
		f.tel2.value='';
		f.tel3.value='';
		f.tel1.focus();
		return false;
	}
	if(f.email && (needEmail || f.email.value.length>0) && !isEmail(f.email)) return false;
	if(needAddr && f.addr1 && (f.post.value.length==0 || f.addr1.value.length==0 || f.addr2.value.length==0)){
		alert("ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		return false;
	}
	if(needHome && f.homepage && !isNotNull(f.homepage,"È¨ÆäÀÌÁö ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä.")) return false;
	if(!isNotNull(f.subject,"Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä")) return false;
	if(allowEditor && f.text_type[2].checked)f.content.value=FCKeditorAPI.GetInstance('FCKeditor1').GetXHTML(true);
	if(f.content.value.replace(/ /g,'').length==0){
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä");
		return false;
	}
	if(deny_str.length>0){
		deny_strs=deny_str.split(",");
		for(i=deny_strs.length-1;i>=0;i--){
			if(f.content.value.indexOf(deny_strs[i])>=0){
				alert("³»¿ëÁß¿¡ Á¦ÇÑµÈ ´Ü¾î°¡ Á¸ÀçÇÕ´Ï´Ù.");
				f.content.focus();
				return false;
			}
		}
	}

	//³»¿ëÁß ÁÖ¹Îµî·Ï¹øÈ£°¡ ÀÔ·ÂµÇ¾ú´ÂÁö °Ë»ç
	//var re1 =/([0-9][0-9][0-9][0-9][0-9][0-9])([0-9][0-9][0-9][0-9][0-9][0-9][0-9])/g;
	//var re2 =/([0-9][0-9][0-9][0-9][0-9][0-9])-([0-9][0-9][0-9][0-9][0-9][0-9][0-9])/g;
	//var re3 =/([0-9][0-9][0-9][0-9][0-9][0-9]) - ([0-9][0-9][0-9][0-9][0-9][0-9][0-9])/g;
	//var _data = f.content.value.replace(/ /g,"");
	//if(_data.search(re1) > -1 || _data.search(re2) > -1 || _data.search(re3) > -1) { alert("º»¹®¿¡ ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ½Ç¼ö ¾ø½À´Ï´Ù"); return false;}

	//³»¿ëÁß ÈÞ´ëÆù ¹øÈ£°¡ ÀÔ·ÂµÇ¾ú´ÂÁö °Ë»ç
	var hp1 = /(0[0-9][0-9])([0-9][0-9][0-9])([0-9][0-9][0-9][0-9])/g;
	var hp2 = /(0[0-9][0-9])([0-9][0-9][0-9][0-9])([0-9][0-9][0-9][0-9])/g;
	var hp3 = /(0[0-9][0-9])-([0-9][0-9][0-9])-([0-9][0-9][0-9][0-9])/g;
	var hp4 = /(0[0-9][0-9])-([0-9][0-9][0-9][0-9])-([0-9][0-9][0-9][0-9])/g;
	var hp5 = /(0[0-9][0-9])-([0-9][0-9][0-9][0-9])([0-9][0-9][0-9][0-9])/g;
	//if(_data.search(hp1) > -1 || _data.search(hp2) > -1 || _data.search(hp3) > -1 || _data.search(hp4) > -1 || _data.search(hp5) > -1) { alert("º»¹®¿¡ ÈÞ´ëÆù ¹øÈ£¸¦ ÀÔ·ÂÇÏ½Ç¼ö ¾ø½À´Ï´Ù"); return false;}

	if(deny_ext.length>0){
		deny_exts=","+deny_ext.replace(/ /g,'').toLowerCase()+",";
		for(i=0; i<cnt; i++){
			if(f["upload"+i].value.length>0){
				ext=f["upload"+i].value.substring(f["upload"+i].value.lastIndexOf('.')+1).toLowerCase();
				if(allowExt){
					if(deny_exts.indexOf(ext)<0){
						alert("¾÷·Îµå°¡ Á¦ÇÑµÈ ÆÄÀÏÀÔ´Ï´Ù.");
						f["upload"+i].focus();
						return false;
					}
				}else{
					if(deny_exts.indexOf(ext)>=0){
						alert("¾÷·Îµå°¡ Á¦ÇÑµÈ ÆÄÀÏÀÔ´Ï´Ù.");
						f["upload"+i].focus();
						return false;
					}
				}
			}
		}
	}
	if(f.is_secret && f.is_secret.checked && f.keys.value.replace(/ /g,'').length==0){
		alert("ºñ¹Ð±ÛÀÇ Çã¿ë¾ÏÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		f.keys.focus();
		return false;
	} 
	//f.action = "/dev/board/cf_proc.jsp?id="+f.id.value;
	//parent.document.boardWriteForm.cf.value = "N";
	//parent.FSubmit();
	return true;
}

function changeWriteForm(el){if(el.form.text_type.length<3 || !el.form.text_type[2].checked){if(document.all.DivEditor){
if(FCKeditorAPI.GetInstance('FCKeditor1').GetXHTML(true).length>0)el.form.content.value=FCKeditorAPI.GetInstance('FCKeditor1').GetXHTML(true);
document.all.DivEditor.style.display='none';}document.all.DivText.style.display='';}
else{if(document.all.DivEditor){FCKeditorAPI.GetInstance('FCKeditor1').SetHTML(el.form.content.value);document.all.DivEditor.style.display='';}
document.all.DivText.style.display='none';}}

// ºñ¹Ð¹øÈ£ ÀÔ·ÂÃ¢
function showPassForm(e, mode, action, idx) {xOffset= (action=="comment") ? -280 : 10; yOffset=0;
if(ie||ns6) {crossobj=document.getElementById? document.getElementById("passFormDiv") : document.all.passFormDiv;
crossobj.style.left=ns6? pageXOffset+e.clientX+xOffset: event.clientX +xOffset; //document.documentElement.scrollLeft+
crossobj.style.top=ns6? pageYOffset+e.clientY+yOffset: document.documentElement.scrollTop+event.clientY+yOffset;
}else if(ns) {document.passFormDiv.left=e.x+xOffset; document.passFormDiv.top=e.y+yOffset;}
crossobj.style.display="block";
document.passForm.mode.value=mode;
document.passForm.actiontype.value=action;
document.passForm.idx.value=idx;document.passForm.chk_data.value=idx;document.passForm.passwd.focus();}//document.documentElement.scrollTop
function hidePassForm() {crossobj=document.getElementById? document.getElementById("passFormDiv"):document.passFormDiv; crossobj.style.display="none";}

// °£´ÜÇÑ ´ñ±ÛÃ³¸®
function commentSubmit(f){ if(!isNotNull(f.uname,"±Û¾´ÀÌ ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä")) return false;
if(f.c_passwd && !isNotNull(f.c_passwd,"´ñ±Û»èÁ¦¿¡ ÇÊ¿äÇÑ ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä")) return false;
if(!isNotNull(f.content,"´ñ±Û ³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä")) return false; return true; }
//images popup
function viewPic(img){ 
    img1= new Image(); 
    var imgsrc = ""+img.src;
    img1.src=(imgsrc);
    call(imgsrc); 
} 
function call(img){ 
    if((img1.width!=0)&&(img1.height!=0)){ 
        viewImg(img); 
    }else{ 
        funzione="call('"+img+"')"; 
        intervallo=setTimeout(funzione,20); 
    } 
} 
function viewImg(img){ 
    WinW=img1.width+20; 
    WinH=img1.height+20; 
    LeftPosition =0 ;
    TopPosition =0;
    options = "";
    if(img1.width > 990 || img1.height > 660){
    WinH = 660;
    WinW = 990;
    options = "height="+WinH+",width="+WinW+",scrollbars=yes,top="+TopPosition+",left="+LeftPosition+",";
    }else{
    options ="height="+WinH+",width="+WinW+",top="+TopPosition+",left="+LeftPosition+",";
    }
    imgWin=window.open("","",options);
    imgWin.document.write("<html><head><title>±¹ÅäÇØ¾çºÎ</title><META HTTP-EQUIV='imagetoolbar' CONTENT='no'></head>");//»õÃ¢ÀÇ Å¸ÀÌÆ²¹®±¸
    imgWin.document.write("<img src="+img+" onclick='self.close()' style='cursor:hand'>");//»õÃ¢ÀÇ ÀÌ¹ÌÁö¸¦ Å¬¸¯ÇÏ¸é Ã¢ÀÌ ´ÝÈ÷°Ô ÇÔ
} 
/**
 * img Change control
 */
function imgChangeControl(img,imgid){
    eval("document.getElementById('"+imgid+"').src = '"+img.src+"' ");
}
function listSearchD(val){
    if(val == "regdate"){
        document.getElementById("listSText1").style.display = 'none';
        document.getElementById("listSText2").style.display = '';
    }else{
        document.getElementById("listSText2").style.display = 'none';
        document.getElementById("listSText1").style.display = '';
    }
}
/**
 * if there is not date search type, insert empty to value
 */
function listSearchD2(selbox){
    if(selbox.value == "regdate"){
        document.getElementById("listSText1").style.display = 'none';
        document.getElementById("listSText2").style.display = '';
        if( selbox.form.V ){
            selbox.form.V.value = "";
        }        
    }else{
        document.getElementById("listSText2").style.display = 'none';
        document.getElementById("listSText1").style.display = '';
        if( selbox.form.V2 ){
            selbox.form.V2.value = "";
        }
        if( selbox.form.V3 ){
            selbox.form.V3.value = "";
        }
    } 
}
function showConfirm(_url, _msg,site_id){
	if( _msg==null) _msg = '½Ç¸íÀÎÁõ ÈÄ, ±Û µî·ÏÀÌ °¡´ÉÇÕ´Ï´Ù.\n½Ç¸íÀÎÁõ ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?';
	if(confirm(_msg)){
		if("eastship" == site_id) {
			location.href='/USR/LOGN/m_657/FRM.jsp?flag=3&rtUrl='+_url;
		} else if("westship" == site_id) {
			location.href='/USR/LOGN/m_1121/FRM.jsp?flag=3&rtUrl='+_url;
		} else {
			location.href='/USR/LOGN/FRM.jsp?flag=3&rtUrl='+_url;
		}
	}
	 	
}
function showScrapConfirm(_url){
	if(confirm('·Î±×ÀÎ ÈÄ, ±Û µî·ÏÀÌ °¡´ÉÇÕ´Ï´Ù.\n·Î±×ÀÎ ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?')){
	 	location.href='/USR/LOGN/FRM.jsp?flag=1&rtUrl='+_url;
	}
}
function goDelete(_url){if(confirm('»ç¿ëÀÚÈ­¸é¿¡¼­ ¼û±èÃ³¸®ÇÏ½Ã°Ú½À´Ï±î?')){document.boardWriteForm.action = _url;document.boardWriteForm.submit();}return;}
function goRecover(_url){if(confirm('»ç¿ëÀÚÈ­¸é¿¡¼­ º¸ÀÓÃ³¸®ÇÏ½Ã°Ú½À´Ï±î?')){document.boardWriteForm.action = _url;document.boardWriteForm.submit();}return true;}
function goRemove(_url){if(confirm('DB¿¡¼­ ¿µ±¸ÀûÀ¸·Î »èÁ¦µË´Ï´Ù.\n\n°è¼ÓÇÏ½Ã°Ú½À´Ï±î?')){document.boardWriteForm.action = _url;document.boardWriteForm.submit();}return true;}
