Death from being upside down

I am attempting to make a small racing game. I need a java script that knows if the car has been upside down for say, 3 seconds. Then death.

I am more of a 3D environment guys. I know very little about scripting. I am assuming I need to track the Y position of of the car. Can anyone help me?

That is the tricky part about eulerAngle and rotation, one set can yield different results.

See if you spin around the z axis, you are upside down and you eulerAngle(0,0,180) and you consider dead after three seconds.

But what about (180,0,0)? Yep, you are also upside down.

One simple way could be to use dot product between the transform.up of the car and the normal of the ground or simply the Vector3.up. If the two vector are in opposite directions you get negative value between 0 and 1

 if (Vector3.Dot(transform.up,Vector3.up) < 0)//you are upside down