var longRef = "document.forms.form";

function displayOrHideFormSection(formSection)
{
	if ((document.getElementById(formSection).style.display == 'block')||(document.getElementById(formSection).style.display == ''))
	{
		hideFormSection(formSection);
	}
	else
	{
		displayFormSection(formSection);
	}
}

function displayOrHideFormRow(formRow)
{
	if ((document.getElementById(formRow).style.display == 'table-row')||(document.getElementById(formRow).style.display == ''))
	{
		hideFormRow(formRow);
	}
	else
	{
		displayFormRow(formRow);
	}
}

function displayFormSection(formSection)
{
	document.getElementById(formSection).style.display = 'block';
}

function displayFormRow(formRow)
{   
    // set to default for browser.
    // Mozilla will interpret this as 'table-row'
    // IE will interpret this as block 
    // (IE does not support 'table-row' as a display value)
	document.getElementById(formRow).style.display = '';

}

function hideFormSection(formSection)
{
	document.getElementById(formSection).style.display = 'none';
}

function hideFormRow(formRow)
{
	document.getElementById(formRow).style.display = 'none';
}


function resetFields()
{   
	eval(longRef).reset();
}

function populateCurrentDayMonthYear(month_field, day_field, year_field, year_code)
{
	// if year_code = 0, years go from 1900 up until current year
	// if year_code = 1, years go from (current year - 5) to (current year + 5)
	
	//var longRef = "document.forms.nyucardAuthorizationForm.";
	
	var temp=0;
	var today= new Date();
	var day= today.getDate();
	var month= today.getMonth();
	var year= today.getFullYear();

	var longRefDay = longRef + "." + day_field;
	var longRefMonth = longRef + "." +  month_field;
	var longRefYear = longRef + "." +  year_field;
	
	if ((eval(longRefMonth).value <= 1)||(eval(longRefMonth).value == ""))
	{
	   eval(longRefMonth).options[month].selected = true;
    }
	populateDaysOfMonth(month_field, day_field);
	if ((eval(longRefDay).value <= 1)||(eval(longRefDay).value == ""))
	{
	   eval(longRefDay).options[day-1].selected = true;
    }
	
	y = 1900;
	var y_dif = 0;
	if (year_code == 0)
	{
		y_dif = (year-y);
	}
	else
	if (year_code == 1)
	{
		y = year - 5;
		y_dif = 10;
	}

	var curYearSel = eval(longRefYear).value;
	for (var i=0; i<=y_dif; i++)
	{
		eval(longRefYear).options[i] = new Option(y,y);
		if (y == curYearSel)
		{
            eval(longRefYear).value = curYearSel;		
		}
		if (y == year)
		{
	       if ((curYearSel == null)||(curYearSel == ""))
	       {      
                eval(longRefYear).options[i].selected = true;
           }
		}
		y = y + 1;
	}
}


function populateDaysOfMonth(month_field, day_field)
{
	//var longRef = "document.forms.nyucardAuthorizationForm.";
	var longRefMonth = longRef + "." +  month_field;
	var longRefDay = longRef + "." +  day_field;
	
	var curDaySel = eval(longRefDay).value;
	
	var dayCt = 0;
	if (eval(longRefMonth).options[1].selected)
	{
		dayCt = 29;
	}
	else 
	{
		if ((eval(longRefMonth).options[8].selected) || 
			(eval(longRefMonth).options[3].selected) ||
			(eval(longRefMonth).options[5].selected) ||
			(eval(longRefMonth).options[10].selected))
		{
			dayCt = 30;
		}
		else
		{
			dayCt = 31;
		}
	}
		
	for(i=0;i<31;i++)
	{
		eval(longRefDay).options[i] = null;
	}
	
	for (var i=0; i < dayCt ; i++)
	{
		var day= String(i+1);
        eval(longRefDay).options[i] = new Option(day, day);
	}
	
	eval(longRefDay).value = curDaySel;
}

function processAffiliateType()
{
		if (document.forms.nyucardAuthorizationForm.affiliate_type.value == 3)
		{
			document.getElementById('affiliate_family_id').style.visibility = 'visible';
		}
		else
		{
			document.getElementById('affiliate_family_id').style.visibility = 'hidden';
		}
}

/*
function processSubmit()
{
	var reqStr = "The following information is still needed:\n";
	var valid = 1;
	
	if (valid == 0)
	{
		alert(reqStr);
		return false;
	}
	else
	{
		return true;
	}
}
*/
