function AutoTab(obj,len,next,nest)
{
	nest=(!nest) ? "":'document.'+nest+'.'
	evnt = document.getElementById?document.getElementById(obj):document.all?document.all[obj]:document.layers?eval(nest+'document.'+obj):0;
	if (evnt.value.length == len)
	{
		nxt_evnt = document.getElementById?document.getElementById(next):document.all?document.all[next]:document.layers?eval(nest+'document.'+next):0;
		nxt_evnt.focus();
	}
	return;
}


function charInString (c, s){
	for (i = 0; i < s.length; i++) {
		if (s.charAt(i) == c)
			return true;
	}
	return false
}

function stripInitialWhitespace(s) {
	var whitespace = " \t\n\r";	
	var i = 0;
	while ((i < s.length) && charInString (s.charAt(i), whitespace))
		i++;
		
	return s.substring (i, s.length);
}


function adjustCalendar(month,obj,nest,year)
{
	nest=(!nest) ? "":'document.'+nest+'.'
	evnt = document.getElementById?document.getElementById(obj):document.all?document.all[obj]:document.layers?eval(nest+'document.'+obj):0;
	
	if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
	{
		if (evnt.length < 31)
		{
			for (i=(evnt.length+1); i<32; i++)	
			{
				evnt.length=i;
				evnt.options[i-1].value = i;
				evnt.options[i-1].text = i;
			}
		}
	}
	else if (month==4 || month==6 || month==9 || month==11)
	{
		if (evnt.length < 30)
		{
			for (i=(evnt.length+1); i<31; i++)	
			{
				evnt.length=i;
				evnt.options[i-1].value = i;
				evnt.options[i-1].text = i;
			}
		}
		else if (evnt.length > 30)
		{
			evnt.length = 30;
		}
	}
	else //February	
	{
		if (Leap(year))
		{
			evnt.length = 29;
			evnt.options[28].value = 29;
			evnt.options[28].text = 29;
		}
		else
			evnt.length = 28;
	}
}

function Leap(Year)
{
	if ( (Year % 4) == 0)
		{
		// It is exactly divisible by 4

		if ( (Year % 100) == 0)
			{
			// It is exactly divisible by 100
			// Is it also exactly divisible by 400?
			Result = ( (Year % 400) == 0);
			}
		else
			{
			Result = 1;
			}
		}
	else
		{
		// It is not exactly divisible by 4
		// It is not a leap year
		Result = 0;
		}

	return (Result);
}
