Transparency and Material Nodes Won't Mix!

I have an object set up with three different materials, one of which is partly transparent. I have combined the three materials in the material nodes editor like this:

http://www.pasteall.org/pic/show.php?id=14778

The top material is a mask to separate the two materials. I enabled transparency in the render pipeline options tab and the materials show up transparent in the preview window. However, when I render the object, both materials appear but there is no transparency. Can anyone help me fix this?

The mix node combines only the colors of the 2 materials. The alpha socket of the 2nd material isn’t connected to anything. If you’d connect that to the alpha socket of the output node, it would at least get the same transparency.

Thanks for your help. I fixed the problem by inverting the color of the transparent material and connecting it to the alpha socket of the output node.