// AjaxLoader
AjaxProgressController = {
init : function () {
AjaxProgressController.bodyTag = jQuery(jQuery('body')[0]);

AjaxProgressController.ajaxCount = 0;
AjaxProgressController.lastClickedElement = null;
AjaxProgressController.bodyTag.bind('click', AjaxProgressController.clickFunc);
 try {
Wicket.Ajax.registerPreCallHandler(AjaxProgressController.ajaxRequested);
Wicket.Ajax.registerPostCallHandler(AjaxProgressController.ajaxRequestFinished);
Wicket.Ajax.registerFailureHandler(AjaxProgressController.ajaxRequestFinished);
Wicket.throttler.postponeTimerOnUpdate = true;
}
catch(e) {
}
},
isAjaxInProgress : function() {
return AjaxProgressController.ajaxCount > 0;
},
ajaxRequested : function() {
AjaxProgressController.ajaxCount = 1 + AjaxProgressController.ajaxCount;
AjaxProgressController.addBusyAjaxClassToBody();
},
ajaxRequestFinished : function() {
AjaxProgressController.ajaxCount = -1 + AjaxProgressController.ajaxCount;
AjaxProgressController.lastClickedElement = null;
if(!AjaxProgressController.isAjaxInProgress()) {
AjaxProgressController.removeBusyAjaxClassToBody();
}
},
addBusyAjaxClassToBody : function () {
if(!AjaxProgressController.bodyTag.hasClass('ajaxInProgress')) {
AjaxProgressController.bodyTag.addClass('ajaxInProgress');
}
},
removeBusyAjaxClassToBody : function () {
if(AjaxProgressController.bodyTag.hasClass('ajaxInProgress')) {
AjaxProgressController.bodyTag.removeClass('ajaxInProgress');
}
},
clickFunc : function(eventData) {
var clickedElement = (window.event) ? event.srcElement : eventData.target;
  if(clickedElement.tagName.toUpperCase() == 'SPAN') {
clickedElement = clickedElement.parentNode;
}
if (clickedElement.tagName.toUpperCase() == 'BUTTON' || clickedElement.tagName.toUpperCase() == 'A' || clickedElement.parentNode.tagName.toUpperCase() == 'A'
|| (clickedElement.tagName.toUpperCase() == 'INPUT' && (clickedElement.type.toUpperCase() == 'BUTTON' || clickedElement.type.toUpperCase() == 'SUBMIT'))) {
if (!jQuery(clickedElement).closest(".noBusySign").hasClass('noBusySign') && !AjaxProgressController.isAjaxInProgress()) {
AjaxProgressController.ajaxRequested();
}
if (clickedElement === AjaxProgressController.lastClickedElement) {
eventData.stopPropagation();
return false;
}
else {
AjaxProgressController.lastClickedElement = clickedElement;
}
}
},
addNoBusyWithRetry:function(locator){
if($(locator).is(":visible")){
$(locator).addClass("noBusySign");
}else{
setTimeout("AjaxProgressController.addNoBusyWithRetry('" + locator +"');", 200);
}
}
};
$(document).ready(AjaxProgressController.init);
$(window).unload(AjaxProgressController.removeBusyAjaxClassToBody);


$(document).ready(function() 
{
	// Buttons
	$(".Button").livequery(function(){	$(this).click(function(){
		$(this).parents().submit();
 });});
	Lade=0;
	$("form").livequery(function(){	$(this).submit(function(){
			if(Lade==0) {	$(this).children(".Button").children("b").append("<div class='Lade'><\/div>"); Lade=1;	}
	});});
	// Lade
	$("#Lade").hide();
	$('.lade').livequery(function(){	$(this).click(function()
	{    
		$("#Lade").fadeIn();
		$.ajax({
			url: $(this).attr("href")+'&b=1',
			success: function(data) {
					$('#Inhalt').html(data);
					$("#Lade").fadeOut();
			}
		}); return false;
	});});
	// Accordion
	$('.Accordion').livequery(function(){	$(this).click(function(){
		if( $(this).next().is(':hidden') )	{	$(this).removeClass('Eu Accordion_o').next().slideUp();	}
		$(this).toggleClass('Eu Accordion_o').next().slideToggle();
	});});
	// fancybox
	$("a.zoom1").livequery(function(){	$(this).fancybox({ 'overlayOpacity' : 0.6, 'overlayColor' : '#333', 'width' : 850, 'height' : '100%',	'centerOnScroll' : true, 'titleShow' : false });});
	$("a.zoom2").livequery(function(){	$(this).fancybox({ 'overlayOpacity' : 0.6, 'overlayColor' : '#333', 'centerOnScroll' : true });});
	$("a.zoomReload").livequery(function(){	$(this).fancybox({ 'overlayOpacity' : 0.6, 'overlayColor' : '#333', 'width' : 850, 'height' : '100%',	'centerOnScroll' : true, 'titleShow' : false, onClosed : function() { location.reload(); } });});
	$("#tt_Guthaben").livequery(function(){	$(this).tooltip({ position: "bottom right", offset: [10, -105], effect: 'slide'}); });
	$("#tt_Daten").livequery(function(){	$(this).tooltip({ position: "bottom right", offset: [10, -125], effect: 'slide'}); });
	$("a.zoomZahlung").livequery(function(){	$(this).fancybox({ 'overlayOpacity' : 0.6, 'overlayColor' : '#333', 'centerOnScroll' : true, 'type' : 'iframe', 'width' : 500, 'height' : 370, 'scrolling' : 'no', 'hideOnOverlayClick' : false });});
	$("a.zoomVideo").livequery(function(){	$(this).fancybox({ 'padding' : 0, 'overlayOpacity' : 0.8, 'overlayColor' : '#000', 'width' : 832, 'height' : 468, 'centerOnScroll' : true });});
	$("a.zoomSpiel").livequery(function(){	$(this).fancybox({ 'padding' : 0, 'overlayOpacity' : 0.8, 'overlayColor' : '#000', 'autoDimensions' : true, 'centerOnScroll' : true, 'hideOnOverlayClick' : false });});
	$("a.Anmelden").livequery(function(){	$(this).fancybox({ 'overlayOpacity' : 0.6, 'overlayColor' : '#333', 'width' : 550, 'height' : 530,	'centerOnScroll' : true, 'hideOnOverlayClick' : false, 'titleShow' : false, 'scrolling' : 'no' });});
});
