$(document).ready(function(){	
	$("a[rel='external']").attr('target','_blank');
	
	$('div.img p.overlay').hide();
	$('div.img img').mouseenter(function(){
		$(this).parent().find('p.overlay').fadeIn('fast');
		var n = $(this).attr('rel');
		var src = $(this).attr('src');
		$(this).attr('rel',src);
		$(this).attr('src',n);
		
	});
	
	$('div.img p.overlay').mouseleave(function(){
		$(this).fadeOut('fast');
		var n = $(this).parent().find('img').attr('rel');
		var src = $(this).parent().find('img').attr('src');
		$(this).parent().find('img').attr('rel',src);
		$(this).parent().find('img').attr('src',n);
	});
	
	
	$('#home_photo').cycle({ 
		fx:'fade',
		speed:1000,
		timeout:5000,
		pager:'#home_nav'
	});
	
	/*
	$('div.slide a').click(function(){
		var r = parseInt($(this).attr('rel'));
		$('#home_photo').cycle(r);
		return false;
	});
	*/
	
	
	$('#nav_search form').submit(function(){
		var q = $('#nav_search form input').val();
		if(q == ""){
			return false;
		}
		$('#nav_search form input').val(q + ' site:savebabies.org');
		return true;
	});
	
	$('#scroll_content').tinyscrollbar({sizethumb:80});
	
	$('area').each(function(){
	  $(this).qtip({
		 content: $($(this).attr('alt')),
		 position: {
			 corner: {
				 target: 'center',
				 tooltip: 'topLeft'
			 }
		 },
		 style: {
			name: 'light',
			border: {
			   width: 0, 
			   radius: 4 
			}, 
			tip: true
		 },
		 show: { 
			delay: 100,
			solo: true // Only show one tooltip at a time
		 },
		 hide: {
			delay: 900,
			fixed: true
		 }
	  });
	});
	
});
