var Spirit_rules = {

	'a' : function(el) {
		el.onfocus = function() {
			this.blur();
			if (el.getAttribute('rel') == 'external') {
				el.setAttribute('target', '_blank');
		   }
		}
	}, 

	'img' : function(el) {
		el.setAttribute('galleryimg', 'no');
	}
}

Behaviour.register(Spirit_rules);

function init() {
	$('#inline_inge').hide();
	$('#inline_jan').hide();
	$('#inline_contact').hide();
    $('#ithing').overscroll();
	
	// mail rewrite (href)
	$('a[href*="mailto:"]').each(function() {
		var mailto = $(this).attr('href').split('[at]');
		$(this).attr("href", mailto[0] + "@" + mailto[1]);
	});
	// mail rewrite (text node)
	$('a:contains("[at]")').each(function() {
		var mailto = $(this).text().split('[at]');
		$(this).text(mailto[0] + "@" + mailto[1]);
	});
}
Behaviour.addLoadEvent(init);

$(document).ready(function() {
	$("a[rel=showcase]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});

	$("#linkinge").fancybox({
		'autoDimensions'	: 'false',
		'width'				: '500',
		'height'			: '300',
		'titleShow' 		: 'false',
		'onStart'			 : function(){$('#inline_inge').show()},
		'onCleanup'			 : function(){$('#inline_inge').hide()}
	});

	$("#linkjan").fancybox({
		'autoDimensions'	: 'false',
		'width'				: '500',
		'height'			: '300',
		'titleShow' 		: 'false',
		'onStart'			 : function(){$('#inline_jan').show()},
		'onCleanup'			 : function(){$('#inline_jan').hide()}
	});

	$("#linkcontact").fancybox({
		'autoDimensions'	: 'false',
		'width'				: '500',
		'height'			: '300',
		'titleShow' 		: 'false',
		'onStart'			 : function(){$('#inline_contact').show()},
		'onCleanup'			 : function(){$('#inline_contact').hide()}
	});

});

