
function displayCharCountSum(id)
{	
    var text_area_id = "txtCommentSum" + id;
	var boxLength = getTextBoxLength(text_area_id);

	var txtComment = getElement(text_area_id);

	if (boxLength > maxCommentChar)
	{
		window.alert("Your message can have a max of " + maxCommentChar + " characters");
	
		txtComment.value = txtComment.value.substring(0, maxCommentChar);
		boxLength = getTextBoxLength(text_area_id);
	}
	
	var characterCount = document.getElementById("characterCountSum" + id);
	characterCount.innerHTML = (maxCommentChar - boxLength);
}
	
function openReplyFormSum(userReviewId)
{
	var txtComment = document.getElementById('txtCommentSum');
	
	txtComment.disabled = true;
	txtComment.style.backgroundColor = "#e2e2e2";

    var div = getDiv("replySum_" + userReviewId);
	if (div) {
		div.className = div.className.replace(/hide/, "show");
	}
	
	ieFix();
	selectedUserReview = userReviewId;
}

function cancelReplySum(userReviewId) {
	var txtComment = document.getElementById('txtCommentSum');
	
	txtComment.disabled = false;
	txtComment.style.backgroundColor = "#fff";

    var div = getDiv("replySum_" + userReviewId);
	if (div) {
		div.className = div.className.replace(/show/, "hide");
	}
	
    var txt = getDiv("txtCommentSum" + userReviewId);
	if (txt) {
		txt.value = "";
	}
	ieFix();
    
	selectedUserReview = 0;
}

function submitReplySum(userReviewId, movieId, typeid) {
	var txtComment = document.getElementById('txtCommentSum');
	
	txtComment.disabled = false;
	txtComment.style.backgroundColor = "#fff";

	if (getTextBoxLength('txtCommentSum' + userReviewId) < minCommentChar)
	{
		window.alert("Your reply must be at least " + minCommentChar+ " characters");
	    return;
	}
	var txt = getDiv('txtCommentSum'+userReviewId);
	if (txt && movieId) {
	    backendSubmitReviewSum(movieId, txt.value, typeid);
	}
	// hide things again;
	cancelReply(userReviewId);
}

function submitReviewSum(movieid,typeid) {
	if (getTextBoxLength('txtCommentSum') < minCommentChar)
	{
		window.alert("Your message must be at least " + minCommentChar+ " characters");
	    return;
	}
	
	backendSubmitReviewSum(movieid, document.getElementById('txtCommentSum').value,typeid);
	document.getElementById('txtCommentSum').value = "";
	// this is a link activated script;
	//return false;
}

function cancelReviewSum() {
	var txtComment = document.getElementById('txtCommentSum');
	txtComment.value = "";
}

function backendSubmitReviewSum(movieid, txt, typeid)
{
	var toPost = "reviewtext=" + encodeURI(txt) + "&";
	toPost += "objectid=" + movieid + "&";
	toPost += "typeid=" + typeid + "&";
	toPost += "parentid=" + selectedUserReview + "&";
	toPost += "subjecttext=&";
	toPost += "siteguid=" + getCookie('__REELZ_ACCOUNT_ID');

	makeRequest(BASE_URL + "data/adduserreview.aspx", reviewSubmittedSum, toPost);
	
	ieFix();
}

function reviewSubmittedSum()
{
	 if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var response = http_request.responseText;
	        
			if (response.length > 0)
			{
				var divUserReviews = document.getElementById("divUserReviewList");
				
				divUserReviews.innerHTML = response;
                var scripts = divUserReviews.getElementsByTagName("SCRIPT");
                for (var i = 0; i < scripts.length; i++) {
                    eval(scripts[i].innerHTML);
                }
                changeCurrentTo(document.getElementById('comments').parentNode) 
              document.documentElement.scrollTop = 0;
			}
			
			ieFix();
		}
	}
}

function submitReviewRatingSum(ratingId, rating)
{
	var toPost = "rating=" + rating + "&";
	toPost += "userreviewid=" + ratingId + "&";
	toPost += "siteguid=" + getCookie('__REELZ_ACCOUNT_ID');

	makeRequest(BASE_URL + "data/adduserreviewrating.aspx", reviewRatingSubmittedSum, toPost);
	
	return false;
}


function reviewRatingSubmittedSum()
{
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var response = http_request.responseText;
	        
			if (response.length > 0)
			{
				var aryRatingInfo = response.split(':');
				
				var ratingContainer = document.getElementById("ratingSum" + aryRatingInfo[0]);
				ratingContainer.innerHTML = aryRatingInfo[1];
			}
		}
	}
}

function submitRatingReportSum(ratingId)
{
	var answer = confirm("Are you sure you want to report this?");
	if (answer)
	{
		var author = document.getElementById("authorSum" + ratingId).innerHTML;
		var comment = document.getElementById("commentSum" + ratingId).innerHTML;
		
		var toPost = "author=" + encodeURI(author) + "&";
		toPost += "comment=" + encodeURI(comment) + "&";
		toPost += "location=" + encodeURI(window.location) + "&";
		toPost += "ratingid=" + ratingId;

		makeRequest(BASE_URL + "data/senduserreviewreport.aspx", ratingReportSubmitted, toPost);
		
		var reported = document.getElementById("reported" + ratingId);
		reported.innerHTML = "abuse reported";
	}
}




