function clearField(object) {
object.value ="";
}

function validate()
{
    var words;
    var result = true;

    with( document.main )
    {
        words = txtName.value.split(" ");
        if( result == true &&
            (txtName.value == "" || words.length < 2) )
        {
            alert("Please enter your full name.");
            txtName.focus();
            txtName.select();
            result = false;
        }

        txtEmail.value.replace(/ /, "");
        txtPh1.value.replace(/ /, "");
        txtPh2.value.replace(/ /, "");
        txtPh3.value.replace(/ /, "");
        if( result == true )
        {
			if( txtEmail.value == "" &&
                (txtPh1.value == "" &&
                 txtPh2.value == "" &&
                 txtPh3.value == "") )
			{
                alert("Please enter a valid email address or phone number.");
                txtEmail.focus();
                result = false;
            }
        }

        if( result == true )
        {
            if( txtEmail.value != "" )
            {
                match = txtEmail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
                if( match == null )
                {
                    alert("Please enter a valid email address.");
                    txtEmail.focus();
                    txtEmail.select();
                    result = false;
                }
            }
        }

        if( result == true && ( txtPh1.value != "" || txtPh3.value != "" || txtPh2.value != "" ) )
        {
            if( txtPh1.value.match(/^[2-9][0-9][0-9]$/) == null )
            {
                alert("Please enter a valid area code.");
                txtPh1.focus();
                txtPh1.select();
                result = false;
            }

            if( result == true &&
                txtPh2.value.match(/^\d\d\d$/) == null )
            {
                alert("Please enter a valid phone number prefix.");
                txtPh2.focus();
                txtPh2.select();
                result = false;
            }

            if( result == true &&
                txtPh3.value.match(/^\d\d\d\d$/) == null )
            {
                alert("Please enter a valid phone number suffix.");
                txtPh3.focus();
                txtPh3.select();
                result = false;
            }
        }
		if( result == true && txtComments.value == "" )
        {
            alert("Please enter your comments.");
            txtComments.focus();
            result = false;
        }
    }

    return result;
}

function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

function validate_index()
{
    var words;
    var result = true;

    with( document.main )
    {
        words = txtName.value.split(" ");
        if( result == true &&
            (txtName.value == "" || words.length < 2) )
        {
            alert("Please enter your full name.");
            txtName.focus();
            txtName.select();
            result = false;
        }

        txtEmail.value.replace(/ /, "");
        txtPhone.value.replace(/ /, "");
        if( result == true )
        {
			if( txtPhone.value == "" )
			{
                alert("Please enter a phone number.");
                txtPhone.focus();
                result = false;
            }
        }

        if( result == true )
        {
            if( txtEmail.value != "" )
            {
                match = txtEmail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
                if( match == null )
                {
                    alert("Please enter a valid email address.");
                    txtEmail.focus();
                    txtEmail.select();
                    result = false;
                }
            }
        }

		if( result == true && txtComments.value == "" )
        {
            alert("Please enter your comments.");
            txtComments.focus();
            result = false;
        }
    }

    return result;
}