


if(typeof(require)==="undefined"){
	// create dummy require():
	window.require = function(deps, callback){
		callback();
	}
}


	/*
 *	jquery-plugin accordion
 *
 *	This script is part of the OpenWGA CMS plattform.
 *	(c) Innovation Gate
 */
 
!function(root, factory) {
  	if(typeof define === 'function' && define.amd)
    	define("jquery-accordion", ["jquery"], factory);
  	else factory(root.jQuery);
}(window, function($){

	function expand(panel, speed, index){
		panel.addClass("active").next().slideDown({
			duration: speed,
			complete: function(){
				panel.trigger("activated", [this, index]);
			}
		});
		// give child elements a chance to resize if necessary:
		$(window).trigger("resize");
	}

	function activate(el, index){
		var header = $("> .accordion-header", el).eq(index)
		var isActive = header.hasClass("active");
		var speed = el.data("accordion-effect-speed") || "fast"
		$("> .accordion-header", el).removeClass("active").next().slideUp(speed);
		if(!isActive)
			expand(header, speed, index)
		
	}
	
	var exports={
		activate: activate
	}	
	
	$.fn.wga_accordion = function(config){
		var config = config||{};
		return this.each(function(){
			var el = $(this);

			if(typeof(config)=="string"){
				try{
					var f = exports[config.toLowerCase()]
					return f.apply(el, [el].concat(args));
				}
				catch(e){
					throw("jquery plugin wga_accordion: method '" + config + "' not found.")
					return null;
				}
			}
			else{
				var speed = config.effectSpeed||'fast';
				el.data("accordion-effect-speed", speed)
				if(config.active!=undefined){
					if(config.delay){
						setTimeout(function(){
							expand($("> .accordion-header", el).eq(config.active), speed, config.active)
						}, config.delay);
					}
					else expand($("> .accordion-header", el).eq(config.active), speed, config.active)
				}
				$("> .accordion-header", el).click(function(ev){
					ev.preventDefault();
					var $this = $(this);
					var isActive = $this.hasClass("active");
					$("> .accordion-header", el).removeClass("active").next().slideUp(speed);
					if(!isActive)
						expand($this, speed, $("> .accordion-header", el).index($this));
				})
			}
		})
	}

	// data interface:
	$(document).on('click.wga_accordion_activate', "[data-accordion='activate']", function(e){
		e.preventDefault();
		var root_el = $(this).data("target") || $(this).parents(".accordion")
		var index = $(this).data("index") || this.hash.substr(1) || 0
		activate(root_el, index);
	})
	
	
});

	/*
 *	jquery-plugin modal
 *
 *	This script is part of the OpenWGA CMS plattform.
 *	(c) Innovation Gate
 */

!function(root, factory) {
  	if(typeof define === 'function' && define.amd)
    	define("jquery-modal", ["jquery"], factory);
  	else factory(root.jQuery);
}(window, function($){

	var bodyMask;
	var currentModal;
	var onload;
	var onclose;
	var triggerEl;
		
	function maskBody(){
		if(!bodyMask){
			$("body").append('<div class="body-mask" id="modal-body-mask"></div>')
			bodyMask = $("#modal-body-mask").on("click.hide-modal", function(){hideModal()})
		}
		bodyMask.fadeIn({duration: 200})
	}
	
	function hideModal(callback){
		if(callback){
			onclose=callback;
		}
		var fn = $.wga_modal.effect == "slide" ? "slideUp" : "fadeOut"
		bodyMask && bodyMask.fadeOut({duration: 200});
		currentModal[fn]({
			duration: 200,
			complete: function(){
				$("body").removeClass("modal-open");
				if(onclose){
					onclose.call(currentModal);
					onclose=null
				}
				$(this).trigger("modal-closed", currentModal);
				if(triggerEl){
					$(triggerEl).trigger("modal-closed", currentModal);
					$(triggerEl).trigger("close", currentModal);	// deprecated
					triggerEl=null;
				}
			}
		});
	}
	
	function showModal(id, callback){
		var el = $(id);
		if(!el.length){
			if(callback)
				callback.call(el);
			return alert("Modal with ID " + id + " not found");
		}
		if(!el.hasClass("modal-popup"))
			el.addClass("modal-popup");
		currentModal=el;
		maskBody();
		if(callback)
			onload=callback;
		var fn = $.wga_modal.effect == "slide" ? "slideDown" : "fadeIn"
		el[fn]({
			duration: 200,
			complete: function(){
				$("body").addClass("modal-open");
				if(onload){
					onload.call(el);
					onload=null;
				}
				$(this).trigger("modal-shown", [el, triggerEl && $(triggerEl).data()]);
				if(triggerEl){
					$(triggerEl).trigger("load", el);	// deprecated
					$(triggerEl).trigger("modal-shown", el);
				}
			}
		});
	}

	var exports={
		show: showModal,
		hide: function(el, callback){
			hideModal(callback);
		}
	}

	$.fn.wga_modal = function(config){
		var config = config||{};
		var args = [];
		for(i=1; i<arguments.length; i++)
			args.push(arguments[i]);
		
		return this.each(function(){
			$this = $(this);
			if(typeof(config)=="string"){
				try{
					var f = exports[config.toLowerCase()]
					return f.apply($this, [$this].concat(args));
				}
				catch(e){
					throw("jquery plugin wga_modal: method '" + config + "' not found.")
					return null;
				}
			}
			else{
				$this.on("click", function(e){
					e.preventDefault();
					onload = config.onload;		// deprecated. Use jquery events instead
					onclose = config.onclose;	// deprecated. Use jquery events instead
					triggerEl=this;
					var target = config.target || $this.data("target") || this.hash
					if(config.width){
						$(target).css({
							width: config.width,
							marginLeft: -config.width/2 
						})
					}
					showModal(target);
				})
			}
		})
	}
	

	$(document).on('click.wga_modal_close', ".modal-popup > .close, .modal-popup a.close-modal, [data-modal='hide']", function(e){
		e.preventDefault();
		hideModal();
	})

	// data interface:
	$(document).on('click.wga_modal_show', "[data-modal='show']", function(e){
		e.preventDefault();
		triggerEl=this;
		showModal($(this).data("target") || this.hash);
	}) 

	// Globals
	$.wga_modal={
		hide: hideModal,
		show: showModal,
		effect: "fade"
	}

	return $.wga_modal

});




	


	

	
		$(function(){
	$(".module-waldmann_slideshow .slideshow").each(function(){
		
		var $this = $(this),
		 	pause_time = $this.data("pause") || 3000,
			fade_time = $this.data("fade") || 5000,
			images = $(this).find(".module-cm_image"),
			i=0;
			
		images.eq(0).show()
		setTimeout(slideshow, pause_time)
		
		function slideshow(){
			images.eq(i++).fadeOut(fade_time)
			if(i>=images.length)
				i=0;
			images.eq(i).fadeIn(fade_time, function(){
				setTimeout(slideshow, pause_time)
			})
		}
	})
});
	
	
