function marcarTodo(obj){
	if(obj.desmarcar){
		obj.src='/images/intranet/btn_marcar.gif';
		obj.desmarcar=false;
	}else{
		obj.src='/images/intranet/btn_desmarcar.gif';
		obj.desmarcar=true;
	}
	$(obj).getParent().getParent().getElements('table input').each(function(el){
		if(el.type=='checkbox'){
			el.checked=obj.desmarcar;
		}
	});
}

function dosCifras(valor){
	if(valor.toString().length==1){
		valor='0'+valor;
	}
	return valor;
}

function filtroFechasSelect(obj){
	var indice=obj[obj.selectedIndex].value;
	if(indice==4){
		$('label_desde').setStyle('display','block');
		$('label_hasta').setStyle('display','block');
	}else{
	//	$('label_desde').setStyle('display','none');
	//	$('label_hasta').setStyle('display','none');
	}
	var hoy=new Date();	
	switch (indice){
		case '1':
			var fecha_desde='01'+'/'+dosCifras((hoy.getMonth()+1))+'/'+hoy.getFullYear();
			var fecha_hasta=dosCifras(hoy.getDate())+'/'+dosCifras(hoy.getMonth()+1)+'/'+hoy.getFullYear();
			break;
		case '2':
			var mes=hoy.getMonth();
			var anyo=hoy.getFullYear();
			if(mes==0){
				mes=12;
				anyo=anyo--;
			}
			var fecha_desde='01'+'/'+dosCifras(mes)+'/'+anyo;
			hoy=new Date(new Date(hoy.getFullYear(),(hoy.getMonth()),1).getTime()-(1000*60*60*24));
			var fecha_hasta=dosCifras(hoy.getDate())+'/'+dosCifras((hoy.getMonth()+1))+'/'+hoy.getFullYear();
			break;
		case '3':
			var mes=(hoy.getMonth()+9)%12;
			var anyo=hoy.getFullYear();
			if(mes>9){
				anyo=anyo--;
			}
			var fecha_desde='01'+'/'+dosCifras(mes+1)+'/'+anyo;
			hoy=new Date(new Date(hoy.getFullYear(),(hoy.getMonth()),1).getTime()-(1000*60*60*24));
			var fecha_hasta=dosCifras(hoy.getDate())+'/'+dosCifras((hoy.getMonth()+1))+'/'+anyo;
			break;
		case '4':
			fecha_desde='';
			fecha_hasta='';
			break;
	}
	
	$E('#label_desde input').value=fecha_desde;
	$E('#label_hasta input').value=fecha_hasta;
	
}