function click() { 
   if (event.button==2) { 
      return false;
   } 
} 
//document.onmousedown=click 
//document.oncontextmenu = function(){return false} 
function fcnValidarMm(fec1, fec2){
	var arFec1 = fec1.split("/"); var arFec2 = fec2.split("/");
	var dt1 = new Date(arFec1[1] + '/' + arFec1[0] + '/' + arFec1[2]);
	var dt2 = new Date(arFec2[1] + '/' + arFec2[0] + '/' + arFec2[2]);				
	if (dt2 < dt1){
	 return false;
	}
	return true;
}
function fcndateDiff(tipo, fec1, fec2){
	var iout = 0;
	var arFec1 = fec1.split("/"); var arFec2 = fec2.split("/");
	var dt1 = new Date(arFec1[1] + '/' + arFec1[0] + '/' + arFec1[2]);
	var dt2 = new Date(arFec2[1] + '/' + arFec2[0] + '/' + arFec2[2]);				
	var buffer = dt2 - dt1;
	switch(tipo.charAt(0)){
		case 'm': case 'M':
			iout = parseInt(buffer/2592000000);
			break;
		case 'y': case 'Y':
			iout = parseInt(buffer/31104000000);
			break;
	}
	return iout;
}
function fcnImprimir(){
	tblBotones.style.visibility = 'hidden';
	window.print();
	tblBotones.style.visibility = 'visible';
}
function ValidaVacio(obj,texto){
	if (obj.value == '') {
		alert('El campo ' + texto + ' es obligatorio.');
		try {
		obj.focus();
		} catch (e) {}
		finally{}
		return '0';
	}
	else return '1';
}

function ValidaEmail(obj,texto){
	var a='@';
	if ((obj.value).indexOf(a)==-1 ) {
		alert('El campo ' + texto + ' no es correcto');
		try {
		obj.focus();
		} catch (e) {}
		finally{}
		return '0';
	}
	else return '1';
}

function fcnValidaVacio_nuevo(obj,obj1,obj2){
	if (obj.value == '') 
	{
	 if (obj1.value == '') 
	 {
	  if (obj2.value == '') 
	  {
		
		alert('Debe llenar algun número teléfonico para poder contactarnos con usted');
		try {
		obj.focus();
		} catch (e) {}
		finally{}
		return '0';
	 
	  }
	  else return '1';
	 }
	 else return '1';
	}
	else return '1';

}
function ValidaCombo(obj,texto){
    if (obj.length == 0){
		alert('El campo ' + texto + ' es obligatorio.');
		try {
		obj.focus();
		} catch(e) {}
		finally {}
		return '0';
    }
	if (obj.options[obj.selectedIndex].value == '' || obj.options[obj.selectedIndex].value == '00' || obj.options[obj.selectedIndex].value == '00|00' || obj.options[obj.selectedIndex].value == '00|00|00' || obj.options[obj.selectedIndex].value == '00|00|00|00') {
		alert('El campo ' + texto + ' es obligatorio.');
		try {
		obj.focus();
		} catch(e) {}
		finally {}
		return '0';
	}
	else return '1';
}
function ValidaLista(obj,texto){
	if (obj.selectedIndex == -1) {
		alert('El campo ' + texto + ' es obligatorio.');
		try {
		obj.focus();
		} catch(e) {}
		finally {}
		return '0';
	}
	else return '1';
}
function fcnValidaInt(obj,texto){
	if (isNaN(obj.value)){
		alert('El valor ingresado en ' + texto + ' es incorrecto.');
		obj.focus();
		return '0';
	}
	else return '1';
}
function fcnValidaPuCo(obj,texto){
	if (obj.value.indexOf(",")!=-1){
		alert('El valor ingresado en ' + texto + ' es incorrecto.');
		obj.focus();
		return '0';
	}
	else{
		if (obj.value.indexOf(".")!=-1){
			alert('El valor ingresado en ' + texto + ' es incorrecto.');
			obj.focus();
			return '0';
		}	
		else return '1';
	}
	
}

function fcntTrim(strCad){
	var strCadena = new String(strCad);
	retorno = "";
	retorno2 = "";
	if (strCadena != ""){
		i = strCadena.length;
		while ((i==0) || (strCadena.substring(i-1,i) == " "))
			i--;
		retorno = strCadena.substring(0,i);
		i = 0;
		while ((i==retorno.length) || (strCadena.substring(i,i+1) == " "))
			i++;
		retorno2 = retorno.substring(i,retorno.length);
	}
	if (retorno2 == " "){
		retorno2 = "";
	}
	return retorno2;
}
function fp_ValidacionAdicional(){
  if (window.event.keyCode==124){
    window.event.keyCode=0
  }
  if (window.event.keyCode==34) {
  	window.event.keyCode=0
  }
}
function fcnTeclaEnter(){
	if (window.event.keyCode == 13){
		BuscaCliente();
		return;
	}
}
function fp_IngresaNumeros(strNameObj){
	var Obj = document.all[strNameObj];
	var intEncontrado = "1234567890".indexOf(String.fromCharCode(window.event.keyCode));
	if (intEncontrado == -1) {
		window.event.keyCode = 0;
	}
}
function fp_IngresaDecimal(strNameObj){
	var Obj = document.all[strNameObj];
	var intEncontrado = "1234567890,".indexOf(String.fromCharCode(window.event.keyCode));
	if (intEncontrado == -1) {
		window.event.keyCode = 0;
	}
}
function fp_IngresaEmail(strNameObj){
	var Obj = document.all[strNameObj];
	var strCaracter = String.fromCharCode(window.event.keyCode)
	var intEncontrado = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@.-_".indexOf(strCaracter);
	if (intEncontrado == -1) {
		window.event.keyCode = 0;
	}
}
function fp_IngresaOtro(strNameObj){
	var Obj = document.all[strNameObj];
	var strCaracter = String.fromCharCode(window.event.keyCode)
	var intEncontrado = "|#*".indexOf(strCaracter);
	if (intEncontrado != -1) {
		window.event.keyCode = 0;
	}
}
function fp_validafecha(objDia, objMes, objAnio){
   var sAnio = objAnio.value;
   var sMes = objMes.value;
   var sDia = objDia.value;
   var iCont = objDia.length;
   var iMax;
   var sSetDia = '00';
  
	if(sMes=='01' || sMes=='03' || sMes=='05' || sMes=='07' || sMes=='08' || sMes=='10' || sMes=='12'){
	   iMax = 31;
	}
	if(sMes=='04' || sMes=='06' || sMes=='09' || sMes=='11'){
	   iMax = 30;
	}
	if(sMes=='02'){
	   if(fcnEsBisiesto(sAnio*1)){
   	   iMax = 29;
	   }else{
   	   iMax = 28;
	   }
	}
	for(i=0;i<iCont;i++){
   	objDia.options[i]=null;
   }
	for(i=1;i<=iMax;i++){
	   sSetDia = ''+i.toString();
	   if(i < 10){sSetDia = '0'+i.toString();}
	   newOption = new Option(sSetDia, sSetDia, false, false);
      objDia.options[i-1] = newOption;
   }
   if(sSetDia < sDia){
      objDia.value = sSetDia;
   }else{
      objDia.value = sDia;
   }
}
function ValidaOpcion(sNombre,sCadena,texto){
   var arrCad = sCadena.split(',');
   for(i=0;i<=arrCad.length-1;i++){
      if(eval(sNombre + arrCad[i] + '.checked')){
      	return '1';
      }
	}
	alert('El campo ' + texto + ' es obligatorio.');
	try {
	eval(sNombre + arrCad[i] + '.focus()');
	} catch(e) {}
	finally {}
	return '0';
}
function fcnEsBisiesto(iAnio){
   var iBase = 1996;
   for(j=iBase;j<=iAnio;j=j+4){
      if(j == iAnio){return true;}
   }
   for(j=iBase;j>=iAnio;j=j-4){
      if(j == iAnio){return true;}
   }
   return false;
}
function fcnMaxLongitud(obj,max){
   obj.value = obj.value.substr(0,max);
}
function fcnMostrarDiv(sValor, sDiv, nMax, sNomObj){
    for(i=1;i<=nMax;i++){
        eval(sDiv + i.toString() + ".style.visibility='hidden'");
    }
    eval(sDiv + sValor + ".style.visibility='visible'");
    if(sNomObj!=''){eval("document.form1." + sNomObj + ".focus()");}
}
function fcnOptBoton(sValor){
    document.form1.hdnAccion.value = sValor;
}

function esnulo(campo){ return (campo == null||campo=="");}
function esnumero(campo){ return (!(isNaN( campo )));}
function eslongrucok(ruc){return ( ruc.length == 11 );}
function eslongdniok(dni){return ( dni.length == 8 );}
function trim(cadena){
  cadena2 = "";
  len = cadena.length;
  for ( var i=0; i <= len ; i++ ) if ( cadena.charAt(i) != " " ){cadena2+=cadena.charAt(i);	}
  return cadena2;
}
function valruc(valor){
  valor = trim(valor)
  if ( esnumero( valor ) ) {
    if ( valor.length == 8 ){
      suma = 0
      for (i=0; i<valor.length-1;i++){
        digito = valor.charAt(i) - '0';
        if ( i==0 ) suma += (digito*2)
        else suma += (digito*(valor.length-i))
      }
      resto = suma % 11;
      if ( resto == 1) resto = 11;
      if ( resto + ( valor.charAt( valor.length-1 ) - '0' ) == 11 ){
        return true
      }
    } else if ( valor.length == 11 ){
      suma = 0
      x = 6
      for (i=0; i<valor.length-1;i++){
        if ( i == 4 ) x = 8
        digito = valor.charAt(i) - '0';
        x--
        if ( i==0 ) suma += (digito*x)
        else suma += (digito*x)
      }
      resto = suma % 11;
      resto = 11 - resto
      
      if ( resto >= 10) resto = resto - 10;
      if ( resto == valor.charAt( valor.length-1 ) - '0' ){
        return true
      }      
    }
  }
  return false
}
function esrucok(obj){
    if ( ( esnulo(obj.value) || !esnumero(obj.value) || !eslongrucok(obj.value) || !valruc(obj.value) ) ){
        alert('Por favor, ingrese numero de RUC valido.');
        obj.focus();
        return false;
    }else{
        return true;
    }
}
function esdniok(obj){
    alert(obj.value);
    if ( ( esnulo(obj.value) || !esnumero(obj.value) || !eslongdniok(obj.value) ) ){
        alert('Por favor, ingrese numero de DNI valido.');
        obj.focus();
        return false;
    }else{
        return true;
    }
}
function eslongusuok(obj, texto){
    if( obj.value.length < 6 ){
        alert('El campo ' + texto + ' debe ser de longitud mayor o igual a 6.');
        obj.focus();
        return false;
    }else{
        return true;
    }
}

