// javascript functions

function trim(str)
{
	str = '' + str;
	var re = /^ */;
	var res = str.replace(re, '');
	re = / *$/;
	return(res.replace(re, ''));
}

function ShowAlert(sAlertString, hForm, FormElement)
{
	alert(sAlertString);
	if ( (!hForm.elements[FormElement].disabled) && (!hForm.elements[FormElement].length) )
	{
		if (hForm.elements[FormElement].type != 'hidden')
			hForm.elements[FormElement].focus();
		if (!hForm.elements[FormElement].options) // select
			hForm.elements[FormElement].select();
	}
	return false;
}

function parse_int(str)
{
	str = '' + str;
	var re = /^0*/;
	var res = str.replace(re, '');
	return parseInt(res);
}

function GetValue(el)
{
	if ( (el.length) && (!el.options) )
	{
		for (var i=0; i<el.length; i++)
			if (el[i].checked)
				return el[i].value;
		return '';
	}
	else
		return el.value;
}

