﻿// Carrega Chamados
function LoadChamado(chamadoid) {
    var divq = document.getElementById("dv_detalhesChamado").style;
    
    if (divq.display == 'none') {
        iframe_detalhesChamado.document.location = "iFrameChamado.aspx?chamadoid="+ chamadoid;
        divq.display = 'block';
    }else{
        divq.display = 'none';
    }
}

// Carrega Div sem passar parametros para o sistemas
function LoadDiv(div)
{
    var div = document.getElementById(div).style;
    if(div.display == 'none')
    {
        div.display = 'block';
    }
    else

    {
        div.display = 'none';
    }
}

function LoadDivPar(dominio, dominioid, idowner) {
    var divq = document.getElementById("dv_renovarConteduo").style;
    if (divq.display == 'none') {
        if_Renovar.document.location = "iFrameRenovar.aspx?dominio="+ dominio +"&dominioid="+ dominioid +"&dominioOwner="+idowner;
        divq.display = 'block';
    }else{
        divq.display = 'none';
    }
}

function LoadCerts(chamadoid) 
{
    var divq = document.getElementById("dv_certs").style;
    if (divq.display == 'none') 
    {
        Ifrm_Certs.document.location = "iframecerts.aspx?certificadoid="+ chamadoid;
        divq.display = 'block';
        Alert();
    }
    else
    {
        divq.display = 'none';
    }
}

function isNumberKeyPress (e) { 
	var codigo = (isIE) ? window.event.keyCode : e.which;
	
	// se diferente de numero
	if ((codigo<48) || (codigo>57)) {
		if ((codigo!=0) && (codigo!=8)) {
			return false;
		}
	}
	
	return true;
}

function formataCNPJ(cp) {
	if ((event.keyCode<48) || (event.keyCode>57))
		return false;
	else{
		var v = cp.value;
		var maxlen = 18;
		
		if (v.length>=maxlen)
			return false;
		if (v.length==2 || v.length==6)
			cp.value = v +'.';
		else if (v.length==10)
			cp.value = v +'/';
		else if (v.length==15)
			cp.value = v +'-';
	}
}

function formataCPF(cp) {
	if ((event.keyCode<48) || (event.keyCode>57))
		return false;
	else{
		var v = cp.value;
		var maxlen = 14;
		
		if (v.length>=maxlen)
			return false;
		if (v.length==3 || v.length==7)
			cp.value = v +'.';
		else if (v.length==11)
			cp.value = v +'-';
	}
}

function formataString(campo, mask, evt) {
 /*
 onkeypress="return formataString(this,'???.???.???-??',Event)"
 o caracter '?' define que só será permitido números
 o caracter '!' define que só será permitido caracter
 */
 if(document.all) { // Internet Explorer
    key = evt.keyCode; }
    else{ // Nestcape
       key = evt.which;
     }

if (key == 8) {
return true;
}

 string = campo.value;  
 i = string.length;

 if (i < mask.length) {
  if (mask.charAt(i) == '?') {
       return (key > 47 && key < 58);
      } else {
       if (mask.charAt(i) == '!') {  return true;  }
   for (c = i; c < mask.length; c++) {
         if (mask.charAt(c) != '?' && mask.charAt(c) != '!')
         campo.value = campo.value + mask.charAt(c);
      else if (mask.charAt(c) == '!'){
                return true;
       } else {
         return (key > 47 && key < 58);
          }
       }
    }
  } else return false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}