$(document).ready(function(){
/* search box */
	var $s = $("#keywords");
	var searchLabel = "Search...";
	
	function restoreSearch() {   
		if ($s.val() == "") {$s.val(searchLabel);} 
		if ($s.val() == searchLabel) {$s.addClass("faded");}
	 }
	  
	restoreSearch();
	  
	$s.focus(function() {
		$s.removeClass("faded");
		if ($s.val() == searchLabel) {$s.val("");}
	})
	.blur(restoreSearch);

	/* / search box */
	
	/* remove underline from imgs wrapped in link */
	 $(".maincontentwrap img").each(function () {
	      var parentTag = $(this).parent().get(0).tagName.toLowerCase();
	      if (parentTag == "a"){
	    	  $(this).parent().addClass("no_underlines");
	      }
	     
	    });

		//open all external links and pdf's in  a new window
		$("a[href^='http']").not("[href*='"+window.location.host+"']").attr('target','_blank'); 
		//$("a[href^='http']").attr('target','_blank');
		$("a[href*=.pdf]").attr('target','_blank');
		
		//$('<img src="/assets/images/css/mail_icon.png" class="mail_icon">').insertBefore("a[href^='mailto']");
		$('<img src="/assets/images/css/mail_icon.png" class="mail_icon">').insertBefore("a.mail");
		
	
});

function setHeaderImage(image) {
	var theImages = new Array();  // regular array to store all our images for the homepage

	theImages[0] = 'humaneye.jpg';
	theImages[1] = 'gecko.jpg';
	theImages[2] = 'fly.jpg';
	theImages[3] = 'fly2.jpg';
	theImages[4] = 'cat.jpg';
	theImages[5] = 'tiger.jpg';
	theImages[6] = 'cat2.jpg';
	
	if(image && image!="") {
		$('.header_image').css('backgroundImage','url(' + image +')'); 
	} else {
		var x = Math.floor(Math.random() * (theImages.length));
		var randomImage = theImages[x]; // get random image from array
		var src = "/assets/images/header/default/" + randomImage;
		$('.header_image').css('backgroundImage','url(' + src +')');
	}
}