function commentResize()
{
	if(document.getElementById("commentBoxResize").innerHTML == 'Make Bigger') {
		document.getElementById("commentComment").style.height = "300px";
		document.getElementById("commentBoxResize").innerHTML = 'Make Smaller';
	} else {
		document.getElementById("commentComment").style.height = "100px";
		document.getElementById("commentBoxResize").innerHTML = 'Make Bigger';
	}
}

function commentValidateForm(form)
{
	var errorcount = 0;
	with(form)
	{
		nam = commentName.value;
		www = commentWebsite.value;
		comment = commentComment.value;
		email = commentEmail.value;
		// reset classnames
		commentName.className = 'commentFormOK';
		commentEmail.className = 'commentFormOK';
		commentWebsite.className = 'commentFormOK';
		commentComment.className = 'commentFormOK';
		if(!nam.match(/[A-Z\-\' ]{4,}/i))
		{
			errorcount++;
			commentName.className = 'commentFormError';
		}
		if(!email.match(/^([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})$/i))
		{
			errorcount++;
			commentEmail.className = 'commentFormError';
		}
		if(www!='http://'&&www!='')
		{
			if(!www.match(/^http:\/\/([\w\d:#@%\/;$\(\)~_\?\+\-=\\\.&])+\.[A-Z]{2,4}(\/?[\w\d:#@%\/;$\(\)~_\?\+\-=\\\.&]+)*$/i))
			{
				errorcount++;
				commentWebsite.className = 'commentFormError';
			}
		}
		if(comment.match(/((<script.+?<\/script>)|(<a.+?<\/a>))/im))
		{
			
			errorcount++;
			commentComment.className = 'commentFormError';
		}
		if(comment.length<20)
		{
			errorcount++;
			commentComment.className = 'commentFormError';
		}

	}
	
	if(errorcount>0)
	{
		document.getElementById("commentFormMessage").className = 'commentCommentNote commentFormError';
	}
	return errorcount == 0;
}

function checkCommentLength(form)
{
	var cStart = form.selectionStart;
	var cEnd = form.selectionEnd;
	var remainder = 1000-form.textLength;
	if(remainder<1)
	{
		
		form.value = form.value.substring(0,1000);
		remainder = 0;
	}
	document.getElementById("commentLength").innerHTML = remainder;
	/*form.selectionStart = cStart;
	form.selectionEnd = cEnd;*/
}

// here are some useful regular expressions
var ALPHAREGEX = "\w\-\' ";
var PUNCTREGEX = "!\"£$%&\(\)_\?,\.;:";
var EMAILREGEX = "(?i)[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}";
var WWWREGEX = "http:\/\/([\w\d:#@%\/;$\(\)~_\?\+\-=\\\.&])+\.[A-Z]{2,4}";
var SCRIPTREGEX = "<script.+?<\/script>";
var LINKSREGEX = "<a.+?<\/a>";


