var loading = $("#loading");
var comments = $("#comments");
var more = $("#more");
var target_page, query, now_showing, total_cmts, sm_pg;


function showLoading(){
	loading.slideDown("slow");
}

function hideLoading(){
	loading.slideUp("slow");
};

function update_now()
{
	now_showing = parseInt($("#now_showing").attr("value")) + parseInt($("#show_more").attr("value"));
	$("#now_showing").attr("value", now_showing );
	
	total_cmts = parseInt($("#total_cmts").attr("value"));
	if(now_showing >= total_cmts)
		more.slideUp("slow");
}

more.click(function(){
	showLoading();
	
	sm_pg = $("#sm_pg").attr("value");
	
	if(sm_pg == "7e0frugf4jf83j39ryh29f732y9r3y9hd9")
	 target_page = "bx-autoinfo/show-more-autoinfo.php";
	else if(sm_pg == "8e20032b736bc4adf8bab3b3f76d0f25")
	 target_page = "bx-eventmore/show-more-event.php";
	else if(sm_pg == "55205e333b34b0e35b09ecb97e318f37")
	 target_page = "bx-merchandise/show-more-merchandise.php";
	else if(sm_pg == "410e741dec9ed486bb50984dcf4b19cd")
	 target_page = "bx-innovtech/show-more-innovtech.php";
	else if(sm_pg == "dd906aa227a3b9a2e4ae6677e0edc52f")
	 target_page = "bx-commnews/show-more-commnews.php";
	else if(sm_pg == "gfew98fyu94ef9u329u9f9e8y94y93fh4")
	 target_page = "bx-comment/show-more-comment.php";
	else if(sm_pg == "yj93jdjf97aefau934hidvhu793uh")
	 target_page = "bx-review/show-more-review.php";

	query = $("#myForm").serialize();
	
	$.post(target_page, query , function(data){
		comments.append(data);
		hideLoading();
		update_now();
	});
});

hideLoading();
