var IE_all_cache = new Object();
function IE_getElementById(id) {
  if (IE_all_cache[id] == null) {
    IE_all_cache[id] = document.all[id];
  }
  return IE_all_cache[id];
}

if (document.all) {
  if (!document.getElementById) {
    document.getElementById = IE_getElementById;
  }
}

//-----------------------------------
// Browser detection
var agt = navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_opera;
var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all;


function valida()
{
	var l1 = window.document.form_contato.nome;
	var l2 = window.document.form_contato.email;
	var l3 = window.document.form_contato.assunto;
	var l4 = window.document.form_contato.fone;
	var l5 = document.getElementById('texto');	//window.document.form_contato.texto;

    if ( l1.value.length == 0 ) {
		alert("Digite o Seu Nome !!");     l1.focus();     return false;
	}
	if ( !valida_texto(l1.value) ) {
		alert("Por favor, não utilize tags html !!");     l1.focus();     return false;
	}
	
    if ( l2.value.length == 0 ) {
		alert("Digite o Seu E-mail !!");     l2.focus();     return false;
	}
	if ( !valida_texto(l2.value) ) {
		alert("Por favor, não utilize tags html !!");     l2.focus();     return false;
	}

	if ( l3.value.length == 0 ) {
		alert("Digite o assunto do email !!");     l3.focus();     return false;
	}
	if ( !valida_texto(l3.value) ) {
		alert("Por favor, não utilize tags html !!");     l3.focus();     return false;
	}
	if ( l4.value.length == 0 ) {
		alert("Digite um telefone válido com DDD !!");     l4.focus();     return false;
	}
    //if ( !l4.item(0).checked && !l4.item(1).checked && !l4.item(2).checked && !l4.item(3).checked ) {
	//	alert("Selecione para quem deseja enviar a mensagem !!");     return false;
	//}
    if ( l5.value.length == 0 ) {
		alert("Digite o texto da mensagem !!");     l5.focus();     return false;
	}
	if ( !valida_texto(l5.value) ) {
		alert("Por favor, não utilize tags html !!");     l5.focus();     return false;
	}
    var botao = document.getElementById('enviar');
    if ( botao != null ) {
        botao.style.enabled = false;
	}
    return true;
}

function valida_texto(texto) {
	if ( texto.indexOf("<") >= 0 || texto.indexOf(">") >= 0 || texto.indexOf("javascript") >= 0 || texto.indexOf("Javascript") >= 0 || texto.indexOf("JavaScript") >= 0 ) {
		return false;
	} else {
		return true;
	}
}

function seleciona(nr_campo) {
    var oCampo = document.getElementById('op'+nr_campo);
	if ( oCampo != null ) {
	    desmarcar();
	    oCampo.checked = true;
        window.document.form_contato.contato.value = oCampo.value;
        return true;
	} else {
	    return false;
	}
}

function desmarcar() {
	var oCampo;
	for ( var i=1; i<=10; i++ ) {
    	oCampo = document.getElementById('op'+i);
	    if ( ( oCampo != null ) && ( oCampo.checked ) ) {
		    oCampo.checked = false;
	    }
	}
}

function meligue() {
   var contato = document.getElementById('contato');
   var meligue = document.getElementById('meligue');
	if ( contato != null ) {
		if ( meligue != null ) {
			contato.style.display = "none";
			meligue.innerHTML = '<iframe style="width: 610px; height: 460px;" id="callback" frameborder="no" marginheight="0" marginwidth="0" name="callback" scrolling="no" src="http://admin.onevoip.com.br/faturamento/meligue/deltainf/?origem=120030">Seu Navegador de Internet não suporta iFrames ou este recurso não está habilitado.</iframe>';
			meligue.style.display = "";
		}
	}
}

