function checkRating(){
	if(document.forms[1].total_rating.value==0){
		document.getElementById('total_rating').style.visibility='visible';
		return false;
	}
	else{
		document.getElementById('total_rating').style.visibility='hidden';
		return validateFrm(document.forms[1]);
	}
}

function checkEmail(emField){ //reference to email field passed as argument

	var fieldValue = emField.value // store field's entire value in variable

	// Begin Valid Email Address Tests

	//if field is not empty
	if(fieldValue != ""){
		var atSymbol = 0

		//loop through field value string
		for(var a = 0; a < fieldValue.length; a++){

			//look for @ symbol and for each @ found, increment atSymbol variable by 1
			if(fieldValue.charAt(a) == "@"){
				atSymbol++
			}

		}

		// if more than 1 @ symbol exists
		if(atSymbol > 1){
			// then cancel and don't submit form
			alert("Please Enter A Valid Email Address")
			return false
		}

		// if 1 @ symbol was found, and it is not the 1st character in string
		if(atSymbol == 1 && fieldValue.charAt(0) != "@"){
			//look for period at 2nd character after @ symbol
			var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2)

			// "." immediately following 1st "." ?
			var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false

			//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
				// then cancel and don't submit form
				alert("Please Enter A Valid Email Address")
				return false
			}

		}
		// no @ symbol exists or it is in position 0 (the first character of the field)
		else{
			// then cancel and don't submit form
			alert("Please Enter A Valid Email Address")
			return false
		}
	}
	// if field is empty
	else{
		// then cancel and don't submit form
		alert("Please Enter A Valid Email Address")
		return false
	}

	//all tests passed, submit form

	return true
}//end VALIDATE EMAIL ADDRESS

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	countfield.value = maxlimit - field.value.length;
}

var is_selectable=true;

function makeCurrentSelection(sel_elem_count) {
	document.getElementById('current-rating').style.width=(sel_elem_count*20)+'px';
	document.getElementById('current-rating').style.visibility='visible';

	//document.getElementById('unit_ul1').innerHTML='<li class="current-rating" style="width: '+(sel_elem_count*20)+'px;" onmouseover="remakeSelectable();" onmouseout="is_selectable=true;">'+sel_elem_count+'/5</li><li class="current-rating-remain" style="width: '+((5-sel_elem_count)*20)+'px;" onmouseover="remakeSelectable();" onmouseout="is_selectable=true;">&nbsp;</li>';
	document.forms[1].total_rating.value=sel_elem_count;
	is_selectable=false;
}

function remakeSelectable() {
	if(is_selectable==true) {
		document.getElementById('current-rating').style.visibility='hidden';
		document.getElementById('unit_ul1').innerHTML=
		'<li><a href="javascript: void(0);" onclick="makeCurrentSelection(1);" title="1 out of 5" class="r1-unit" rel="nofollow" onmouseover="document.getElementById(\'current-rating\').style.visibility=\'hidden\';">1</a></li>'+
		'<li><a href="javascript: void(0);" onclick="makeCurrentSelection(2);" title="2 out of 5" class="r2-unit" rel="nofollow" onmouseover="document.getElementById(\'current-rating\').style.visibility=\'hidden\';">2</a></li>'+
		'<li><a href="javascript: void(0);" onclick="makeCurrentSelection(3);" title="3 out of 5" class="r3-unit" rel="nofollow" onmouseover="document.getElementById(\'current-rating\').style.visibility=\'hidden\';">3</a></li>'+
		'<li><a href="javascript: void(0);" onclick="makeCurrentSelection(4);" title="4 out of 5" class="r4-unit" rel="nofollow" onmouseover="document.getElementById(\'current-rating\').style.visibility=\'hidden\';">4</a></li>'+
		'<li><a href="javascript: void(0);" onclick="makeCurrentSelection(5);" title="5 out of 5" class="r5-unit" rel="nofollow" onmouseover="document.getElementById(\'current-rating\').style.visibility=\'hidden\';">5</a></li>';
	}
}