$(document).ready(function() {

	/* Signup form */
	
	$('#inscriptionform').submit(function() {
		$('#loadinginscription').show();
		$.ajax({
  			type: 'POST',
			data: $("#inscriptionform").serialize(),
			success: function(data){
				$('#loadinginscription').hide();
				if(data.iserror){
					$('#resultinscription').html(data.message).fadeIn(500);
				}
				else{
					$('#resultinscription').html(data.message).fadeIn(500);
				}
			},
			dataType: 'json'
		});									  
		return false;
	});

	/* Comment Form */
	
	$("#commentForm").submit(function() {
	$(this).ajaxSubmit({
				beforeSubmit: function(before) {
				$('#loadingcomment').css('display','block');
				$("#resultcomment").html('');
				$("#resultcomment").css('display','none');
				},
				success: function(data) {
					$('#loadingcomment').css('display','none');
					if(data.iserror){
						$('#resultcomment').html(data.message).fadeIn(500);
					}
					else{
						$('#resultcomment').html(data.message).fadeIn(500);
						var count = $('div.user_comments').length;
						comment = data.comment;
						comment = comment.replace(/comment_no/g, count+1);
						$('.cmt').append(comment).fadeIn('slow').fadeOut('slow').fadeIn('slow');
					}
					//setTimeout("$('#resultsubmit').fadeOut();",5000);
				},
				dataType: 'json'
		}); 
		return false;
	});
	
	$("#passwordform").submit(function() {
		$(this).ajaxSubmit({
			beforeSubmit: function(before) {
				$('#loadingpassword').css('display','block');
				$("#resultpassword").html('');
				$("#resultpassword").css('display','none');
			},
			success: function(data) {
				$('#loadingpassword').css('display','none');
				$('#resultpassword').html(data).fadeIn(500);
			}
		}); 
		return false;
	});
});