"Ahhhhhh! Oh my god!! That stupid chameleon gave me a fright!"
"Huh? Where, where?"
"It just ran past us! It's on the tree trunk now!"
"Huh? I can't see it!"
Have you ever had such an experience before? Personally, I had, many times. As we know, chameleons are well-known for their ability to display different colours within a short time. I always thought that they are really smart to be able to adopt this kind of colour-changing mechanism to blend into their surroundings so as to ward off possible predators, until I started surfing the internet for information about the reptile.

(image from http://news.softpedia.com/news/Why-Do-Chameleons-Change-Color-47360.shtml)
The chameleon is able to change colours via specialized cells, which are called chromatophores, under its outer skin layer. The top layers of the chromatophores consists of red and yellow pigments, while the lower layers consists of blue or white pigments. The messages sent to the chameleon's brain will inform it to alterits pigment cells to suit the current situation. It has a chemical called melanin as well, which primarily darkens it when released.
So, when do chameleons send messages to change their colour pigmentation?
Some researchers still believe that camouflage is one of the main reasons, which is similar in the cases of other animals such as the Golden Tortoise Beetle and the Flounder. However, other studies illustrate, contrary to common beliefs, that it is not true and quite the opposite in the case of the chameleon!
"Because these signals are quick--chameleons can change color in a matter of milliseconds--the animal can afford to make it obvious, as the risk that a predator will notice is limited.This finding means that the evolution of color change serves to make chameleons more noticeable, the complete opposite of the camouflage hypothesis."
- http://www.sciencedaily.com/releases/2008/01/080129125524.htm
Rather, it does so as a kind of communication as well as a form of response to changes in temperature. Although different species of chameleon can change into different colours or differ in the variation of colour change, the basic functions of this useful mechanism is quite consistent. The common situations when a chameleon displays colour changes are:
1) Temperature changes
For example, when it is cold, the chameleon might make itself darker, as darker colours trap more heat.
2) Light conditions
For example, when the chameleon is out in the sun for long, it might enlarge its yellow pigments so as to reflect the bright light away.
3) Mood changes/ Communication
When two males want to compete with each other, this happens:
"If a male is challenged by another male they both begin by showing their brightest colours - until one figures out the other is going to win and changes to a submissive, dark, 'don't beat me up colour,"
- Dr Stuart-Fox
Also, when a male chameleon is interested in attracting a female one, it will display striking and bright colours. This kind of courtship technique displays how sexual selection of the chameleon works- the more flashy and colourful, the more attractive a male chameleon is!
Since the main communication tool of the chameleon is through visual cues, colour changes play a most significant role in conveying various messages to other chameleons, such as the desire to mate as mentioned above.
From the video:
Please view this link because I don't know how to embed the video here!
http://www.youtube.com/watch?v=cNPDvsWISx0
I was very amazed at how colourful the male chameleon can become to get to hook up with the female one!
All the information I managed to derive from online sources, I am glad to say, have changed my opinion and knowledge about these small eyed and long-tongued reptiles! And they are so lucky-- they do not have to spend a bundle on new coats!

(image from http://en.wikipedia.org/wiki/Chameleon)
References:
http://library.thinkquest.org/C0115747/
http://www.wildwatch.com/living_library/other-2/chameleon
http://www.youtube.com/watch?v=cNPDvsWISx0
"Chameleon colour not to blend in" by Anna-Marie Lever
BBC News, 29 January 2008.
"Chameleons" by Sharon Katz Cooper. National Geographic, October 2002. Retrieved from http://magma.nationalgeographic.com/ngexplorer/0210/articles/mainarticle.html
PLoS Biology (2008, February 3). Conspicuous Social Signaling Drives Evolution Of Chameleon Color Change. ScienceDaily. Retrieved from http://www.sciencedaily.com/releases/2008/01/080129125524.htm
"Why do chameleons change colour? - It's about mood, temperature and light" By Stefan Anitei.
Retrieved from http://news.softpedia.com/news/Why-Do-Chameleons-Change-Color-47360.shtml