/*#################################################
 * °Ô½ÃÆÇ ³»¿ëº¸±â ÆäÀÌÁö ½ºÅ©¸³Æ® ±â´É ÆÄÀÏ
 ###################################################*/

function comment_Valid(){
	var session_id = jQuery("#session_id").val();
	if( session_id == "" ){
		alert("·Î±×ÀÎÀ» ÇÏ½Å ÈÄ¿¡ µî·ÏÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");
		return false;
	}
	if(jQuery("#notice_yn").attr("checked")){
		jQuery("#notice_yn").val("Y");
	}

	if(jQuery("#secret_yn").attr("checked")){
		jQuery("#secret_yn").val("Y");
	}
	var contents = jQuery.trim(jQuery("#contents").val());
	if( contents.length < 1 ){
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼Å¾ß µË´Ï´Ù.");
		return false;
	}

	return true;
}

function func_commentwrite(){
	if(comment_Valid()){
		jQuery.getJSON(context + "/board.do",
				{mode : 'insertComment',
				brd_seq : jQuery("#brd_seq").val(),
				mod_id : jQuery("#mod_id").val(),
				notice_yn : jQuery("#notice_yn").val(),
				secret_yn : jQuery("#secret_yn").val(),
				contents :  encodeURIComponent(jQuery("#contents").val())
				},
				function(data){
					jQuery("#comment").html("").html(data.result);
					/*
					jQuery("#comment img").not("#comm_write img").each(function(){
				  		jQuery(this).attr("src",skin_path+"/"+jQuery(this).attr("src"));
				 	});*/
				}
		);
		jQuery("#contents").val("");
	}
}

function func_comm_page( num ){
	jQuery("#comment_current_page").val( num );
	jQuery.getJSON(context + "/board.do",
			{mode : 'comment',
			brd_seq : jQuery("#brd_seq").val(),
			mod_id : jQuery("#mod_id").val(),
			paging_size : jQuery("#comment_paging_size").val()+"",
			current_page : jQuery("#comment_current_page").val()+"",
			first_row : (1+jQuery("#comment_paging_size").val()*(parseInt(jQuery("#comment_current_page").val())-1)) ,
			last_row : (jQuery("#comment_current_page").val()*jQuery("#comment_paging_size").val())
			},
			function(data){
				jQuery("#comment").html("").html(data.result);
				/*
				jQuery("#comment img").each(function(){
			  		jQuery(this).attr("src",skin_path+"/"+jQuery(this).attr("src"));
			 	});*/
			}

	);
}


function func_removeComm( comm_seq ) {
	if(confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) {
		jQuery.getJSON(context + "/board.do",
				{mode : 'deleteComment',
				brd_seq : jQuery("#brd_seq").val(),
				mod_id : jQuery("#mod_id").val(),
				comm_seq : comm_seq
				},
				function(data){
					jQuery("#comment").html("").html(data.result);
					/*
					jQuery("#comment img").each(function(){
				  		jQuery(this).attr("src",skin_path+jQuery(this).attr("src"));
				 	});*/
				}
		);
	}
}

function func_modifyComm( comm_seq ) {
	var param = "?mode=commentModifyForm&comm_seq="+comm_seq+"&brd_seq="+jQuery("#brd_seq").val()+"&mod_id="+jQuery("#mod_id").val();
	popup(context+"/board.do"+param,"POPUP" ,400, 255);
}


function func_delete(){
	if(confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) {
		var queryString = "";
		if( jQuery("#query_string").val().length > 0 ) {
			queryString = "?"+jQuery("#query_string").val();
		}
		document.nf.action = jQuery("#page_control").val() + queryString;
		jQuery("#cmd").val("D");
		document.nf.submit();
	}

}

function func_loadComm() {
	jQuery.getJSON(context + "/board.do",
			{mode : 'comment',
			brd_seq : jQuery("#brd_seq").val(),
			mod_id : jQuery("#mod_id").val()
			},
			function(data){
				jQuery("#comment").html("").html(data.result);
				/*
				jQuery("#comment img").each(function(){
			  		jQuery(this).attr("src",skin_path+jQuery(this).attr("src"));
			 	});*/
			}
	);
}



