Formula

Min*() should return 0 if the value is lower, e.g.:

Examples

Example 1 

50% of the ad is above the top of the window

Example 2

The whole ad is below the fold