function js_redireccionar(strURL){
   top.document.location.href = strURL; 
}
function js_trim(cadena){
   cadena = js_rtrim(cadena);
	cadena = js_ltrim(cadena);	
	return cadena;
}
function js_rtrim(cadena){
    for (i = 0; i <= cadena.length -1 ; i++){
		if (cadena.charAt(i) != " "){
			return cadena.substring(i,cadena.length);
		}
	}
	return "";
}
function js_ltrim(cadena){
    for (i = cadena.length -1 ; i >= 0; i--){
		if (cadena.charAt(i) != " "){
			return cadena.substring(0, i + 1);
		}
	}
	return cadena;
}
function js_tecla_nombre(cadena, obj, e){
   opc = false;
   tecla = (document.all) ? e.keyCode : e.which;
   if(tecla==8 || tecla==0 || tecla==32 || tecla==241 || tecla==209) return true;
   if ((tecla >= 65 && tecla <= 90) || (tecla >= 97 && tecla <= 122)) opc = true;
   return opc;
}
function js_tecla_numero(cadena, obj, e){
   opc = false;
   tecla = (document.all) ? e.keyCode : e.which;
   if ((tecla >= 48 && tecla <= 57) || tecla==8 || tecla==0)
   opc = true;   
   return opc;
}

function js_tecla_numero_letra(cadena, obj, e){
   opc = false;
   tecla = (document.all) ? e.keyCode : e.which;
   if ((tecla >= 48 && tecla <= 57) || (tecla >= 65 && tecla <= 90) || (tecla >= 97 && tecla <= 122) || tecla==8 || tecla==0)
   opc = true;   
   return opc;
}

function js_tecla_numero_decimal(cadena, obj, e){
   opc = false;
   tecla = (document.all) ? e.keyCode : e.which;
   if(obj.value.indexOf(".") > -1 && tecla == 46) return opc;
   if ((tecla >= 48 && tecla <= 57) || tecla==8 || tecla==0 || tecla==46)
   opc = true;   
   return opc;
}
function js_tecla_telefono(cadena, obj, e){
   opc = false;
   tecla = (document.all) ? e.keyCode : e.which;
   if ((tecla >= 48 && tecla <= 57) || tecla==8 || tecla==0  || tecla==40 || tecla==41 || tecla==43 || tecla==45)
   opc = true;   
   return opc;
}
function js_email_validar(email){
	var re  = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
	if (!re.test(email)) {
		return false;
	}
	return true;
}
function js_url_codificar(url){   
   url = escape(url);
   url = url.replace("+",'%2B');
   return url;
}
function js_mensaje(mensaje){
   alert(mensaje);
}

function js_divprotector_desactivar(){
   document.getElementById('div_protector').style.display = 'none';
}

function js_divprotector_activar(){
   document.getElementById("foco_temporal").focus();
   document.getElementById("div_protector").style.height = document.body.scrollHeight-4;
   document.getElementById("div_protector").style.width = document.body.scrollWidth-4;            
   document.getElementById('div_protector').style.display = 'block';
}

function js_imprimir(){
   var cabecera = "";
   var contenido = "";
   if(document.getElementById("div_cabecera") != null) cabecera = document.getElementById("div_cabecera").innerHTML;
   if(document.getElementById("div_contenido") != null) contenido = document.getElementById("div_contenido").innerHTML;
   ifrm_impresion.document.getElementById("impresion_cabecera").innerHTML = cabecera;
   ifrm_impresion.document.getElementById("impresion_contenido").innerHTML = contenido;

   ifrm_impresion.focus();
   ifrm_impresion.print();
}

function js_openwindow( dscURL, W, H, vars, nombre)
{
	var winl = (screen.width - W) / 2;
	var wint = (screen.height - H) / 2;
	winprops = ',height='+H+',width='+W+',top='+wint+',left='+winl+'resizable=0,scrollbars =1,status=yes ';
	vars=vars+winprops;
	var nwindow = window.open(dscURL, nombre ,vars);
	return nwindow; 
}