I have 3 div\'s like on this image:
div1 has fixed width but variable hei
As CSS doesn't provide anything for that job yet, you will have to use Javascript.
I would firstly create a page like on your first picture. Then I would use
$("#div").height()
, which returns the height of your div and compare this to your second div's height:
if($("#div1").height() > $("div2").height())
//change website...
In the if body put the required css changes... That should do the trick.