function validate(str)
{
 	var supported = 0;
	var errormsg = "";

 	if (window.RegExp)
	{
   		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
  	}

	if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,5}|[0-9]{1,3})(\\]?)$");
		
	var validemail = (!r1.test(str) && r2.test(str));
		
	if (validemail == false)
		errormsg += "'"+str+"'" + " is not a valid Email address.\n";

	var inputs = document.getElementsByTagName('input');
		
	var checked = false;
		
	for (var i=0; i<inputs.length; i++) {
		if (inputs[i].className == 'type_checkbox' && inputs[i].checked == true)
		{
			checked = true;
			break;
		}
		else if (i==inputs.length-1)
			errormsg += "Please select at least one practice area.";
	}
		
	if (validemail && checked)
		return true;

	alert(errormsg);
				
	return false;
}



// Create the new window
function openInNewWindowEmail(e) {
    if (!e) var e = window.event;
        // Abort if a modifier key is pressed
        if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
            return true;
        }
        else {
            // Change "_blank" to something like "newWindow" to load all links in the same new window
            var newWindow = window.open(this.getAttribute('href'), 'newswindow', 'width=600,height=450,toolbar=no,copyhistory=no,scrollbars=yes,resizable=no,directories=no,menubar=no,status=no,location=no');
            if (newWindow) {
                if (newWindow.focus) {
                    newWindow.focus();
                    return false;
                }
            }
        return true;
    }
}

function getNewWindowLinks() {
    // Check that the browser is DOM compliant
    if (document.getElementById && document.createElement && document.appendChild) {
        // Change this to the text you want to use to alert the user that a new window will be opened
        // Find all links
        var link;
        var links = document.getElementsByTagName('a');
        for (var i = 0; i < links.length; i++) {
            link = links[i];
            // Find all links with a class name of "targetblank"
            if (/\btargetblank2\b/.exec(link.className)) {
                link.onclick = openInNewWindowEmail;
            }
        }
    }
}    