// JavaScript Document

$(document).ready(function() {
	
	$('div#gs-overlay').gsoverlay({
    	trigger: jQuery('a#gs-overlay-badge'),
    	grid: 978,
    	color: '#aa1b4a',
    	opacity: 0.15
  	});

	
	//Image Hovers
	$('a.img_link').hover(function() {
		$(this).find("div:last").fadeIn();
	}, 
	function() {
		$(this).find("div:last").fadeOut();
	});	
	
	
	//Tool tips
	$("#philosophy a").append("<em></em>");
	
	$("#philosophy a").hover(function() {
		$(this).find("em").animate({opacity: "show", top: "-75"}, "slow");
		var hoverText = $(this).attr("atitle");
	    $(this).find("em").text(hoverText);
	}, function() {
		$(this).find("em").animate({opacity: "hide", top: "-85"}, "fast");
	});

	
	//Search box
	window.onload = function() {
	  applyDefaultValue(document.getElementById('s'), 'Enter search term');
	}
	
	function applyDefaultValue(elem, val) {
	  elem.style.color = '#525252';
	  elem.value = val;
	  elem.onfocus = function() {
		if(this.value == val) {
		  this.style.color = '';
		  this.value = '';
		}
	  }
	  elem.onblur = function() {
		if(this.value == '') {
		  this.style.color = '#525252';
		  this.value = val;
		}
	  }
	};
	
	//Initialize Lazy Load
	$("img").lazyload({ 
    	placeholder : "../img/ajax-loader.gif",
    	effect : "fadeIn"
	});
	
	
});
