jQuery(function() {
	if ($('#flash-message-wrapper').length) {
		$('#flash-message-wrapper').modal({onClose: function() {
			$('#flash-message-wrapper').remove();
			$('#simplemodal-overlay').remove();
			$('#simplemodal-container').remove();
		}});
	}
	
	if ($('#flashMessage').length) {
		$('#flashMessage').modal({onClose: function() {
			$('#flashMessage').remove();
			$('#simplemodal-overlay').remove();
			$('#simplemodal-container').remove();
		}});
	}
	
	$('.date-select').datepicker({ dateFormat: 'yy-mm-dd' });
	
	$('.detailed-information').hide();
	
	$('.information').bind('click', function(event) {
		var $target = $(event.target);
		if(!$target.is('a') && !$target.is(':checkbox')) {
			$(this).toggleClass('expanded');
			$(this).next().toggle();
		}
	});
	
	$('textarea.editor').ckeditor({
		toolbar_Kitchenwiz: [
			['Bold', 'Italic', 'TextColor', 'BGColor','Format','FontSize', 'NumberedList', 'BulletedList', 'Link', 'Unlink']
		],
		toolbar: 'Kitchenwiz',
		language: 'sv'
	});
	
	globalStash = {};
	
	$('.allergies img').hover(
		function() {
			globalStash.title = $(this).attr('title');
			$('.hover-info').remove();
			$(this).removeAttr('title');
			$('body').append('<div class="hover-info" style="position:absolute;left:' + (($(this).offset().left - 42) + ($(this).width())) + 'px;top:' + ($(this).offset().top - 30) + 'px;"><img src="/img/allergy_hover_arrow.png" />' + globalStash.title + '</div>');
		},
		function() {
			$(this).attr('title', globalStash.title);
			$('.hover-info').remove();
		}
	);
});
function campaignDetails(data)
{
	var cont = $('#popup');
	if(!cont.length) {
		$('#yield').after('<div id="popup"></div>');
		cont = $('#popup');
	}
	cont.html($(data).html());
	cont.modal({overlayClose:true,closeHTML:'<a class="modalCloseImg" title="Stäng"></a>'});
	return false;
}

