//libreria de funciones 
function mostrar(valor, total){
	
	for(i=1; i<=valor; i++){
		document.getElementById('hab'+i).className='show';				
	}
	
	for(j=i; j<=total; j++){
		document.getElementById('hab'+j).className='noshow';				
	}
	

	if(valor>total){
		for(i=1; i<=total; i++){
			document.getElementById('hab'+i).className='noshow';				
		}	
	}

}



function mostrarEdades(cantidad, total, hab){
	
	for(i=1; i<=cantidad; i++){
		document.getElementById('n1'+hab+i).className='show';	
		//$('n2'+hab+i).className='show';	
	}
	
	for(j=i; j<=total; j++){
		document.getElementById('n1'+hab+j).className='noshow';
		//$('n2'+hab+j).className='noshow';				
	}
	
}





function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
}



function alterTotales(check, total, reserva, pagar_hotel){
	
	if(check.checked){
			
		document.getElementById('total').innerHTML = formatAsMoney(parseInt($('vTot').value) + parseInt(total));
		document.getElementById('reserva').innerHTML = formatAsMoney(parseInt($('vRes').value) + parseInt(reserva));
		document.getElementById('hotel').innerHTML = formatAsMoney(parseInt($('vHot').value) + parseInt(pagar_hotel));
		
		document.getElementById('vTot').value = parseInt($('vTot').value) + parseInt(total);
		document.getElementById('vRes').value = parseInt($('vRes').value) + parseInt(reserva);
		document.getElementById('vHot').value = parseInt($('vHot').value) + parseInt(pagar_hotel);
		
	}else{
			
		
	
		document.getElementById('total').innerHTML =  formatAsMoney(parseInt($('vTot').value) - parseInt(total));
		document.getElementById('reserva').innerHTML = formatAsMoney(parseInt($('vRes').value) - parseInt(reserva));
		document.getElementById('hotel').innerHTML = formatAsMoney(parseInt($('vHot').value) - parseInt(pagar_hotel));
		
		document.getElementById('vTot').value = parseInt($('vTot').value) - parseInt(total);
		document.getElementById('vRes').value = parseInt($('vRes').value) - parseInt(reserva);
		document.getElementById('vHot').value = parseInt($('vHot').value) - parseInt(pagar_hotel);
		
		
	}
	
}


