$(function() {
	// Open a tags in new window if appropriate
	$('a.new_window, a.newwintrue').click(function() {
		window.open(this.href);
		return false;
	});
	// Mini in-page photo stip
	$('#page-slideshow').each(function() {
		var $wrap = $(this),
			$slides = $('.slide').show(),
			total = $slides.size(),
			cur = 1;
		$('#slide-prev').click(function() { return update(parseInt(cur-1)); });
		$('#slide-next').click(function() { return update(parseInt(cur+1)); });
		function update(e) {
			if (e > total) e = 1;
			if (e < 1) e = total;
			$slides.eq(cur).fadeToggle().end().eq(e).fadeToggle();
			cur = e;
			return false;
		};
	});
	// Image tooltip for WYSIWYG images
	$('.wysiwyg img').wrap('<span class="imgwrap" />');
	$('.wysiwyg .imgwrap').each(function() {
		var img1 = $(this).find('img');
		var style  = img1.attr('style');
		img1.removeAttr("style");
		var newborder = 'right';
		if (style == 'float: right;') { newborder = 'left'; }
		if (style == 'float: left;')  { newborder = 'right'; }
		$(this).attr('style',style);
		$(this).css('border-' + newborder,'20px solid #FFFFFF');
		$(this).css('display','block');
	});
	$('.wysiwyg .imgwrap').hover(
		function (){
			var img = $(this).find('img');
			var alttext  = img.attr('alt');
			img.after('<span class="imgalt">' + alttext + '</span>');
		},
		function (){
			$('.wysiwyg').find('span.imgalt').remove();
		}
	);
	// --
});


