// 빈칸이 있는지 확인 
function CheckSpaces(strValue) {   //공백을 체크해서 Boolean 값을 넘겨 줍니다.
    var flag=true;

    if (strValue!=" ") {
       for (var i=0; i < strValue.length; i++) {
          if (strValue.charAt(i) != " ") {
             flag=false;
             break;
          }
       }
    }
    return flag;
}

// 수정처리 - Q&A 또는 자유게시판일때
function Bbs_edit()
{
	if(CheckSpaces(document.form.bbs_title.value)){
	alert("제목을 입력해 주세요.")
	document.form.bbs_title.focus();
	return false;
}
	if(CheckSpaces(document.form.bbs_content.value)){
	alert("내용을 입력해 주세요.")
	document.form.bbs_content.focus();
	return false;
}
	if(CheckSpaces(document.form.bbs_name.value)){
	alert("작성자를 입력해 주세요.")
	document.form.bbs_name.focus();
	return false;
}
	if(CheckSpaces(document.form.bbs_pw.value)){
	alert("비밀번호를 입력해 주세요.")
	document.form.bbs_pw.focus();
	return false;
}
	if(confirm("내용을 수정하시겠습니까?") == false)
{
	return false;
}
	document.form.action = "Bbs_edit.php";
	document.form.submit()
}

// 삭제
function sendit( url ) { 
	var response = confirm( "\n정말 삭제하시겠습니까?" );
	if( response == true ) {
		if ( url == 0 ) {
			return false;
		}
		else {
			location.href="" + url;
		}
	} 
	return;
}

function wopen(N,H,K){
     window.open(N,H,K)
}

// 전체선택
var bname = navigator.appName; 
var IE = 'Microsoft Internet Explorer'; 
if (bname==IE) { ie = 1; } 
else { ie = 0; } 

//전체 체크를 눌렀을 경우 이름이 "chkName"인 모든 체크박스를 일괄 체크 / 일괄 해제
function CheckAll(checked) 
{
	len = document.myForm.elements.length;
	var i=0;
	for( i=0; i<len; i++) {
		if (document.myForm.elements[i].name=='chkName[]') 
		{
			if ((document.myForm.chkAll.checked==true))
			{
				document.myForm.elements[i].checked=true;
			}
			else
			{
				document.myForm.elements[i].checked=false;
			}
		}
	}
}

//전체 체크가 되어 있을 경우, 그외의 다른 체크박스의 체크를 해제했을 경우, "전체체크" 버튼도 체크해제한다.
function FreeCheckAll()
{
	document.myForm.chkAll.checked=false;
}

function Chkform(f) {
	var box_count=0; 
	for(j=0;j<document.myForm.elements.length;j++) {
		if(document.myForm.elements[j].type == "checkbox") {
			if (eval(document.myForm.elements[j].checked)==true) { 
			box_count++;
			}
		}
	}
	if (box_count<=0) { 
		alert("선택된 게시물이 없습니다. 적어도 하나 이상 선택하셔야 합니다."); 
		return; 
	} else {
		if(confirm("선택된 게시물을 삭제하시겠습니까?") == false)
		{
			return false;
		}
		document.myForm.submit();
	}
}

function WindowAutoSize() {
	window.resizeTo(0,0)
	document.body.scrollLeft = 400 // resize 될 창 width 값 제한
	winWidth = document.body.scrollLeft + document.body.clientWidth + 10; // 스크롤 가로 길이 + 처음 화면 가로 길이 + 창틀 사이즈

	document.body.scrollTop = 600 // resize 될 창 height 값 제한
	winHeight = document.body.scrollTop + document.body.clientHeight + 30; // 스크롤 세로 길이 + 처음 화면 세로 길이 + 메뉴 사이즈

	window.resizeTo(winWidth,winHeight);

}

function resetWindow() {
	document.body.scrollLeft = 0
	document.body.scrollTop = 0
}

function printClick() {
	var temp = printarea.innerHTML;
	if (temp) {
		temp_css = "<link rel='stylesheet' href='../wtf_eng/inc/style.css' type='text/css'>\n";
		temp_print = "\n<script>function sleep(){ window.close(); };window.print();setTimeout('sleep()', 1000);<\/script>";
		preWindow= open("", '','width=690,height=600');          
		preWindow.document.open();
		preWindow.document.write(temp_css);
		preWindow.document.write(temp);
		preWindow.document.write(temp_print);
		preWindow.document.close();
		
	}
}