var K = {
	tooltip_pattern: '${title}'
}

jQuery(function(){
	 // add class 'js' to body element for progressive enhacement if JS is enabled
	$('body').addClass('js').css('display','block');
	$('.nice').each(function(){
		$(this)
			.prepend('<span class="ir"><!-- ir --></span>')
			.removeClass('nice')
			.addClass('niced');
	});
	$('.gallery img').each(function(){
		var mysrc = this.src,
			altsrc = mysrc.replace('.thumb', 'b.thumb'),
			temp = new Image();
		temp.src = altsrc;
		$(this).hover(
			function(){this.src = altsrc;},
			function(){this.src = mysrc;}
		);
	})
	.each(function(){
		var $this = $(this);
		if(!$this.is('[title]')) return;
		$this.data('title', $this.attr('title'));
		$this.removeAttr('title');
		$this.wTooltip({
			//appendTip: $('#content').get(0),
			content: true,
			className: "tooltip",
			callBefore: function(tooltip, node, settings) {
				$(tooltip).html(K.tooltip_pattern.replace('${title}', $(node).data('title')));
			},
			style: false // use css
		});
	});
	$('ul.image-chooser img').each(function(){
		var temp = new Image();
		temp.src = this.src.replace('.thumb', '');
		$(this).click(function(){
			$('.chooser-target').attr('src', temp.src);
		});
	});
});

