$(document).ready(
	function()
	{
		$(".fullUserComment").css("height", "47px");
	}
);


function funcShowUserCommentAddBox()
{
	var addCommentBox = $("#userCommentAdd");
	//alert (addCommentBox.width());
	
	$("#txtName").val("");
	$("#txtTown").val("");
	$("#txtEmail").val("");
	$("#txtComment").val("");
	$("#commentMessage").html("").hide();
	
	//if (addCommentBox.is(":hidden"))
		addCommentBox.vCenter().fadeIn("slow");
	//else
		//addCommentBox.fadeOut("slow");
	
	return false;
}

function funcAddUserComment()
{
	var strName = $.trim($("#txtName").val());
	var strTown = $.trim($("#txtTown").val());
	var strEmail = $.trim($("#txtEmail").val());
	var strComment = $.trim($("#txtComment").val());
	var iCommentID = $("#ci").val();
	
	
	if (strName == "")
	{
		funcShowAddUserCommentMessage("Please give your name");
		$("#txtName").focus();
	}
	else if (strTown == "")
	{
		funcShowAddUserCommentMessage("Please give your town");
		$("#txtTown").focus();
	}
	else if (strEmail == "")
	{
		funcShowAddUserCommentMessage("Please give your email");
		$("#txtEmail").focus();
	}
	else if (!func_is_email(strEmail))
	{
		funcShowAddUserCommentMessage("Please give a valid email");
		$("#txtEmail").focus();
	}
	else if (strComment == "")
	{
		funcShowAddUserCommentMessage("Please give your comment");
		$("#txtComment").focus();
	}
	else
	{
		$.ajax(
			{
				url:		"index.php?fuseaction=comment.insertusercomment",
				type:		"POST",
				dataType:	"script",
				data:		"name=" + strName + "&town=" + strTown + "&email=" + strEmail + "&comment=" + strComment + "&commentid=" + iCommentID,
				beforeSend: function()
							{
								
							},
				success:	function(reply)
							{
								
							},
				error:		function()
							{
								
							},
				complete:	function()
							{
								
							}
			}
		);
	}
	
	return false;
}

function funcShowAddUserCommentMessage(strMessage)
{
	var objCommentMessage = $("#commentMessage");
	objCommentMessage.fadeOut(function(){objCommentMessage.html(strMessage); }).fadeIn("slow"); //.animate({"background-color" : "#FFFFFF"}, 2000).fadeOut("slow");
	//objCommentMessage.css("width", "1px").html("Please give your email").animate({width: "430px"}, "slow").animate({width: "430px"}, 2000).animate({width: "1px"}, "slow");
}

function funcHideAddUserCommentDiv()
{
	$("#userCommentAdd").fadeOut("slow");
	return false;
}

function funcHideUserAddCommentMessageBox()
{
	$("#userCommentAddResult").fadeOut("slow");
	return false;
}

function funcShowUserCommentList()
{
	if ($("#userCommentList").is(":hidden"))
	{
		
		$("#userCommentList").slideDown("slow", function() { $("#readCommentsLink").html("Hide comments"); window.location= "#comments";  });
	}
	else
	{
		
		$("#userCommentList").slideUp("slow", function(){ $("#readCommentsLink").html("Read comments");  });
	}
	//return false;
}

function funcShowUserFullComment(innerCommentID, fullCommentID, linkID)
{
	contentHeight = $("#" + innerCommentID).height();
	currentHeight = $("#" + fullCommentID).height();
	
	if (currentHeight == 47)
	{
		$("#" + linkID).html("Hide details ...");
		$("#" + fullCommentID).animate({height : contentHeight + "px"}, "slow");
	}
	else
	{
		$("#" + linkID).html("Click for more ...");
		$("#" + fullCommentID).animate({height : "47px"}, "slow");
	}
	
	return false;
}
