// JScript source code

function bNavegador() {
  if( navigator.appName )
  {
    if( navigator.appName == "Microsoft Internet Explorer")  return 1;
    if( navigator.appName == "Netscape")  return 2;
  }
  return 0;
}

var urlBancaInternet = 'https://www.mibanco.com.pe/webib/servlet/com.dlya.bantotal.hhbkm275?S,com.dlya.bantotal.hebanking';
	
function AbreBancavirtual() {
  var w=640, h=480;
  var windowName 
  windowName = "vbi1"
  var x = bNavegador();	
  if (window.screen && window.screen.availHeight) {
    h = window.screen.availHeight - 63; // 63
    if( x==2 ) h = h - 11;
    w = window.screen.availWidth - 4;
    if(h>590) h = 590;
    if(w>800) w = 800;	

  }
  window.open(urlBancaInternet, windowName, "status=yes,resizable=no,toolbar=no,scrollbars=yes,top=0,left=0,width=" + w + ",height=" + h, 1 );

}

function trim(cadena){ //Retorna cadena sin espacion emblanco a los extremos	
	while (cadena.substr(0,1)==" ")
		cadena=cadena.substr(1);
	while (cadena.substr(cadena.length-1,1)==" ")
		cadena=cadena.substr(0,cadena.length-1);
	while (cadena.indexOf("  ")!=-1)
		cadena=cadena.replace("  "," "); 
	return(cadena); 
}

function validar_Fecha(fecha){   
	if (fecha != undefined && fecha.value != "" ){ 
		if (!/^\d{2}\/\d{2}\/\d{4}$/.test(fecha.value)){ 
			fecha.focus();
			alert("formato de fecha no valido (dd/mm/aaaa)"); 
			return false; 
		} 
	var dia = parseInt(fecha.value.substring(0,2),10); 
	var mes = parseInt(fecha.value.substring(3,5),10); 
	var anio = parseInt(fecha.value.substring(6),10); 
	switch(mes){ 
		case 1: 
		case 3: 
		case 5: 
		case 7: 
		case 8: 
		case 10: 
		case 12: 
			numDias=31; 
			break; 
		case 4: case 6: case 9: case 11: 
			numDias=30; 
			break; 
		case 2: 
			if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28}; 
			break; 
		default: 
			fecha.focus();
			alert("Fecha introducida errónea"); 
			return false; 
	} 
	if (dia>numDias || dia==0){ 
		fecha.focus();
		alert("Fecha introducida errónea"); 
		return false; 
	} 
		return true; 
	} 
} 	

function comprobarSiBisisesto(anio){ 
	if (( anio % 100 != 0) && ((anio % 4 == 0) || (anio % 400 == 0)))
		return true; 	
	else
		return false; 
} 

function getInternetExplorerVersion(){
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer'){
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function objFormulario(frm,nombre) { //Permite obtener un objeto (campo) de un formulario basado en el nombre del objeto
	for (i=0; i<frm.length; i++){		
		if (frm.elements[i].name.indexOf(nombre) !=-1){		
			return frm.elements[i];
		}
	}
	return null;
}

function objFormulario2(ById, ByTagName, nombre){
	var table = document.getElementById(ById);   
	var cells = table.getElementsByTagName(ByTagName);   
	for (var i = 0; i < cells.length; i++) {  
		if (cells[i].id.indexOf(nombre)!=-1){		
			return cells[i].id;
		}
	} 
}

function retornaValorRadioBotton(rbgroup){
	for (i=0;i<rbgroup.length;i++){ 
		if (rbgroup[i].checked){ 
			return rbgroup[i].value; 					
		} 
	} 
	return '';
}

function retornaValorRadioBotton2(rblname){
	var f = document.getElementsByTagName("input");
	for (var i = 0 ; i < f.length ; ++i){ 
		if (f[i].type == "radio"){ 
			var radiogroup = f[i].name; 
			if (radiogroup==rblname){
				var obj = document.getElementsByName(radiogroup);
				for(var j = 0 ; j < obj.length; ++j){
					if (obj[j].checked)
						return true;
				}
			}
		}
	} 
	return false;
} 

function verifica(obj, mensaje) { //Valida si el campo presenta caracteres en blanco
	if (trim(obj.value)=="") {
		if (trim(mensaje)!="") {
			alert(mensaje);
			obj.focus();
			obj.select();
		}
		return false;
	}
	else {
		return true;
	}
}

function solonumeroEntero(){
	var tecla=window.event.keyCode;
	if(tecla<48 || tecla>58){
		window.event.keyCode=0;
	}
}

function solonumeroDecimal(){
	var tecla=window.event.keyCode;
	if (tecla < 46 || tecla > 58){				
		window.event.keyCode=0;
	}	
}

function validaSeleccion(obj,valorSeleccionado) { //Retorna si esta seleccionado el valor indicado
	//obj = document.formulario.campoSelection
	if (obj) {
		if (obj.options[obj.selectedIndex].value==valorSeleccionado)
			return true;
		else
			return false;
	}
}

function msgErrorCamp(obj, EtiqCamp) {
	if (trim(EtiqCamp)!='') 
		alert(EtiqCamp);
	obj.focus();
	if (obj.type=='text') obj.select();
}