I found out HOW they work on wiki and stuff before I asked here, I was wondering if anyone knew when/where in the tree of life they evolved. After all, insects, SOME reptiles, birds, and SOME fish use it, that means not all reptiles use it and not all fish use it, which puzzled me as to the timing of it coming about. If that makes sense.
Ok, but you'll probably know not everyone looks things up before asking such questions and this one is actually a tricky one to answer!
It's first important to realise that XY and ZW are sex selecting
systems, which means that the X and Y chromosomes of plants say, are not homologous with those of mammals. In the XY system the male selects the gender whilst in the ZW system it is the female that decides, and the differentiation is reversed (male is ZZ, female is ZW).
It is generally believed that, in species where there are two genders, sex chromosomes evolved from ancestral hermaphrodites that didn't have sex chromosomes. It's thought that genes that define female or male were then epigenetically suppressed, creating the first male or female genders and the potential for sex chromosomes to emerge. It is assumed all sexually reproducing organisms evolved from a common single celled eukaryotic ancestor so sex-chromosome pairs arose independently among different lineages from separate pairs of ordinary (non sex) chromosomes.
The sex chromosomes of one biological group therefore differ in origin and structure from those of others. So, as has been pointed out, the sex chromosomes of mammals are not specifically related to those of insects, plants or birds.
As is typical in Biology, not everything is quite so straight forward as the diagram above might convey. Analysis of monotreme (egg laying mammals like the echidna and duck-billed platypus) reveals a lack of homology between platypus X and the Xs of placental mammals and marsupials, so monotremes have a unique XY sex chromosome system. Moreover, genetic mapping studies show chicken Z homologous genes in the sex chromosome system with the main clusters on platypus X3 and X5 and echidna X3 and X4. Other Z homologous genes map to autosomes (ordinary non-sex chromosomes), indicating many rearrangements between the monotreme and avian lineages.
I can't really find much regarding evolutionary dates for appearance of XY and WZ systems, nor for divergence and evolution of the various sex chromosomes themselves. This has a lot to do with the plasticity of sex-determining systems, chromosomes and genes. However, since the platypus sex chromosomes have homology with bird, but not with placental mammals (and marsupials) it implies that human X and Y chromosomes evolved from a non-sex chromosome pair after the divergence of monotremes, just 166 million years ago. Whether this is true or not I really don't know — further genetic mapping will shed more light on it.
Some links for you:-
The Y chromosome as a battle ground for sexual selectionE
http://hominid.uchicago.edu/publications/2001 NatRevGen-Y chromosome.pdf
Weird Animal Genomes and the Evolution of Vertebrate Sex and Sex Chromosomes - Annual Review of Genetics, 42(1):565 - Abstract
CSIRO PUBLISHING - Reproduction, Fertility and Development
The multiple sex chromosomes of platypus and echidna are not completely identical and several share homology with the avian Z
Access : In the platypus a meiotic chain of ten sex chromosomes shares genes with the bird Z and mammal X chromosomes : Nature
Theory for why dioecious plants have equal length sex chromosomes -- Gorelick 92 (6): 979 -- American Journal of Botany
There's even a book, but you need to be pretty rich to purchase it!
"Evolution of Sex Determining Mechanisms" by James J. Bull