function inTd(obj)
{
	obj.style.backgroundColor = "#FAFCB1";
}

function outTd(obj)
{
	obj.style.backgroundColor = "";
	obj.style.cursor = "";
}

function changeLocation(url)
{
	location.href = url;
}

function HotKeys()
{	
	if (window.event.keyCode == 13 && document.forms[0])
	{
		var wtype = window.event.srcElement.type;
		if (wtype != "submit" && wtype != "button" && wtype != "textarea")
		{
			window.event.keyCode = 0;
			for (i = 0; i <= document.forms[0].length; i++)
				if (window.event.srcElement == document.forms[0].elements[i])
					break;
					
			if (i > 0)
			{
				var j = 0;
				for (j=i + 1;j<document.forms[0].length;j++)
				{
					if (document.forms[0].elements[j].type == "button" || document.forms[0].elements[j].type == "submit")
					{
						document.forms[0].elements[j].focus();
						break;
					}
				}
			}
		}
	}
}

function ffocus()
{
	for(var i = 0; i < document.forms[0].length; i ++)
	{
		var obj = document.forms[0][i];
		if(obj.type == "text" || obj.type == "textarea")
		{
			if(!obj.readOnly || !obj.disabled)
			{
				if(!obj.disabled)
				{
					if(!obj.readOnly)
					{
						obj.focus();
						break;
					}
				}
			}
		}
	}
}

function abrirCalendario(strField)
{
	var win = window.open('../AspxObjetos/DatePicker.aspx?field=' + strField,'calendarPopup','width=208,height=148,resizable=no');
	centraForm(win);
}

function centraForm(janela)
{
	janela.moveTo(((screen.width / 2) - (289 / 2)), ((screen.height / 2) - (228 / 2)));
}

document.onkeydown = HotKeys;
//document.onunload = finalizaSessao()

ffocus();

function limita(obj, limite)
{
	if(obj.value.length > limite)
		obj.value = obj.value.substring(0, limite - 1);
}
