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(db, no, id, range, keyword, keymode) {
   answer = confirm("ÀÌ±ÛÀ» ÃßÃµÇÏ½Ã°Ú½À´Ï±î?");
   urlstr = '&id=' + id + '&range=' + range + '&keyword=' + keyword + '&keymode=' + keymode;
   if(answer == true) { location.replace('./navigator.php?contents=board&usemode=vote&DB=' + db + '&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') {
      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();
}

