// Basic Functions
//
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject();

//----------------------------------------------------------------------------------------------------------
function pesquisar_dados(table,field,dado,igual,diretorio)
{
	if(dado != "") {
		http.open("GET", diretorio+"consult.php?table=" + table + "&field=" + field + "&data=" + dado + "&exato=" + igual, false);
		http.send(null);
    	results = http.responseText;
		if(results == "FOUND") {
			alert(results);
			return(false); 
		} else { 
			return(true);
		}
	} else {
		return(true);
	}
}

function removeHTMLTags(elemento){
 	if(document.getElementById && document.getElementById(elemento)){
 		var strInputCode = document.getElementById(elemento).innerHTML;
 		/* 
  			This line is optional, it replaces escaped brackets with real ones, 
  			i.e. < is replaced with < and > is replaced with >
 		*/	
 	 	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "<" : ">";
 		});
 		var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
   //	alert("Output text:\n" + strTagStrippedText);	
   // Use the alert below if you want to show the input and the output text
   //	alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
		document.getElementById(elemento).innerHTML = strTagStrippedText;
 	}	
	return true;
}

//----------------------------------------------------------------------------------------------------------
function stripHTML(){
	var re= /<\S[^><]*>/g
	for (i=0; i<arguments.length; i++)
	arguments[i].value=arguments[i].value.replace(re, "")
}

function checkmail(e) {
	if(!e.length) return(false);
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	return emailfilter.test(e);
}


