function Contato()
{
	/* FORMUL'ARIO DE CONTATO */
  if (document.contato.assuntoGrupo.value == ""){
  		alert("Digite o Tipo");
  		document.contato.assuntoGrupo.style.borderColor = "#ff0000"
		document.contato.assuntoGrupo.style.borderStyle = "solid"
		document.contato.assuntoGrupo.style.borderWidth = "1px"
		document.contato.assuntoGrupo.focus();
      return false;
  }
  if (document.contato.nome.value == ""){
  		alert("Digite seu nome");
  		document.contato.nome.style.borderColor = "#ff0000"
		document.contato.nome.style.borderStyle = "solid"
		document.contato.nome.style.borderWidth = "1px"
		document.contato.nome.focus();
      return false;
  }
  if (document.contato.email.value == ""){
  		alert("Digite seu E-mail");
  		document.contato.email.style.borderColor = "#ff0000"
		document.contato.email.style.borderStyle = "solid"
		document.contato.email.style.borderWidth = "1px"
		document.contato.email.focus();
      return false;
  }
  if (document.contato.telefone1.value == ""){
  		alert("Digite seu Telefone");
  		document.contato.telefone1.style.borderColor = "#ff0000"
		document.contato.telefone1.style.borderStyle = "solid"
		document.contato.telefone1.style.borderWidth = "1px"
		document.contato.telefone1.focus();
      return false;
  }
  if (document.contato.mensagemtext.value == ""){
  		alert("Você deve digitar uma mensagem.");
  		document.contato.mensagemtext.style.borderColor = "#ff0000"
		document.contato.mensagemtext.style.borderStyle = "solid"
		document.contato.mensagemtext.style.borderWidth = "1px"
		document.contato.mensagemtext.focus();
      return false;
  }
  
   return true;
}

function ValidaAmigo()
{
	/* FORMUL'ARIO DE CONTATO */
  if (document.Formamigo.nome1.value == ""){
  		alert("Você deve digitar seu nome");
  		document.Formamigo.nome1.style.borderColor = "#ff0000"
		document.Formamigo.nome1.style.borderStyle = "solid"
		document.Formamigo.nome1.style.borderWidth = "1px"
		document.Formamigo.nome1.focus();
      return false;
  }
  if (document.Formamigo.nome2.value == ""){
  		alert("Você deve digitar o nome de seu amigo");
  		document.Formamigo.nome2.style.borderColor = "#ff0000"
		document.Formamigo.nome2.style.borderStyle = "solid"
		document.Formamigo.nome2.style.borderWidth = "1px"
		document.Formamigo.nome2.focus();
      return false;
  }
  if (document.Formamigo.email.value == ""){
  		alert("Você deve digitar o e-mail de seu amigo");
  		document.Formamigo.email.style.borderColor = "#ff0000"
		document.Formamigo.email.style.borderStyle = "solid"
		document.Formamigo.email.style.borderWidth = "1px"
		document.Formamigo.email.focus();
      return false;
  }
  
   return true;
}

function request(param){	
	var qString = ''; //texto da querystring
	var arrayIndice; //array com o nome do parametro
	var arrayParam; //array com o valor do parametro
	var posQs = 0; //posicao inicial da da interrogação
	var location = window.self.location.href; //url completa acessada
	var aux;
	if(param != ''){
		posQs = location.indexOf("?"); //localiza a primeira interrogação
		qString = '&' + location.substr(posQs+1); //substritui a interrogação pelo '&'
		arrayIndice = qString.split('&'); //monta o array pelo '&'
		for (var i = 0; i < arrayIndice.length; i++){ //percorre todas as posições do array
			arrayParam = arrayIndice[i].split('='); //novo array para separar o nome do valor
			aux = arrayParam[0];
			if (aux.toUpperCase() == param.toUpperCase()){ //se o nome do parametro do array = nome do parametro da função
				aux	=	arrayParam[1];
				aux = aux.replace('#', '');
				return aux; //retorna o valor
				break;
			}
		}
	}
	//se não encontrou devolve vazio
	return '';
}

function ValidaIntegra()
{
	/* FORMUL'ARIO DE CONTATO */
  if (document.frEntrar.txtIdentificacao.value == ""){
  		alert("Voce deve digitar seu Usuario");
  		document.frEntrar.txtIdentificacao.style.borderColor = "#ff0000"
		document.frEntrar.txtIdentificacao.style.borderStyle = "solid"
		document.frEntrar.txtIdentificacao.style.borderWidth = "1px"
		document.frEntrar.txtIdentificacao.focus();
      return false;
  }
  if (document.frEntrar.txtSenha.value == ""){
  		alert("Voce deve digitar sua Senha");
  		document.frEntrar.txtSenha.style.borderColor = "#ff0000"
		document.frEntrar.txtSenha.style.borderStyle = "solid"
		document.frEntrar.txtSenha.style.borderWidth = "1px"
		document.frEntrar.txtSenha.focus();
      return false;
  }
     
   var usuario = document.getElementById('txtIdentificacao').value;
	var senha = document.getElementById('txtSenha').value;
	var origem = 5;
	if(request('origem') > 0){
		origem = 	request('origem');
	}
	if (usuario == '') {
		alert('Preencha seu nome de usuário do Integra');
		document.getElementById('txtIdentificacao').focus();
	}else if (senha == '') {
		alert('Preencha o a sua Senha');
		document.getElementById('txtSenha').focus();
	}	
//usuario = usuario.replace('ã', '&atilde;');
	document.frEntrar.target = "_self";
	document.frEntrar.action = "index_logar.php";
	document.frEntrar.submit();
	//window.location = "http://www.api.adv.br/integra4/include/logarSistema.asp?txtUsuario=" + usuario +  "&txtSenha=" + senha;
	
	//return true;
}

