function makeFlash(arquivo,id,largura,altura) {
    if (window.navigator.appName == "Microsoft Internet Explorer") {
        document.write('<object id="'+id+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+largura+'" height="'+altura+'">');
        document.write('<param name="allowScriptAccess" value="sameDomain">');
        document.write('<param name="movie" value="'+arquivo+'">');
        document.write('<param name="quality" value="high">');
        document.write('<param name="menu" value="false">');
        document.write('<param name="wmode" value="transparent">');
        document.write('<param name="salign" value="t">');
        document.write('</object>');

    }else{
        document.write('<embed src="'+arquivo+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'" menu="false" wmode="transparent"></embed>');
    }
}

function verificaContato(){
		form = document.formContato;
		if(form.nome.value.length==0){
			alert('Campo Nome Obrigatório!');
			form.nome.focus();
			return false;
		}
		if(form.empresa.value.length==0){
			alert('Campo Empresa Obrigatório!');
			form.empresa.focus();
			return false;
		}
		if(form.email.value.length==0){
			alert('Campo E-mail Obrigatório!');
			form.email.focus();
			return false;
		}
		if(form.pretelefone.value.length==0){
			alert('Campo DDD Obrigatório!');
			form.pretelefone.focus();
			return false;
		}
		if(form.telefone.value.length==0){
			alert('Campo telefone Obrigatório!');
			form.telefone.focus();
			return false;
		}
		if(form.mensagem.value.length==0){
			alert('Campo mensagem Obrigatório!');
			form.telefone.focus();
			return false;
		}
		document.formContato.remetente.value = form.email.value;
	}
	
var m = 0;
	
function scrollNews(elemento, tipo) {
    if (tipo == 'vai') {
        if (m == '0') {
            document.getElementById(elemento).style.top = '0';
        }
        else {
            document.getElementById(elemento).style.top = m = m - 319;
		}
    }
    else if (tipo == 'volta') {
        if (m == '-4500') {
            document.getElementById(elemento).style.top = '-4500';
        }
        else {
            document.getElementById(elemento).style.top = m = m - 450;
        }
    }
    alert(document.getElementById(elemento).style.top);
}

function linkarLocalizacao() {
	document.getElementById("localizacaoBase").href = "http://maps.google.com/maps?f=q&hl=pt-BR&geocode=&time=&date=&ttype=&q=Rua+Coromandel+47&sll=-23.57837,-46.662217&sspn=0.011623,0.023389&ie=UTF8&ll=-23.524762,-46.723437&spn=0.023255,0.046778&z=15&om=1";
	document.getElementById("localizacaoBase").target = "_blank";
}

function abrirAtendimento() {
	window.open('http://www.cyber1.net.br/craft/livehelp.php?page=livehelp.php&department=2&tab=1', 'AtendimentoOnline', 'width=1020,height=580,resize=no,scrollbars=no,menubar=no,status,no');
}

function formAparecer(acao, id) {
		if (acao == "aparecer") {
			document.getElementById(id).className = "aparecer";
		}
		if (acao == "sumir") {
			document.getElementById(id).className = "sumir";
		}
}

function habilitar(quem) {
	if (quem == "deficiencia") {
			document.getElementById("tipo_deficiencia").disabled = false;
			document.getElementById("ajudas_tecnicas").disabled = false;
			document.getElementById("meio_locomocao").disabled = false;
	}
	if (quem == "experiencia_profissional") {
			document.getElementById("area_atuacao_ultima").disabled = false;
			document.getElementById("renumeracao").disabled = false;
			document.getElementById("tipo_relacao_funcional").disabled = false;
			document.getElementById("nivel_profissional").disabled = false;
	}
}

function validarTrabalheConosco() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";

  // validações dos campos gerais
  if (document.getElementById("nome_completo").value == "") {
	 passou = false; alerta += "- Nome preenchido incorretamente.\n";
  }
    if (document.getElementById("dia").value == "") {
	 passou = false; alerta += "- Dia preenchido incorretamente.\n";
  }
    if (document.getElementById("mes").value == "") {
	 passou = false; alerta += "- Mês preenchido incorretamente.\n";
  }
    if (document.getElementById("ano").value == "") {
	 passou = false; alerta += "- Ano preenchido incorretamente.\n";
  }
  if (document.getElementById("estado_civil").value == "") {
	 passou = false; alerta += "- Estado Civil preenchido incorretamente.\n";
  }
   if (document.getElementById("email_trabalhe").value == "") {
     passou = false; alerta += "- E-mail preenchido incorretamente.\n";
  }else{
      if (!validarEmail(document.getElementById("email_trabalhe").value)) {
           passou = false; alerta += "- E-mail preenchido incorretamente.\n";
      }
  }
  if (document.getElementById("telefone").value == "") {
	 passou = false; alerta += "- Telefone preenchido incorretamente.\n";
  }
  if (document.getElementById("celular").value == "") {
	 passou = false; alerta += "- Celular preenchido incorretamente.\n";
  }
    if (document.getElementById("endereco").value == "") {
	 passou = false; alerta += "- Endereço preenchido incorretamente.\n";
  }
  if (document.getElementById("numero").value == "") {
	 passou = false; alerta += "- Número preenchido incorretamente.\n";
  }
    if (document.getElementById("bairro").value == "") {
	 passou = false; alerta += "- Bairro preenchido incorretamente.\n";
  }
  if (document.getElementById("estado").value == "") {
	 passou = false; alerta += "- Estado preenchido incorretamente.\n";
  }
    if (document.getElementById("cidade").value == "") {
	 passou = false; alerta += "- Cidade preenchido incorretamente.\n";
  }
    if (document.getElementById("cep").value == "") {
	 passou = false; alerta += "- CEP preenchido incorretamente.\n";
  }
    if (document.form1.experiencia_profissional.value == "Sim") {
	 
	  if (document.getElementById("area_atuacao_ultima").value == "") {
		 passou = false; alerta += "- Área de Atuação preenchido incorretamente.\n";
	  }
	  if (document.getElementById("renumeracao").value == "") {
		 passou = false; alerta += "- Remuneração preenchido incorretamente.\n";
	  }
	  if (document.getElementById("tipo_relacao_funcional").value == "") {
		 passou = false; alerta += "- Tipo de relação funcional preenchido incorretamente.\n";


	  }
	  if (document.getElementById("nivel_profissional").value == "") {
		 passou = false; alerta += "- Nível Profissional preenchido incorretamente.\n";
	  }
  }
  if (document.getElementById("curriculo").value == "") {
	 passou = false; alerta += "- Currículo preenchido incorretamente.\n";
  }
  if (document.getElementById("ingles_leitura").value == "" || document.getElementById("ingles_escrita").value == "" ||  document.getElementById("ingles_fala").value == ""){
	 passou = false; alerta += "- Nível de Inglês preenchido incorretamente.\n";
  }
  if (document.getElementById("espanhol_leitura").value == "" || document.getElementById("espanhol_escrita").value == "" ||  document.getElementById("espanhol_fala").value == ""){
	 passou = false; alerta += "- Nível de Espanhol preenchido incorretamente.\n";
  }
  if (document.getElementById("info_word").value == "" || document.getElementById("info_ppt").value == "" ||  document.getElementById("info_excel").value == "" || document.getElementById("info_internet").value == "") {
	 passou = false; alerta += "- Conhecimentos em Microinformática preenchido incorretamente.\n";
  }
  
  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validarEmail(email)
{
	var s = email;
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	return false;
}

// Função que monta Ajax
function ajaxFuncao(){
    var xmlHttp;
    try{
        // Internet Explorer
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
        try{
            // Firefox, Opera 8.0+, Safari
            xmlHttp=new XMLHttpRequest();
        }
        catch (e){
            try{
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e){
                alert("O seu browser não suporta AJAX!");
                return false;
            }
        }
    }
    return xmlHttp;
}

// Objeto do Ajax
var ajax;

function montaCidade(estado){
	ajax=ajaxFuncao();
	parametros='estado='+estado;
	ajax.open('post','../system/cidade.php',true);
    ajax.setRequestHeader('encoding','ISO-8859-1');
    ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
    ajax.setRequestHeader("Pragma", "no-cache");
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded, text/xml, charset=iso-8859-1');
    ajax.setRequestHeader("Content-length", parametros.length);
    ajax.setRequestHeader("Connection", "close");
    ajax.onreadystatechange=montadoCidade;
    ajax.send(parametros);
}

function montadoCidade(){
	if(ajax.readyState==4){
    	 if(ajax.status == 200){
    	 	document.getElementById('cidade_div').innerHTML=ajax.responseText;
    	 }
	}
}

function abrirJanelaV2(h, w, imagem, nome) {

  //var altura_img = h - 29;

  Win = window.open("","","height="+h+",width="+w+",scrollbars=no,status=0,resizable=0");
  Win.document.write("<html>\n<head>\n");
  Win.document.write("<title>QualityManager - "+nome+"</title>\n");
  Win.document.write("<style type=\"text/css\">@import url(\"../css/estilos.css\");</style>\n");
  Win.document.write("</head>\n<body>\n");
  Win.document.write("<img src=\""+imagem+"\" width=\""+w+"\" height=\""+h+"\" />\n");
  Win.document.write("</body>\n</html>")
  Win.document.close();
}

function validarLogin() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";

  // validações dos campos gerais
  if (document.getElementById("codigo").value == "") {
	 passou = false; alerta += "- Digite o seu login.\n";
  }
  if (document.getElementById("senha").value == "") {
	 passou = false; alerta += "- Digite sua senha.\n";
  }
  
  if (passou == true) { document.login.submit(); limpar(); }
  else { alert(alerta); return false; }
}

function limpar() {
	document.getElementById("codigo").value = ""
	document.getElementById("senha").value = ""
}

function formataNumero(campo, event){
	var codigo 	= 	event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	var palavra = String.fromCharCode(codigo);
	
	if(codigo == 32){
		return false;
	}
	
	if(palavra >= 0 || palavra <= 9){
		return true;	
	}else if(codigo == 37 || codigo == 39 || codigo == 8){
		return true;
	}else if(campo.value.length == 10 && codigo == 97){
		return true;
	}else{
		return false;
	}	
}

function OnEnter(evt) {
	var key_code = evt.keyCode ? evt.keyCode : evt.charCode ? evt.charCode : evt.which ? evt.which : void 0;
	if (key_code == 13) {
		validarLogin()
	}
}