﻿Shadowbox.init();
$(document).ready(function () {
	$('a#sbe').click(function () { return eventbox($(this).attr('href').substr(1)); });
	$('div.id').each(function () { eventbox($(this).text()); });
});

function eventbox(id) {
	$.get('/json/e/' + id, function (ret) {
		if (ret.err) alert(ret.err);
		$.each(ret.event, function (i, e) {
			document.title = 'Mavericks Eventkalender: ' + e.titel;
			var html = '<div style="padding:1em"><div class="bloggrp"><div class="blogleft">' + e.titel + '</div><div class="blogright">' + e.datumstart;
			if (e.datumend) html += ' - ' + e.datumend;
			html += '</div></div><div style="clear:both;margin-top:1em">' + e.beschrieb;
			html += '<p><h3>FACTS:</h3>'
			html += 'Datum: ' + e.datumstart;
			if (e.datumend) html += ' - ' + e.datumend;
			html += '<br />';
			if (e.ort) html += 'Ort: ' + e.ort + ' (' + e.cdland + ')<br />';
			if (e.website) html += 'WebSite: <a href="http://' + e.website + '" target="_blank" style="overflow:hidden;">' + e.website + '</a><br />';
			if (e.email) html += 'E-Mail: <a href="mailto:' + e.email + '">' + e.email + '</a><br />';
			html += '</p>';
			//html += '<div style="float:right;"><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.mavericks.ch%2FEvents%2F' + id + '%2F&src=sp" share_url="http://www.mavericks.ch/News/' + id + '/">Share</a></div>';			
			html += '</div></div>';
			Shadowbox.open({
				content: html,
				player: 'html',
				width: 850,
				height: 500
			});
		});
	});
	return false;
}
