$(function () {
	ajaxPing();
	
	$('ul.sermon-nav li:last').before('<li style="float: right"><a href="javascript:window.print()" title="Print this Sermon"><img src="/core/graphics/icons/printer.png" alt="Print" /></a></li>');
	
	if ($.fn.gallery) {
		$('div.image-gallery').gallery({ selectorCallback: replaceH2 });
	}
	if ($.fn.lightbox) {
		$('ul.image-gallery a').lightbox();
	}
	
	$('#feed-url').focus(function() {
		this.select();
	});
});

var ajaxPing = function () {
	setTimeout("$.post(document.location.href, { ajax_ping : '1' }, ajaxPing)", 10 * 60 * 1000);
}

function fieldHint(element, default_value) {
	$(element).each(function () {
		if (this.value == "" || this.value == default_value) {
			$(this).val(default_value).addClass("blur");
		}
	});
	$(element).focus(function () {
		if (this.value == default_value) {
			$(this).val("").removeClass("blur");
		}
	});
	$(element).blur(function () {
		if (this.value == "") {
			$(this).val(default_value).addClass("blur");
		}
	});
}


/* sIFR Configuration */

var gill_sans = { 
	src: '/flash/gill-sans-std.swf',
	forceClear: true,
	wmode: 'transparent'
};

sIFR.activate(gill_sans);

var sIFRcss_em = 'em { font-style:italic; }';
var sIFRcss_strong = 'strong { font-weight:bold; }';
var sIFRcss_a = 'a { color: #7E93C8; text-decoration: none; }';
var sIFRcss_a_hover = 'a:hover { color: #7E93C8; text-decoration: none; }';

sIFR.replace(gill_sans, {
	selector: '.home h1',
	css: [
		'.sIFR-root { font-weight:normal; }',
		'em { font-style: italic; display: block; font-size: 70%; }',
		'strong { display: block; margin-left: 35px; font-weight: normal}',
		sIFRcss_a,
		sIFRcss_a_hover
    ]
});

sIFR.replace(gill_sans, {
	selector: 'h1',
	css: [
		'.sIFR-root { font-weight:normal; }',
		sIFRcss_em,
		sIFRcss_strong,
		sIFRcss_a,
		sIFRcss_a_hover
    ]
});

var replaceH2 = function() {
	sIFR.replace(gill_sans, {
		selector: 'h2',
		css: [
			'.sIFR-root { font-weight:normal; leading: 0; }',
			sIFRcss_em,
			sIFRcss_strong,
			sIFRcss_a,
			sIFRcss_a_hover,
			'.subtext { display: block; font-style: italic; font-size: 80%; }'
	    ]
	});
}
replaceH2();