// JavaScript Document
  function enable_disable(check,form)
	{
	  for (i=0;i<form.elements.length;++i)
		{
		  if (form.elements[i].type=="checkbox")
			  form.elements[i].checked=check.checked;
		}
	}

  function count_checked(form)
	{
	  iCount=0;
	  for (i=0;i<form.elements.length;++i)
		{
		  iCount+=((form.elements[i].type=="checkbox") && (form.elements[i].checked))?1:0;
		}
		return iCount;
	}

  function action_with_checks(form,action,message,query)
	{
	  if (count_checked(form)==0)
		{
		  alert(message);
			return;
		}
		if (confirm(query))
		{
		  form.action=action;
			form.submit();
		}
	}

  function check_selected(form)
	{
	  index=0;
	  for (i=0;i<form.elements.length;++i)
		{
		  if ((form.elements[i].type=="checkbox") && (form.elements[i].checked))
			{
			  index=i;
				break;
			}
		}
		return index;
	}
	
  function buscaAutor(form)	
	{
		if (form.NombreAutor.value.length<6)
		{
		  alert("Especifique por lo menos 6 caracteres del nombre del autor a buscar por favor");
			return;
		}
		wnd=window.open("./autorView.php?act=list&subtask=select&frm="+form.name+"&search="+form.NombreAutor.value,"autorSelect","toolbar=0,width=700,height=500,screenx=100,screeny=100,scrollbars=yes");
	}
	
	function seleccionaAutor(to,id,nombre)
	{
		 wnd=window.opener.document;
		 wnd.forms[to].elements["IdAutor"].value=id;
		 wnd.forms[to].elements["NombreAutor"].value=nombre;
	}
	
	function buscaLibro(form,index)	
	{
		if (form.elements["NombreLibro"+index].value.length<6)
		{
		  alert("Especifique por lo menos 6 caracteres del nombre del libro a buscar por favor");
			form.elements["NombreLibro"+index].focus();
			return;
		}
		wnd=window.open("./libroView.php?act=list&subtask=select&frm="+form.name+"&search="+form.elements["NombreLibro"+index].value+"&index="+index,"autorSelect","toolbar=0,width=700,height=500,screenx=100,screeny=100,scrollbars=yes");
	}
	
	function seleccionaLibro(to,index,id,nombre)
	{
		 wnd=window.opener.document;
		 wnd.forms[to].elements["IdLibro"+index].value=id;
		 wnd.forms[to].elements["NombreLibro"+index].value=nombre;
	}

	function buscaUnLibro(form)	
	{
		if (form.elements["NombreLibro"].value.length<6)
		{
		  alert("Especifique por lo menos 6 caracteres del nombre del libro a buscar por favor");
			form.elements["NombreLibro"].focus();
			return;
		}
		wnd=window.open("./libroView.php?act=list&subtask=select&frm="+form.name+"&search="+form.elements["NombreLibro"].value,"autorSelect","toolbar=0,width=700,height=500,screenx=100,screeny=100,scrollbars=yes");
	}
	
	function seleccionaUnLibro(to,id,nombre)
	{
		 wnd=window.opener.document;
		 wnd.forms[to].elements["IdLibro"].value=id;
		 wnd.forms[to].elements["NombreLibro"].value=nombre;
	}

	function updateLayer(wnd,layer,texto)
	{
		if(wnd.document.layers)
		{
			 //"NN4";
			lyr= wnd.document.layers[layer];
			lyr.document.open();
			lyr.document.write(texto);
			lyr.document.close();
		}
		 if(wnd.document.all)
		 {
				//"ie"
				wnd.document.all(layer).innerHTML=texto;
			}
			
		if(!wnd.document.all && wnd.document.getElementById)
		{
		  //"NN6";
			lyr= wnd.document.getElementById(layer);
			lyr.innerHTML =texto;
		}
	}
