function article_search(){var obj=document.search;var strURL="article_list.php";var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$("#list_pane").html(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function article_add(obj){$("input[type='submit']",obj).css("display","none");var sw=true;if(sw&&typeof(obj.elements["data[Article][board_category_id]"])!="undefined")sw=CheckForm(obj,"data[Article][board_category_id]","Sub Category");if(sw)sw=CheckForm(obj,"data[Article][title]","Title");if(sw)sw=CheckForm(obj,"data[Article][writer]","Writer");if(sw&&typeof(obj.elements["data[Article][password]"])!="undefined")sw=CheckForm(obj,"data[Article][password]","Password");if(sw&&typeof(obj.elements["data[article_property][area]"])!="undefined")sw=CheckForm(obj,"data[article_property][area]","Area");if(sw&&typeof(obj.elements["data[article_property][price]"])!="undefined"){sw=CheckForm(obj,"data[article_property][price]","Price")
if(sw&&obj.elements["data[article_property][price]"].value==""){alert("가격을 선택 해 주세요");obj.elements["data[article_property][price]"].focus();sw=false;};}
if(sw&&typeof(obj.elements["data[article_delicious][phone]"])!="undefined")sw=CheckForm(obj,"data[article_delicious][phone]","Phone");if(sw&&typeof(obj.elements["data[article_delicious][addr]"])!="undefined")sw=CheckForm(obj,"data[article_delicious][addr]","Address");if(sw&&typeof(obj.elements["data[article_delicious][area]"])!="undefined")sw=CheckForm(obj,"data[article_delicious][area]","Area");if(sw&&typeof(obj.elements["data[article_shopping][price]"])!="undefined")sw=CheckForm(obj,"data[article_shopping][price]","Price");if(sw&&typeof(obj.elements["data[article_shopping][original_price]"])!="undefined")sw=CheckForm(obj,"data[article_shopping][original_price]","Original Price");if(sw&&typeof(obj.elements["data[article_shopping][addr]"])!="undefined")sw=CheckForm(obj,"data[article_shopping][addr]","Address");if(sw&&typeof(obj.elements["data[article_shopping][phone]"])!="undefined")sw=CheckForm(obj,"data[article_shopping][phone]","Phone");if(sw&&typeof(obj.elements["data[article_shopping][email]"])!="undefined")sw=CheckForm(obj,"data[article_shopping][email]","Email");if(sw&&typeof(obj.elements["data[article_shopping][from_date]"])!="undefined")sw=CheckForm(obj,"data[article_shopping][from_date]","From date");if(sw&&document.getElementById("uploader")){var uploader=$('#uploader').plupload('getUploader');if(uploader.total.uploaded==0){if(uploader.files.length>0){sw=false;uploader.bind('UploadProgress',function(){if(uploader.total.uploaded==uploader.files.length){}});uploader.bind('UploadComplete',function(up,files){obj.target="iupload";obj.action="/board/article_add_proc.php";obj.submit();});uploader.start();}else{}}}
if(sw){obj.target="iupload";obj.action="/board/article_add_proc.php";obj.submit();}else{$("input[type='submit']",obj).css("display","inline");}}
function article_add_result(result){var obj=document.varform;switch(parseInt(result)){case 0:alert("Saved your article.");if(obj.article_id.value==""){location.href="/"+obj.request.value+"&mode=list";}else{location.href="/"+obj.request.value+"&mode=view";}
break;case 1:alert("Error in file upload.");break;case 2:alert("Unknown error.");break;case 3:alert("보유하신 포인트가 부족합니다.");break;case 4:alert("현재 작성하신 내용에 금지된 단어가 있어 게시물을 저장할 수 없습니다.");break;default:alert("Unknown error.");}}
function artcle_file_del(file_obj,file_id,board){var strURL="/board/article_file_del.php";var params="file_id="+file_id;params+="&board="+board;var sw=confirm("Would you like to delete this file?");if(sw){$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$("#"+file_obj).remove();alert("deleted.");},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}}
function boardtype_image_del(board_type,article_id,image_id){var strURL="/board/article_image_del.php";var params="article_id="+article_id;params+="&board_type="+board_type;params+="&image_id="+image_id;var sw=confirm("Would you like to delete this file?");if(sw){$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$("#"+image_id).html(msg);alert("deleted.");},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}}
function article_del(article_id){var strURL="/board/article_del.php";var params="article_id="+article_id;var sw=confirm("이 게시물을 삭제 하겠습니까?\nWould you like to delete this article?");if(sw){$.ajax({type:"POST",url:strURL,data:params,success:function(msg){alert("삭제되었습니다\n deleted.");if(navigator.userAgent.toLowerCase().indexOf('applewebkit')>-1){history.go(-2);}else{history.go(-1);}},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}}
function article_chng_status(status,article_id){var strURL="article_del.php";var params="article_id="+article_id;params+="&status="+status;var sw=confirm("이 게시물의 상태를 변경 하겠습니까?\nWould you like to change this article's status?");if(sw){$.ajax({type:"POST",url:strURL,data:params,success:function(msg){alert("상태가 변경 되었습니다\nArticle's status has been changed.");},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}}
function article_move(){var strURL="article_move.php";var params="";$.ajax({type:"POST",url:strURL,data:params,success:function(msg){modal_jQuery(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function article_move_proc(obj){var obj_select=document.getElementsByName("chk_item");var obj=obj.elements["board"];var strURL="article_move_proc.php";var params="board="+obj.value;for(i=0;i<obj_select.length;i++){if(obj_select[i].type=="checkbox"&&obj_select[i].checked){params+="&id[]="+obj_select[i].value;}}
$.ajax({type:"POST",url:strURL,data:params,success:function(msg){alert(msg);article_search();HideMe("modal");},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function article_secret(board,alias,article_id,action){var strURL="/board/article_secret.php";var params="board="+board;params+="&alias="+alias;params+="&article_id="+article_id;params+="&action="+action;$.ajax({type:"POST",url:strURL,data:params,success:function(msg){modal_jQuery(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function article_secret_proc(obj){var strURL="/board/article_secret_proc.php";var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$return=parseInt(msg);var request=location.href.split("?");var request=request[1]
switch($return){case 0:switch(obj.action.value){case"mod":location.href="/"+obj.alias.value+"?mode=write&"+params;break;case"del":article_del(obj.article_id.value)
break;}
HideMe("modal");break;case 1:alert("You can't access this article.");break;case 2:alert("Your password is wrong.");break;}},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function comment_show(article_id){var strURL="/board/comment_list.php";var params="article_id="+article_id;$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$("#board_comments").html(msg);show_comment_list($(".show_comment_list"));},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function comment_chk(obj){var sw=true;if(sw&&typeof(obj.elements["data[Comment][writer]"])!="undefined")sw=CheckForm(obj,"data[Comment][writer]","Nickname");if(sw&&typeof(obj.elements["data[Comment][password]"])!="undefined")sw=CheckForm(obj,"data[Comment][password]","Password");if(sw)sw=CheckForm(obj,"data[Comment][contents]","Comment");if(sw){var strURL="/board/comment_add_proc.php";var params=$(obj).serialize();var article_id=obj.elements["data[Comment][article_id]"].value;$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$result=parseInt(msg);switch($result){case 0:comment_show(article_id);break;case 1:alert("Error in store in DB.");break;case 4:alert("금칙어가 포함되어 있어 저장할 수 없습니다.");break;default:alert("Unknown error.");}},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}}
function comment_mod(comment_id){var strURL="/board/comment_mod_proc.php";var params="comment_id="+comment_id;$.ajax({type:"POST",url:strURL,data:params,dataType:"json",success:function(data){$.each(data,function(){$("input[name='comment_id']").val(comment_id);$("input[name='data[Comment][member_id]']").val(this["member_id"]);$("input[name='data[Comment][writer]']").val(this["writer"]);$("input[name='data[Comment][email]']").val(this["email"]);$("#comment_contents").val(urldecode(this["contents"])).focus();});location.href="#comment_write";},error:function(data,status,err){console.log("error forward : "+data);alert(err);HideMe("modal");}});}
function comment_del(comment_id){var obj=document.board_comment;var sw=confirm("Would you like to delete this comment?");if(sw){var strURL="/board/comment_del_proc.php";var params="comment_id="+comment_id;var article_id=obj.elements["data[Comment][article_id]"].value;$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$result=parseInt(msg);switch($result){case 0:comment_show(article_id);break;case 1:alert("Error in delete");break;default:alert("Unknown error.");}},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}}
function comment_password(comment_id){var strURL="/board/comment_pw.php";var params="comment_id="+comment_id;$.ajax({type:"POST",url:strURL,data:params,success:function(msg){modal_jQuery(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function comment_password_proc(obj){var strURL="/board/comment_pw_proc.php";var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$return=parseInt(msg);switch($return){case 0:comment_del(obj.comment_id.value);HideMe("modal");break;case 1:alert("Blocked by security.");HideMe("modal");break;case 2:alert("Wrong password.");break;}},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function show_comment_list(obj){if($(obj).text()=="펼쳐보기"){$("#comment_list").slideDown();$(obj).text("닫기");}else{$("#comment_list").slideUp();$(obj).text("펼쳐보기");}}
function article_recommend(article_id,member_id){var strURL="/board/article_evalue_proc.php";var params="data[article_evalue][article_id]="+article_id;params+="&data[article_evalue][member_id]="+member_id;params+="&data[article_evalue][evalue]="+1;$.ajax({type:"POST",url:strURL,data:params,beforeSend:function(){},success:function(msg){alert(msg);location.reload();},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");},complete:function(){}});}
function article_evalue(article_id){var strURL="/board/article_evalue.php";var params="article_id="+article_id;$.ajax({type:"POST",url:strURL,data:params,beforeSend:function(){},success:function(msg){modal_jQuery(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");},complete:function(){}});}
function article_evalue_proc(obj){if(obj.elements["data[article_evalue][evalue]"].value.trim()==""){alert("적어도 하나 이상의 평가를 선택 해 주시기 바랍니다.");return;}
var strURL="/board/article_evalue_proc.php";var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,beforeSend:function(){},success:function(msg){alert(msg);location.reload();},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");},complete:function(){}});}
function article_evalue_change(avg,id){if(id<2)id=2;document.modal_form.elements["data[article_evalue][evalue]"].value=id;var img_src="/images/deli/";for(i=1;i<=5;i++){var img_obj=document.getElementById("rate_"+i);if(i<=id){img_obj.src=img_src+"icon_evalue.png";}else{img_obj.src=img_src+"icon_evalue_r.png";}}}
function article_photo(article_id){var strURL="/board/article_photo.php";var params="article_id="+article_id;$.ajax({type:"POST",url:strURL,data:params,beforeSend:function(){},success:function(msg){modal_jQuery(msg);init_plupload();},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");},complete:function(){}});}
function article_photo_proc(obj){var sw=true;if(sw)sw=CheckForm(obj,"data[Comment][contents]","comment")
if(sw&&$("input[name='uploader_0_status']").val()!="done"){alert("You should upload photo file at least 1");sw=false;}
if(sw){var strURL="/board/article_photo_proc.php";var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,beforeSend:function(){},success:function(msg){alert(msg);location.reload();},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");},complete:function(){}});}}
function show_mypage(category,alias){var obj=document.paging;obj.category.value=category;obj.alias.value=alias;var strURL="/board/skin_mypage.php";var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,success:function(msg){$("#"+alias).html(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
function show_search(category,alias){var obj=document.paging;obj.category.value=category;obj.alias.value=alias;if(category=="05"){var strURL="/board/skin_search_biz.php";}else{var strURL="/board/skin_search.php";}
var params=$(obj).serialize();$.ajax({type:"POST",url:strURL,data:params,beforeSend:function(){if($("#"+alias).html()==""){$("#"+alias).html("<div class='noList'><img src='/images/common/progress_1.gif' /></div>")}},success:function(msg){$("#"+alias).html(msg);},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");},complete:function(){HideMe("modal");}});}
function send_email(member_id){var strURL="/board/send_email.php";var params="member_id="+member_id;$.ajax({type:"POST",url:strURL,data:params,success:function(msg){if(msg!=""){location.href="mailto:"+msg;}},error:function(data,status,err){console.log("error forward : "+data);alert('Server networking error.');HideMe("modal");}});}
