//ALTERA IDIOMA
function idioma() {
	boxPT = document.getElementById("pt");
	boxEN = document.getElementById("en");
	
	if (boxEN.style.display=="none"){
		boxEN.style.display="block";
		boxPT.style.display="none";
	}else{
		boxEN.style.display="none";
		boxPT.style.display="block";
	}
}

// POP UP
function popup(theURL, width, height, features) { 
	if(window.screen){
		per_ancho=(width/screen.width)*100;
		per_alto=(height/width)*100;
		win_ancho=(screen.width*per_ancho)/100;
		win_alto=(win_ancho*per_alto)/100;
		x=(screen.width-win_ancho)/2;
		y=(screen.height-win_alto)/2;
	}else{
		x=0;
		y=0;
		win_ancho=w;
		win_alto=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+","+features);
	window.open(theURL, 'popup', winfeatures);
}

//FLASH
/*
versao = 8 .................. <- Versão do player
largura = 200px ............. <- Largura do SWF
altura = 200px .............. <- Altura do SWF
nome = arquivo.swf .......... <- Caminho do SWF, essa opção não pode ser vazia
modo = transparent/opaque ... <- Flash transparente ou opaco / pode ser vazia
cor = #ffffff ............... <- Cor de fundo
*/
function flash(versao, largura, altura, nome, modo, cor)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+versao+',0,0,0" width="'+largura+'" height="'+altura+'>\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="'+nome+'" />\n');
	document.write('<param name="wmode" value="'+modo+'" />\n');
	document.write('<param name="bgcolor" value="'+cor+'" />\n');
	document.write('<embed src="'+nome+'" wmode="'+modo+'" bgcolor="'+cor+'" width="'+largura+'" height="'+altura+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
}


function nada() {
   return;
}

function execSubmit(page, acao)
{
	frm=document.form1;
	frm.action=page;
	frm.acao.value=acao;	
	frm.submit();
}

//LAYER
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=MM_findObj(args[i]))!=null){
			v=args[i+2];
			if (obj.style){
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			}
			if (obj.visibility=='hidden'){
				obj.visibility='visible';
			}
			else{
				obj.visibility='hidden';
			}
			
		}
	}
}

function data(){

	mdata      = new Date()
	mhora      = mdata.getHours()
	mminuto    = mdata.getMinutes()
	msegundos  = mdata.getSeconds()
	mdia       = mdata.getDate()
	mdiasemana = mdata.getDay()
	mmes       = mdata.getMonth()
	mano       = mdata.getFullYear()

if(mdiasemana == 0)
	document.write("'Domingo, ");
		else if(mdiasemana == 1)
			document.write("Segunda Feira, ");
		else if(mdiasemana == 2)
			document.write("Ter&ccedil;a Feira, ");
		else if(mdiasemana == 3)
			document.write("Quarta Feira, ");
		else if(mdiasemana == 4)
			document.write("Quinta Feira, ");
		else if(mdiasemana == 5)
			document.write("Sexta Feira, ");
		else if(mdiasemana == 6)
			document.write("S&aacute;bado, ");

			document.write(+mdia+' de ');
if(mmes == 0)
	document.write("Janeiro de ");
		else if(mmes == 1)
			document.write("Fevereiro de ");
		else if(mmes == 2)
			document.write("Mar&ccedil;o de ");
		else if(mmes == 3)
			document.write("Abril de ");
		else if(mmes == 4)
			document.write("Maio de ");
		else if(mmes == 5)
			document.write("Junho de ");
		else if(mmes == 6)
			document.write("Julho de ");
		else if(mmes == 7)
			document.write("Agosto de ");
		else if(mmes == 8)
			document.write("Setembro de ");
		else if(mmes == 9)
			 document.write("Outubro de ");
		else if(mmes == 10)
			 document.write("Novembro de ");
		else if(mmes == 11)
			 document.write("Dezembro de ");
			 document.write(mano);
}

function formTrabalheConosco(){
	frm=document.form1;
	
	if (frm.nome.value.length==0){
		alert('Preencha o campo "Nome" !!!');
		frm.nome.focus();
		return false;
	}
	if (frm.email.value.length==0){
		alert('Preencha o campo "e-mail" !!!');
		frm.email.focus();
		return false;
	}
	if (frm.dddRes.value.length==0){
		alert('Preencha o campo "DDD" !!!');
		frm.dddRes.focus();
		return false;
	}
	if (frm.telRes.value.length==0){
		alert('Preencha o campo "Telefone" !!!');
		frm.telRes.focus();
		return false;
	}
		if (frm.dddCel.value.length==0){
		alert('Preencha o campo "DDD" !!!');
		frm.dddCel.focus();
		return false;
	}
	if (frm.telCel.value.length==0){
		alert('Preencha o campo "Telefone" !!!');
		frm.telCel.focus();
		return false;
	}
		if (frm.area.value==0){
		alert('Preencha o campo "Área de Atuação" !!!');
		frm.area.focus();
		return false;
	}
	if (frm.curriculum.value.length==0){
		alert('Preencha o campo "Seu curriculum" !!!');
		frm.curriculum.focus();
		return false;
	}
}

function formFaleConosco(obj){
	frm=document.form1;
	
	if (frm.nome.value.length==0){
		alert('Preencha o campo "Nome" !!!');
		frm.nome.focus();
		return false;
	}
	if (frm.email.value.length==0){
		alert('Preencha o campo "e-mail" !!!');
		frm.email.focus();
		return false;
	}
		if (frm.ddd.value.length==0){
		alert('Preencha o campo "DDD" !!!');
		frm.ddd.focus();
		return false;
	}
	if (frm.telefone.value.length==0){
		alert('Preencha o campo "Telefone" !!!');
		frm.telefone.focus();
		return false;
	}
		if (frm.empresa.value.length==0){
		alert('Preencha o campo "Empresa" !!!');
		frm.empresa.focus();
		return false;
	}
	if (frm.msg.value.length==0){
		alert('Preencha o campo "Comentários" !!!');
		frm.msg.focus();
		return false;
	}
	
	desabilita(obj);
	frm.submit();	
}

function habilita(){
	var frm = document.getElementById("FormLogin");
	
	frm.hiddenEntidade.value=frm.lstEntidade.selectedIndex;
	
	document.getElementById("usuario").innerHTML="Login";
	if(frm.lstEntidade.value==1 ){
		document.getElementById("estabelecimento").style.display = "block";
	}
	else if(frm.lstEntidade.value==5){
		document.getElementById("estabelecimento").style.display = "block";
		document.getElementById("usuario").innerHTML="Login POS";
	}
	else{
		document.getElementById("estabelecimento").style.display = "none";
	}
}

function ReiniciaSenha() 
{
    var frm = document.getElementById("FormLogin");
    var serverName = document.getElementById("hAmbiente").value;

    if (frm.lstEntidade.value != 4) 
    {
        alert('Opção válida sómente para Representate!');
        return false;
    }
    
    if (frm.txtUsuario.value.length == 0){
        alert('Preencha o login !!!');
        frm.txtUsuario.focus();
        return false;
    }

    frm.txtReinicia.value = 'true';

    frm.lstEntidade.selectedIndex = 0;

    var url = 'http://www.ativi.com.br/serv/login/wfrmLogin.aspx';

    if (serverName.indexOf("www") < 0){
        if (serverName.indexOf("localhost") < 0)
            url = 'http://'+ serverName +'/ativi/serv/login/wfrmLogin.aspx';
        else			
            url = 'http://'+ serverName +'/web/serv/login/wfrmlogin.aspx';
    }

    frm.action = url;
    frm.submit();

}
	        
function HabilitaReiniciar() 
{

    var e = document.getElementById('lstEntidade').value;
            
    if (e == 4) 
    {
        document.getElementById('divReinicia').style.visibility = 'visible';
    }
    else 
    {
        document.getElementById('divReinicia').style.visibility = 'hidden';               
    }        
}

function desabilita(obj){
	obj.disabled=true;
}

function ValidaPortalServ(){
	var frm = document.getElementById("FormLogin");
	var serverName = document.getElementById("hAmbiente").value;
	
	if ((frm.txtEstabelecimento.value.length == 0)&&
	    ((frm.lstEntidade.value == 5)||(frm.lstEntidade.value == 1))
	   ){
		alert('Preencha o número do estabelecimento !!!');
		frm.txtEstabelecimento.focus();
		return false;
	}
	if ((frm.lstEntidade.value==5)){
		var e;
		try{
			var e=frm.txtUsuario.value
			//e = parseInt(valor);
			if((e/1)!=e){
				alert('Usuário inválido!');
				return false;
				
			}
		}
		catch(e){
			alert('Usuário inválido!');
			return false;
		}
	}
	
	if (frm.txtUsuario.value.length == 0){
		alert('Preencha o login !!!');
		frm.txtUsuario.focus();
		return false;
	}
	
	if (frm.txtSenha.value.length == 0){
		alert('Preencha a senha !!!');
		frm.txtSenha.focus();
		return false;
	}
	
	frm.txtReinicia.value = 'false';
	frm.lstEntidade.selectedIndex = 0;

    var url = 'http://www.ativi.com.br/serv/login/wfrmLogin.aspx';

	if (serverName.indexOf("www") < 0){
	    if (serverName.indexOf("localhost") < 0)
		    url = 'http://'+ serverName +'/ativi/serv/login/wfrmLogin.aspx';
		else			
		    url = 'http://'+ serverName +'/web/serv/login/wfrmlogin.aspx';
	}
	
	frm.action = url;
	frm.submit();
	

}