$(document).ready(function() {
	//QueryLoader.init();
	// remove outline from links
	$("a").click(function(){
		$(this).blur();
	});
	// open a[rel='external'] in a new window, target="_blank" is deprecated for now
	$("a[rel='external']").click( function()
	{
		window.open( $(this).attr("href") );
		return false;
	});
	// disable contextmenu's
	//$(document).bind("contextmenu",function(e){
	//	return false;
	//});
	$("div#events a, ul#upcomingevents_agenda li div a").hover(
		function ()
		{
			$(this).animate({color:"#c1d832"}, {queue:false, duration: 250});
		},
		function ()
		{
			$(this).animate({color:"#999"}, {queue:false, duration: 500});
		});
	$("div#events h1 a, div#events h2 a, ul#upcomingevents_agenda li a").hover(
		function ()
		{
			$(this).animate({color:"#fff"}, {queue:false, duration: 250});
		},
		function ()
		{
			$(this).animate({color:"#fff"}, {queue:false, duration: 500});
		});
	// embed the flash particles in the logo div
	$("div#logo").flashembed({src: "assets/swf/swf_particles2.swf", w3c: true, version: [8, 115], wmode: "transparent"});
	// initialize menu
	$("ul#navigation li").hover(
		function () {
			$("ul", this).fadeIn(250);
		}, 
		function () {
			$("ul", this).fadeOut(550);
		}
	);
	// mark the menu-item as bold onclick
	// website urlutils system
	$.blockUI.defaults.fadeIn  = 50;
	$.blockUI.defaults.fadeOut = 250;
	$("div#events").ajaxStart(function() {
		$(this).block({message: "<img src='assets/img/gif_img_loader.gif' />", css: { border: "0", background: "0", padding: "20px" } });
	}).ajaxStop(function() {
		$(this).unblock();
	});
	$.fragmentChange(50);
	$(document).bind("fragmentChange", function(e) {
		actOnFragment(e.fragment); 
	});
	var content = [];
	function actOnFragment(fragment) {
			element=$("div#events");
			
		if (fragment.indexOf("/") != -1 && fragment.length > 1) {
				var id = content.length;
				old = null;
				if(content[id-1]) {
			old = content[id-1];
				}
				
			$.get(fragment, function(html) {
			//$("#event-viewer").hide();
			content[id] = (element.append('<div id='+id+' style="display: none;"></div>').find("#"+id));
			content[id].append(html);
			if(old && old.size() > 0) old.hide();
					content[id].fadeIn(500);
			});
	} else {
		//$("#event-viewer").fadeIn(500);
			if(content.length > 0) {
				jQuery.each(content, function() {
					this.fadeOut(250);
				});
			};
		};
	};
	$("a[href*='page/']").live("click", function() {
		var url = this.href.replace(window.location.protocol + "//" + window.location.host, "").replace("#browser","");
		if ( url.length == 0  || url.indexOf("/") == -1 ) {return false};
		$.setFragment(url);
		return false;
	});
	if (document.location.hash.length > 0 && document.location.hash.substring(1).indexOf("/") != -1) {
		$("div#events").empty();
			$.get("empty.php", function(html) { 
				$("div#events").append(html);
				//alert('if');
				actOnFragment(document.location.hash.substring(1));
			});
		}
	});
	// fader for the navigation (IE is too retarded to run this function so we have to wipe it :()
//	jQuery("ul#navigation").children().hover(function () {
//		jQuery(this).siblings().stop().fadeTo(400, 0.4);
//	},
//	function () {
//		jQuery(this).siblings().stop().fadeTo(300, 1);
//	});

// center popups
var win= null;
function centerpop(mypage,myname,w,h,scroll)
{
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars='+scroll+',';
	settings +='resizable=yes';
	win=window.open(mypage,myname,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
function popup_tickets()
{
	centerpop("https://www.paylogic.nl/frontoffice/?command=moduleList&merchantID=463", "paymentMenu", 450, 525, "no");
}
