// settings
/*	emailURL = "/movies/email.html?title=%%title%%&url=%%url%%";
	printURL = "/movies/article_print.html?id=%%id%%";
	similarURL = "/movies/search.html?similar=%%url%%";
*/

// rating functions
	function toggleEdit(currItem, editItem)	{
		if (document.getElementById) {	
			my_div = document.getElementById(currItem).style;
			my_div.display = (my_div.display == "none") ? "inline" : "none";	
			my_div = document.getElementById(editItem).style;
			my_div.display = (my_div.display == "inline") ? "none" : "inline";	
			return false;
		}
		else {				
			return true;
		}
	}
	
	function returnStar(hidestar, showstars, starimg, theRating, theForm)	{
		if (document.getElementById) {	
			my_vote = document.getElementById(hidestar).style;
			my_result = document.getElementById(showstars).style;
			my_img = document.getElementById(starimg);
			my_vote.display = (my_vote.display == "none") ? "inline" : "none";	
			my_result.display = (my_result.display == "inline") ? "none" : "inline";				
			
			switch(theRating) {
				case "1":
					my_img.src = "/movies/comments/img/stars-1.gif";
					theForm.rating.value = '25';
					break;
				case "2":
					my_img.src = "/movies/comments/img/stars-2.gif";
					theForm.rating.value = '50';
					break;
				case "3":
					my_img.src = "/movies/comments/img/stars-3.gif";
					theForm.rating.value = '75';
					break;
				case "4":
					my_img.src = "/movies/comments/img/stars-4.gif";
					theForm.rating.value = '100';
					break;
				default:
					my_img.src = "/movies/comments/img/stars-0.gif";
					theForm.rating.value = '0';
					break;
				}
			return false;
		}
		else {				
			return true;
		}
	}
	

	function validateDelete(theName){
		msg = confirm("Are you sure you want to delete the comment from " + theName + "?");
		if (msg==true) {
			return true;
		}
		return false;
	}	

	function validateUserDelete(){
		msg = confirm("Are you sure you want to delete your comment?");
		if (msg==true) {
			return true;
		}
		return false;
	}		
	
	function checkStarRate(theForm){
		/*if (theForm.rating.value == '0') {
			alert("Please select a Star Rating")
			return false;
		}*/
		return true;
	}

	var form_submitted = false;	
	
	function submitRateForm(theForm) {
		if (checkStarRate(theForm)) {
			if (form_submitted) {
				alert ("Your form has already been submitted. Please wait...");
				return false;
			} else {
				form_submitted = true;
				return true;
			}	
			return true;	
		} else {
			return false;
		}		
	}

// limit characters in a text area
	//
	// Usage:
	// <span id="limitText"><strong>1000</strong> characters remaining</span>
	// <textarea name="#" id="#" onkeyup="charCount(this,1000)" />
	//
	// Note: change limit of characters as needed
	//
	
	function charCount(what, maxCount) {
		var str = new String(what.value);
		var len = str.length;
		var limitSpan = document.getElementById("limitText");
		
		len = maxCount - len;
		
		if (document.getElementById) {	
			if (len < 0) {
				what.value = what.value.substring(0, maxCount);
			} else if (len > 1) {
				limitSpan.innerHTML = "<strong>" + len + "</strong> characters remaining";
			} else {
				limitSpan.innerHTML = "<strong>" + len + "</strong> character remaining";
			}
		}
	}
		
	function validateMessageBox() {
		var my_textarea = document.getElementById("message");
		if (my_textarea && my_textarea.value.length > 1000) {
			alert("Please limit your response to 1000 characters maximum.");
			return false;
		} else {
			return true;
		}
	}

	function stripURL(urlinput) { 
		urlString = new String(urlinput.value)
		strip_start = urlString.lastIndexOf('/');
		strip_end = urlString.length;
		strip_string = (urlString.substring(strip_start+1, strip_end)); 
		urlString ='http://christianitytoday.com/movies/comments/admin?url='+strip_string ;
		return(urlString);
		
	}