// JavaScript Document

function viewComments(blogID) {
	var div = document.getElementById("BlogComments"+blogID)
	var val = div.style.display;
	if (val == "none") {
		div.style.display = "block";
	} else {
		div.style.display = "none";
	}
	return false;
}

function addCommentForm(blogID) {
	document.getElementById("CommentBlogID").value = blogID;
	document.getElementById("AddComment").style.display = "block";
	return false;
}

function closeCommentForm() {
	document.getElementById("AddComment").style.display = "none";
	return false;
}

function checkAddComment() {
	//alert(document.getElementById("CommentBlogID").value);
	var isOK = 1;
	var FullName = document.getElementById("FullName").value;
	var WhereFrom = document.getElementById("WhereFrom").value;
	var Comment = document.getElementById("Comment").value;
	var allContent = " "+Comment+" "+WhereFrom+ " "+FullName;
	
	if (FullName == "" || WhereFrom == "" || Comment == "") {
		alert("Please complete all fields");
		return false;
	} else {
		if (allContent.indexOf("<") > 0) { isOK = 0; }
		if (allContent.indexOf(">") > 0) { isOK = 0; }
		if (allContent.indexOf("[url") > 0) { isOK = 0; }
		if (allContent.indexOf("[URL") > 0) { isOK = 0; }
		if (allContent.indexOf("http") > 0) { isOK = 0; }
		if (allContent.indexOf("www.") > 0) { isOK = 0; }
		if (isOK == 0) {
			alert("Form contains invalid characters");
			return false;
		} else {
			document.AddCommentForm.action = "/library/AddReview.asp";
			return true;
		}
	}
}

function openextract(page) { 
	window.open (page, 'newwindow', config='height=370, width=330, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}

function addReviewForm() {
	document.getElementById("AddReview").style.display = "block";
}

function closeReviewForm() {
	document.getElementById("AddReview").style.display = "none";
}

function checkAddReview() {
	//alert(document.getElementById("CommentBlogID").value);
	var isOK = 1;
	var Reviewer = document.getElementById("Reviewer").value;
	var Email = document.getElementById("Email").value;
	var Review = document.getElementById("Review").value;
	var allContent = " "+Reviewer+" "+Email+ " "+Review;
	if (Reviewer == "" || Email == "" || Review == "") {
		alert("Please complete all fields");
		return false;
	} else {
		if (allContent.indexOf("<") > 0) { isOK = 0; }
		if (allContent.indexOf(">") > 0) { isOK = 0; }
		if (allContent.indexOf("[url") > 0) { isOK = 0; }
		if (allContent.indexOf("http") > 0) { isOK = 0; }
		if (allContent.indexOf("www.") > 0) { isOK = 0; }
		if (isOK == 0) {
			alert("Form contains invalid characters");
			return false;
		} else {
			document.AddReviewForm.action = "/library/AddReview.asp";
			return true;
		}
	}
}