How to check stock of associated product in magento

During customization of magento product detail page, cart page or any other page we must need to know whether product is available in our inventory stock . If product is not in our inventory then product should not be added to cart or any desired activity should n’t happen.   In order to check stock(…)