$(document).ready(function() {
				document.getElementById("group_ids").style.display = "none";
				document.getElementById("replace").style.display = "block";
				lis = document.getElementById("options").getElementsByTagName("li");
				for (i = 0; i < lis.length; i++) {
					lis[i].onclick = function() {
						document.getElementById("group_ids").value = this.getAttribute("rel");
						document.getElementById("options").style.display = "none";
						document.getElementById("current").innerHTML = this.innerHTML;
					}
					lis[i].onmouseover = function() { this.style.backgroundColor = "#b20086"; this.style.color = "#fff"; }
					lis[i].onmouseout = function() { this.style.backgroundColor = "#fff"; this.style.color = "#000"; }
				}
				document.getElementById("replace").onmousedown = function() {
					document.getElementById("options").style.display = "block";
				}
				document.getElementById("replace").onmouseout = function() {
					//$("options").style.display = "none";
				}
});

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

function checkValid() {	
	$(".form_error").removeClass('form_error_display').removeClass('submit_error_display');
	var hasError = false;
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	
	var fnameVal = $("#firstname").val();
	if(trim(fnameVal) == '') {
		$("#fname_error").addClass('form_error_display');
		hasError = true;
	}
	
	var lnameVal = $("#lastname").val();
	if(trim(lnameVal) == '') {
		$("#lname_error").addClass('form_error_display');
		hasError = true;
	}

	var emailVal = $("#email_address").val();
	if(trim(emailVal) == '') {
		$("#email_error").addClass('form_error_display');
		hasError = true;
	} else if(!emailReg.test(trim(emailVal))) {
		$("#email_error").addClass('form_error_display');
		hasError = true;
	}

	var typeVal = $("#group_ids").val();
	if(typeVal == '') {
		$("#type_error").addClass('form_error_display');
		hasError = true;
	}

	if(hasError == false) {
		return true;
	}

	return false;
}