//Função para abrir página em ajax loadurl()
var ddajaxtabssettings={}
ddajaxtabssettings.bustcachevar=1  //bust potential caching of external pages after initial request? (1=yes, 0=no)
ddajaxtabssettings.loadstatustext="<img src='../images/loading.gif' /> Carregando..." 

function loadurl(dest) {
   
      try { 
          // Moz supports XMLHttpRequest. IE uses ActiveX.
          // browser detction is bad. object detection works for any browser
          xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
   
      } catch (e) {
  
          // browser doesn't support ajax. handle however you want
      }
  
      // the xmlhttp object triggers an event everytime the status changes
      // triggered() function handles the events
      xmlhttp.onreadystatechange = triggered;
  
       
      // open takes in the HTTP method and url.
      xmlhttp.open("GET", dest);
  
      // send the request. if this is a POST request we would have  
      // sent post variables: send("name=aleem&gender=male) 
      // Moz is fine with just send(); but 
      // IE expects a value here, hence we do send(null); 
      xmlhttp.send(null);
}
  
       
function triggered() {
  
      // if the readyState code is 4 (Completed)  
      // and http status is 200 (OK) we go ahead and get the responseText  
      // other readyState codes: 
      // 0=Uninitialised 1=Loading 2=Loaded 3=Interactive 
	  document.getElementById("div_abrir_pagina").innerHTML=ddajaxtabssettings.loadstatustext
      if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
          // xmlhttp.responseText object contains the response.
          document.getElementById("div_abrir_pagina").innerHTML = xmlhttp.responseText;
      }
}
/////

//FUNÇÂO ABRIR PAGINA AJAX CALENDARIO
function loadurl_calendario(dest) {
   
      try { 
          // Moz supports XMLHttpRequest. IE uses ActiveX.
          // browser detction is bad. object detection works for any browser
          xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
   
      } catch (e) {
  
          // browser doesn't support ajax. handle however you want
      }
  
      // the xmlhttp object triggers an event everytime the status changes
      // triggered() function handles the events
      xmlhttp.onreadystatechange = triggered_calendario;
  
       
      // open takes in the HTTP method and url.
      xmlhttp.open("GET", dest);
  
      // send the request. if this is a POST request we would have  
      // sent post variables: send("name=aleem&gender=male) 
      // Moz is fine with just send(); but 
      // IE expects a value here, hence we do send(null); 
      xmlhttp.send(null);
}
  
       
function triggered_calendario() {
  
      // if the readyState code is 4 (Completed)  
      // and http status is 200 (OK) we go ahead and get the responseText  
      // other readyState codes: 
      // 0=Uninitialised 1=Loading 2=Loaded 3=Interactive 
	  // document.getElementById("div_calendario").innerHTML=ddajaxtabssettings.loadstatustext
      if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
          // xmlhttp.responseText object contains the response.
          document.getElementById("div_calendario").innerHTML = xmlhttp.responseText;
      }
  
}



//////////
function loadurl_estatisticas(dest) {
   
      try { 
          // Moz supports XMLHttpRequest. IE uses ActiveX.
          // browser detction is bad. object detection works for any browser
          xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
   
      } catch (e) {
  
          // browser doesn't support ajax. handle however you want
      }
  
      // the xmlhttp object triggers an event everytime the status changes
      // triggered() function handles the events
      xmlhttp.onreadystatechange = triggered_estatisticas;
  
       
      // open takes in the HTTP method and url.
      xmlhttp.open("GET", dest);
  
      // send the request. if this is a POST request we would have  
      // sent post variables: send("name=aleem&gender=male) 
      // Moz is fine with just send(); but 
      // IE expects a value here, hence we do send(null); 
      xmlhttp.send(null);
}
  
       
function triggered_estatisticas() {
  
      // if the readyState code is 4 (Completed)  
      // and http status is 200 (OK) we go ahead and get the responseText  
      // other readyState codes: 
      // 0=Uninitialised 1=Loading 2=Loaded 3=Interactive 
	  document.getElementById("div_estatisticas").innerHTML=ddajaxtabssettings.loadstatustext
      if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
          // xmlhttp.responseText object contains the response.
          document.getElementById("div_estatisticas").innerHTML = xmlhttp.responseText;
      }
}
/////



//Função envia via POST dados form
 var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            //result = http_request.responseText; 
			result = http_request.responseText; 

			document.getElementById('div_abrir_pagina').innerHTML = result;
			
         } else {
            alert('There was a problem with the request. Houve um problema com o pedido');
         }
      }
   }

   
   //BUSCA FORM AVANCADO
   function get(obj) {
	//var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
    //                "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
    var poststr = 	"data_inicio=" + escape(encodeURI(document.getElementById("data_inicio").value))+
                    "&data_termino=" + escape(encodeURI(document.getElementById("data_termino").value))+
					"&id_emissora=" + escape(encodeURI(document.getElementById("id_emissora").value))+
					"&id_programa=" + escape(encodeURI(document.getElementById("id_programa").value))+
					"&avaliacao=" + escape(encodeURI(document.getElementById("avaliacao").value))+
					"&id_personalidade=" + escape(encodeURI(document.getElementById("id_personalidade").value))+
					"&palavra=" + encodeURI(document.getElementById("palavra").value);
	
      makePOSTRequest('pesquisa_lis.php', poststr);
   }
  
   
    //BUSCA FORM RAPIDO
   function get_busca(obj) {
   
    var poststr = 	"palavra_busca=" + encodeURI( document.getElementById("palavra_busca").value );
		
      makePOSTRequest('pesquisa_lis.php', poststr);
   }
   
   
    //BUSCA FORM RAPIDO
   function get_estatisticas(obj) {
   
	var poststr = 	"data_inicio=" + escape(encodeURI(document.getElementById("data_inicio").value))+
                    "&data_termino=" + escape(encodeURI(document.getElementById("data_termino").value))+
					"&id_emissora=" + escape(encodeURI(document.getElementById("id_emissora").value))+
					"&id_programa=" + escape(encodeURI(document.getElementById("id_programa").value))+
					"&avaliacao=" + escape(encodeURI(document.getElementById("avaliacao").value))+
					"&id_tema=" + escape(encodeURI(document.getElementById("id_tema").value));
		
      makePOSTRequest('estatisticas_lis.php', poststr);
   }



function checa_formulario(thisForm){

	if (thisForm.data_inicio.value == ""){
		alert("É necessário colocar uma Data de Início.");
		thisForm.data_inicio.focus();
		return (false);
	}

	if (thisForm.data_termino.value == ""){
		alert("É necessário colocar uma Data Término.");
		thisForm.data_termino.focus();
		return (false);
	}

return (true);
}


////Função de Load na pagina inteira
function OnLoad() {
if (document.getElementById) // IE5 NN6
document.getElementById("loading").style.visibility="hidden";
else if (document.layers) // NN4
document.loading.visibility="hidden";
else if (document.all) // IE4
document.all.loading.style.visibility="hidden";
}


// Função de abrir o browser com pop up no centro
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
/*settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)*/
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+''
win = window.open(mypage,myname,settings)
}




//Diversas Funções
function SomenteNumerico(e)
{
	var tecla=new Number();
 	if(window.event) {
		tecla = e.keyCode; 
	}
	else if(e.which) {
		tecla = e.which; 
	}
	else {
		return true;
	}
	if(
	((tecla < 48) || (tecla > 57)) && 
	(tecla!=9)  && 
	(tecla!=13) && 
	(tecla!=8) && 
	(tecla!=44) &&
	(tecla!=46)
	)
	{
		if (window.event){
			//e.keyCode = 0;
			//return false;
		   window.event.returnValue = null;
		}else {
			e.preventDefault();
		}		
	}
}
function SomenteAlfaNumericoE(e){
	var tecla=new Number();
 	if(window.event) {
		tecla = e.keyCode; 
	}
	else if(e.which) {
		tecla = e.which; 
	}
	else {
		return true;
	}
	if(
    (tecla==9 || tecla==13 || tecla==8)||
	(tecla == 45 || tecla == 46 || tecla == 95)||
	(tecla  > 47 && tecla < 58)||(tecla > 63 && tecla < 91)||(tecla > 96 && tecla < 123)){
		return true;
	}else{
		if (window.event){
		   window.event.returnValue = null;
		}else {
			e.preventDefault();
		}		
	}
}
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
/*
* Utilização no formulario: onkeypress="return  MaskFormat(event, this, '99.999-999');">
* CEP -> 99.999-999
* CPF -> 999.999.999-99
* CNPJ -> 99.999.999/9999-99
* Fone -> (99) 9999-9999
* Data -> 99/99/9999
* Data -> 99/99/9999 99:99
*/
function MaskFormat(evento, campo, mascara, d) {
    var i, nCount, bolmascara, sCod;
	var nTecla=new Number();

 	if(window.event) {
		nTecla = evento.keyCode; 
	}
	else if(evento.which) {
		nTecla = evento.which; 
	}
	else {
		return true;
	}
//    if(nTecla == 13)
//    {
//        evento.cancelBubble = true;
//		return false;
//    }
//    if ((nTecla == 9)&&(evento.which)){
//	return false;
//	}
	if (d)
    alert(nTecla);
    //seta esquerda = 37
    //seta direita = 39
    //backspace = 8
    //delete = 46
    //shiftkey = 16
    //tab= 9

    if (((nTecla == 8)||(nTecla == 46))&&(campo.value.length > 0)){
		if (window.event){
		   campo.value = campo.value.substring(0,campo.value.length - 1);
		   evento.cancelBubble;
		   return false;
		 }else{
			return;
		 }
    }

    var sValue = campo.value.toString();

    sValue = replaceAll(sValue,' ','');	//  == 32
    sValue = replaceAll(sValue,'#',''); //  == 35
    sValue = replaceAll(sValue,'\\$',''); //  == 36
    sValue = replaceAll(sValue,',',''); // == 44
    sValue = replaceAll(sValue,'\\(',''); //  == 40
    sValue = replaceAll(sValue,'\\)',''); //  == 41
    sValue = replaceAll(sValue,'-',''); //  == 45
    sValue = replaceAll(sValue,'\\.',''); //  == 46
    sValue = replaceAll(sValue,'\/',''); //  == 47
    sValue = replaceAll(sValue,':',''); //  == 58
    sValue = replaceAll(sValue,'<',''); //  == 60
    sValue = replaceAll(sValue,'>',''); //  == 62
    sValue = replaceAll(sValue,'\\[',''); //  == 91
    sValue = replaceAll(sValue,'\\]',''); //  == 93
    sValue = replaceAll(sValue,'{',''); //  == 123
    sValue = replaceAll(sValue,'}',''); //  == 125

    var tamcmp = sValue.length;
    var tammsk = mascara.length;
	
    i = 0;
    nCount = 0;
    sCod = "";
    tammsk = tamcmp;

    while (i <= tammsk) {
		try {
			bolmascara = ((mascara.charAt(i) == "-") || (mascara.charAt(i) == ".") ||  (mascara.charAt(i) == "/"))|| (mascara.charAt(i) == ",")
			bolmascara = bolmascara || ((mascara.charAt(i) == "(") || (mascara.charAt(i) == ")") || (mascara.charAt(i) == " ")) 
			if (bolmascara) {
				sCod += mascara.charAt(i);
				tammsk++; 
				}
			else {
				if (mascara.charAt(i)=="9")
					sCod += sValue.charAt(nCount);
				else
					tammsk--;
				nCount++;
			}
			i++;
		} catch ( e ) {
			alert(e);
		}
    }

    campo.value = sCod;
    if (nTecla != 8) {
		if ((mascara.charAt(i-1) == "9")) { 
			return ((nTecla > 47) && (nTecla < 58)); 
		} 
		else { 
			return true;
		} 
    }
    else {
		evento.cancelBubble = true;
		return false;
    }
}
function isNull(val){
	return(val==null);
}
function fncrtnNull(val){
	if(!val){
		return 'null';
	} else {
		return val;
	}
}
function fncRemoveFormatacao(numFormatado)
{
	return String(numFormatado).replace(/\D/g, "").replace(/^0+/, "");
}
function replaceAll(str, procura, substitui)
{
    return str.replace( new RegExp(procura,"g"), substitui );    
}
function replaceSQL(str){
	str = str.replace(/\\/g,"\\\\");
	str = str.replace(/&/g, "&amp;"); 
	str = str.replace(/</g, "&lt;"); 
	str = str.replace(/>/g, "&gt;"); 
	str = str.replace(/"/g, "&quot;"); 
	str = str.replace(/'/g, "&#39;"); 
	str = str.replace(/,/g, "&#44;");
	str = str.replace(/\r\n/g,"\\n");
	str = str.replace(/\n/g,"\\n");
	str = str.replace(/\r/g,"\\n");
	return str;
}
function devolveHTM(textArea, str){
	if (textArea == 1){
		str = str.replace(/\\n/g, '\n');
		str = str.replace(/<br>/g, '\n');
		str = str.replace(/&lt;/g, "<");
		str = str.replace(/&gt;/g, ">");
		str = str.replace(/&quot;/g, '\\"');
		str = str.replace(/&#39;/g, "\\'");
		str = str.replace(/&#44;/g, ",");
		str = str.replace(/\\/g, "");
		str = str.replace(/&amp;/g, "&");
	} else {
		str = str.replace(/\\n/g, "<br>");
		str = str.replace(/&39;/g, "&#39;");
		str = str.replace(/&44;/g, "&#39;");
	}
	str = replaceAll(str, "  ", " ");

	return str;
}
function fncDataCompara(data1,data2){
	var strData1 = parseInt(replaceAll(data1,'-',''));
	var strData2 = parseInt(replaceAll(data2,'-',''));
	if (strData1 == strData2){
		return '=';
	} else if (strData1 > strData2){
		return '>';
	} else if (strData1 < strData2){
		return '<';
	} else {
		return 'e';
	}
} 
function fncDataBanco(datFormatoFrm){
	var datFormatoSQL = '';
	if (datFormatoFrm.length > 5) {
		var v_data = datFormatoFrm.substring(0,10);
		if (v_data.indexOf("/")>0){
			var tempDataFrm = new Array();
			tempDataFrm = v_data.split('/');
			datFormatoSQL = tempDataFrm[2] + '-' + tempDataFrm[1] + '-' + tempDataFrm[0] 
		}
	}
	return datFormatoSQL;
}
function fncValidarData(campo){
      var htmString = campo.value;
	if ((htmString.length > 0)&&(htmString.length < 8))
         {
          alert('Data inválida!\nPor favor, digite a data corretamente.');
          campo.value = '';
          campo.focus();
          return false;
         }

	if (htmString.length == 0)
         {
          campo.value = '';
          return false;
         }

	if(htmString != ''){
		var parametro = htmString;
		teste_parametro = "true"; //variavel para teste de data inválida
		var tamanho_parametro = parametro.length;
		if (tamanho_parametro == 8){
			var v_dia = parametro.substring(0,2);
			var v_mes = parametro.substring(2,4);
			var v_ano = parametro.substr(4);
		}else{
			var v_dia = parametro.substring(0,2);
			var v_mes = parametro.substring(3,5);
			var v_ano = parametro.substr(6);
		} 
			if (((v_ano < 1900) || (v_ano > 2079))){
				teste_parametro= false;
			}
			if (v_dia > 31){
				teste_parametro= false;
			}
			if (v_mes > 12){
				teste_parametro= false;
			}
			if (v_dia == "31"){
				if ((v_mes == "04") || (v_mes == "06") || (v_mes == "09") || (v_mes == "11")){
					teste_parametro= false;
				}
			}

			if (v_mes == "02"){
				if (!(v_ano%4)){
					if (v_dia > 29){
						teste_parametro= false;
					}
				}
				else if (v_dia > 28){
					teste_parametro= false;
				}
			}

			if (((v_dia != "") || (v_mes != "") || (v_ano != "")) && ((v_dia == "") || (v_mes == "") || (v_ano == ""))){
				teste_parametro= false;
			}
		if (!teste_parametro){
               alert('Data inválida!\nPor favor, digite a data corretamente.');
               campo.value = '';
               campo.focus();
               return false;
		}
		else{
		   campo.value = v_dia + '/' + v_mes  + '/' + v_ano;
		   return true;
		}

	}
}
function IsNumeric(passedVal){
   var str = passedVal.value;
   if (passedVal == "")
         {
         return false;
         }
   for (var i = 0; i < passedVal.length; i++) 
      {
      var ch = passedVal.substring(i, i + 1);
      if ((ch < "0" || "9" < ch)) 
         {
      	return false;
         }
      }
   return true;
}
function TrimCampo(campo)
         {
           var htmString = campo.value;

           while (htmString.charAt(htmString.length-1) == " "){htmString = htmString.substring(0,htmString.length-1);} 
           while(htmString.substring(0,1) ==" "){htmString = htmString.substring(1,htmString.length);}

           campo.value = htmString.toUpperCase();
         }
function fncValidarEmail(campo, obrigatorio) {
    var htmString = campo.value;
	if ((obrigatorio == 1)||(htmString.length > 0)){
		if (!isEmail(htmString)){
			  alert('E-mail inválido!\nPor favor, informe o seu e-mail.');
			  campo.value = '';
			  campo.focus();
			  return false;
			 }
	}
}
function fncValidarCPF(campo, obrigatorio) {
    var htmString = campo.value;
	if ((obrigatorio == 1)||(htmString.length > 0)){
		var numCPFsemFormato = Right('00000000000' + fncRemoveFormatacao(htmString),11);
		var numIguais = true;
		for (var i=0; i<10; i++){
			numIguais = numIguais && (numCPFsemFormato.charAt(i) == numCPFsemFormato.charAt(i+1));
		}
		if ((!verificaDigitoCPF(numCPFsemFormato))||(numIguais == true)){
			  alert('CPF Inválido!\nPor favor, digite o número do CPF.');
			  campo.value = '';
			  campo.focus();
			  return false;
			 }
		campo.value = fncCPFFormulario(numCPFsemFormato);
	}
	return true;
}
function isCPF(numCPFqqFormato) {
	var numCPFsemFormato = Right('00000000000' + fncRemoveFormatacao(numCPFqqFormato),11);
	if ((numCPFsemFormato.length == 0)||(numCPFsemFormato.length != 11)){
		return false;
	}
	var numIguais = true;
	for (var i=0; i<10; i++){
		numIguais = numIguais && (numCPFsemFormato.charAt(i) == numCPFsemFormato.charAt(i+1));
	}
	if (numIguais == true){
		return false;
	}
	if ((!verificaDigitoCPF(numCPFsemFormato))||(numIguais == true)){
		return false;
	}else{
		return true;
	}
}
function verificaDigitoCPF(testaCPF){
	if ((testaCPF==null)||(testaCPF.length != 11)){
          return false;
	}
	var rcpf1 = testaCPF.substr(0,9);
	var rcpf2 = testaCPF.substr(9,2);

	var d1 = 0;
	for (i=0;i<9;i++) 
		d1 += rcpf1.charAt(i)*(10-i);
	var d1 = 11 - (d1 % 11);
	if (d1>9) d1 = 0;

	if (rcpf2.charAt(0) != d1){
          return false;
	}
	d1 *= 2;
	for (i=0;i<9;i++) 
		d1 += rcpf1.charAt(i)*(11-i);
	d1 = 11 - (d1 % 11);
	if (d1>9) d1 = 0;
	
	if (rcpf2.charAt(1) != d1){
          return false;
	}else{
          return true;
	}
}
function fncDataFormulario(datFormatoSQL){
	var datFormatoFrm = '';
	if (datFormatoSQL.length > 5) {
		var v_data = datFormatoSQL.substring(0,10);
		if (v_data.indexOf("-")>0){
			var tempDataSQL = new Array();
			tempDataSQL = v_data.split('-');
			datFormatoFrm = tempDataSQL[2] + '/' + tempDataSQL[1] + '/' + tempDataSQL[0] 
		}
	}
	return datFormatoFrm;
}
function fncCPFFormulario(numCPFFormatoSQL)
{
	var numCPFFormatoFrm = Right('00000000000' + fncRemoveFormatacao(numCPFFormatoSQL),11);
	var	v_CPF  = /(\d{3})(\d{3})(\d{3})(\d{2})$/;
	numCPFFormatoFrm = numCPFFormatoFrm.replace(v_CPF, "$1.$2.$3-$4");
	return numCPFFormatoFrm;
}
function fncCEPFormulario(numCEPFormatoSQL)
{
	var numCEPFormatoFrm = Right('00000000' + fncRemoveFormatacao(numCEPFormatoSQL),8);
	if (numCEPFormatoFrm != '00000000'){
		var	v_CEP  = /(\d{2})(\d{3})(\d{3})$/;
		numCEPFormatoFrm = numCEPFormatoFrm.replace(v_CEP, "$1.$2-$3");
	}else{
		numCEPFormatoFrm = '';
	}
	return numCEPFormatoFrm;
}
function fncTelefoneFormulario(numTelefoneFormatoSQL)
{
	var numTelefoneFormatoFrm = fncRemoveFormatacao(numTelefoneFormatoSQL);
	if (numTelefoneFormatoFrm.length > 9){
		numTelefoneFormatoFrm = numTelefoneFormatoFrm.substring(0,10);	
		var	v_Telefone  = /(\d{2})(\d{4})(\d{4})$/;
	} else {
		var	v_Telefone  = /(\d{2})(\d{3})(\d{4})$/;
	}
	numTelefoneFormatoFrm = numTelefoneFormatoFrm.replace(v_Telefone, "($1) $2-$3");
	if (numTelefoneFormatoFrm.length < 9){
		numTelefoneFormatoFrm = '';
	}
	return numTelefoneFormatoFrm;
}

function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
  }
}
function sqlSafe (s)
{
	var new_s = s;
	new_s = replaceAll (new_s, "'", "|");
	new_s = replaceAll (new_s, "|", "''");
	new_s = replaceAll (new_s, "\"", "|");
	new_s = replaceAll (new_s, "|", "''");
	return new_s;
}

function makeSafe (i)
{
	i.value = sqlSafe (i.value);
}
var whitespace = " \t\n\r";

function isWhitespace (s)
{
   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}
function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function isEmail(string) {
    if (isWhitespace(string)) return false;
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
		return true;
	}else{
		return false;
	}
}
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
   var obj = document.layers ? document.layers[szDivID] :
   document.getElementById ?  document.getElementById(szDivID).style :
   document.all[szDivID].style;
   obj.visibility = document.layers ? (iState ? "show" : "hide") :
   (iState ? "visible" : "hidden");
}


//Função de mostrar objetos ao clicar
function mostrainfo(id_mostrainfo) { //sempre chama o id_mostrainfo
	if(document.getElementById(id_mostrainfo).style.display == '') {	//em branco para não aparecer
		document.getElementById(id_mostrainfo).style.display = 'none';	//colocar none para o display ficar vazio na DIV
	} else {
		document.getElementById(id_mostrainfo).style.display = '';
	};
}

//Função para o calendario
function ShowDataInputInicio(val) { document.thisForm.data_inicio.value = val; }
function ShowDataInputTermino(val) { document.thisForm.data_termino.value = val; }

function mostrar_inicio(div_calendario_inicio){
document.getElementById(div_calendario_inicio).style.visibility="visible";
}
function ocultar_inicio(div_calendario_inicio){
document.getElementById(div_calendario_inicio).style.visibility="hidden";
} 


function mostrar_termino(div_calendario_termino){
document.getElementById(div_calendario_termino).style.visibility="visible";
}
function ocultar_termino(div_calendario_termino){
document.getElementById(div_calendario_termino).style.visibility="hidden";
} 