function defineFocoForm()
{
	y=0;
	while (x = document.getElementsByTagName('input')[y])
	{
		if (x.type!='hidden')
		{
		//	if (x.value=="")
		//	{
				x.focus();
				x.select();
				return true;
		//	}
		}
		y++;
	}
}

function esqueciSenha(bolSite)
{
	strEmail = prompt('Informe o seu email');
	strEndereco = 'esqueci_senha.php';
	if (bolSite) strEndereco = 'cms/esqueci_senha.php';
	self.location = strEndereco+'?email='+strEmail;
}

//verifica se é a bosta do IE
var IE = document.all?true:false


//centraliza o objeto na tela
function centralizarObjeto(objElemento)
{
	var intWidthElemento = objElemento.offsetWidth;
	if (intWidthElemento==0)
	{
		intWidthElemento = trocarTodos(objElemento.style.width,'px','');
	}
	
	//pega tamanho da tela do browser (janela)
	if (IE)
	{
		intTamanhoTelaHeight = document.documentElement.clientHeight;
		intTamanhoTelaWidth = document.documentElement.clientWidth;
		
		if (intTamanhoTelaWidth==0)
		{
			intTamanhoTelaHeight = document.body.clientHeight;
			intTamanhoTelaWidth = document.body.clientWidth;
		}
	}
	else
	{
		intTamanhoTelaWidth = window.innerWidth;
		intTamanhoTelaHeight = window.innerHeight;
	}	
	
//	alert('janela '+document.body.clientHeight+' e Scrroll: '+document.body.scrollTop+' elemento: '+objElemento.offsetHeight);
//	alert(objElemento.style.top);	
//	alert((document.body.clientHeight+document.body.scrollTop)-(document.body.clientHeight/2)-(objElemento.offsetHeight/2));

	//topo nao pode ser 0 nunca
    //quando o arquivo é xhtml o document.body.scrollTop nao funciona (é sempre zero)
    var intScrollTop = window.pageYOffset ||
                       document.body.scrollTop ||
                       document.documentElement.scrollTop;
    intTopElemento = (intTamanhoTelaHeight+intScrollTop)-(intTamanhoTelaHeight/2)-(objElemento.offsetHeight/2);

	if (intTopElemento<0) intTopElemento = '0';
	
	objElemento.style.top = intTopElemento+'px';
	objElemento.style.left = (intTamanhoTelaWidth+document.body.scrollLeft)-(intTamanhoTelaWidth/2)-(intWidthElemento/2)+'px';
}

function fazLogin(strForm,bolCms)
{
	objFrame = document.getElementById("frameLogin");
	if (bolCms)
	{
		objFrame.src = 'form_captcha.php?strForm='+strForm;
	}
	else
	{
		objFrame.src = 'cms/form_captcha.php?strForm='+strForm;
	}
	
	objDiv = document.getElementById("divFrameLogin");
	objDiv.style.display = 'block';
	objDiv.style.position = 'absolute';
	centralizarObjeto(objDiv);
}

function completaLogin(strForm)
{
	if (strForm)
	{
		eval('document.'+strForm+'.submit();');
	}
	else
	{
		document.frmLoginGestor.submit();
	}
}
function escondeLogin()
{
	objDiv = document.getElementById("divFrameLogin");
	objDiv.style.display = 'none';	
}


