function openLogWindow()
{
	jan_login = window.open('modulos/mt4/ferramentas/seguranca/login_if.php', '_self', 'width=660,height=570,toolbar=no,menubar=no,scrollbars=no,resizable=yes');
}

function popUp(url)
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=550,height=300');
	self.name = "mainWin";
	if(!sealWin){
		alert("Não foi possível abrir a janela! \nVerifique se não há um mecanismo de anti-popup ativado.");
	}
}

function openPopupCenter(url, target, status, width, height)
{
	if (status == null || status == '') {
		status = 'yes';
	}

	if (width == null || width == 0) {
		width = 100;
	}

	if (height == null || height == 0) {
		height = 100;
	}

	return window.open(url, target, 'status=' + status + ',width=' + width + ',height=' + height + ',screenX=200,screenY=200,top='+((window.screen.height - height) / 2)+',left='+((window.screen.width - width) / 2)+',resizable=yes,maximize=yes,scrollbars=no,toolbar=no,menubar=no');
}

function BrowserCheck()
{
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}

var is = new BrowserCheck()

function positionLayer(tabela)
{
	var areaWidth	

	if (is.ns) {
		areaWidth = window.innerWidth;
	} else {
		if (is.ie4 && document.body.scrollWidth > 800) {
			areaWidth = document.body.scrollWidth+140;
		} else {
			areaWidth = document.body.scrollWidth;
		}
	}

	areaWidth = (areaWidth - tabela) / 2;

	if (areaWidth <  0 ) {
		areaWidth = 0;
	}

	return areaWidth;	
}

function MostrarTeclado(intResize,blnOffLine,topW)
{
	if(!topW){
		topW = 270	
	}	
	TecladoVirtual(intResize,topW,0,15,blnOffLine)
}	

function window_onresize(pos,topW) 
{
	if(!pos){
		pos = 170
	}		
	MostrarTeclado(positionLayer(pos)+25,true,topW)
}

function submeteForm(usuario, agencia, conta, senha) 
{
	var usuarioField = document.getElementById('usuario');
	var agenciaField = document.getElementById('agencia');
	var contaField   = document.getElementById('conta');
	var senhaField   = document.getElementById('senha');

	// checa se a senha tem menos que 8 caracteres
	if (usuarioField.value.length > 0 && agenciaField.value.length > 0 
			&& contaField.value.length > 0 && senhaField.value.length < 8)  {
		alert("Senha deve possuir 8 caracteres");
		senha.value = "";
		return false;
	}

  	return true;
}

error = 0;

function DataHora()
{
	var tempo = document.getElementById('tempo');

	if (tempo != undefined) {
		var data = new Date();
		tempo.innerHTML = format(data.getHours()) + ":" + format(data.getMinutes()) + ":" + format(data.getSeconds());
	} else {
		error++;
	}

	if (error < 10) {
		setTimeout("DataHora()", 1000);
	}
}
	
function format(value)
{
  var fmt = "";

  if (value < 10) {
    fmt += "0";
  }

  fmt += value;

  return fmt;
}

function pass()
{
	var localForm     = document.getElementById('usuario');
	var passwordField = document.getElementById('password');
	var pwField       = document.getElementById('pw');
	
	passwordField.value = pwField.value;
	pwField.value = 'Merllin V2.1 - MT4 Tecnologia';
	
	return true;
}

function startPage()
{
	DataHora();
	var usernameField = document.getElementById('username');
	
	usernameField.focus();
}

function validarConfirmacao(){
	if(!document.getElementById("concordo").checked){
		alert("Você deve confirmar que leu e concorda com os termos de uso do sistema");
		return false;
	}
	return true;
}
