var PageUtils = 
{
	$: function(elementId)
	{return document.getElementById(elementId) != null ? document.getElementById(elementId) : null;},
	setAction: function(oForm, value){if(oForm.elements["action"] != null)oForm.elements["action"].value = value;},
	focusIn: function(elementId){if(PageUtils.$(elementId) != null)PageUtils.$(elementId).focus();},
	gotoURL: function(url){self.location.replace(url);},
	pageDisplay: function(path)
	{window.open(path, 'imgDisplay_window','scrollbars=no,toolbar=no,statusbar=no');return false;},
	getMeasures: function(oSource)
	{
		if(oSource.getBoundingClientRect)
		{
			var rectRange = oSource.getBoundingClientRect();
			var objWidth = rectRange.right - rectRange.left;
			var objHeight = rectRange.bottom - rectRange.top;
		}
		else
		{
			var objWidth = oSource.clientWidth;
			var objHeight = oSource.clientHeight;
		}
		return {'width': objWidth, 'height': objHeight};
	},
	getScreenMeasures: function()
	{
		var x,y;
		if (self.innerHeight)
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		
		return {'width': x, 'height': y};
	},
	vert_centered: function(oTarget)
	{
		var measures	= PageUtils.getMeasures(oTarget);
		var screen_info	= PageUtils.getScreenMeasures();
		
		var pos_top		= parseInt((screen_info.height / 2) - (measures.height / 2));
		if(pos_top < 0)pos_top = measures.height;
		
		oTarget.style.top = pos_top + 'px';
	},
	delRegistry: function(sourceForm, action)
	{
		if(sourceForm.elements['action'] != null)sourceForm.elements['action'].value = action;
		sourceForm.submit();
	}
};

var FormUtils = 
{
	loginValidate: function(sForm)
	{
		var vFields = 
		{
			'login': sForm.elements['login'],
			'password': sForm.elements['password']
		};
		
		try
		{
			if(vFields.login.value == '')throw new FormError(vFields.login, 'Por favor, informe o seu login.','focus');
			if(vFields.password.value == '')throw new FormError(vFields.password,'Por favor, informe a sua senha.','focus');
		}
		catch(e)
		{
			hilightField(vFields, e);
			return false;
		}
	}
};