function carregaFlash(caminho,largura,altura)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="movie" value="'+caminho+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="menu" value="false">');
	document.write('<embed src="'+caminho+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" menu="false"  width="'+largura+'" height="'+altura+'"></embed>');
	document.write('</object>');
}

function carregaFlash_transp(caminho,largura,altura)
{
	document.write('<object data="'+caminho+'" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="movie" value="'+caminho+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="menu" value="false">');	
	document.write('</object>');
}

function somente_numero(campo){  
	var digits="0123456789.-/() "  
	var campo_temp   
    for (var i=0;i<campo.value.length;i++){  
        campo_temp=campo.value.substring(i,i+1)   
        if (digits.indexOf(campo_temp)==-1){  
            campo.value = campo.value.substring(0,i);  
        }  
    }  
}  

function FormataFone(campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 14)
	{
		if (tam == 3)
			campo.value = '(' + vr.substr(0, 2) + ') ';
		if (tam == 10)
			campo.value = vr.substr(0, 10) + '-';
	}
}

/**
* Formata o Campo de acordo com a mascara informada.
* Ex de uso: onkeyup="AplicaMascara('00:00:00', this);".
* @author Igor Escobar (blog@igorescobar.com)
* @param Mascara String que possui a mascara de formatação do campo.
* @param elemento Campo que será formatado de acordo com a mascara, voce pode informar o id direto ou o próprio elemento usando o this.
* @returns {void}
*/
function AplicaMascara(Mascara, elemento){
 
    // Seta o elemento
    var elemento = (elemento) ? elemento : document.getElementById(elemento);
    if(!elemento) return false;
 
    // Método que busca um determinado caractere ou string dentro de uma Array
    function in_array( oque, onde ){
            for(var i = 0 ; i < onde.length; i++){
            if(oque == onde[i]){
                return true;
            }
        }
        return false;
    }
    // Informa o array com todos os caracteres que podem ser considerados caracteres de mascara
    var SpecialChars = [':', '-', '.', '(',')', '/', ',', '_'];
    var oValue = elemento.value;
    var novo_valor = '';
    for( i = 0 ; i < oValue.length; i++){
        //Recebe o caractere de mascara atual
        var nowMask = Mascara.charAt(i);
        //Recebe o caractere do campo atual
        var nowLetter = oValue.charAt(i);
        //Aplica a masca
        if(in_array(nowMask, SpecialChars) == true && nowLetter != nowMask){
            novo_valor +=  nowMask + '' + nowLetter;
        } else {
            novo_valor += nowLetter;
        }
        // Remove regras duplicadas
        var DuplicatedMasks = nowMask+''+nowMask;
        while (novo_valor.indexOf(DuplicatedMasks) >= 0) {
            novo_valor = novo_valor.replace(DuplicatedMasks, nowMask);
        }
    }
    // Retorna o valor do elemento com seu novo valor
    elemento.value = novo_valor;
 
}

function sobre(what) {
	ajax = ajaxInit();
	if(ajax)
	{
		ajax.open("GET", "sobre_view.php?what="+what, true);
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)
				{
					document.getElementById('textos').innerHTML = '';
					document.getElementById('textos').innerHTML = ajax.responseText;					
				}
				else
				{
					alert(ajax.statusText);
				}
			}		     	
		}
	ajax.send(null);
	}
	
	if(what == "sobre_institucional") {
		document.getElementById('sobIMG').innerHTML = '<a rel="light" href="imgs/ARXO1.jpg" title="Soldas Pereira em 1967."><img src="imgs/soldasPereira.jpg" alt="Soldas Pereira" /></a><p>Soldas Pereira em 1967.</p><a rel="light" href="imgs/areaG.jpg" title="Matriz ARXO Pi&ccedil;arras."><img src="imgs/fotoaerea.jpg" alt="Matriz ARXO Pi&ccedil;arras" /></a><p>Matriz ARXO Pi&ccedil;arras.</p><a rel="light" href="imgs/filial_recife_max.jpg" title="Filial ARXO Recife."><img src="imgs/filial_recife.jpg" alt="Filial ARXO Recife" /></a><p>Filial ARXO Recife.</p>';
	}
	else if(what == "sobre_competencias") {
		document.getElementById('sobIMG').innerHTML = '<a rel="light" href="imgs/competencia_1_max.jpg"><img src="imgs/competencia_1.jpg" /></a><p></p><a rel="light" href="imgs/competencia_2_max.jpg"><img src="imgs/competencia_2.jpg"/></a><p></p>';
	}
	
}

function segmento(cdsegmento) {
	ajax = ajaxInit();
	if(ajax)
	{
		ajax.open("GET", "segmento_view.php?cdsegmento="+cdsegmento, true);
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)
				{
					document.getElementById('textos').innerHTML = '';
					document.getElementById('textos').innerHTML = ajax.responseText;
				}
				else
				{
					alert(ajax.statusText);
				}
			}		     	
		}
	ajax.send(null);
	}
}

function noticias_pag(pag) {
	ajax = ajaxInit();
	if(ajax)
	{
		ajax.open("GET", "noticias_pag.php?pag="+pag, true);
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)
				{
					document.getElementById('inner_menu').innerHTML = '';
					document.getElementById('inner_menu').innerHTML = ajax.responseText;
				}
				else
				{
					alert(ajax.statusText);
				}
			}		     	
		}
	ajax.send(null);
	}
}

function noticias(cdnoticia) {
	ajax = ajaxInit();
	if(ajax)
	{
		ajax.open("GET", "noticias_view.php?cdnoticia="+cdnoticia, true);
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)
				{
					document.getElementById('textos').innerHTML = '';
					document.getElementById('textos').innerHTML = ajax.responseText;
				}
				else
				{
					alert(ajax.statusText);
				}
			}		     	
		}
	ajax.send(null);
	}
}

function newsletter() {
	if(document.news.n_email.value == '') { alert('Por favor, preencha o campo e-mail corretamente.'); document.news.n_email.focus(); return(false); }
	else {
		ajax = ajaxInit();
		if(ajax)
		{
			dados = RetornaValores(document.news);
			ajax.open("GET", "newsletter_add.php?"+dados, true);
			ajax.onreadystatechange = function()
			{
				if(ajax.readyState == 4)
				{
					if(ajax.status == 200)
					{
						alert(ajax.responseText);
						document.news.reset();
					}
					else
					{
						alert(ajax.statusText);
					}
				}		     	
			}
		ajax.send(null);
		}
	}
}

function contato() {
	if(document.contact.c_nome.value == '') { alert('Por favor, preencha o campo nome corretamente.'); document.contact.c_nome.focus(); return(false); }
	else if(document.contact.c_email.value == '') { alert('Por favor, preencha o campo e-mail corretamente.'); document.contact.c_email.focus(); return(false); }
	else if(document.contact.departamento.value == '') { alert('Por favor, preencha o campo área de interesse corretamente.'); document.contact.departamento.focus(); return(false); }
	else if(document.contact.c_msg.value == '') { alert('Por favor, preencha o campo mensagem corretamente.'); document.contact.c_msg.focus(); return(false); }
	else {
		ajax = ajaxInit();
		if(ajax)
		{
			dados = RetornaValores(document.contact);
			ajax.open("GET", "contato_envia.php?"+dados, true);
			ajax.onreadystatechange = function()
			{
				if(ajax.readyState == 4)
				{
					if(ajax.status == 200)
					{
						alert(ajax.responseText);
						document.contact.reset();
					}
					else
					{
						alert(ajax.statusText);
					}
				}		     	
			}
		ajax.send(null);
		}
	}
}

function representantes() {
	if(document.repre.r_nome.value == '') { alert('Por favor, preencha o campo nome corretamente.'); document.repre.r_nome.focus(); return(false); }
	else if(document.repre.r_email.value == '') { alert('Por favor, preencha o campo e-mail corretamente.'); document.repre.r_email.focus(); return(false); }
	else if(document.repre.r_msg.value == '') { alert('Por favor, preencha o campo mensagem corretamente.'); document.repre.r_msg.focus(); return(false); }
	else {
		ajax = ajaxInit();
		if(ajax)
		{
			dados = RetornaValores(document.repre);
			ajax.open("GET", "representantes_envia.php?"+dados, true);
			ajax.onreadystatechange = function()
			{
				if(ajax.readyState == 4)
				{
					if(ajax.status == 200)
					{
						alert(ajax.responseText);
						document.repre.reset();
					}
					else
					{
						alert(ajax.statusText);
					}
				}		     	
			}
		ajax.send(null);
		}
	}
}

function pesquisa() {
	ajax = ajaxInit();
	if(ajax)
	{
		dados = RetornaValores(document.form);
		ajax.open("GET", "pesquisa_envia.php?envio=sim&"+dados, true);
		ajax.onreadystatechange = function()
	    {
	    	if(ajax.readyState == 4)
	    	{
	    		if(ajax.status == 200)
	    		{
					eval(ajax.responseText);					
	       		}
	       		else
	       		{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
	ajax.send(null);
	}	
}

function cotacao() {
	if(document.frmcotacao.c_nome.value == '') { alert('Por favor, preencha o campo nome corretamente.'); document.frmcotacao.c_nome.focus(); return(false); }
	else if(document.frmcotacao.c_email.value == '') { alert('Por favor, preencha o campo e-mail corretamente.'); document.frmcotacao.c_email.focus(); return(false); }
	else if(document.frmcotacao.departamento.value == '') { alert('Por favor, preencha o campo segmento corretamente.'); document.frmcotacao.departamento.focus(); return(false); }
	else if(document.frmcotacao.c_msg.value == '') { alert('Por favor, preencha o campo mensagem corretamente.'); document.frmcotacao.c_msg.focus(); return(false); }
	else {
		ajax = ajaxInit();
		if(ajax)
		{
			dados = RetornaValores(document.frmcotacao);
			ajax.open("GET", "cotacao_envia.php?"+dados, true);
			ajax.onreadystatechange = function()
			{
				if(ajax.readyState == 4)
				{
					if(ajax.status == 200)
					{
						alert(ajax.responseText);
						document.frmcotacao.reset();
					}
					else
					{
						alert(ajax.statusText);
					}
				}		     	
			}
		ajax.send(null);
		}
	}
}

function utm() {
	ajax = ajaxInit();
	if(ajax)
	{
		dados = RetornaValores(document.formUtm);
		ajax.open("GET", "utm_envia.php?envio=sim&"+dados, true);
		ajax.onreadystatechange = function()
	    {
	    	if(ajax.readyState == 4)
	    	{
	    		if(ajax.status == 200)
	    		{	
					alert(ajax.responseText);
					document.formUtm.reset();
					eval(ajax.responseText);
	       		}
	       		else
	       		{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
	ajax.send(null);
	}	
}