//Valida el nombre de fichero pasado por parámetro con las extensiones separadas por comas
//pasadas como string
function checkFileExtesion( pathName, allowedExt ){

	var ext = allowedExt.split( "," );

	for ( i=0; i < ext.length; i++ ){
		
		if ( pathName.toUpperCase().lastIndexOf( "." + Trim( ext[i].toUpperCase() ) ) > -1 ){
			return true;
		}
		
	}
	
	return false;

}

//Se encarga de chequear-deschequear un grupo de checkbox con el mismo "name" 
//a partir de otro checkbox selector
function HeaderCheck( selector, checkboxArray ){
	
	var chkState = selector.checked;
	
	if ( checkboxArray ){
		
		if ( checkboxArray.length ){
	
			for( i=0; i < checkboxArray.length; i++ ){
				checkboxArray[i].checked = chkState;
			}
		
		} else {
		
			checkboxArray.checked = chkState;
		
		}
	
	}
	
}

//Pasado un array de checkbox devuelve el número de elementos seleccionados
function CountSelectedCheckboxes( checkboxArray ){
	
	var checkedCount = 0;
	
	if ( checkboxArray ){
	
		if ( checkboxArray.length ){
		
			for( i=0; i < checkboxArray.length; i++ ){
			
				if( checkboxArray[i].checked ) 
					checkedCount++
					
			}
		
		} else {
		
			if( checkboxArray.checked ) 
					checkedCount++
		
		}
	
	}
	
	return checkedCount;

}

// Modifica la imagen de todos los "radiobuttons" a una determinada(src)
function uncheckall(obj, src) {
		
	var sId;

	if(obj) {
				
		if(obj.length) {
						
			for(i=0;i<obj.length;i++) {
				sId = obj[i].id.substring(1);
				document.getElementById(sId).src = src;
			}
			
		}
		else {
				sId = obj.id.substring(1);
				document.getElementById(sId).src = src;
		}
				
	}
			
}

// Activa/Desactiva una caja de texto
function activate(objid, action) {

	var obj;
	obj = document.getElementById(objid);

	if(obj) {
	
		if (action == true) {
			
			obj.disabled = false;
			obj.focus();
			
		}
		else {
			
			obj.disabled = true;
			obj.value = "";
			
		}
	
	}
	
}
