$('html').addClass('js');

$(document).ready(function () {

	if ($('body#home').length) {  
	  $.getJSON('/js/masthead.json', function(data) {

			var item = data.images[Math.floor(Math.random()*data.images.length)];
			$('#mastheadImg').replaceWith('<img id="mastheadImg" src="/images/masthead/' + item.image + '">');

	  });
	};
	
	var cta = '<div class="mastheadAd"></div>';
	$('#main').prepend(cta);

	$('input[type="text"]').focus(function() {
		if (this.value=='Enter Search Text') {
			$(this).val('');
		};
	});

// Skillbase to hold extra checkbox - has publications on skillbase Y/N
// If YES, template adds h2 "recent pubs" and empty #publications div with class = surname
// e.g. <div id="publications" class="westby"></div>
//
// gala.json contains a key-value listing for all staff members with publications on gala
// If #pubs exists lookup publications URL from gala.json matching class attrib and load()
// Refactor as a function?

	if ($('#gala').length) {
		
		$('#gala').prepend('<h2>Recent Publications</h2>');

		$.getJSON('/js/gala.json', function(data) {
			
			$('#gala-pubs').html('<img src="/images/ajax-loader.gif" width="16" height="16" />');
			var author = $('#gala-pubs').attr('class');
			var authorsPubs = data[author];
			
			$('#gala-pubs').load(authorsPubs);
		});		
	};

});

