<!--
var d = document, w = window, IE = document.all ? true : false;

function BoxT( frm, campo, vl ){
obj = d.getElementsByName(frm)[0];
    for( i=0; i < obj.elements.length;i++ ){
         if( obj.elements[i].name == campo && obj.elements[i].type == "checkbox" ){
             if( obj.elements[i].value == vl ){ obj.elements[i].checked=true; }
         }
    }//fim for
}//fim function


//function seta focus
function SetaFocus( campo ){
obj = d.getElementsByName(campo)[0];

    if( obj ){ obj.focus(); }

}
//function seta focus - fim
//##################################################
//function trim
function JTrim( txt ){
txt = txt.replace(/^( )+/, '');
txt = txt.replace(/( )+$/, '');
return txt;
}
//function trim - fim
//##################################################
//function abre janela
function OpenForm( url, janela ){
tela = w.open(url, janela);
}
//function abre janela - fim
//##################################################
//Function Abre Janela Modal
function openModal(pUrl, Janela, pWidth, pHeight) {
	winwidth = 770; // width of the new window 
	winheight = 500; // height of the new window 
	winleft   = 200; // just dummie values (nao alterar)
	wintop    = 200; // just dummie values (nao alterar)
	  
	if(parseInt(navigator.appVersion)>=4) {
		winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left 
		wintop = (screen.height / 2) - (winheight / 2); // center the window top to bottom 
	}
	tela = window.open(pUrl, Janela,  'scrollbars=1,status=1,top=' + wintop + ',left=' + winleft + ',height=' + winheight + ',width=' + winwidth);
}
//Function Abre Janela Modal
//##################################################
//function atribui um valor ao value input
function InsereValue( ParaCampo, Txt ){
obj = d.getElementsByName(ParaCampo)[0];
   if( obj ){
   obj.value = JTrim( Txt );
   }

}
//function atribui um valor ao value input - fim
//##################################################
//function atribui um valor ao value input
function MudaStatus( txt ){
w.status=txt;
}
//function atribui um valor ao value input - fim
//##################################################
//function envia form
function formEnvia(frm){
obj = d.getElementsByName(frm)[0];
obj.submit();
}
//function envia form - fim
//##################################################
//function valida cnpj
function verifycnpj(campo){
obj = d.getElementsByName(campo)[0];
if (obj.value==""){
	alert("Preencha o Cnpj");
	obj.focus();
	return false;
}
if(obj.value != "" || obj.value.length != 0){
len = obj.value.length;
soma=0;
mlt=5;
res=0;
	if((len!=14) || (obj.value=="00000000000000")){
		alert("Cnpj Inválido/invalid");
		obj.focus();
		return false;
	}
	for (var i=0;i < obj.value.length - 2 ;i++){
		soma = soma + (obj.value.substring(i,i+1) * mlt);
		mlt--;
		if (mlt==1){
			mlt=9;
		}
	}
	soma = soma % 11;
	if((soma==0) || (soma==1)){
		res=0;
    } else {
        res=11-soma;
    }
	if(res==obj.value.substring(12,13)){
		mlt=6;
		soma=0;
		for (var i=0;i <= obj.value.length - 2 ;i++){
			soma = soma + (obj.value.substring(i,i+1) * mlt);
			mlt--;
			if (mlt==1){
				mlt=9;
			}
		}
		soma = soma % 11;
		if((soma==0) || (soma==1)){
			res=0;
	    } else {
	        res=11-soma;
	    }
		if(res==obj.value.substring(13,14)){
			return true;
		} else {
			alert("Cnpj Inválido/invalid");
			obj.focus();
			return false;
		}
	} else {
		alert("Cnpj Inválido/invalid");
		obj.focus();
		return false;
	}
}
return true;
}
//function valida cnpj - fim
//##################################################
//function valida resp preenchimento
function formRespValida( frm ){
obj      = d.getElementsByName(frm)[0];
RespNome = obj.elements['_str_NomeResp'];
RespFone = obj.elements['_str_FoneResp'];
RespNome.value = JTrim(RespNome.value);
RespFone.value = JTrim(RespFone.value);

           if( RespNome.value == '' ){
           alert("Obrigatório Preenchimento do Campo / Obligator Fulfilling");
           RespNome.focus();
           return false;
           }else if( RespFone.value == '' ){
           alert("Obrigatório Preenchimento do Campo / Obligator Fulfilling");
           RespFone.focus();
           return false;
           }//
return true;
}
//function valida resp preenchimento - fim
//##################################################
//function valida formato da data
function VLDateFormat( v  ){
   return v.match(/[0-9]{2}[/][0-9]{2}[/][0-9]{4}/);
}
//function valida formato da data - fim
//##################################################
//function valida cpf/cnpj
function isCPF( campo_cpf ) {

	//StrCPF = document.frm_novo.elements[campo_cpf].value;
	StrCPF = campo_cpf;
	if (StrCPF.substring(0,3) == StrCPF.substring(3,6) && StrCPF.substring(0,3) == StrCPF.substring(6,9) && StrCPF.substring(3,6) == StrCPF.substring(6,9)) {
		alert (" CPF Inválido ! \n Por favor informe corretamente o CPF sem pontuação.");
		//document.frm_novo.elements[campo_cpf].focus();
		return false;
	}

	if (StrCPF.length < 11) {

		alert (" CPF Inválido ! \n Por favor informe corretamente o CPF sem pontuação.");
		//document.frm_novo.elements[campo_cpf].focus();
		return false;
	}
	x = 0;
	soma = 0;
	dig1 = 0;
	dig2 = 0;
	texto = "";
	StrCPF1="";
	len = StrCPF.length;
	x = len -1;
	for (var i=0; i <= len - 3; i++) {
		y = StrCPF.substring(i,i+1);
		soma = soma + ( y * x);
		x = x - 1;
		texto = texto + y;
	}
	dig1 = 11 - (soma % 11);
	if (dig1 == 10) dig1=0 ;
	if (dig1 == 11) dig1=0 ;
	StrCPF1 = StrCPF.substring(0,len - 2) + dig1 ;
	x = 11; soma=0;
	for (var i=0; i <= len - 2; i++) {
		soma = soma + (StrCPF1.substring(i,i+1) * x);
		x = x - 1;
	}
	dig2= 11 - (soma % 11);
	if (dig2 == 10) dig2=0;
	if (dig2 == 11) dig2=0;
	if ((dig1 + "" + dig2) == StrCPF.substring(len,len-2)) {
		return true;
	}
	alert ("CPF Inválido ! \nPor favor informe corretamente o CPF sem pontuação.");
	//document.frm_novo.elements[campo_cpf].focus();
	return false;
}
//function valida cpf/cnpj - fim
//##################################################
//function valida campos - vazios
function validaCampoControl( frm ){
obj = d.getElementsByName(frm)[0];
       for( i=0; i < obj.elements.length;i++ ){
          if (obj.elements[i].value == ""){
           alert('Preencher todos os campos / Fill all the fields')
           obj.elements[i].focus();
           return false;
          }
       }
return true;
}
//function valida campos - fim
//##################################################
//function valida cnpj
function verifycnpj2(value){
if(value != "" || value.length != 0){
len = value.length;
soma=0;
mlt=5;
res=0;
	if((len!=14) || (value=="00000000000000")){
		alert("Cnpj Inválido/invalid ");
		return false;
	}
	for (var i=0;i < value.length - 2 ;i++){
		soma = soma + (value.substring(i,i+1) * mlt);
		mlt--;
		if (mlt==1){
			mlt=9;
		}
	}
	soma = soma % 11;
	if((soma==0) || (soma==1)){
		res=0;
    } else {
        res=11-soma;
    }
	if(res==value.substring(12,13)){
		mlt=6;
		soma=0;
		for (var i=0;i <= value.length - 2 ;i++){
			soma = soma + (value.substring(i,i+1) * mlt);
			mlt--;
			if (mlt==1){
				mlt=9;
			}
		}
		soma = soma % 11;
		if((soma==0) || (soma==1)){
			res=0;
	    } else {
	        res=11-soma;
	    }
		if(res==value.substring(13,14)){
			return true;
		} else {
			alert("Cnpj Inválido/invalid ");
			return false;
		}
	} else {
		alert("Cnpj Inválido/invalid ");
		return false;
	}
}
return true;
}
//-->
