function validate(form)
{ 
	var returncheck = 0;
	
	// Publication Type Selection(s)
	// at least one should be checked
	if ((form.PENNENERGY_JOBS.checked==false) && (form.WORKFORCE_GUIDE.checked==false))
	{
 		document.getElementById('fieldgroup_pubtype').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_pubtype').style.padding = "5px";
		document.getElementById('fieldgroup_pubtype').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_pubtype').style.display = "inline";
		returncheck++;
	}
	
	// First Name
	if(form.FNAME.value == "")
	{
		document.getElementById('fieldgroup_fname').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_fname').style.padding = "5px";
		document.getElementById('fieldgroup_fname').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_fname').style.display = "inline";
		returncheck++;
	}
	
	// Last Name
	if(form.LNAME.value == "")
	{
		document.getElementById('fieldgroup_lname').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_lname').style.padding = "5px";
		document.getElementById('fieldgroup_lname').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_lname').style.display = "inline";
		returncheck++;
	}
	
	// Email Address	
    if(form.EMAIL_ADDRESS.value == "")
	{
		document.getElementById('fieldgroup_email').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_email').style.padding = "5px";
		document.getElementById('fieldgroup_email').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_email_missing').style.display = "inline";
		returncheck++;
    }
	else if(!isValidEmail(form.EMAIL_ADDRESS.value))
	{
		document.getElementById('fieldgroup_email').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_email').style.padding = "5px";
		document.getElementById('fieldgroup_email').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_email_invalid').style.display = "inline";
		returncheck++;
	}

	// Email Format Preference
	if(form.TEXT_HTML[0].checked == false && form.TEXT_HTML[1].checked == false)
	{
		document.getElementById('fieldgroup_format').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_format').style.padding = "5px";
		document.getElementById('fieldgroup_format').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_format').style.display = "inline";
		returncheck++;
	}
	
	if(returncheck == 0)
		get(document.SignUp, 'all');
		// return true;
	else
		return false;
		
}		

function isValidEmail(email)
{
	invalidchars = " /:;"

	for(i=0; i < invalidchars.length; i++)
	{ //checks for invalid chars
			
		badchars = invalidchars.charAt(i);
		
		if(email.indexOf(badchars,0) != -1)
		{
			return false;
		}
	}
	
	atPos = email.indexOf("@",1)  //holds position of "@"
			
	if(atPos == -1) 
	{	//checks to see if "@" present
		return false;
	}
							
	if(email.indexOf("@",atPos+1) != -1) 
	{ //checks for second "@"
		return false;
	}
							
	periodPos = email.indexOf(".",atPos) //holds position of "."
			
	if(periodPos == -1)
	{ //checks for presence of "."
		return false;
	}
	
	if(periodPos+3 > email.length)
	{//makes sure at least two chars after the period
		return false;
	}
	
	return true;
}

function validate_moreinfo(form)
{ 
	var returncheck = 0;
	
	// First Name
	if(form.fname.value == "")
	{
		document.getElementById('fieldgroup_fname').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_fname').style.padding = "5px";
		document.getElementById('fieldgroup_fname').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_fname').style.display = "inline";
		returncheck++;
	}
	
	// Last Name
	if(form.lname.value == "")
	{
		document.getElementById('fieldgroup_lname').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_lname').style.padding = "5px";
		document.getElementById('fieldgroup_lname').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_lname').style.display = "inline";
		returncheck++;
	}
	
	
	// If phone is the preference and no phone # is provided, throw a warning
	if(form.preference[0].checked == true && form.phone.value == "")
	{
		document.getElementById('fieldgroup_phone').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_phone').style.padding = "5px";
		document.getElementById('fieldgroup_phone').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_phone').style.display = "inline";
		returncheck++;
	}
	
	// Email Address	
    if(form.email2.value == "")
	{
		document.getElementById('fieldgroup_email').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_email').style.padding = "5px";
		document.getElementById('fieldgroup_email').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_email_missing').style.display = "inline";
		returncheck++;
    }
	else if(!isValidEmail(form.email2.value))
	{
		document.getElementById('fieldgroup_email').style.border = "1px solid #df0032";
		document.getElementById('fieldgroup_email').style.padding = "5px";
		document.getElementById('fieldgroup_email').style.backgroundColor = "#fde9eb";
		document.getElementById('warning_email_invalid').style.display = "inline";
		returncheck++;
	}
	
	if(returncheck == 0)
		form.submit();
	else
		return false;
		
}		

function isValidEmail(email2)
{
	invalidchars = " /:;"

	for(i=0; i < invalidchars.length; i++)
	{ //checks for invalid chars
			
		badchars = invalidchars.charAt(i);
		
		if(email2.indexOf(badchars,0) != -1)
		{
			return false;
		}
	}
	
	atPos = email2.indexOf("@",1)  //holds position of "@"
			
	if(atPos == -1) 
	{	//checks to see if "@" present
		return false;
	}
							
	if(email2.indexOf("@",atPos+1) != -1) 
	{ //checks for second "@"
		return false;
	}
							
	periodPos = email2.indexOf(".",atPos) //holds position of "."
			
	if(periodPos == -1)
	{ //checks for presence of "."
		return false;
	}
	
	if(periodPos+3 > email2.length)
	{//makes sure at least two chars after the period
		return false;
	}
	
	return true;
}


function resetWarning(id) {
				var fieldgroup = "fieldgroup_" + id;
				
				document.getElementById(fieldgroup).style.border='0px';
				document.getElementById(fieldgroup).style.padding='6px';
				document.getElementById(fieldgroup).style.backgroundColor='#ffffff';
				
				if(id == "email" || id == "email2") {
					var warning = "warning_" + id + "_missing";
					var warning2 = "warning_" + id + "_invalid";
					
					document.getElementById(warning).style.display='none';
					document.getElementById(warning2).style.display='none';
				}
				else {
					var warning = "warning_" + id; 
					document.getElementById(warning).style.display='none';
				}
			}