var dd = 'ct';var f=true;function ValidaNumerico( strValue ) { var objRegExp = /(^-?\d\d*\,\d*$)|(^-?\d\d*$)|(^-?\,\d\d*$)/; return objRegExp.test(strValue);}function ValidaDecimal( strValue ) { var objRegExp = /^-?([0-9])+\,?([0-9])+$/; return objRegExp.test(strValue);}function Trim( strValue ) { var objRegExp = /^(\s*)$/;  if(objRegExp.test(strValue)) {    strValue = strValue.replace(objRegExp, '');    if( strValue.length == 0)     return strValue;  }  objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;  if(objRegExp.test(strValue)) {    strValue = strValue.replace(objRegExp, '$2');  } return strValue;}function IniciaXmlhttp(){ try { x = new XMLHttpRequest(); } catch(ee) { try {   x = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {  try  {  x = new ActiveXObject("Microsoft.XMLHTTP");  }  catch(E)  {  x = false;  } } } return x;}function e(id){return document.getElementById(id);}function ld(ini){if (ini=="true"){e('ld').style.display = '';}else{e('ld').style.display = 'none';}}function alertContents(){ if (x.readyState == 4) {  if (x.status == 200)  {   e(dd).innerHTML = x.responseText;   ld("false");      if(document.getElementsByTagName('input')&&f==true)   {    var inputs = document.getElementsByTagName('input');    if(inputs.length>0)    {     if(inputs[0].type!='submit')     {      if(inputs[0].value.length==0)      {       inputs[0].focus();      }     }    }   }  }  else  {   alert('[erro inesperado]');   ld("false");  }   }}function ProcessaUpload(){ if (window.frames[0].document.getElementById('nome_arquivo')) {  document.getElementById('nome_arquivo').value=window.frames[0].document.getElementById('nome_arquivo').value; } if(window.frames[1]) {  if (window.frames[1].document.getElementById('nome_arquivo2'))  {   document.getElementById('nome_arquivo2').value=window.frames[1].document.getElementById('nome_arquivo2').value;  } } if(window.frames[2]) {  if (window.frames[2].document.getElementById('nome_arquivo3'))  {   document.getElementById('nome_arquivo3').value=window.frames[2].document.getElementById('nome_arquivo3').value;  } } if(window.frames[3]) {  if (window.frames[3].document.getElementById('nome_arquivo4'))  {   document.getElementById('nome_arquivo4').value=window.frames[3].document.getElementById('nome_arquivo4').value;  } } }function ProcessaUpload2(){ if (window.frames[0].document.getElementById('nome_arquivo1')) {  document.getElementById('nome_arquivo1').value=window.frames[0].document.getElementById('nome_arquivo1').value; }  if (window.frames[0].document.getElementById('nome_arquivo2')) {  document.getElementById('nome_arquivo2').value=window.frames[0].document.getElementById('nome_arquivo2').value; }}function ValidaCadastro(formulario){ var error = false; for (i=0;i<formulario.length;i++) { var tempobj=formulario.elements[i]; tempobj.value = Trim(tempobj.value); if (tempobj.name.substring(0,2)=="v_") {  if (tempobj.name.substring(2,4)=="1_")  {  if(   (tempobj.type=="text"||tempobj.type=="password"||tempobj.type=="textarea")   &&((tempobj.value=='')||(tempobj.value.substring(0,1)=='*'))   ||   (tempobj.type.toString().charAt(0)=="s")&&(tempobj.selectedIndex<=0)   )  {   error = true;   shortFieldName=tempobj.name.substring(18,40);   tempobj.style.color='red';   tempobj.value='* Campo obrigatório';   if(e('m_1_0_0_000_0_000_'+shortFieldName))   {   e('m_1_0_0_000_0_000_'+shortFieldName).style.display = '';   }   if(tempobj.type.toString().charAt(0)=="s")tempobj.selectedIndex=0;  }  }  if ((tempobj.name.substring(4,6)=="1_")&&(error == false))  {  if (tempobj.value!='')  {   if (!ValidaNumerico(tempobj.value))   {   error = true;   shortFieldName=tempobj.name.substring(18,40);   tempobj.style.color='red';   tempobj.value='* Campo deve ser numérico';   if(e('m_0_1_0_000_0_000_'+shortFieldName))   {    e('m_0_1_0_000_0_000_'+shortFieldName).style.display = '';   }   }  }  }   if ((tempobj.name.substring(4,6)=="2_")&&(error == false))  {  if (tempobj.value!='')  {   if (!ValidaDecimal(tempobj.value))   {   error = true;   shortFieldName=tempobj.name.substring(18,40);   tempobj.style.color='red';   tempobj.value='* Campo deve ser decimal';   if(e('m_0_2_0_000_0_000_'+shortFieldName))   {    e('m_0_2_0_000_0_000_'+shortFieldName).style.display = '';   }   }  }  }  if ((tempobj.name.substring(6,8)=="1_")&&(error == false))    {  var tamanho = parseFloat(tempobj.name.substring(8,11));  if (tempobj.value.length<tamanho)  {   error = true;   shortFieldName=tempobj.name.substring(18,40);   tempobj.style.color='red';   tempobj.value='* Tamanho mínimo: '+tamanho;   if(e('m_0_0_1_'+tamanho+'_0_000_'+shortFieldName))   {   e('m_0_0_1_'+tamanho+'_0_000_'+shortFieldName).style.display = '';   }  }  }    if ((tempobj.name.substring(12,14)=="1_")&&(error == false))  {  var tamanho = parseFloat(tempobj.name.substring(14,17));  if (tempobj.value.length>tamanho)  {   error = true;   shortFieldName=tempobj.name.substring(18,40);   tempobj.style.color='red';   tempobj.value='* Tamanho máximo: '+tamanho;   if(e('m_0_0_0_000_1_'+tamanho+'_'+shortFieldName))   {   e('m_0_0_0_000_1_'+tamanho+'_'+shortFieldName).style.display = '';   }  }  } } } if(error == false) { e(formulario.id).submit(); } else { alert('Revise os dados digitados - O formulário não foi enviado'); } return null;}function Get(div,id,qs,dir){ ld("true"); if(div!=''){dd=div;} e(dd).innerHTML = ""; x = IniciaXmlhttp(); x.open("GET", dir+id+".php?"+qs,true); x.onreadystatechange = alertContents; x.send(null)}function Post(formulario,dir){ var url = "";  for (i=0;i<formulario.length;i++) {  var tempobj=formulario.elements[i];  if (tempobj.type=="text"||tempobj.type=="password"||tempobj.type=="textarea"||tempobj.type.toString().charAt(0)=="s"||tempobj.type=="hidden"||tempobj.type=="checkbox")  {   if (tempobj.name.substring(0,2)=="v_")   {     shortFieldName = tempobj.name.substring(18,40);   }   else   {     shortFieldName = tempobj.name;   }   if (tempobj.type=="checkbox")   {    if (tempobj.checked)    {     if (url!="")     {      url = url + "&";     }     url = url + shortFieldName+"="+escape(tempobj.value);    }   }   else   {    if (url!="")    {     url = url + "&";    }    url = url + shortFieldName+"="+escape(tempobj.value);   }  } } ld('true'); dd = 'ct'; e(dd).innerHTML = ''; x = IniciaXmlhttp(); x.onreadystatechange = alertContents; x.open('POST', dir+formulario.id+'.php', true); x.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); x.setRequestHeader("Content-length", url.length); x.setRequestHeader("Connection", "close"); x.send(url);}function show_hide(id){ if (e(id)){if (e(id).style.display=='none'){e(id).style.display='';} else{e(id).style.display='none';}}}function hide_element(id){ if (e(id)){e(id).style.display='none';}}function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) {  var anchor = anchors[i];  if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")  anchor.target = "_blank"; } }window.onload = externalLinks;function ow(url,width,height,scroll) { var left = (screen.Width-width)/2; var top = (screen.Height-height)/2; window.open(url,'','top='+ top +',left='+ left +',width='+ width +', height='+ height +', status=no, scrollbars='+ scroll);}
