
function hanCheck(x)
{
   for(i=0;i<x.value.length;i++)
   {
       var a=x.value.charCodeAt(i);
       if (a > 128)
       {
           x.value="";
           x.focus();
           return -1;
       }
   }
   return 0;
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e)
{
   var keyCode = (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 && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
        var found = false, index = 0;
        while(!found && index < arr.length)
        if(arr[index] == ele)
        found = true;
        else
        index++;
        return found;
}

function getIndex(input) {
        var index = -1, i = 0, found = false;
        while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
        }
return true;
}

function jumin_no_check(id_no1,id_no2)
{
   var max_day=new Array("31","28","31","30","31","30","31","31","30","31","30","31");
   var check_digit=new Array(2,3,4,5,6,7,8,9,2,3,4,5);
   var id_no=id_no1+id_no2;

   var imsi_year=eval(id_no.substring(0,2))+1900;
   var imsi_month=eval(id_no.substring(2,4));
   var imsi_day=eval(id_no.substring(4,6));

   // ³âµµ Ã¼Å©
   if (((imsi_year % 4)==0) && ((imsi_year % 100)!=0) || ((imsi_year % 400)==0)) 
   {
         max_day[1]="29";
   }
   else
   {
         max_day[1]="28";
   }
 
   // »ý¿ù Ã¼Å©
   if (imsi_month<1 || imsi_month>12)
   {
       return -1;
   }

   // »ýÀÏ Ã¼Å©
   if (imsi_day<1 || imsi_day>max_day[imsi_month-1])
   {
       return -1;
   }

   // ¼ºº° Ã¼Å©
   if (id_no2.substring(0,1)!="1" && id_no2.substring(0,1)!="2")
   {
       return -1;
   }

   // ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
   var sum=0;
   for(var i=0;i<id_no.length-1;i++)
   {
       sum+=check_digit[i]*eval(id_no.substring(i,i+1));
   }

   var id_check=sum%11;
   var id_check=11-id_check;
   var id_check=id_check%10;

   if (id_check!=id_no.substring(12,13))
   {
       return -1;
   }
   
   return 0;
}

function email_check(mail_str)
{
   //IE5.5¿¡¼­ ¿¡·¯ ¹®Á¦·Î º¯°æ(2005.01.24)
   //var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
   var filter=/^[\w_-]+(\.[\w_-]+)*@[\w_-]+(\.[\w_-]+)*\.\w{2,3}$/;
   var url_check=new Array("com","net","org","info","biz","co.kr","pe.kr","or.kr","ne.kr","re.kr","ac.kr",
                           "go.kr","seoul.kr","busan.kr","daegu.kr","incheon.kr","gwangju.kr","daejeon.kr",
                           "ulsan.kr","gyeonggi.kr","gangwon.kr","chungbuk.kr","chungnam.kr",
                           "jeonbuk.kr","jeonnam.kr","gyeongbuk.kr","gyeongnam.kr","jeju.kr");

   if (filter.test(mail_str))
   {
		/*
		// test@bobchang.co.kr
		// ¾ÆÀÌµð¿¡ . À» »ç¿ëÇÏ¸é °áÁ¦½Ã ¿¡·¯°¡ ³­´Ù.
	   var imsi_pos=mail_str.indexOf(".");
	   //alert(imsi_pos) 13
       var imsi_pos=mail_str.indexOf(".")+1;
	   // alert(imsi_pos) 14
       var imsi_str=mail_str.substring(imsi_pos,mail_str.length);
	   // alert(imsi_str) co.kr
	   */

       var imsi_pos1=mail_str.indexOf("@")+1;
	   //alert(imsi_pos1)
       var imsi_str1=mail_str.substring(imsi_pos1,mail_str.length);
	   //alert(imsi_str1)

		var imsi_pos = imsi_str1.indexOf(".")+1;
		//alert(imsi_pos);
		var imsi_str = imsi_str1.substring(imsi_pos,imsi_str1.length);
		//alert(imsi_str);

// ¾Ë·Î¿¡ÀÇ ¿äÃ»À¸·Î daum¸ÞÀÏÀº ½ÂÀÎºÒ°¡ÇÑ Ç×¸ñ »èÁ¦(2005-01-27 Mr.Son HR)
/*
       if (imsi_str1=="daum.net" || imsi_str1=="hanmail.net")
       {
           return -2;
       }
*/
       imsi_check=0;
       for(var i=0;i<url_check.length;i++)
       {
           if (url_check[i]==imsi_str)
           {
               imsi_check=i+1;
           }
       }
       if (imsi_check==0)
       {
           return -1;
       }
       else
       {
           return 0;
       }
   }
   else
   {
       return -1;
   }
}

function zipcode_search(form,addressTitle) {
	ZipSearch = window.open("/member/member_post_search.php?form=" + form + "&addressTitle=" + addressTitle ,"ZipCodeSearch", "width=440,height=400, screenX=200,screenY=200, menubar=auto, toolbar=auto, scrollbars=yes");
	ZipSearch.focus();
   return;
}

function result_no_send()
{
   if (document.myform.mm_name.value=="")
   {
       alert("¼º¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä !!!");
       document.myform.mm_name.focus();
       return;
   }
   if (document.myform.mm_jumin_no1.value=="")
   {
       alert("ÁÖ¹Îµî·Ï¹øÈ£(¾Õ6ÀÚ¸®)¸¦ ÀÔ·ÂÇÏ¼¼¿ä !!!");
       document.myform.mm_jumin_no1.focus();
       return;
   }
   if (document.myform.mm_jumin_no2.value=="")
   {
       alert("ÁÖ¹Îµî·Ï¹øÈ£(µÞ7ÀÚ¸®)¸¦ ÀÔ·ÂÇÏ¼¼¿ä !!!");
       document.myform.mm_jumin_no2.focus();
       return;
   }
   if (document.myform.mm_email.value=="")
   {
       alert("ÀÌ¸ÞÀÏÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä !!!");
       document.myform.mm_email.focus();
       return;
   }
			window.open("result_no_send.php?mm_name=" + document.myform.mm_name.value + "&mm_jumin_no1=" + document.myform.mm_jumin_no1.value + "&mm_jumin_no2=" + document.myform.mm_jumin_no2.value + "&mm_email=" + document.myform.mm_email.value,"new","width=30,height=30, top=5000, left=5000, resizable=no, scrollbars=no");
   return;
}

function calendar(var1)
{
   window.open("/common/calendar.php?chk_pos=" + var1,"","width=250,height=250, top=5, left=5, resizable=no, scrollbars=no");
   return;
}

function id_check()
{
   if (document.member_insert.mm_id.value.length<4)
   {
       alert("È¸¿ø ¾ÆÀÌµð´Â 4ÀÚÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä. !!!");
       document.member_insert.mm_id.focus();
       return;
   }
   else
   {
       x=hanCheck(document.member_insert.mm_id);
       if (x==-1)
       {
           alert("ÇÑ±ÛÀº ¾ÆÀÌµð·Î »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. !!!");
           document.member_insert.mm_id.value="";
           document.member_insert.mm_id.focus();
           return;
       }
   }
			window.open("/common/id_check.php?id=" + document.member_insert.mm_id.value,"new","width=283,height=230, top=5, left=5, resizable=no, scrollbars=no");
   return;
}

function idpw_search()
{
			window.open("/member/idpw_search.php","new","width=300,height=180, top=200, left=200, resizable=no, scrollbars=no");
   return;
}

function logout()
{
			document.location="/logout.php";
   return;
}

function member_insert()
{
			document.location="/member/member_join1.php";
   return;
}

function member_modify()
{
			document.location="/member/member_modify.php";
   return;
}

function check_number1(check_data)
{
   var imsi=0;

/*
   for(var i=0;i<check_data.length;i++)
   {
       imsi=check_data.substr(i,1).charCodeAt(0);
       if (imsi>=48 && imsi<=57)
       {
           return -1;
       }
   }
*/
   if (isNaN(check_data)==true)
   {
        return -1;
   }
   else
   {
        return 0;
   }
}

function setComma(str) 
{ 
   var retValue = ""; 

   for(i=0; i<str.length; i++) 
   { 
       if (i > 0 && (i%3)==0)
       { 
           retValue = str.charAt(str.length - i -1) + "," + retValue; 
       }
       else
       { 
           retValue = str.charAt(str.length - i -1) + retValue; 
       } 
   } 
   return retValue; 
} 

function login_check()
{
   if (document.login_form.login_id.value.length<4)
   {
       alert("È¸¿ø ¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä. !!!");
       document.login_form.login_id.focus();
       return false;
   }
   if (document.login_form.login_passwd.value.length<4)
   {
       alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä. !!!");
       document.login_form.login_passwd.focus();
       return false;
   }
   document.login_form.submit();
   return true;
}

function poll_check(var1)
{
   var check_data=""
   for(i=0;i<document.poll_data.po_result.length;i++)
   {
       if (document.poll_data.po_result[i].checked==true)
       {
           check_data=document.poll_data.po_result[i].value;
       }
   }

   if (check_data!="")
   {
    			window.open("./poll_request.php?poll_seqno=" + var1 + "&poll_data=" + check_data,"new","width=30,height=30, top=3000, left=3000, resizable=no, scrollbars=no");
       return;
   }
   else
   {
       alert("¼³¹®Ç×¸ñÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä. !!!");
       return;
   }
}

function poll_request(var1)
{
 		window.open("./poll_result.php?poll_seqno=" + var1,"new","width=616,height=250, top=100, left=100, resizable=no, scrollbars=yes");
   return;
}



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_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_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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// textarea Á¶ÀýÇÏ±â.
function textarea_size(fld, size)
{
	var rows = parseInt(fld.rows);

	rows += parseInt(size);
	if (rows > 0) {
		fld.rows = rows;
	}
}

function adjustimage(target_img)
{
	var newX;
	var newY;
	var newHeight;
	var newWidth;
	var maxWidth = 566;
	var maxHeight = 300;
	var newImg = new Image();

	newImg.src = target_img.src;
	imgw = newImg.width;
	imgh = newImg.height;

	if (imgw > maxWidth || imgh > maxHeight)
	{
		if (imgw > imgh)
		{
			if (imgw > maxWidth)
				newWidth = maxWidth;
			else
				newWidth = imgw;
				newHeight = Math.round((imgh * newWidth) / imgw);
		}
		else
		{
			if (imgh > maxHeight)
				newHeight = maxHeight;
			else
				newHeight = imgh;
				newWidth = Math.round((imgw * newHeight) / imgh);
		}
	}
	else
	{
		newWidth = imgw;
		newHeight = imgh;
	}

	newX = maxWidth / 2 - newWidth / 2;
	newY = maxHeight / 2 - newHeight / 2;

	target_img.onload = null;
	target_img.src = newImg.src;
	target_img.width = newWidth;
	target_img.height = newHeight;
}

function adjustimage2(target_img,mWidth,mHeight)
{
	var newX;
	var newY;
	var newHeight;
	var newWidth;
	var maxWidth = mWidth;
	var maxHeight = mHeight;
	var newImg = new Image();

	newImg.src = target_img.src;
	imgw = newImg.width;
	imgh = newImg.height;

	if (imgw > maxWidth || imgh > maxHeight)
	{
		if (imgw > imgh)
		{
			if (imgw > maxWidth)
				newWidth = maxWidth;
			else
				newWidth = imgw;
				newHeight = Math.round((imgh * newWidth) / imgw);
		}
		else
		{
			if (imgh > maxHeight)
				newHeight = maxHeight;
			else
				newHeight = imgh;
				newWidth = Math.round((imgw * newHeight) / imgh);
		}
	}
	else
	{
		newWidth = imgw;
		newHeight = imgh;
	}

	newX = maxWidth / 2 - newWidth / 2;
	newY = maxHeight / 2 - newHeight / 2;

	target_img.onload = null;
	target_img.src = newImg.src;
	target_img.width = newWidth;
	target_img.height = newHeight;
}

// webzine open script
function FullscreenOpen(url){
		
    var fullwidth = 1000;
	var fullheight = 720;
	
	var newWin = window.open(url+"?full&right&normal&42&0&42&zoomgo&5",'webzine_new','titlebar=yes,toolbar=no, location=no,  menubar=no, resizable=no, status=0, left=0, top=0, width=' + fullwidth + ', height=' + fullheight);

	newWin.focus();
	//opener = self;
	//self.close();

}