//se usa para mostar los elementos escogidos en un formulario
function autoFormAssign($id, $value){
	$obj = document.getElementById($id);
    switch($obj.tagName.toLowerCase()) { //tolower
         case 'input':
         case 'textarea': //added text area
         switch($obj.type){
             case 'checkbox':
             	if ($value == 'true'){
             		$obj.checked = true;
             	} else {
             		$obj.checked = false;
             	}	
             	break;
             case 'radio':
             	$radios = document.getElementsByName($id);
             	for($i in $radios){
                 $radio = $radios[$i];
                 if ($radio.value == $value)
                 $radio.checked = true;
                 else
                 $radio.checked = false;
             }
             	break;
             default:
             $obj.value = $value;
         }
         break;
         case 'select':
	         for ($i=0;$i<$obj.options.length;$i++)
	         if ($obj.options[$i].value == $value) //added the value
	         $obj.options[$i].selected = true;
	         //else                                                      // added this line
	         //$obj.options[$i].selected = false;
	         break;
     }
 }
 
//se usa para mostar los elementos escogidos en un select con enum
function autoFormAssignEnum($id, $value){
     $obj = document.getElementById($id);
     switch($obj.tagName.toLowerCase()) //tolower
     {
         case 'select':
         for ($i=0;$i<$obj.options.length;$i++)
         if ($obj.options[$i].text == $value) //added the value
         $obj.options[$i].selected = true;
         //else                                                      // added this line
         //$obj.options[$i].selected = false;
         break;
     }
}

//se usa para quitar los elementos seleccionados en un select múltiple
function clearSelect($id){
	$obj = document.getElementById($id);
	for ($i=0;$i<$obj.options.length;$i++)
    $obj.options[$i].selected = false;	
}

//deshabilita objetos en un formulario
function disableObjects($form,$id){
	$obj = document.getElementById($id);
	$obj.disabled = true;
 }

//agrega opciones a un menu <select>
function addOption(selectId, txt, val){
    var objOption = new Option(txt, val);
    document.getElementById(selectId).options.add(objOption);
}

//elimina opciones de un menu <select>
function clearOptionList(selectId){
    document.getElementById(selectId).options.length = 0;
}

//confirma la eliminación de un registro
function confirmaBorrar($tabla, $id, $recarga){
	var agree=confirm("¿Esta Usted seguro de querer eliminar este registro?");
	if (agree)
		xajax_lw_borrar_registro($tabla, $id, $recarga);
	else
		return false ;
}
//confirma la eliminación de un registro
function confirmaBorrarEspaciosPlanes($id,$id_servidores){
	var agree=confirm("¿Esta Usted seguro de querer eliminar este registro?");
	if (agree)
		xajax_lw_borrar_registro_espacios_planes($id,$id_servidores);
	else
		return false ;
}
//confirma la eliminación de un registro
function confirmaBorrarImagen($id,$id_solicitud_particulares){
	var agree=confirm("¿Esta Usted seguro de querer eliminar este documento?");
	if (agree)
		xajax_lw_borrarimagen($id,$id_solicitud_particulares);
	else
		return false ;
}

//confirma la eliminación de un registro
function confirmaBorrarFoto($id){
	var agree=confirm("¿Esta Usted seguro de querer eliminar esta foto?");
	if (agree)
		xajax_lw_borrarfoto($id);
	else
		return false ;
}

//confirma ver registro existente
function confirmaVerRegistro($id,$quien){
	var agree=confirm("Número de cédula registrado como "+$quien+" en el sistema. ¿Desea ver solicitud?");
	if (agree)
		xajax_lw_mostrardetallessolicitudparticular($id);
	else
		limpiaFormulario('formParticularCedula');
}

//limpia un formulario
function limpiaFormulario(selectId){
	document.getElementById(selectId).reset();	
}

function soloLectura(selectId){
	document.getElementById(selectId).readOnly=true;	
}

function test() {
	alert("hola");	
}
