
$jquery('#JumpToComment')
  		.bind('click', function() {
      	var $panel = $jquery('#container');
      	$panel[0].scrollTo( $jquery(this.hash).offset().top - $panel.offset().top );
      	return false;
  	});
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}			

function showCommentForm(ContentId,ParentCommentId)	{
	blockUI();
        var url = "/gospot/ajax.ShowCommentForm/ContentId/" + ContentId + "/ParentCommentId/" + ParentCommentId;
	$jquery('#AddCommentFormTop'+ContentId).load(url);
    $jquery('#AddCommentFormTop'+ContentId).fadeIn(500);
	return false;
}
function toggleCommentForm(id,callbackElement){
	var element = document.getElementById(callbackElement);
    if (element.style.display=='block'){
    	$jquery('#'+callbackElement).fadeOut(500);
	}
	else {
		showCommentForm(id,callbackElement);
	} 
}
function showComments(id)	{
	var url = "/gospot/ajax.DisplayContentComments/ContentId/" + id;
	blockUI();
	$jquery('#Comments'+id).load(url);
	$jquery('#Comments'+id).fadeIn(500);
	return false;
}
function toggleComments(id){
	var element = document.getElementById("Comments" + id);
    if (element.style.display=='block'){
    	$jquery('#Comments'+id).fadeOut(500);
		$jquery('#Comments'+id).html("<h3>Loading....</h3><img src='/images/loader-bar.gif' />");
	}
	else {
    	//$jquery('#Comments'+id).fadeIn(500);
		showComments(id);
	} 
}
function showReplyForm(ContentId,CommentId)	{
	showCommentForm(ContentId,CommentId);
	$jquery('#endcontentbody'+ContentId).ScrollTo(700,"easeout");
}
function submitComment(id){
	var Text = $jquery("#CommentTextArea"+id).val();
	var Form = eval("document.frmCommentForm"+id);
	if (Text.length > 0){
		var ResponseCount = 0;
		blockUI();
		$jquery('#CommentForm'+id).fadeOut(500);
		$jquery('#CommentFormLoading'+id).fadeIn(500);
		$jquery.ajax({
			type: "POST",
 				url: "/gospot/ajax.SubmitComment",
 				async: false,
 				data: "Email=" + Form.Email.value + "&Text=" + Text + "&Password=" + Form.Password.value + "&Name=" + Form.Name.value + "&GuestEmail=" + Form.GuestEmail.value + "&PostAsUser=" + getCheckedValue(Form.PostAsUser) + "&ContentId=" + id  + "&ParentCommentId=" + Form.ParentCommentId.value + "&Subscribe=" + Form.Subscribe.checked,
 				dataType: "script",
 				success: function() { 
 					if (!ResponseCount++)	{
					$jquery('#CommentFormLoading'+id).html(ResultMessage);
 						if (CommentId && ReloadComments)	{
						showComments(id);
						updateCommentCount(id);
 						}
 					} 
 				} 
 			});
		return false;
	}
}			
function updateCommentCount(id)	{
	$jquery('#CommentCount'+id).load("/gospot/ajax.UpdateCommentCount/ContentId/"+id);
}	
function togglereplies(id){
	try	{
	var element = document.getElementById('messagereplies'+id);
    if (element.style.display=='block'){
		$jquery('#messagereplies'+id).fadeOut(500);
		$jquery('#viewreplies'+id).show();		
	}
	else {
		$jquery('#messagereplies'+id).fadeIn(500);
		$jquery('#viewreplies'+id).hide();	
	} 
	}
	catch (excpt) { /* nothing */ }
}
function vote(direction,id){

	showLoginForm();

}

			