function css_9thrace_menu()
{
	if(navigator.appVersion.indexOf("MSIE")==-1){return;}
	var i,k,g,lg,r=/\s*hvr/,nn='',c,cs='hvr',bv='menubar';
	for(i=0;i<10;i++){g=document.getElementById(bv+nn);if(g){
	lg=g.getElementsByTagName("LI");if(lg){for(k=0;k<lg.length;k++){
	lg[k].onmouseover=function(){c=this.className;cl=(c)?c+' '+cs:cs;
	this.className=cl;};lg[k].onmouseout=function(){c=this.className;
	this.className=(c)?c.replace(r,''):'';};}}}nn=i+1;}
}

function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	}
	else
	{
		countfield.value = maxlimit - field.value.length;
	}
}

function autoTab(element, nextElement)
{
	if (element.value.length == element.maxLength && nextElement != null)
	{
		element.form.elements[nextElement].focus();
	}
}

function trim(stringToTrim)
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim)
{
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim)
{
	return stringToTrim.replace(/\s+$/,"");
}

function validateEmail(elementValue)
{
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return emailPattern.test(elementValue);
}

function removeHTMLTags(htmlContent)
{
	/*
		This line is optional, it replaces escaped brackets with real ones,
		i.e. &lt; is replaced with < and &gt; is replaced with >

	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
		return (p1 == "lt")? "<" : ">";
	});
	*/
	var strTagStrippedText = htmlContent.replace(/<\/?[^>]+(>|$)/g, "");
	return strTagStrippedText;
}

function processComments()
{
	var userName = trim(removeHTMLTags(document.comments.name.value));
	document.comments.name.value = userName;
	var nameLength = userName.length;

	var userEmail = trim(removeHTMLTags(document.comments.email.value));
	document.comments.email.value = userEmail;
	var emailLength = userEmail.length;

	var userComments = trim(removeHTMLTags(document.comments.content.value));
	document.comments.content.value = userComments;
	var commentsLength = userComments.length;

	var userVerify = trim(removeHTMLTags(document.comments.imgverify.value));
	document.comments.imgverify.value = userVerify;
	var verifyLength = userVerify.length;

	var readyToSubmit = 1;

	if (nameLength == 0)
	{
		alert("You must enter your name in the box provided to leave a comment!");
		readyToSubmit = 0;
	}
	else if ((emailLength == 0) || (!validateEmail(userEmail)))
	{
		alert("You must enter your e-mail address in the box provided to leave a comment!");
		readyToSubmit = 0;
	}
	else if ((verifyLength < 6) || (verifyLength > 6))
	{
		alert("You must enter the correct number of characters in the image verification box!");
		readyToSubmit = 0;
	}
	else if (commentsLength == 0)
	{
		alert("You didn't enter any comments");
		readyToSubmit = 0;
	}

	if (readyToSubmit == 1)
	{
		document.comments.submit();
	}
}

function focusComments()
{
	location.hash="#postyourcomment";
	document.comments.name.focus();
}