How do you calculate the margin required for F&O trades?

How is margin calculated for futures and options trades and what factors influence it?,