function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}



function drawItem(item)
{
	obj = document.getElementById(item);
	visible = (obj.style.display != 'none');
	
	if (visible)
	{
		obj.style.display = 'none';
 		
	}
	else
	{
		obj.style.display = 'block';
	}
}

function disableFields() {
	if(document.createChild.overrideAddress.checked) {
		document.createChild.address.disabled = true;
		document.createChild.city.disabled = true;
		document.createChild.state.disabled = true;
		document.createChild.postal.disabled = true;
		document.createChild.country.disabled = true;
		}
		else
		{
		document.createChild.address.disabled = false;
		document.createChild.city.disabled = false;
		document.createChild.state.disabled = false;
		document.createChild.postal.disabled = false;
		document.createChild.country.disabled = false;
	}
}

function disableEmail(item) {
	if(document.createChild.email_override.checked) {
		document.createChild.email.disabled = true;
		document.createChild.email.value = item;
		}
		else
		{
		document.createChild.email.disabled = false;
		}
}



if (document.images) {

  privacy_roll = new Image(100,58); privacy_roll.src="images/privacy_policy_btn_on.gif";
  submit_roll = new Image(144,80); submit_roll.src="images/submit_btn_on.gif";

  privacy_off = new Image(100,58); privacy_off.src="images/privacy_policy_btn.gif";
  submit_off = new Image(144,80); submit_off.src="images/submit_btn.gif";

  function imgOver(imgTxt, state) {
    if (state == 'on') {
      document[imgTxt].src = eval(imgTxt + "_roll.src");
    } else {
      document[imgTxt].src = eval(imgTxt + "_off.src");
    }
  }
}

function thesame(value1, value2)
{
  if (((value1 != null) || (value1 != ''))
       && value2 != '' && value1 != value2)
  {
       alert('The passwords must be identical.');
       return (false);
  }
  return (true);
}

function openPrivacy()

{

window.open("http://www.mgae.com/privacy.asp","_blank", "scrollbars=yes,toolbar=yes,height=600,width=600");

}

function openTerms()

{

window.open("https://www.mgae.com/terms.asp", "_blank", "scrollbars=yes,toolbars=yes,height=600,width=600");

}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_email(parentemail,"Please enter a valid e-mail address!")==false)
  {parentemail.focus();return false}
}
}

