/*
고객센터 관련 스크립트
*/

//공지사항 글보기로 이동
function goNoticeView(nid,page) {
	var nid;
	var page;
	document.location.href='customer/notice_view.php?page='+page+'&nid='+nid;
}

//공지사항 리스트로이동
function goNoticeList(page)	{
	var page;
	document.location.href='../c_notice.php?page='+page;
}

//글보기로 이동
function goView(nid,page,pname,temp) {
	var nid;
	var page;
	var pname;
	var temp;	//qna 카테고리아이디
	document.location.href='./'+pname+'.php?page='+page+'&nid='+nid+'&q_cate_id='+temp;
}

//리스트로이동
function goList(page,pname)	{
	var page;
	document.location.href='./'+pname+'.php?page='+page;
}

//faq 서브카테고리 이동
function faq_sub(sub_id)	{
	var sub_id;
	document.location.href='./c_faq.php?s_category_id='+sub_id;
}

//QNA 패스워드 입력
function chkLock()	{
	if(document.writeForm.q_Lock.checked == true){ 
		document.writeForm.q_pwd.disabled = false; 
	}else{ 
		document.writeForm.q_pwd.disabled = true; 
	} 
}

//QNA 패스워드 체크
function goQnaPass(nid,page,temp)	{
	document.frm.action = 'qna_view.php?page='+page+'&nid='+nid+'&q_cate_id='+temp;
	document.frm.submit();
}

//null값 체크
function cx_trim(str){
    return str.replace(/(^\s*)|(\s*$)/g,"");
}

// QNA 글쓰기
function writeBoard() {
	//alert (document.writeForm.email2.value);
	if (document.writeForm.q_cateid.value=="")	{
		alert("문의분야를 선택해주세요.");
		document.writeForm.q_cateid.focus();
		return;
	} 
	else if (document.writeForm.phone1.value=="") {
		alert("연락처를 입력해주세요.");
		document.writeForm.phone1.focus();
		return;
	} 
	else if (!cx_trim(document.writeForm.phone2.value)) {
		alert("연락처를 입력해주세요.");
		document.writeForm.phone2.focus();
		return;
	} 
	else if (!cx_trim(document.writeForm.phone3.value)) {
		alert("연락처를 입력해주세요.");
		document.writeForm.phone3.focus();
		return;
	} 
	else if (!cx_trim(document.writeForm.email1.value))	 {
		alert("이메일을 입력해주세요.");
		document.writeForm.email1.focus();
		return;
	} 
	else if (document.writeForm.email2.value=="") {	
		alert("이메일을 선택해주세요.");
		document.writeForm.email2.focus();
		return;
	} 
	else if (!cx_trim(document.writeForm.q_title.value)) {	
	//else if(document.writeForm.q_title.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length<=0){
		alert("제목을 입력해주세요.");
		document.writeForm.q_title.focus();
		return;
	} 
	else if (!cx_trim(document.writeForm.q_content.value)) {	
		alert("내용을 입력해주세요.");
		document.writeForm.q_content.focus();
		return;
	}   
	else if (document.writeForm.q_Lock.checked == true) {	
		if (document.writeForm.q_pwd.value=="")
		{
			alert("비밀번호를 입력해주세요.");
			document.writeForm.q_pwd.focus();
			return;
		}

	} 	
	document.writeForm.action = "qna_insert.php?mode=insert";
	document.writeForm.submit();
	//alert("eojojojoojojoojojo");
}

//이메일자동입력
function board_email() { 
	var form = document.writeForm;

	//alert(form.email_list.value);
	form.email2.value = form.email_list.value;
} 

//popup_엑셀
function excel_delete_pop( ) {
	window.open("./popup_excel_delete.php","win","width=450,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=100,left=200");
}

//게시글삭제
function goDelete(mode, table_name, nid) {
	var form = document.WriteForm;
	var mode, table_name, nid;

	if(!confirm('정말 삭제하시겠습니까?')) {
		return;
	}		

	document.location.href = "qna_insert.php?mode=delete&table_name="+table_name+"&nid="+nid;
	
}
