function openAjax() {
	var ajax;
	try {
		ajax = new XMLHttpRequest();
	} catch(ee) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				ajax = false;
			}
		}
	}
	return ajax;
}


function enviar(){
	var ajax = openAjax(); // ajax (pode ser qualquer variavel)
	
	nome = document.getElementById('name').value;
	empr = document.getElementById('company').value;
	cidd = document.getElementById('city').value;
	estd = document.getElementById('Estados').value;
	mail = document.getElementById('Email').value;
	
	
	if (nome != '' & empr != "" & cidd != "" & estd != "" & mail != "") {
		
				carg= document.getElementById('cargo').value;
				ende = document.getElementById('address').value;
				cep = document.getElementById('Zip').value;
				telf = document.getElementById('Telefone').value;
			
				//sist = document.getElemntById('TodosSistemas').checked;
				
							sist = document.getElementById('todossistemas').checked;
									if (sist == true) {
								sist = document.getElementById('todossistemas').value;
							}
				
							repr = document.getElementById('Representacao').checked;							
									if (repr != false) {
							repr = document.getElementById('Representacao').value;
									}
				
							
							cont_pub = document.getElementById('ContabilidadePublica').checked;
											if (cont_pub != false) {
							cont_pub = document.getElementById('ContabilidadePublica').value;
							}
							
							cont_pre = document.getElementById('ContabilidadePrevidenciaria').checked;
											if (cont_pre != false) {
							cont_pre = document.getElementById('ContabilidadePrevidenciaria').value;
							}
							
							folh_pag = document.getElementById('FolhaPagamento').checked;
											if (folh_pag != false) {
							folh_pag = document.getElementById('FolhaPagamento').value;
							}
							
							saud_ocu = document.getElementById('SaudeOcupacional').checked;
											if (saud_ocu != false) {
							saud_ocu = document.getElementById('SaudeOcupacional').value;
							}
											
							saud_pub = document.getElementById('SaudePublica').checked;
											if (saud_pub != false) {
							saud_pub = document.getElementById('SaudePublica').value;
							}
							
							tribut = document.getElementById('Tributos').checked;
											if (tribut != false) {
							tribut = document.getElementById('Tributos').value;
							}
							
							teso = document.getElementById('Tesouraria').checked;
											if (teso != false) {
							teso = document.getElementById('Tesouraria').value;
							}
							
							audit = document.getElementById('AuditoriaFiscal').checked;
											if (audit != false) {
							audit = document.getElementById('AuditoriaFiscal').value;
							}
							
							arrec = document.getElementById('Arrecadacao').checked;
											if (arrec != false) {
							arrec = document.getElementById('Arrecadacao').value;
							}
							
							
							
							bibli = document.getElementById('Biblioteca').checked;
											if (bibli != false) {
							bibli = document.getElementById('Biblioteca').value;
							}
							
							obitu = document.getElementById('Obituario').checked;
											if (obitu != false) {
							obitu = document.getElementById('Obituario').value;
							}
							
							prot_pro = document.getElementById('ProtocoloeProcessos').checked;
											if (prot_pro != false) {
							prot_pro = document.getElementById('ProtocoloeProcessos').value;
							}
							
							legis = document.getElementById('Legislativo').checked;
											if (legis != false) {
							legis = document.getElementById('Legislativo').value;
							}
							
							regis = document.getElementById('RegistrodeLeis').checked;
												if (regis != false) {
							regis = document.getElementById('RegistrodeLeis').value;
							}
							
							almox = document.getElementById('Almoxarifado').checked;
											if (almox != false) {
							almox = document.getElementById('Almoxarifado').value;
							}
							
							lici_co = document.getElementById('licitacao').checked;
											if (lici_co != false) {
							lici_co = document.getElementById('licitacao').value;
											}
							
							patri = document.getElementById('Patrimonio').checked;
											if (patri != false) {
							patri = document.getElementById('Patrimonio').value;
							}
							
							sane_bas = document.getElementById('SaneamentoBasico').checked;
												if (sane_bas != false) {
							sane_bas = document.getElementById('SaneamentoBasico').value;
							}
							
							veic = document.getElementById('Veiculos').checked;
											if (veic != false) {
							veic = document.getElementById('Veiculos').value;
							}
							
							gera_rel = document.getElementById('GeradordeRelatorios').checked;
											if (gera_rel != false) {
							gera_rel = document.getElementById('GeradordeRelatorios').value;
							}
							

							text = document.getElementById('textObs').value;
							
							//document.submit();

							ajax.open ('Get','mail.php?nome='+nome +'& empr='+empr +'& cidd='+cidd +'& estd='+estd +'& mail='+mail +'& carg='+carg +'& ende='+ende +'& cep='+cep +'& telf='+telf +'& sist='+sist +'& repr='+repr +'& cont_pub='+cont_pub +'& cont_pre='+cont_pre +'& folh_pag='+folh_pag +'& saud_ocu='+saud_ocu +'& saud_pub='+saud_pub +'& tribut='+tribut +'& teso='+teso +'& audit='+audit +'& arrec='+arrec +'& bibli='+bibli +'& obitu='+obitu +'& prot_pro='+prot_pro +'& legis='+legis +'& regis='+regis +'& almox='+almox +'& lici_co='+lici_co +'& patri='+patri +'& sane_bas='+sane_bas +'& veic='+veic +'& gera_rel='+gera_rel +'& text='+text, true);
						
				
				
							ajax.onreadystatechange = function () {		
						var conteudo = document.getElementById('resposta');		
						//andamento
						if (ajax.readyState == 1) {
							// Hora atual
							conteudo.innerHTML='Carregando ...';			
						}//if		
						//verifica o status da aquisição no caso 4 é completa
						if (ajax.readyState == 4){
							conteudo.innerHTML='';		
							//verifica o codigo http enviado pelo servidor web no caso 200 = ok
							if (ajax.status == 200){			
								//conteudo.innerHTML='Pagina encontrada';
							document.getElementById('formulario').innerHTML=ajax.responseText;	
							
							
							
							}//if		
						}//if	
					}// ajax
					ajax.send(null);
			
	}else {
			document.getElementById('resposta').innerHTML='<font color="red"><n>Preencha todos os campos com asterisco !!!</n></font>';
	}//else
	
	
}//function fo_pag
