function externalLinks() {
  if (!document.getElementsByTagName && document.getElementById) return;

  var anchors = document.getElementsByTagName("a");

  for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
       anchor.target = "_blank";
 }
}
window.onload = externalLinks;

$(document).ready(function(){
    //fade success message in
	$('div#message').fadeIn('slow');

	//png fix for IE
    $(document).pngFix(); 


	//clear form fields
	$('.clearme').one("focus", function() {
  		$(this).val("");
	});

	//Hide div w/id extra
    $("#anatomy-of-a-tooth, #flash-know-your-teeth").css("display","none");
	//toggles anatomy of a tooth div
	$(".show-anatomy").click(function() {
		$("#anatomy-of-a-tooth").toggle("slow");								
	});
	
	$(".show-teeth").click(function() {
		$("#flash-know-your-teeth").toggle("slow");								
	});

	
	//home page flash
	$('#flash-home').flash(
		{ 
		  src: 'flash/home.swf',
		  width: 577,
		  height: 226,
		  wmode: 'transparent'
		},
		{ version: 8 }
	);
	// add 'back to top' link when the content is taller than the window
	// this has to be done after flash replacement because the content height changes
	if ($('#content').height() > $(window).height()) {
	$('#content').append('<p class="top-link"><a href="#">Back to top &uarr;</a></p>');
	}


	//know your teeth
	$('#flash-know-your-teeth').flash(
		{ 
		  src: 'flash/know-your-teeth.swf',
		  width: 500,
		  height: 400,
		  wmode: 'transparent'
		},
		{ version: 8 }
	);
	
	//brushing and flossing
	$('#flash-brushing-and-flossing').flash(
		{ 
		  src: 'flash/brushing-and-flossing.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			//change value to false to pause on start
			autoPlay: 'false',
			//change hex color (default=639CCE)
			thisColor: '0x' + '524123',
			//change item value to false to omit
			brushing: 'true',
			flossing: 'true'
			}
		},
		{ version: 8 }
	);

});