
function validateForm(){
//IMPORTANT! You have to call this function when the
//form submits by adding the following text to your
//form tag:  onsubmit="return validateForm()"
//ie.. <form name="formy" action="myscript.asp" onsubmit="return validateForm()"
if (document.formy.fname.value.length < 1){
alert("The First Name field must be at least 1 character(s) in length.")
document.formy.fname.focus()
return (false)
}
if (document.formy.lname.value.length < 1){
alert("The Last Name field must be at least 1 character(s) in length.")
document.formy.lname.focus()
return (false)
}
if (document.formy.email.value.length < 1){
alert("The email field must be at least 1 character(s) in length.")
document.formy.email.focus()
return (false)
}

if (document.formy.address1.value.length < 1){
alert("The address field must be at least 1 character(s) in length.")
document.formy.address1.focus()
return (false)
}

if (document.formy.city.value.length < 1){
alert("The city field must be at least 1 character(s) in length.")
document.formy.city.focus()
return (false)
}

if (document.formy.zip.value.length < 1){
alert("The zip field must be at least 1 character(s) in length.")
document.formy.zip.focus()
return (false)
}

var ChkRad8 = false
for (i=0;i<document.formy.units.length;i++){
if (document.formy.units[i].checked==true){
ChkRad8 = true
}
}
if (ChkRad8==false){
alert("The units field is required. Please select one of the options.")
return (false)
}
if (document.formy.username.value.length < 1){
alert("The username field must be at least 1 character(s) in length.")
document.formy.username.focus()
return (false)
}
if (document.formy.username.value.length > 20){
alert("The username field must be no more than 20 character(s) in length.")
document.formy.username.focus()
return (false)
}
if (document.formy.country.selectedIndex<1){
alert("The country field is required. Please select one of the options.")
document.formy.country.focus()
return (false)
}
if (document.formy.athlete_type.selectedIndex<1){
alert("The athlete_type field is required. Please select one of the options.")
document.formy.athlete_type.focus()
 return (false);
}
if (document.formy.password.value.length < 6){
alert("The password must be at least 6 characters long")
document.formy.password.focus()
return (false);
}
if (document.formy.password.value != document.formy.password2.value)
{
alert("Please re-enter your password. The two entries did not match.");
document.formy.password.value = "";
document.formy.password2.value = "";
document.formy.password.focus();
return (false);
}

var terms_agree = false

if (document.formy.terms_agree.checked==true){
terms_agree = true
}
if (terms_agree==false){
alert("You must agree to the TERMS AND CONDITIONS")
return (false)
}

if (chkDate(document.formy.birthday.value) == false) {
alert('Please enter a valid Birthday. Make sure you use 2 digits for day and month and year');
document.formy.birthday.focus();
return false;
}
}

function chkDate(x) {
var j,k,l
    var d = x.substring(3,5);
var m = x.substring(0,2);
var year = x.substring(6,10);
if (d.substring(0,1) == 0) {
d = d.substring(1,2);
}
if (m.substring(0,1) == 0) {
m = m.substring(1,2);
}

if (isDate(year,m,d) == true) {
  return true 
}
else {
  return false;
}
}

function isDate (year, month, day) {
var daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31]
if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) {
return false;
}
var intYear = parseInt(year);
var intMonth = parseInt(month);
var intDay = parseInt(day);

if (intDay > daysInMonth[intMonth-1]) {
return false;
}
if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) {
return false;
}
return true;
}
function isYear (s) {
return ((s.length == 2) || (s.length == 4));
}
function isMonth (s) {
if ((s > 0) && (s < 13)) {
return true;
}
else {
return false;
}
}
function isDay (s) {
if ((s > 0) && (s < 32)) {
return true;
}
else {
return false;
}
}
function daysInFebruary (year)
{
return ( ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function openwindow(theurl){
newwin=window.open(theurl,'newwin','height=400,width=450,screenX=50,left=50,screenY=50,top=50,
channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0')
}

function checkcookie(){
if (document.cookie){
return true;
}else{
document.location = "/system_message.asp?msg=40"
return false;
}
}
