<!-- Marcado múltiple de casillas checkbox

function marcaNum(field1,field2,total) {
	total = total * 1;
    if ((field2.length > 1) && (field2.length < (total+1))) {  // de 2 a 'total' celdas, siempre más de 1 elementos
      if (field1.checked) {
        for (i = 0; i < field2.length; i++) {
	      field2[i].checked = true;
	      comprueba(field2[i]); } }
      else {
        for (i = 0; i < field2.length; i++) {
          field2[i].checked = false;
	      comprueba(field2[i]); } } }
    else if (field2.length = 1) {                        // cuando sólo hay 1 elemento
      if (field1.checked) {
	      field2.checked = true;
	      comprueba(field2); }
      else {
          field2.checked = false;
	      comprueba(field2); } }
}

function marcaNumDoble(field1,field2,field3,total) {	// modificación para doble checkox (para tablas con doble Id)
	total = total * 1;
    if ((field2.length > 1) && (field2.length < (total+1))) {  // de 2 a total, siempre más de 1 elementos
      if (field1.checked) {
        for (i = 0; i < field2.length; i++) {
	      field2[i].checked = true;
	      field3[i].checked = true;
	      comprueba(field2[i]);
	      comprueba(field3[i]); } }
      else {
        for (i = 0; i < field2.length; i++) {
          field2[i].checked = false;
          field3[i].checked = false;
	      comprueba(field2[i]);
	      comprueba(field3[i]); } } }
    else if (field2.length = 1) {                        // cuando sólo hay 1 elemento
      if (field1.checked) {
	      field2.checked = true;
	      field3.checked = true;
	      comprueba(field2);
	      comprueba(field3); }
      else {
          field2.checked = false;
          field3.checked = false;
	      comprueba(field2);
	      comprueba(field3); } }
}

function marca2(field1,field2,total) {  //	Marca las casillas desde la uno a la 'total'
  total = total * 1;
  var campo = field1;
 
  if (field1.checked) {
    for (i = 1; i < total+1; i++) {
      campo = eval('document.form1.' + field2 + i);  //esta celda es de nombre variable campo_i
	  campo.checked = true; } }
  else {
    for (i = 1; i < total+1; i++) {
      campo = eval('document.form1.' + field2 + i);	  
      campo.checked = false; } }
}
// -->

<!-- Sombreado de celdas
// Requiere este css para inicializar el color de celda: tr.h { background-color: #FFFFFF; }

function comprueba(casilla) {	// comprueba si está marcada la casilla
  if (casilla.checked) sombrea(casilla);
  else  desSombrea(casilla);
}

ie = document.all?1:0

function sombrea(celda){
  if (ie) { while (celda.tagName!="TR") { celda=celda.parentElement; } }
  else { while (celda.tagName!="TR") { celda=celda.parentNode; } }
  celda.className = "H";
  }

function desSombrea(celda){
  if (ie) { while (celda.tagName!="TR") { celda=celda.parentElement; } }
  else { while (celda.tagName!="TR") { celda=celda.parentNode; } }
  celda.className = "";
  } 
// -->

<!-- Corrección de formato numérico de la coma "," por punto "."

function comaPorPunto(celda) {
  var tempCadena ="";
  var valorCelda = eval('document.form1.' + celda + '.value');
  var laCelda = eval('document.form1.' + celda);
  for (i=0; i<valorCelda.length; i++) {
	if (valorCelda.charAt(i) != ',') {
	  tempCadena = tempCadena + valorCelda.charAt(i); }
	else tempCadena = tempCadena + '.';  }
  laCelda.value = tempCadena;
}
// -->

<!-- Alfa de texto en las celdas de texto. Efecto 'desactivada'

function fcolor(casilla,campo) {
  if (casilla.checked) { campo.style.color = '#00000'; }
  else { campo.style.color = '#cccccc'; }
}
// -->

<!-- Elimina caracteres de celdas de texto

function remove_XS_whitespace(item)	{	// elimina espacios
  if (item.value == ' '){item.value = ''};
}

function remove_XS_whitespace_Char(item) {	// elimina caracteres especiales
  item.value = item.value.replace(/\r/g, " ");
  item.value = item.value.replace(/[^ áÁéÉíÍóÓúÚñÑ€ªº!¡·¿çÇ¬¨´A-Za-z0-9`~!@#\$%\^&\*\(\)-_=\+\\\|\]\[\}\{'";:\?\/\.>,<]/g, "");
  item.value = item.value.replace(/'/g, "");
  item.value = item.value.replace(/ +/g, " ");  
  item.value = item.value.replace(/^\s/g, "");
  item.value = item.value.replace(/\s$/g, "");	
  if (item.value == ' '){item.value = ''};
}

function remove_XS_whitespace_BR(item) {	// idem pero añade cambio de linea
  item.value = item.value.replace(/\r/g, "<br>");
  item.value = item.value.replace(/[^ áÁéÉíÍóÓúÚñÑ€ªº!¡·¿çÇ¬¨´A-Za-z0-9`~!@#\$%\^&\*\(\)-_=\+\\\|\]\[\}\{'";:\?\/\.>,<]/g, "");
  item.value = item.value.replace(/'/g, "");
  item.value = item.value.replace(/ +/g, " ");  
  item.value = item.value.replace(/^\s/g, "");
  item.value = item.value.replace(/\s$/g, "");	
  if (item.value == ' '){item.value = ''};
}
//-->

<!-- Iguala celdas de texto al valor del combobox
function iguala(combo,celda) {
   celda.value = combo;
}
// -->

<!--  Ir a URL

function abreURLcombo(pagina, id) {  //abre la dirección que indica el combo
  direccion = pagina + id;
  abreURL('parent',direccion);
  return document.devuelveValor;
}

function abreURL() {
  var i, args=abreURL.arguments; document.devuelveValor = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
// -->

<!-- Abre ventana 
function ventanaFlotante(url, nombre, caracteristicas) {
  nuevaVentana=window.open(url, nombre, caracteristicas);
}

function abreVentana(theURL,Id,winName,popWidth,popHeight) { // añadir ;return document.MM_returnValue
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;
  features = 'fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars_sectores=no,resizable=no'
  winAlign = 'center'
  ignorelink = 'ignoreLink'
  alwaysOnTop = ''
  autoCloseTime = 0
  borderless = ''

  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

function abreFoto(imageName,texto,imageWidth,imageHeight,bgcolor) {

	hugger = 'hug image'
	alt = " " + texto + " ________________________________________________________________________________________________"
	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

    if(w<740){
      var lift=0.90;
    }
    if(w>=740 & w<835){
      var lift=0.91;
    }
    if(w>=835){
      var lift=0.93;
    }

	if (imageWidth>w){	
		byFactor = w / imageWidth;			
		imageWidth = w;
		imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
		byFactor = h / imageHeight;
		imageWidth = (imageWidth * byFactor);
		imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
		imageHeight=imageHeight*lift;
		imageWidth=imageWidth*lift;
	}

	var posLeft=0
	var posTop=0
	
	if (hugger=="hug image") {
		posTop = (scrHeight-imageHeight)/2;
		posLeft = ((w-imageWidth)/2);
		scrHeight = imageHeight-adj;
		scrWidth = imageWidth-adj;
 	}
	
	imageHeight=imageHeight-adj;
	imageWidth=imageWidth-adj;

	newWindow = window.open("","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><meta http-equiv="imagetoolbar" content="no"><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td align="center">');
	newWindow.document.write('<img src='+imageName+' alt=\"Cerrar\&nbsp\;-\&nbsp\;Pechar\" >'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function abreFlash(flashName,texto,imageWidth,imageHeight,bgcolor) {

	hugger = 'hug image'

	alt = " ___ " + texto + " ________________________________________________________________________________________________"
	if (bgcolor=="") {
		bgcolor="#D8E0E8";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

    if(w<740){
      var lift=0.90;
    }
    if(w>=740 & w<835){
      var lift=0.91;
    }
    if(w>=835){
      var lift=0.93;
    }

	if (imageWidth>w){	
		byFactor = w / imageWidth;			
		imageWidth = w;
		imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
		byFactor = h / imageHeight;
		imageWidth = (imageWidth * byFactor);
		imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
		imageHeight=imageHeight*lift;
		imageWidth=imageWidth*lift;
	}

	var posLeft=0
	var posTop=0
	
	if (hugger=="hug image") {
		posTop = (scrHeight-imageHeight)/2;
		posLeft = ((w-imageWidth)/2);
		scrHeight = imageHeight-adj;
		scrWidth = imageWidth-adj;
 	}
	
	imageHeight=imageHeight-adj;
	imageWidth=imageWidth-adj;

	newWindow = window.open("","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop+",resizable=yes");
	newWindow.document.open();
	newWindow.document.write('<html><head><title>'+alt+'</title><scrip');
	newWindow.document.write('t language="JavaScript">function openNewWindow(URLtoOpen, windowName, windowFeatures){newWindow=window.open(URLtoOpen, windowName, windowFeatures)}</scrip');
	newWindow.document.write('t></head><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor);  
	newWindow.document.write('><table width=100% border="0" cellspacing="0" cellpadding="0" height=100%><tr><td align="center">');
	newWindow.document.write('<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%">');
	newWindow.document.write('<param name="movie" value="' + flashName + '" ><param name="quality" value="high"><param name="bgcolor" value="#D8E0E8">');
	newWindow.document.write('<embed src="' + flashName+ '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%"></embed>');
	newWindow.document.write('</object>');
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
}

<!-- Funciones para generar usuarios, sus contraseñas y activar las cuentas

function genera_usuarios(id,email,usuario) {
	if (email.value != "") { usuario.value = email.value; }
	else {usuario.value = id.value + "@estilo27.com"}
}

function genera_contrasena(campo) {
	valor = Math.random() * 100000000;
	valor = Math.round(valor);
	campo.value = valor;
}

//-->
