<!--

var newWindow = null;

function openWindow(contentURL,windowName,windowWidth,windowHeight) {
	widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;
	newWindow = window.open(contentURL,windowName,widthHeight) ;
	newWindow.focus()
}
/*
function closeWindow() {
	if (newWindow != null)  {	
	 newWindow.close();
	 newWindow = null;
	}
}*/
function closeWindow()	{ window.close();	}
/*
function sameCode()
{
	var a=document.getElementById("securitycode").value;
	alert(a);
	var b=document.getElementById("matchthis").value;
	alert(b);
	/*
	var c=document.getElementById('b').value;
	alert(c);

	if (a!==b)
	{
	return false;
	}
}
*/
function validate_required(field)
{
with (field)
{
if (value==null||value=="selsect" || value=="-Month-" || value=="-Day-" || value=="-Year-" || value=="Enter name here"||value==""|| value=="Enter your name here" || value=="Enter teen name here" || value =="Enter Your Email")
  {
  return false;
  }
else {return true}
}
}

function validate_email(field)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {return false}
else {return true}
}
}

function validate_group(group)
{
var isSet=false;
var groupItems = document.getElementsByName(group);
for(x=0; x<groupItems.length; x++)
	{
 	if (groupItems[x].checked) {isSet=true;}
	}
return isSet;
}

function class_selected()
{
var classes=new Array()
classes[0]="ppp"
classes[1]="mnc"
classes[2]="tnc" 
classes[3]="nmb"
classes[4]="hpc"
classes[5]="tpc"

var g = false;
for(x=0; x<= 5; x++) {
	var h=document.getElementById(classes[x]);
	if (h.checked)
		{	g=true; return true;	}
	}
	if (g!==true) {	return false;	}
}

function validate_form(thisform)
{
var errors="";
var valid=true;
with (thisform)
	{
	/*
	if (sameCode()==false)
		{valid=false; errors +="You didn't match the security word in the required field. Please try again. \n"}
	*/
	if (validate_email(email)==false)
  		{valid= false; errors +="Not a valid e-mail address! \n"}
		
	if (validate_required(parent_name)==true)
			{ if(validate_group('childSex')==false)
  				{valid= false; errors +="Please enter the sex of the child! \n"}
			}
		
	if (class_selected()==false)
  		{valid= false; errors +="No class was selected! \n"}
	if ((validate_required(mom_name)==false) && (validate_required(parent_name)==false))
  		{valid= false; errors+="Please supply  us with the mother's or parent's name! \n"}
	if (validate_required(comments)==false)
  		{valid= false; errors +="You didn't leave a comment! \n"}
	}
if (valid==false){alert("Oops there is a problem! \n" + errors); return false;}
else { return true }	
}
function valid_subscribe(thisform)
{
var errors="";
var valid=true;
with (thisform)
	{
	if (validate_email(addmail)==false)
  		{valid= false; errors +="Not a valid e-mail address format! \n"}
	if (validate_required(addmail)==false)
  		{valid= false; errors +="Please enter an email address! \n"}
	}
if (valid==false){alert("Oops there is a problem! \n" + errors); return false;}
else { return true }
	
}
function erase(field, defaulttext) {
if (field.value == defaulttext) {
field.value = "";
}

}
function recall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

function reveal(identity){
	var elem=document.getElementById(identity);
	elem.style.display='inline';
}	
function hide(identity){
	var elem=document.getElementById(identity);
	elem.style.display='none';
}
function goodform(thisform){
var errors="";
var valid=true;
var checked =0;
var count = document.getElementById('classcount').value;
for (var t = 0; t < count; t++) 
{
	var newclass = "class"+t;
	elem=document.getElementById(newclass);
	if (elem.checked) 
	{
   		checked =1;
	}
}
if(checked==0)
{
	valid=false; 
	errors +="You must select a class!\n"; 
}

var isSelected = false;
//alert(document.contactform.Type.length);
var type = document.contactform.type.value;
var types = new Array("Expecting Teen Mom", "Parenting Teen", "Parent of Teen");
for(var i=0; i<types.length; i++)
{
	if(type == types[i])
	{
		var typeNum = i;
		//alert("Typenum = "+typeNum);
		var email = "mail" +typeNum; 
		var name = "name" +typeNum;
   }
}
if(email)
{
//alert(email);
var mail=document.getElementById(email);
//alert(mail.value);
if (validate_email(mail)==false)
  		{valid= false; errors +="Not a valid e-mail address! \n"}
}
if(name)
{
	//alert(typeNum);
	var noName=false;
	var name=document.getElementById(name);
	if (validate_required(name)==false)
  		{valid= false; errors +="Please enter your name! \n";}	
	if(typeNum==2)
	{
		var name=document.getElementById("name3");
		if (validate_required(name)==false)
  			{valid= false; errors +="Name of Teen Parent is required! \n";}
		var age=document.getElementById("age");
		if(!age.value) 
			{valid= false; errors +="Age of Teen Parent is  required! \n";}
		
	}
}
with(thisform)
{
	if(typeNum ==0)
	{
	if(mommonth.value==""||momday.value==""||momyear.value=="")
		{  valid=false; errors +="Please enter Expectant Teen Mom's birthday! \n";	}
	}
	if(typeNum ==1)
	{
	if(childmonth.value==""||childday.value==""||childyear.value=="")
		{  valid=false; errors +="Please enter a birthdate for your child \n";	}
	var sex = new Array("boy", "girl");
	var checkedsex = false;
	for( var x=0; x<2; x++)
	{
		var gender = sex[x];
		var elem=document.getElementById(gender);
		if(elem.checked) checkedsex=true;
	}
	if(!checkedsex) {valid= false; errors +="Please enter the sex of the child! \n"}
	}
}
if (valid==false){alert("Oops there is a problem! \n" + errors); return false;}
}
function validtypeandcity(thisform){
var errors="";
var valid=true;
with(thisform)
	{
	for (i=thisform.type.length-1; i > -1; i--) {
	if (thisform.type[i].checked) var validtype=1;
	}
	for (i=thisform.city.length-1; i > -1; i--) {
	if (thisform.city[i].checked) var validcity=1;
	}
	if(!(validtype && validcity))	   
	{  valid=false; errors +="Please select both type and city. \n";	}
	}
if (valid==false){alert("Oops there is a problem! \n" + errors); return false;}
}
function npnptform(thisform){
var valid=true;
var errors = "";
with(thisform){
var num = count.value;
if(!validate_required(name)) { valid=false; errors+="Please supply your name \n"; }
if(!validate_required(mail) || !validate_email(mail))
	{
		valid=false; errors+=("Please enter your email carefully \n");
	}
//alert(month.value+" "+day.value+" "+year.value);
	if(month.value=="-Month-"||day.value==""|| year.value=="") 
	{  
	valid=false; errors +="Please enter your  birthday! \n";	
	}
if(securitycode.value.length <6 || securitycode.value=="") { valid=false; errors+="Please enter the security code carefully \n";}
}
for(i=0; i<num; i++)
{
	var classname="class"+i;
	var check=document.getElementById(classname)
	if(check.checked) {var selected=true;}
}
if(!selected) valid=false; errors+="Please select a class \n";
if(!valid) {alert(errors); return false;} else {return true;}
}
function locationselected(thisform)
{
with(thisform)
	{
	if(thisform.location.length)
	{
		for (i=0; i<thisform.location.length; i++) 
		{
		if (thisform.location[i].checked) var validlocation=1;
		}
	}
	else
	{
		if(thisform.location.checked) validlocation=1;
	}
	}
	if(!validlocation) 
	{
		alert("Please select a location!"); return false;
	}
	else
	{
	return true;
	}
}
function popWindow(url) {
  popupWin = window.open(url, 'open_window', 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0')
}
function validjoin(thisform){
var valid=true;
var errors = ""
	with(thisform)
	{
	if(item.value == "" || item.value==null){valid=false; errors+="Please select the item you would like \n";}
	if(!validate_required(email) || !validate_email(email)){ valid=false; errors+="Please carefully enter your email address \n";}
	}
if(valid == false) 
{
	alert(errors); 
	return false;
}
else 
{ 
return true;	
}
}
//-->