var cnum = 0;
function boardCheck(formname) {
//############################################//ÆûÃ¼Å© ÇÔ¼ö
for (i = 0; i < formname.length; i++) 
	{
	if(formname.item(i).type == "text" || formname.item(i).type == "password" || formname.item(i).type =="textarea")
		{    
			var Obj;
			var itype;
			var msg;

			switch(formname.item(i).name) {
			case "name":
				itype = "Atype";
				msg = "ÀÌ¸§À» ±âÀÔÇØ ÁÖ½Ê½Ã¿ä.";
				break;

			case "pwd":
				itype = "Atype";
				msg = "ÆÐ½º¿öµå¸¦ ±âÀÔÇØ ÁÖ½Ê½Ã¿ä.";
				break;

			case "title":
				itype = "Atype";
				msg = "Á¦¸ñÀ» ±âÀÔÇØ ÁÖ½Ê½Ã¿ä.";
				break;

			case "content":
				itype = "Atype";
				msg = "³»¿ëÀ» ±âÀÔÇØ ÁÖ½Ê½Ã¿ä.";
				break;

			case "limitcontent":
				itype = "Atype";
				msg = "³»¿ëÀ» ±âÀÔÇØ ÁÖ½Ê½Ã¿ä.";
				break;

			default :
				itype = "Atype";
				msg = formname.item(i).name + " ¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä";
				break;
			}
			Obj = formname.item(i);	

			if(Obj.name != "url"){//emailµî Ã¼Å©ÇÏÁö ¾Ê´Â°Íµé
					if(checkValue1(Obj,msg,itype) == false)//°ø¹é ½ºÆäÀÌ½ºÃ¼Å©ÇÔ¼ö
						{
						return false;
						}
			}//if end
		}//if end
	}//for end
}


function ideaBoardCheck(formname) {
//############################################//ÆûÃ¼Å© ÇÔ¼ö
for (i = 0; i < formname.length; i++) 
	{
	if(formname.item(i).type == "text" || formname.item(i).name == "questiongibo" || formname.item(i).name == "ENCODED" || formname.item(i).name == "iseq")
		{    
			var Obj;
			var itype;
			var msg;

			switch(formname.item(i).name) {
			case "iseq":
				itype = "Atype";
				msg = "±âÀü¸íÀ» ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À";
				break;
			case "listtitle":
				itype = "Atype";
				msg = "¸®½ºÆ® Á¦¸ñÀ» ±âÀÔÇØ ÁÖ½Ê½Ã¿À.";
				break;
			case "title":
				itype = "Atype";
				msg = "Á¦¸ñÀ» ±âÀÔÇØ ÁÖ½Ê½Ã¿À";
				break;
			case "questiongibo":
				itype = "Atype";
				msg = "¹®Á¦¿Í ´äÀ» ±âÀÔÇØ ÁÖ½Ê½Ã¿À";
				break;
			case "ENCODED":
				itype = "Atype";
				msg = "³»¿ëÀ» ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À";
				break;
			case "ENCODED":
				itype = "Atype";
				msg = "±âÀüÀ» ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À";
				break;
			default :
				msg = formname.item(i).name + " ¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À";
				break;
			}
			Obj = formname.item(i);	

			if(Obj.name != "url" && Obj.name !="idetail" && Obj.name != "rseq"){//emailµî Ã¼Å©ÇÏÁö ¾Ê´Â°Íµé
					if(checkValue1(Obj,msg,itype) == false)//°ø¹é ½ºÆäÀÌ½ºÃ¼Å©ÇÔ¼ö
						{
						return false;
						}
			}//if end
		}//if end
	}//for end
}


function checkValue1(Obj,msg,itype) {//Ã¼Å© ÇÔ¼ö

	var objtxt;

	if ( Obj.name=="questiongibo") {

		if (Obj.value.length > 348 && document.all.BADUKQUIZ.ObjectHTML.length == 348) {
		return true;
		}
		else{
			Obj.value = document.all.BADUKQUIZ.ObjectHTML;
			if (Obj.value.length == 348 ){
			alert(msg);
			return false;
			}
		}
	}

	if ( Obj.name=="ENCODED") {
		Obj.value = document.all.HTMLEditor.DocumentHTML;

		if (document.all.HTMLEditor.DocumentURL=="" && Obj.value.length - cnum > 256) {
			return true;   
		}
		else if ( Obj.value.length- cnum != 256 && Obj.value.length- cnum > 251) {
			return true;
		}
		else {
			alert(msg);			
			cnum ++ ;
			return false;
		}
	}


	if (Obj.name=="limitcontent") {//±ÛÀÚ¼ö¸¦ Á¦ÇÑ
		if(Obj.value.length > 1200 || trim(Obj.value)==""){
			alert("±ÛÀÚ¼ö´Â 1200ÀÚ ¹Ì¸¸À¸·Î ±âÀÔÇØ ÁÖ½Ê½Ã¿À.");
			Obj.select();
			Obj.focus();
			return false;
		}//end iuf
	}//end if
	else{	
		if((itype == "Atype" || itype == "Btype") && trim(Obj.value)==""){//½ºÆäÀÌ½ºÀÎ°æ¿ì °Ë»ç
			alert(msg);
			
			if (Obj.name != "questiongibo" && Obj.name != "iseq") {
			Obj.select();
			Obj.focus();
			}
			return false;
		}//end if
	}//end else
}

//ÆûÀÇ °ªÀ» ÃÊ±âÈ­ ½ÃÅ²´Ù.
function clearForm(formname) {
for (i = 0; i < formname.length; i++) 
	{
	formname.item(i).value="";
	}
}

//±Û¾²±â ºÎºÐ¿¡¼­ ÀÔ·ÂµÈ ±ÛÀÇ ³»¿ëÀÌ °ø¹é¸¸À¸·Î ÀÌ·ç¾îÁ® ÀÖ´ÂÁö Ã¼Å©ÇÑ´Ù..
function trim(str)
{
	var trimstr = str;
	for (var i=0; i< str.length;i++)
	{
		trimstr = trimstr.replace(' ' ,'');
	}
	return trimstr;
}

function inputMail(formname) {
var contentvalue;
  if( formname.contentinput.checked ) {
  contentvalue = formname.content.value;
  formname.mailcontent.value=contentvalue;
  formname.mailcontent.focus();
  }
  else {
  formname.mailcontent.value="";
  formname.mailcontent.focus();
  }
}


function reset() {
	document.Author4web.Data = "";
}

function reloadGibo() {
	document.Author4web.Data = document.form.gibo.value;
}

function comboChange(obj){
	var selectIndex = obj.selectedIndex;
	position = obj.options[selectIndex].value;
		
	url = "/News/News/gibo_open.asp?iseq="+position;

	if (position > 0) {
		openwindow (url,'open',420,200);		
	}
}

function preview(){	
	document.all.ENCODED.value = document.all.HTMLEditor.DocumentHTML;
	if (document.all.ENCODED.value.length - cnum > 558){
		window.open('','pre','width=630,height=800,top=0,left=0,scrollbars=1,left=200');
		form.target="pre"
		form.action="preview.asp"
		form.submit();
		form.target="_self"
		form.action="write_ok.asp"
	}
	else {
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä");
		cnum ++;
		document.form.HTMLEditor.focus();
	}
}

function setSample(formname) {
    formname.action = "sample_ok.asp";
	formname.submit();
}
