function Form()
{
} // Form
Form.createDaySelect = function(name,
selected)
{
var select = document.createElement('select');
select.setAttribute('name',
name);
select.setAttribute('id',
name);
var option;
for (var i = 1; i < 32; i++)
{
option = document.createElement('option');
if (i < 10)
{
i = '0' + i;
} // if
option.setAttribute('value',
i);
if (i == selected)
{
option.setAttribute('selected',
'selected');
} // if
option.appendChild(document.createTextNode(i));
select.appendChild(option);
} // for
return (select);
} // createDaySelect
Form.createMonthSelect = function(name,
selected)
{
var select = document.createElement('select');
select.setAttribute('name',
name);
select.setAttribute('id',
name);
var option;
var months = {
'01':'Jan',
'02':'Feb',
'03':'Mar',
'04':'Apr',
'05':'May',
'06':'Jun',
'07':'Jul',
'08':'Aug',
'09':'Sep',
'10':'Oct',
'11':'Nov',
'12':'Dec'
};
for (var month in months)
{
option = document.createElement('option');
option.setAttribute('value',
month);
if (month == selected)
{
option.setAttribute('selected',
'selected');
} // if
option.appendChild(document.createTextNode(months[month]));
select.appendChild(option);
} // for
return (select);
} // createMonthSelect
Form.createYearSelect = function(name,
start,
end,
selected)
{
var select = document.createElement('select');
select.setAttribute('name',
name);
select.setAttribute('id',
name);
for (var i = start; i <= end; i++)
{
option = document.createElement('option');
option.setAttribute('value',
i);
if (i == selected)
{
option.setAttribute('selected',
'selected');
} // if
option.appendChild(document.createTextNode(i));
select.appendChild(option);
} // for
return (select);
} // createYearSelect
Form.focusFirst = function(f)
{
if (!f)
{
if (document.forms.length)
{
f = document.forms[0];
} // if
else
{
return;
} // else
} // if
for (var i = 0; i < f.elements.length; i++)
{
if ((f.elements[i].type != 'hidden') &&
(f.elements[i].type != 'button') &&
(f.elements[i].type != 'submit') &&
(!f.elements.disabled))
{
f.elements[i].focus();
return;
} // if
} // for
} // focusFirst
Form.submitOnEnter = function(input,
event)
{
var keycode;
if (window.event)
{
keycode = window.event.keyCode;
} // if
else if (event)
{
keycode = event.which;
} // else if
else
{
return (true);
} // else
if (keycode == 13)
{
input.form.submit();
return (false);
} // if
return (true);
} // submitOnEnter
Form.textareaCountInit = function(textareaId,
countId,
limit)
{
var ta = document.getElementById(textareaId);
var elem = document.getElementById(countId);
if ((ta) &&
(elem))
{
Utils.removeChildren(elem);
elem.appendChild(document.createTextNode(limit - ta.value.length));
} // if
} // textareaCountInit
Form.textareaLimit = function(textarea,
limit,
id)
{
if (textarea.value.length > limit)
{
textarea.value = textarea.value.substring(0,
limit);
} // if
if (id)
{
var elem = document.getElementById(id);
if (elem)
{
Utils.removeChildren(elem);
elem.appendChild(document.createTextNode(limit - textarea.value.length));
} // if
} // if
} // textareaLimit
