
function submit_formt(form) {
	var inputs = $(form).serialize();
	
	$.ajax({
		url: "/en/1/commentsubmit.obyx?nId="+$("input#nId").val(),
		type: "POST",
		data: inputs + '&nId=' + $("input#nId").val() + '&modGroup=' +$("input#modGroup").val(),
		complete: function() {
			//called when complete
		},

		success: function(html) {
			//called when successful
			if($(html).find('form').length >= 1)
			{
				$('#SubmitComment').empty().html($(html).find('form').parent().html());
			}
			else
			{
				$('#SubmitComment').empty().html($(html).find('h3').parent().html());
			}
			$('form').submit(function() {
				submit_formt(this);
				return false;
			});
		},

		error: function() {
			//called when there is an error
		}
	});
}

$(document).ready(function() {
	if(window.commentLoaderRun != true)
	{
	
	var nId = $("input#nId").val();
	var modGroup = $("input#modGroup").val();
	
	if ($('.commentContainer').length >= 1) {
		$('.commentContainer').load('/en/1/commentformp.obyx?nId='+nId+'&modGroup='+modGroup,function(){
		var nId = $(".commentContainer").attr("id");

		$("#SubmitComment").css("display","none");
		$("a#commentSubmitToggle").click(
		  function () {
		    $("div.CommentsBottom").hide();
		    $("div#SubmitComment").slideDown("fast");
		    return false;
		  });


	$(".full").hide();
	$("a.CommentToggle").css({display: 'block'});
	$("a.CommentToggle").click(function () {
		if($(this).is('.Open')) {
			$(this).siblings(".full").hide();
			$(this).siblings(".intro").show();
			$(this).text("Open");
			$(this).removeClass("Open");
		} else {
			$(this).siblings(".intro").hide();
			$(this).siblings(".full").show();
			$(this).text("Close");
			$(this).addClass("Open");
		}
		return false;
	});


		$('#wtLink').click(function(){
			$('div.whatsThis').slideDown();
			return false;
		});
		$('form').submit(function() {
			submit_formt(this);
			return false;
		});
	});
	
	};
	window.commentLoaderRun = true;
	}
});