// JavaScript Document

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function muestra(id) {

	var elObj = MM_findObj(id);

	elObj.style.display = '';

}

function oculta(id) {

	var elObj = MM_findObj(id);

	elObj.style.display = 'none';

}

function genCod (campo, long) {

	cod = ""

	RI_chars = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")

	RILong = RI_chars.length - 1

	if (long == "") {

		long = 12

	}

	for (i=0;i<long;i++) {

		pos = Math.round(RILong * Math.random())

		cod += RI_chars[pos]

	}

	elCampo = MM_findObj(campo)

	elCampo.value = cod

}

function cargaIds() {

	campo = MM_findObj('ids');

	campo.value = "";

	for(i=0;i<2000;i++) {

		elemento = MM_findObj('grupo_'+i);

		if (elemento) {

			if (elemento.checked == true) {

				campo.value += elemento.value+",";

			}

		}

	}

	eti = MM_findObj('etiqueta');

	if (campo.value != "" && eti.value != "") {

		window.document.forms['form2'].submit();

	} else {

		alert("Seleccione al menos un campo y el tipo de papel")	

	}

}

function cargaIds_u() {

	origen = MM_findObj('ids_print');

	destino = MM_findObj('ids');

	destino.value = origen.value

	eti = MM_findObj('etiqueta');

	if (destino.value != "" && eti.value != "") {

		window.document.forms['form2'].submit();

		//alert(destino.value)

	} else {

		alert("No ha seleccionado papel o no hay elementos a imprimir")	

	}

}

function selectAll(nombre) {

	for (i=0;i<2000;i++) {

		elemento = MM_findObj(nombre+"_"+i);

		if (elemento != null) {

			elemento.checked = true

		}

	}

	alert("Tenga en cuenta que generar un informe con todos los elementos seleccionados puede tardar varios minutos y sobrecargar el servidor.")

}




