// JavaScript Document

<!---- Function to Calculate Age
function calcAge(ipYear, ipMonth, ipDay, opAge, rYear, rMonth, rDay)
{
    // Set the form values to variables
    //var yearBorn = document.form1.year.value;
    //var monthBorn=document.form1.month.value;
    //var dayBorn=document.form1.day.value;

    // alert(ipYear);
    var yearBorn = document.getElementById(ipYear).value;
    var monthBorn= document.getElementById(ipMonth).value;
    var dayBorn= document.getElementById(ipDay).value;


    //alert (month);
    //Set array for names of the month
    var monthname=new Array ("January","February","March","April","May","June", "July", "August","September","October","November","December")
    //Set a dayname array
    var daysNames =new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
    // Set the today date object
    //var dateObj=new Date();
    var dayRace = rDay;
    var monthRace = rMonth;
    var yearRace = rYear;
    //alert(yearRace);

    var dateObj = new Date(yearRace,monthRace,dayRace);

    for(x=0; x<monthname.length;x++)
    {
        if(monthname[x]==monthBorn)
        {
            birthDate =new Date(yearBorn,x,dayBorn);
            var nmonthBorn = x+1;
        }
    }
    //var currAge=(dateObj-birthDate)/(1000*60*60*24*365.25);
    //currAge = Math.floor(currAge);
    var currAge= (yearRace - yearBorn);
    //alert (dayRace);
    if (monthRace < nmonthBorn) currAge--;
    if (monthRace == nmonthBorn && dayRace < dayBorn) currAge--;

    BirthDayName=daysNames[birthDate.getDay()-1];
    fullBDate=BirthDayName+" "+monthBorn+" "+dayBorn+", "+yearBorn;
    //document.form1.day.value=fullBDate;
    //document.form1.age.value = currAge;
    document.getElementById(opAge).value = currAge;
//opAge = currAge;

//return (currAge);
}
//--->

<!---- Function to Calculate Age (Month is a number)
function calcAgeNMonth(ipYear, ipMonth, ipDay, opAge, rYear, rMonth, rDay)
{
    // Set the form values to variables
    //var yearBorn = document.form1.year.value;
    //var monthBorn=document.form1.month.value;
    //var dayBorn=document.form1.day.value;

    //alert(ipDay);
    var yearBorn = document.getElementById(ipYear).value;
    var monthBorn= document.getElementById(ipMonth).value;
    var dayBorn= document.getElementById(ipDay).value;
	var nmonthBorn = monthBorn;


    //alert (nmonthBorn);
    //Set array for names of the month
    var monthname=new Array ("January","February","March","April","May","June", "July", "August","September","October","November","December")
    //Set a dayname array
    var daysNames =new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
    // Set the today date object
    //var dateObj=new Date();
    var dayRace = rDay;
    var monthRace = rMonth;
    var yearRace = rYear;
    //alert(yearRace);

    var dateObj = new Date(yearRace,monthRace,dayRace);

    //var currAge=(dateObj-birthDate)/(1000*60*60*24*365.25);
    //currAge = Math.floor(currAge);
    var currAge= (yearRace - yearBorn);
    //alert(currAge);
	//alert (dayRace);
    if (monthRace < nmonthBorn) currAge--;
    if (monthRace == nmonthBorn && dayRace < dayBorn) currAge--;
	//alert(currAge);
    //BirthDayName=daysNames[birthDate.getDay()-1];
    //fullBDate=BirthDayName+" "+monthBorn+" "+dayBorn+", "+yearBorn;
    //document.form1.day.value=fullBDate;
    //document.form1.age.value = currAge;
	//alert(currAge);
    document.getElementById(opAge).value = currAge;
//opAge = currAge;

//return (currAge);
}
//--->


<!---- Function to Calculate Age
function calcTstAge(ipYear, ipMonth, ipDay, opAge, rYear, rMonth, rDay)
{
    // Set the form values to variables
    //var yearBorn = document.form1.year.value;
    //var monthBorn=document.form1.month.value;
    //var dayBorn=document.form1.day.value;

    // alert(ipYear);
    var yearBorn = document.getElementById(ipYear).value;
    var monthBorn= document.getElementById(ipMonth).value;
    var dayBorn= document.getElementById(ipDay).value;


    //alert (month);
    //Set array for names of the month
    var monthname=new Array ("January","February","March","April","May","June", "July", "August","September","October","November","December")
    //Set a dayname array
    var daysNames =new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
    // Set the today date object
    //var dateObj=new Date();
    var dayRace = rDay;
    var monthRace = rMonth;
    var yearRace = rYear;
    //alert(yearRace);
	//alert (monthRace);

    var dateObj = new Date(yearRace,monthRace,dayRace);

    for(x=0; x<monthname.length;x++)
    {
        if(monthname[x]==monthBorn)
        {
            birthDate =new Date(yearBorn,x,dayBorn);
            var nmonthBorn = x+1;
        }
    }
    //var currAge=(dateObj-birthDate)/(1000*60*60*24*365.25);
    //currAge = Math.floor(currAge);
    var currAge= (yearRace - yearBorn);
    //alert (dayRace);
    //alert (dayBorn);
    //alert (nmonthBorn);
	//alert (monthRace);
    if (monthRace < nmonthBorn) currAge--;
    if (monthRace == nmonthBorn && dayRace < dayBorn)
	{
		alert (dayBorn);
		currAge--;
	}

    BirthDayName=daysNames[birthDate.getDay()-1];
    fullBDate=BirthDayName+" "+monthBorn+" "+dayBorn+", "+yearBorn;
    //document.form1.day.value=fullBDate;
    //document.form1.age.value = currAge;
    document.getElementById(opAge).value = currAge;
//opAge = currAge;

//return (currAge);
}
//--->



<!---- Function to Clear Radio Buttons
function clearRadios( radioname )
{
	for( i = 0; i < document.form1[radioname].length; i++ )
		document.form1[radioname][i].checked = false;
}
//--->

