function browserRedirect()
{
  var ns4 = document.layers;
  var ns6 = document.getElementById && !document.all;
  var ie4 = document.all;
  
  if(ns4) URLStr = "1.html";
  else if(ns6) URLStr = "2.html";
  else if(ie4) URLStr = "3.html";
  else URLStr = "4.html";
  location = URLStr;
}
//función trim en javascript
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
//Verificación de email
function femail() {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form.email.value)){
		return (true)
	}
	alert("Dirección de email inválida");
	document.form.email.focus();
}
//para verificar el formato de la foto
function valfoto(foto){
	var str=foto.toLowerCase();
	//detectar formato de foto
	if(foto!=""){
		if(str.lastIndexOf(".jpg")<1){
			alert("La foto debe estar en formato JPG.");
			document.form.foto.value="";
			document.form.foto.focus();
			return true;
		}
		//detectar peso de imagen
		//var actx = new ActiveXObject("Scripting.FileSystemObject");
		//var imagen = actx.getFile(foto);
		//var peso = imagen.size/1024;
		//if(peso > 700){
			//alert("Image size bigger than 700 MBytes, You must lower the size of the file");
			//document.form.foto.focus();
			//return true;
		//}
	}
}
//para abrir link en otra ventana
function viewer(url,ancho,alto){
   	window.open(url,"ventana1","width="+ancho+",height="+alto+",scrollbars=YES");	
}
//pregunta de seguridad antes de borrar
function areusure(question,url){ 
	var answer = confirm (question)
	if (answer){
		document.location.href=url;
	}
}
//
function error(mensaje){ 
	alert(mensaje);
	return true;
} 
//Función para validar los campos RadioBottoms
function validar_radios(nombre) {
	for(var x = 0; x < document.form[nombre].length; x++){
		if(document.form[nombre][x].checked== true){
			return(document.form[nombre][x].value);
		}
	}
	return("");
}
//Función para validar los campos RadioBottoms
function validar_list(nombre) {
	result="";
	coma=" ";
	for(var x = 0; x < document.form[nombre].length; x++){
		if(document.form[nombre][x].selected== true){
			result=result+coma+document.form[nombre][x].value;
			coma=",";
		}
	}
	return(result);
}
//Funcion para ver imagen en grande
function viewer(url,ancho,alto){
   	window.open(url,"ventana1","width="+ancho+",height="+alto+",scrollbars=YES") 	
}
