function isEmail(str)
{
  var supported = 0;
  if (window.RegExp)
  {
  var tempStr = "a";
  var tempReg = new RegExp(tempStr);
  if (tempReg.test(tempStr))
   	supported = 1;
  }
  if (!supported)
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
		
  return (!r1.test(str) && r2.test(str));
}
		
function chequeo()
{
  vari = isEmail(document.envio.MAILFROM.value);
  nombre = document.envio.NOMBRE.value;
  ape1 = document.envio.APELLIDO1.value;
  
  
  if (!vari)
	alert('Su correo electrónico no parece válido.\nIntrodúzcalo en el campo indicado.');
  else if(nombre == "Nombre" || !nombre)
    alert('Introduzca su nombre.');
  else if(ape1 == "1er Apellido")
    alert('Introduzca al menos su primer apellido.');
  else
	document.envio.submit();
}

function popup(id)
{
  var ventana=window.open("includes/otras/popimg.asp?idfoto="+id,"pop","status='no',location=0,0, scrollbars=no, resizable=no,width=640,height=480");
  ventana.opener.top.name="opener";
  ventana.focus();
}
			
function js_Ventana(www,ancho,alto,titulo,target)
{
  var destino=www+'#'+target;
  var ventana=window.open(destino,titulo,'status=no,location=0,0, scrollbars=yes, resizable=no,width='+ancho+',height='+alto);
  ventana.opener.top.name="opener";
  ventana.focus();
}

/***********************************************************/

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

function js_Ventana(www,ancho,alto,titulo,target)
{
	var destino=www+'#'+target;
	var ventana=window.open(destino,titulo,'status=no,scrollbars=yes,location=0,0, resizable=no,width='+ancho+',height='+alto);
	ventana.opener.top.name="opener";
	ventana.focus();
}

function js_UpdateHome(home)
{
	var windowPtr = ( top.opener.location ) ? top.opener : window.open( "", "newWindow" );
	windowPtr.location.href = home;
	windowPtr.focus();
}

function js_Contador(textarea,contador)
{
	if (textarea.value.length>499)
		{textarea.value=textarea.value.substring(0,499);
 		}
 	contador.value=499-textarea.value.length;
}

function js_ChequeaLongitud(textarea,evt)
{
	if (textarea.selected && evt.shiftKey) return true;
 	var allowKey=false;
 	if (textarea.selected && textarea.selectedLength>0) allowKey=true;
 	else
 		{var keyCode=document.layers ? evt.which : evt.keyCode;
   		 if (keyCode<32 && keyCode!=13) allowKey=true;
    		 else allowKey=textarea.value.length < 499;
    		}
 	textarea.selected=false;
 	return allowKey;
}

function js_popup(lista,limpia)
	{n=limpia.indexOf('x');
	 while (n!=-1)
	 	{m=limpia.indexOf('x',n+1);
	 	 if (m!=-1) {final=m;}
	 	 else {final=limpia.length;}
	 	 cadena=limpia.substring(n,final);
	 	 document.all[cadena].style.visibility = "hidden";
	 	 n=m;
	 	}
	 n=lista.indexOf('x');
	 while (n!=-1)
	 	{m=lista.indexOf('x',n+1);
	 	 if (m!=-1) {final=m;}
	 	 else {final=lista.length;}
	 	 cadena=lista.substring(n,final);
	 	 document.all[cadena].style.visibility = "visible";
	 	 n=m;
	 	}
	}

function js_tr(a,b,c,d,e)
	{
	 document.write("<tr>");
	 if (e>0)
	 	{if (a=='s') {document.write("<td>&nbsp;");}
	 	 else	{document.write("<td><a href='familia.asp?IDFAMILIA="+b+"' class='popup' onMouseOver='js_popup(x");
	 	 	 document.write(b+",w);'><img src='iconos/menuleft.gif' ");
	 	 	 document.write("valign='top' align='left' height=9 width=9 border=0></a>");
	 		}
	 	 document.write("</td>");
	 	}	 
	 document.write("<td width='100%'>");
	 if (a=='s')	{document.write("<a href='subfamilia.asp?IDFAMILIA="+b+"' onMouseOver='js_popup(x"+d);}
	 else	{document.write("<a href='familia.asp?IDFAMILIA="+b+"' onMouseOver='js_popup(x"+b);}
	 document.write(",w);' class='popup'>&nbsp;"+c+"</a></td>");
	 if (e==0)
	 	{if (a=='s') {document.write("<td>&nbsp;");}
	 	 else	{document.write("<td><a href='familia.asp?IDFAMILIA="+b+"' class='popup' onMouseOver='js_popup(x");
	 	 	 document.write(b+",w);'><img src='iconos/menuright.gif' ");
	 	 	 document.write("valign='top' align='right' height=9 width=9 border=0></a>");
	 		}
	 	 document.write("</td>");
	 	}
	 document.write("</tr>");
	}

function js_t1(a,b,c,d,e)
	{ 
	 document.write("<div id='x"+a+"' style='position: absolute; z-index:20; visibility:");
	 if (d==1) {document.write("hidden;");}
	 else	{document.write("visible;");}
	 document.write(" top:"+b+"; left:"+c+";'>");
	 document.write("<table border=0 width=0 bgcolor='#000000' cellpadding=0 cellspacing=2><tr><td>");
	 document.write("<table border=0 width="+e+" bgcolor='#E0E0E0' cellpadding=0 cellspacing=0 class='popup'>");
	}
	
function js_t2()
	{
	 document.write("</table></td></tr></table></div>\n");
	 }

function js_popup_limpia(limpia)
	{n=limpia.indexOf('x');
	 while (n!=-1)
	 	{m=limpia.indexOf('x',n+1);
	 	 if (m!=-1) {final=m;}
	 	 else {final=limpia.length;}
	 	 cadena=limpia.substring(n,final);
	 	 document.all[cadena].style.visibility = "hidden";
	 	 n=m;
	 	}
	}

function js_popup_on(uno,dos)
	{if (NS4) {document.layers[dos].visibility = "hide";}
	 else {document.all[dos].style.visibility = "hidden";}
	 if (NS4) {document.layers[uno].visibility = "show";}
	 else	  {document.all[uno].style.visibility = "visible";}	 
	}

function js_popup_off(lista,limpia)
	{n=lista.indexOf('x');
	 while (n!=-1)
	 	{m=lista.indexOf('x',n+1);
	 	 if (m!=-1) {final=m;}
	 	 else {final=lista.length;}
	 	 cadena=lista.substring(n,final);
	 	 document.all[cadena].style.visibility = "hidden";
	 	 n=m;
	 	}
	 n=limpia.indexOf('x');
	 while (n!=-1)
	 	{m=limpia.indexOf('x',n+1);
	 	 if (m!=-1) {final=m;}
	 	 else {final=limpia.length;}
	 	 cadena=limpia.substring(n,final);
	 	 document.all[cadena].style.visibility = "hidden";
	 	 n=m;
	 	}
	}
function resizeIframe(cad){
  var miIframe=document.getElementById(cad);
  var alturaPagina=miIframe.contentWindow.document.body. scrollHeight+20;
  miIframe.style.height=alturaPagina+"px"; 
}
/***********************************************************/