$(document).ready(function(){
	// Form validations
	$("#postForm").validate();
	$("#commentForm").validate();
	$("#contactForm").validate();
	$("comment_wrapper_new").hide();
	//Submit vote for dislike
	$("a.dislike").each(function(){
		
		$(this).click(function(){
			$.post("/index.php/dislike", { ajax_request: "1", post_id: $(this).attr("name") },
				function(data){
					if(data != "false")
					{
						var current_value = $("#dislike_" + data).html();
						current_value++;
						$("#dislike_" + data).html(current_value);
						// Change value
					} else {
						// Do nothing
					}
						
				});
		});
	})	
	
	//Submit vote for like
	$("a.like").each(function(){
		
		$(this).click(function(){
			$.post("/index.php/like", { ajax_request: "1", post_id: $(this).attr("name") },
				function(data){
					if(data != "false")
					{
						var current_value = $("#like_" + data).html();
						current_value++;
						$("#like_" + data).html(current_value);
						// Change value
					} else {
						// Do nothing
					}
						
				});
		});
	})
	//Comment submit form
	//$("#commentForm").submit(function(){
	//		alert('asdss');
	//		$.post("/index.php/comment", {
	//			ajax_request: "1",
	//			post_id: $("input#post_id").val(),
	//			author_name: $("input#cname").val(),
	//			author_email: $("input#cemail").val(),
	//			comment: $("textarea#cbody").val()
	//		}, function(data){
	//			alert('asd');
	//			//$('#comment_form').html("<div id='message'></div>");
	//			//$('#message').html("<h2>Comment Submitted!</h2>").append("<p>Thank you!</p>").html(data);
	//			//$("comment_wrapper_new").fadeIn(1500)
	//		});
	//})
});
