var ie=document.all;
var ns=document.layers;
var ns6=document.getElementById&&!document.all;


// ¸Þ´º¿¡ »ç¿ëÇÏ´Â ½ºÅ©¸³Æ®
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	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);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function DIV_swapImage() { //v3.0
	var i,j=0,x,a=DIV_swapImage.arguments; document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3){k=i/3+1; if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	if (a[i+1]=='0') document.getElementById("divMain"+k).style.display='none'; else document.getElementById("divMain"+k).style.display='';}
}


// ÀÔ·ÂÆû °Ë»ç¿¡ »ç¿ëÇÏ´Â ½ºÅ©¸³Æ®
function isNumeric(el) {
	var pattern=/^(-{0,1})([0-9]+)$/;return (pattern.test(el.value)) ? true : doError(el,"¼ýÀÚÇü½ÄÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
}

function doError(el,msg) {
	alert(msg);el.value="";el.focus();return false;
}

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-]{2,}$/; 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,"ºñ¹Ð¹øÈ£´Â ¿µ¼ýÀÚ¿Í Æ¯¼ö¹®ÀÚ(a-zA-Z0-9!#$%&()*+-.:;<=>?@^_{|}~) ¸¦ Á¶ÇÕÇÏ¿© 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,2})-([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 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 numOnly() {
	if((event.keyCode<48)||(event.keyCode>57)) event.returnValue=false;
}

function nextInput(e1, e2, m) {
	if(e1.value.length==m) e2.focus();
}
function none() {}


// ÀÌ¹ÌÁö »çÀÌÁî Á¶Á¤
function imgSize(el, maxWidth, maxHeight){
	var width = el.width;  var height = el.height;
	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);
	with(window.open("","",'height='+h+',width='+w+',top='+y+',left='+x+',scrollbars=no,resizable=no')){
		document.write("<body topmargin=0 rightmargin=0 bottommargin=0 leftmargin=0><img src=\""+imageRef+"\" style=\"cursor:Hand\" hspace=0 vspace=0 border=0 onmousedown=\"window.close();\" onload=\"document.title=':: "+title+"';window.resizeTo(this.width,this.height);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 setCookie(name, value, expiredays ){
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}


// °£´ÜÇÑ ´ñ±ÛÃ³¸®
function commentSubmit(f){
	if(!isNotNull(f.name,"±Û¾´ÀÌ ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä")) return false;
	if(f.passwd && !isNotNull(f.passwd,"´ñ±Û»èÁ¦¿¡ ÇÊ¿äÇÑ ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä")) return false;
	if(!isNotNull(f.memo,"´ñ±Û ³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä")) return false; return true;
}


// ºñ¹Ð¹øÈ£ ÀÔ·ÂÃ¢
//function showPassForm(e, mode, action, idx) {xOffset= (action=="comment") ? -230 : 10; yOffset=0;
function showPassForm(e, mode, action, idx) {
	//xOffset= (action=="comment") ? -230 : 10; yOffset=-50;//
	xOffset = (action=="comment") ? -230 : -400; yOffset=-50;
	document.passForm.mode.value=mode; document.passForm.action.value=action; document.passForm.idx.value=idx;
	if(ie||ns6) {
		crossobj=document.getElementById? document.getElementById("passFormDiv") : document.all.passFormDiv;
		crossobj.style.left=ns6? pageXOffset+e.clientX+xOffset: document.body.scrollLeft+event.clientX+xOffset;
		crossobj.style.top=ns6? pageYOffset+e.clientY+yOffset: document.body.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.passwd.focus();
}

function hidePassForm() {
	crossobj=document.getElementById? document.getElementById("passFormDiv"):document.passFormDiv; crossobj.style.display="none";
}
