function popupwin(size1, size2) {
   if ( getCookie( "open_popup" ) != "done" ) {
      window.open('./../navigator.php?contents=popup', 'open_popup', 'scrollbars=1, width=' + size1 + ', height=' + size2);
   }
}

function setCookie( name, value, expiredays )
    {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	}

function closeWin() { 
   if ( document.forms[0].Notice.checked ) { setCookie( "open_popup", "done" , 1); }
   self.close(); 
}

function getCookie( name ) {
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function viewimage(image, width, height) {
   var sheight = screen.height - 100; 
   var swidth  = screen.width - 100;
   if (sheight <= height) {
      scrollbar_tag1 = "yes";
      imageheight = sheight;
   }
   else {
      scrollbar_tag1 = "no";
      imageheight = height;
   }

   if (swidth <= width) {
      scrollbar_tag2 = "yes";
      imagewidth = swidth;
   }
   else {
      scrollbar_tag2 = "no";
      imagewidth = width;
   }
   
   scrollbar_tag = "no";
   
   if (scrollbar_tag1 == "yes" || scrollbar_tag2 == "yes") {
      scrollbar_tag = "yes";
   }

   viewwin = window.open('', '' , 'height=' + imageheight + ', width=' + imagewidth + ', scrollbars=' + scrollbar_tag)
   viewwin.document.open();
   viewwin.document.write('<title>ÀÌ¹ÌÁö¸¦ Å¬¸¯ÇÏ¸é Ã¢ÀÌ ´ÝÈü´Ï´Ù.</title><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><center><a href="javascript:self.close()"><img src="'+image+'" border=0 alt="ÀÌ¹ÌÁö¸¦ Å¬¸¯ÇÏ¸é Ã¢ÀÌ ´ÝÈü´Ï´Ù."></a></center></body>')
   viewwin.document.close();
   var x = screen.width / 2 - viewwin.document.body.offsetWidth / 2;
   var y = screen.height / 2 - viewwin.document.body.offsetHeight / 2;
   viewwin.moveTo(x, y);
} 

function menuvisible(submenu, tdnum) {
   var bodywidth = document.all.bodytable.offsetWidth;
   var bodyleft  = document.all.bodytable.offsetLeft;
   var submenu_message = eval("submenutext" + submenu);

   var tdleft    = document.all.tdtopmenu[tdnum].offsetLeft;
   
//   alert(tdnum + tdleft);
   
   document.all.tdsubmenu.innerHTML = submenu_message;
   var mousepos = event.clientX + document.body.scrollLeft - bodyleft;
   var submenupos = document.all.tablesubmenu.offsetWidth;
   if (mousepos - (submenupos / 2) < 0) {
      document.all.divsubmenu.style.left = document.body.scrollLeft;
   }
   else if (mousepos + (submenupos) > bodywidth) {
      document.all.divsubmenu.style.left = bodywidth - submenupos;
   }
   else {
//      document.all.divsubmenu.style.left = mousepos - (submenupos / 2);
      document.all.divsubmenu.style.left = tdleft;
   }
}

function imovisible() {
   document.all.tdimo.innerHTML = eval("imotext");
   document.all.divimo.style.left = mouseposX;
}

function imoinvisible() {
   document.all.tdimo.innerHTML = "";
}

function mousemove() {
   mouseposX = event.clientX;
}


function setimoticon(fileName) {
   document.comment.comment_icon.value = fileName;
   imoinvisible();
}

function boardsearch(){
   if(!document.board_search.keyword.value) {
      alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board_search.keyword.focus();
      return; }	
   document.board_search.submit();
}

function boardvote(board, no, range, keyword, keymode) {
   answer = confirm("ÀÌ±ÛÀ» ÃßÃµÇÏ½Ã°Ú½À´Ï±î?");
   urlstr = '&range=' + range + '&keyword=' + keyword + '&keymode=' + keymode;
   if(answer == true) { location.replace('./sub.php?contents=board&load=board_vote&usemode=vote&board=' + board + '&no=' + no + urlstr); }
   else { return; }
}

function boarddownload(db, no) {
   window.location.replace('./navigator.php?contents=board&usemode=down&DB=' + db + '&no=' + no);
}

function commentwrite() {
   if(!document.comment.comment_name.value) {
      alert('ÀÌ¸§À» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.comment.comment_name.focus();
      return;
   }
   else {
      str = document.comment.comment_name.value;
      if (str.substring(0, 1) == ' ') {
         alert('ÀÌ¸§ÀÇ Ã¹±ÛÀÚ°¡ °ø¹éÀÔ´Ï´Ù.');
         document.comment.comment_name.focus();
         return;
      }
   }

   if(!document.comment.comment.value) {
      alert('³»¿ëÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.comment.comment.focus();
      return;
   }

   if(!document.comment.comment_pwd.value) {
      alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.comment.comment_pwd.focus();
      return;
   }
   else {
      str = document.comment.comment_pwd.value;
      strlen = str.length;
      for(i=0; i <= strlen; i++) {
         if (str.substring(i, i+1) == ' ') {
            alert('ºñ¹Ð¹øÈ£¿¡ °ø¹éÀÌ Æ÷ÇÔµÇ¾ú½À´Ï´Ù.');
            document.comment.comment_pwd.focus();
            return;
         }
      }
   }

   document.comment.submit();
}

function boardmodify() {
   if(!document.board.name.value) {
      alert('ÀÌ¸§À» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.name.focus();
      return;
   }
   else {
      str = document.board.name.value;
      if (str.substring(0, 1) == ' ') {
         alert('ÀÌ¸§ÀÇ Ã¹±ÛÀÚ°¡ °ø¹éÀÔ´Ï´Ù.');
         document.board.name.focus();
         return;
      }
   }

   if(!document.board.title.value) {
      alert('Á¦¸ñÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.title.focus();
      return;
   }
   else {
      str = document.board.title.value;
      if (str.substring(0, 1) == ' ') {
         alert('Á¦¸ñÀÇ Ã¹±ÛÀÚ°¡ °ø¹éÀÔ´Ï´Ù.');
         document.board.title.focus();
         return;
      }
   }

   if(!document.board.content.value) {
      alert('³»¿ëÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.content.focus();
      return;
   }

   if(!document.board.passwd.value) {
      alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.passwd.focus();
      return;
   }
   else {
      str = document.board.passwd.value;
      strlen = str.length;
      for(i=0; i <= strlen; i++) {
         if (str.substring(i, i+1) == ' ') {
            alert('ºñ¹Ð¹øÈ£¿¡ °ø¹éÀÌ Æ÷ÇÔµÇ¾ú½À´Ï´Ù.');
            document.board.passwd.focus();
            return;
         }
      }
   }

   document.board.submit();
}

function boardwrite(){
   if(!document.board.name.value) {
      alert('ÀÌ¸§À» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.name.focus();
      return;
   }
   else {
      str = document.board.name.value;
      if (str.substring(0, 1) == ' ') {
         alert('ÀÌ¸§ÀÇ Ã¹±ÛÀÚ°¡ °ø¹éÀÔ´Ï´Ù.');
         document.board.name.focus();
         return;
      }
   }

   if(!document.board.title.value) {
      alert('Á¦¸ñÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.title.focus();
      return;
   }
   else {
      str = document.board.title.value;
      if (str.substring(0, 1) == ' ') {
         alert('Á¦¸ñÀÇ Ã¹±ÛÀÚ°¡ °ø¹éÀÔ´Ï´Ù.');
         document.board.title.focus();
         return;
      }
   }

   if(!document.board.content.value) {
      alert('³»¿ëÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.content.focus();
      return;
   }

   if(!document.board.passwd.value) {
      alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
      document.board.passwd.focus();
      return;
   }
   else {
      str = document.board.passwd.value;
      strlen = str.length;
      for(i=0; i <= strlen; i++) {
         if (str.substring(i, i+1) == ' ') {
            alert('ºñ¹Ð¹øÈ£¿¡ °ø¹éÀÌ Æ÷ÇÔµÇ¾ú½À´Ï´Ù.');
            document.board.passwd.focus();
            return;
         }
      }
   }

   if (document.board.board_type.value == 'imageboard' || document.board.board_type.value == 'imageboard_add') {
      if(!document.board.userfile.value) {
         alert('¾÷·ÎµåÇÒ ÆÄÀÏÀÌ ÁöÁ¤µÇÁö ¾Ê¾Ò½À´Ï´Ù.');
         document.board.userfile.focus();
         return;
      }
   }
   document.board.submit();
}

function boarddelete() {
	if(!document.boarddelete.passwd.value) {
      alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À');
      document.boarddelete.passwd.focus();
      return;
   }
	document.boarddelete.submit();
}

function IsInteger(st) {
   if (!IsEmpty(st)) {
      for (j=0; j<st.length; j++){
         if (((st.substring(j, j+1) < "0") || (st.substring(j, j+1) > "9")))
         return false;
      }
   }
   else { return false; }

   return true ;
}

function IsEmpty(toCheck) {
   var chkstr = toCheck + "";
   var is_Space = true ;
   if ( ( chkstr == "") || ( chkstr == null ) )
   return false ;
   for ( j = 0 ; is_Space &&  ( j < chkstr.length ) ; j++){
      if( chkstr.substring( j , j+1 ) != " " )
      is_Space = false ;
   }
   return ( is_Space );
}

function IsSpace(toCheck) {
   var chkstr = toCheck + "";
   if ( ( chkstr == "") || ( chkstr == null ) ) { return true ; }
   strlen = chkstr.length;
   for(i = 0 ; i < strlen ; i++) {
      if (chkstr.substring(i, i+1) == ' ') { return true; }
   }
   return false;
}

/*======================================== 
 js_event_anti.js 
 ¿À¸¥ÂÊ¸¶¿ì½º¹öÆ°,Å°º¸µå ÀÔ·Âµî ¹æÁö 

 this_s : ¿øÇÏ´Â ´ë»ó(ÆäÀÌÁö ÀüÃ¼´Â window.document) 
 e : event °´Ã¼ 

 ex1> 
 js_event_anti([°³Ã¼]);//ÆäÀÌÁö º¹»ç¹æÁö(¿À¸¥ÂÊ¸¶¿ì½º,Å°º¸µå, ÆË¾÷Ã¢ÀÌ¶ó¸é ¿Ïº®!) 
 (°³Ã¼À» ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é window.document°¡ ´ë»ó, ÆäÀÌÁö º¹»ç¹æÁö(¿À¸¥ÂÊ¸¶¿ì½º,Å°º¸µå, ÆË¾÷Ã¢ÀÌ¶ó¸é ¿Ïº®!) 
 ex2> 
 [°³Ã¼].ÀÌº¥Æ® = js_event_anti_stop_event; // °³Ã¼ÀÇ ÇØ´ç ÀÌº¥Æ®µ¿ÀÛÀº ¹«½ÃµÈ´Ù 
========================================*/ 

function js_event_anti_right(e) {        // ¿À¸¥ÂÊ ¸¶¿ì½º ¹öÆ° ¸·±â 
   evt = e || event; 
   try {
      if (document.all) {
         if(evt.button == 2 || evt.button == 3) {    
//            alert('¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°Àº »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.');  
            js_event_anti_stop_event(evt); 
            return false;
         } 
      }
      else {
         if(evt.which == 3 || evt.which == 2) {
//            alert('¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°Àº »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.');  
            js_event_anti_stop_event(evt); 
            return false;
         }
      }
   }
   catch(ex) { return false; } 
}

function js_event_anti_processKey(e) {   // Å°º¸µå ÀÔ·Â ¸·±â 
   evt = e || event; 
   alert('Don\'t! Key Input.');
   try { 
      js_event_anti_stop_event(evt); 
      return false; 
   }catch(ex) { return false; } 
}

function js_event_anti_stop_event(evt) { // ÀÌº¥Æ® µ¿ÀÛ ¹«½Ã
   if(window.event) { 
      window.event.keyCode = 0; 
      window.event.cancelBubble = true; 
      window.event.returnValue = true;    
   }
   else { 
      evt.stopPropagation(); 
      evt.preventDefault(); 
      evt.initEvent; 
   } 
   return false; 
} 

function js_event_anti(this_s) {         // ±âº»¾ÈÆ¼ ÀÌº¥Æ® µî·Ï(¿À¸¥ÂÊ¸¶¿ì½º,µå·¡±×,Å°ÀÔ·Â) -¹®Á¦Á¡ : FF¿¡¼­´Â µå·¡±× ÀÌº¥Æ®¸¦ Á¦¾îÇÒ ¼ö ¾ø´Ù. 
   if(!this_s) { this_s = window.document; } 
   if(document.attachEvent) { 
//      this_s.attachEvent("onkeydown", js_event_anti_processKey ); 
      this_s.attachEvent("onmousedown", js_event_anti_right ); 
//      this_s.attachEvent("onselectstart", js_event_anti_stop_event ); 
//      this_s.attachEvent("ondragstart", js_event_anti_stop_event ); 
      this_s.attachEvent("oncontextmenu", js_event_anti_stop_event ); 
   } 
   else { 
      window.captureEvents(Event.MOUSEDOWN); 
      window.captureEvents(Event.ONKEYDOWN); 
//      this_s.addEventListener("keydown", js_event_anti_processKey , false); 
      this_s.addEventListener("mousedown", js_event_anti_right , false); 
//      this_s.addEventListener("selectstart", js_event_anti_stop_event , false);  //FF¿¡¼­ Áö¿øµÇÁö ¾Ê´Â´Ù. 
//      this_s.addEventListener("dragstart", js_event_anti_stop_event , false);  //FF¿¡¼­ Áö¿øµÇÁö ¾Ê´Â´Ù. 
      this_s.addEventListener("contextmenu", js_event_anti_stop_event , false); 
   } 
}

function zipcode2(form,zipcode_field,address_field) {
   window.open("./sub.php?contents=member&load=member_zipcode2&form=" + form + "&zipcode_field=" + zipcode_field + "&address_field=" + address_field, "zipcode", "width=420, height=400, scrollbars=yes");
}
