// Funciones para poblar los combos

var ie=(navigator.appName.toLowerCase().indexOf('microsoft')!=-1);

function crear_opcion_combo(combo,texto_opcion,valor_opcion){
	if (combo && texto_opcion!=''){
		var opcion=document.createElement('option');
		opcion.text=texto_opcion;
		opcion.value=valor_opcion;
		combo.options.add(opcion);
	}
}

function vaciar_combos(id_combo,elemento_vacio){
	if ( document.getElementById(id_combo) ){
			var combo=document.getElementById(id_combo);
			while ( combo.options.length>0 ){
				if (ie){
					combo.options.remove(0);
				}
				else{
					combo.options[0]=null; 
				}
			}
			if (elemento_vacio){
				crear_opcion_combo(combo,'...','');
			}
		}
	}
	
function poblar_combos(id_combo,valor_condicion,caso){
	if ( document.getElementById(id_combo) ){
			var combo=document.getElementById(id_combo);
			var ar_origen=new Array();
			var condicion=null;
			if ( valor_condicion!=null ){
				condicion=valor_condicion;
			}
			
			vaciar_combos(id_combo,true);
			
			switch(caso) {
				case 'pdis':
					ar_origen=ar_subcategorias;
					for (i=0;i<ar_origen.length;i++){
						if ( ar_origen[i][1]==condicion || condicion==null ){
							crear_opcion_combo(combo,ar_origen[i][2],ar_origen[i][0]);
						}
					}
				break;
			}
			
	}
}