//::: Funciones para operaciones con selects
//?IMPORTANTE! le falta corregir que borre el campo hasta en blanco
function select_mover(formu,desde,hasta){
	
	// control de variables
	if(!formu||!desde||!hasta){
		alert("ADVERTENCIA\n\nFaltan argumentos.");
		return;
		}
		
	// variables
	formu=document.forms[formu];
	desde=formu.elements[desde];
	hasta=formu.elements[hasta];
	larga=hasta.length+1;
	
	// se toma el elemento seleccionado
	valor=desde.options[desde.selectedIndex].value;
	nombre=desde.options[desde.selectedIndex].text;
	if(!valor){
		return;
		}
	
	// se elimina el elemento vac?o
	if(hasta.options[0].value=="-1"){
		hasta.options[1]=null;
		}
	
	// se carga el otro select
	opcion=new Option(nombre,valor);
	hasta.options[larga]=opcion;
	
	}

function select_orden(formu,select,direccion){

	// control de variables
	if(!formu||!select||!direccion){
		alert("ADVERTENCIA\n\nFaltan argumentos.");
		return;
		}
		
	// algunas variables
	formu=document.forms[formu];
	select=formu.elements[select];
	pos=select.options.selectedIndex;
	cantidad=select.length-1;
	
	// controles para evitar cosas no permitidas
	if(pos<0){
		alert("Debe seleccionar un registro para ordenar.");
		return;
		}
	if(pos==0&&direccion=='subir'){
		return;
		}
	if(pos==cantidad&&direccion=='bajar'){
		return;
		}
	
	// otras variables
	valor=select.options[pos].value;
	texto=select.options[pos].text;
	pos_nueva=(direccion=='subir')?pos-1:pos+1;

	// valores de switch
	valor2=select.options[pos_nueva].value;
	texto2=select.options[pos_nueva].text;
	
	
	// se carga el valor donde debe ir
	opcion=new Option(texto,valor);
	opcion2=new Option(texto2,valor2);
	select.options[pos_nueva]=opcion;
	select.options[pos]=opcion2;
	
	// se vuelve el foco al cuadro
	select.options[pos_nueva].selected=true;
	
	}

function select_agregar(formu,select,valor,texto){
	
	// control de variables
	if(!formu||!select||!texto){
		alert("ADVERTENCIA\n\nFaltan argumentos.");
		return;
		}

	// algunas variables
	formu=document.forms[formu];
	select=formu.elements[select];
	pos=select.length;

	// se crea la opci?n
	opcion=new Option(texto,valor);	
	select.options[pos]=opcion;
	
	// se selecciona la opci?n
	select.options.selectedIndex=0;
	
	}

function select_seleccionar(formu,select){

	// control de variables
	if(!formu||!select){
		alert("ADVERTENCIA\n\nFaltan argumentos.");
		return;
		}

	// algunas variables
	formu=document.forms[formu];
	select=formu.elements[select];
	cantidad=select.length;
	
	// se recorre el select
	for(i=0;i<cantidad;i++){
		select.options[i].selected=true;
		}

	
	}

function select_quitar(formu,select,confirma,elemento){

	// control de variables
	if(!formu||!select){
		alert("ADVERTENCIA\n\nFaltan argumentos.");
		return;
		}

	// algunas variables
	formu=document.forms[formu];
	select=formu.elements[select];
	pos=(!elemento)?select.options.selectedIndex:elemento;

	// otro control
	if(pos<0){
		alert("Debe seleccionar un registro para eliminar.");
		return;
		}
	
	// m?s variables
	valor=select.options[pos].text;
	letras_cant=valor.length;

	if(confirma&&!confirm('Desea eliminar el registro \''+valor+'\'?')){
		return;
		}
	
	// se quita la opcizzn con efecto especial
	select.options.selectedIndex=-1;	// se quita la selecci?n para que se vea la selecci?n
	select.options[pos]=null;
	select.options.selectedIndex=0;
	}


function select_vaciar(formu,select,confirma){

	// control de variables
	if(!formu||!select){
		alert("ADVERTENCIA\n\nFaltan argumentos.");
		return;
		}

	// algunas variables
	formu=document.forms[formu];
	select=formu.elements[select];

	if(confirma&&!confirm('?Desea vaciar las opciones?')){
		return;
		}
	
	// se quita las opci?nes
	select.options.length=0;
	
	}
//::: /Funciones para operaciones con selects
