/*<RMJSDep>SharedServices\ClientScripts\BrowserUtils; SharedServices\ClientScripts\WindowUtils</RMJSDep>*/

/*
Arquivo que tem funções especíoficas do Login.aspx
*/


function DoLoginFocus()
{
	var txtUser = document.getElementById("txtUser");
	var txtPass = document.getElementById("txtPass");
	
	if ((txtUser!=null) &&
		(txtPass!=null))
	{
		if (txtUser.value!="")
			txtPass.focus();
		else
			txtUser.focus();
	}
}

/*
Verifica se há histórico no atual Browser, se houver, fecha e abre nova janela
*/
function CheckHistory(LoginUrl, WindowFeatures)
{
	if (((isIE()) && history.length >= 1) || 
		(history.length > 1))
	{
		OpenCorporeWindow(LoginUrl,WindowFeatures);
	}
}

function SetUserPass(Pass)
{
	var txtPass = document.getElementById("txtPass");
	if (txtPass!=null)
	{
		txtPass.value = Pass;
	}
}

function SetLoginLayout()
{	
	DoCenterDiv('divLogin');//donotlocalize
}

function DoCenterWindow()
{
	var sizex = (screen.width > 800) ? 900 : 800;
	var sizey = (screen.width > 800) ? 670 : 600;
	
	posx = (screen.availWidth  - sizex) / 2;
	posy = (screen.availHeight - sizey) / 2;
	
	if ((posx > 0) && (posy > 0) && (screen.width > 800))
	{
		self.moveTo(posx, posy);
	}
	else
	{
		self.moveTo(0,0);
	}
}

function DoCenterDiv(ElementId)
{
	var Div = document.getElementById(ElementId);

	var AvailWidth;
	var AvailHeight;
	if (isIE())
	{
		AvailWidth = document.body.offsetWidth;
		AvailHeight = document.body.offsetHeight;
	}
	else
	{
		AvailWidth = window.innerWidth;
		AvailHeight = window.innerHeight;
	}
	
	posx = (AvailWidth  - parseInt(Div.offsetWidth, 10)) / 2;
	posy = (AvailHeight - parseInt(Div.offsetHeight, 10)) / 2;
	
	Div.style.left = posx;
	Div.style.top  = posy;
	Div.style.display = '';
}

function LoginOnLoad()
{
	DoLoginFocus();
}

function OpenCorporeWindow(Url, WindowFeatures)
{
    var OpenedWindow = OpenWindow(Url, '_blank', WindowFeatures);//donotlocalize
    
    if (OpenedWindow!=null)
    {
	    if (isIE())
	    {
		    window.opener = OpenedWindow;		
	        window.close();
	    }
	    else
	    {
		    //Verificando se pode fechar a janela de acordo com o valor passado 
		    //por querystring 'WindowFeaturesApplied=0'
		    if ((window.location.href.indexOf('WindowFeaturesApplied=1')!=-1))//donotlocalize
			    window.close();
	    }
	}
}
function RedirectToNewUser()
{
    window.location.href = 'Source/RHU-RECHUMANOS/RM.Rhu.Curriculo/Public/Login.aspx';
}

function RedirectToCotacao()
{
    window.location.href = 'Source/Cmp-Compras/RM.Cmp.Cotacao/Auth/LoginOrcamento.aspx';
}

function RedirectToExecutor()
{
    window.location.href = 'Source/Tst-Avaliacao/RM.Tst.Provas/Public/TstMain.aspx';
}

function RedirectToProcessoSeletivo()
{
    window.location.href = 'Source/Edu-Educacional/EduPS-ProcessoSeletivo/Public/EduPSFirewall.htm';//donotlocalize
}

function RedirectToPesquisaAcervoBiblios() {
    window.location.href = 'Source/Bib-Biblioteca/Public/BibFirewall.htm'; //donotlocalize
}
