function esMailValido(mail) {  
  var valido = true;
  var posArroba = mail.indexOf("@");
  var len = mail.length;
  if (posArroba > 0 && posArroba < len - 5) {
    if (mail.indexOf("@", posArroba + 1) > 0) {
      valido = false;
    }
    if (valido) {
      posUltPunt = mail.lastIndexOf(".");
      posPriPunt = mail.indexOf(".");      
      if (posUltPunt > len - 3 || posPriPunt == 0 || posPriPunt == -1) {
        valido = false;
      } else {
        if (mail.indexOf("..") >= 0 || mail.indexOf("@.") >= 0 || mail.indexOf(".@") >= 0) {
          valido = false;
        }
      }    
    }
  } else {
    valido = false;
  }  
  return valido;
}

function soloTextoPlano(evt) {
  // NOTA: Backspace=8, Enter=13, '0'=48, '9'=57, 'A'=65, 'Z'=90, 'a'=97, 'z'=122, '''=27, ','=44, '.'=46, 'ñ'=241, 'Ñ'=209, ':'=58, ' '=32 
  // '&'=38, '?'=63, '!'=33, '¡'=173, '¿'=168
	var key = window.event ? evt.keyCode : evt.which;		 	 
	return (key <= 13 || (key >= 48 && key <= 57) || (key >= 65 && key <=90) || (key >= 97 && key <= 122) || (key >= 192 && key <= 252) || 
	  key == 44 || key == 46 || key == 27 || key == 58 || key == 32 || key == 38 || key == 63 || key == 33 || key == 173 || key == 168);    
}

/*
function soloTextoPlanoSub(evt, caja, idioma) {
  // NOTA: Backspace=8, Enter=13, '0'=48, '9'=57, 'A'=65, 'Z'=90, 'a'=97, 'z'=122, '''=27, ','=44, '.'=46, 'ñ'=241, 'Ñ'=209, ':'=58, ' '=32 
  // '&'=38, '?'=63, '!'=33, '¡'=173, '¿'=168
	var key = window.event ? evt.keyCode : evt.which;
	if (key == 13) {
	  location.href = "productos/Productos.aspx?idIdioma=" + idioma + "&buscar=" + caja.value;
	}    		 	 
	return (key <= 12 || (key >= 48 && key <= 57) || (key >= 65 && key <=90) || (key >= 97 && key <= 122) || (key >= 192 && key <= 252) || 
	  key == 44 || key == 46 || key == 27 || key == 58 || key == 32 || key == 38 || key == 63 || key == 33 || key == 173 || key == 168);    
}
*/

function soloTextoMail(evt) {
  // NOTA: Backspace=8, Enter=13, '0'=48, '9'=57, 'A'=65, 'Z'=90, 'a'=97, 'z'=122, '.'=46, '_'=95, '@'=64, '-'=45
  var key = window.event ? evt.keyCode : evt.which;  
  return ((key >= 48 && key <= 57)|| (key >= 65 && key <=90) || (key >= 97 && key <= 122) || key == 46 || key == 95 || 
    key == 64 || key == 45);
}    

function soloNumeros(evt) {				
  // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
	var key = window.event ? evt.keyCode : evt.which; 
	return (key <= 13 || (key >= 48 && key <= 57));
}

function soloTelefonos(evt) {
  // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57, '.'=46, '-'=45, '_'= 95, '('=40, ')'=41, ' '=32
	var key = window.event ? evt.keyCode : evt.which; 
	return (key <= 13 || (key >= 48 && key <= 57) || key == 46 || key == 45 || key == 40 || key == 41 || key == 32);
}

function soloNombres(evt) {
  // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57, '.'=46, '-'=45, '_'= 95, '('=40, ')'=41, ' '=32
	var key = window.event ? evt.keyCode : evt.which; 
	return (key <= 13 || (key >= 65 && key <=90) || (key >= 97 && key <= 122) || key == 32 || key == 46 || (key >= 192 && key <= 252));  
}

function soloDireccion(evt) {
  var key = window.event ? evt.keyCode : evt.which;
  return (key <= 13 || (key >= 48 && key <= 57) || (key >= 65 && key <=90) || (key >= 97 && key <= 122) ||  
	  key == 44 || key == 46 || key == 27 || key == 32 || key == 47 || key == 166 || key == 167 || (key >= 192 && key <= 252));
}

// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG() {
  for(var i = 0; i < document.images.length; i++) {
    var img = document.images[i];
	  var imgName = img.src.toUpperCase();
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		  var imgID = (img.id) ? "id='" + img.id + "' " : ""; 
		  var imgClass = (img.className) ? "class='" + img.className + "' " : "";
		  var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
		  var imgStyle = "display:inline-block;" + img.style.cssText;
		  if (img.align == "left") imgStyle = "float:left;" + imgStyle;
		  if (img.align == "right") imgStyle = "float:right;" + imgStyle;
		  if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
		  var strNewHTML = "<span " + imgID + imgClass + imgTitle 
		    + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	      + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		  img.outerHTML = strNewHTML;
		  i = i - 1;
	  }
  }
  window.attachEvent("onload", correctPNG);
}

function AceptarPolitica(valor){
    
    var btnEnviar = document.getElementById("butAceptar");
    var chkpolitica  = document.getElementById("chkPolitica");
    
    if (valor) {
       btnEnviar.disabled = false;
       
    } else {
       btnEnviar.disabled = true;  
    }

}

function PopupWindow() {
var h,w;
h=400;
w=800;
var winl = (screen.width - h) / 2;
var wint = (screen.height - w) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars="yes",resizable'
win = window.open("politica.aspx","_parent", winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}