$(document).ready(function() {

			var iter = 0;

			$("a.overlay").fancybox({
				'transitionIn'	: 'fade',
				'transitionOut'	: 'fade',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.5,
				'opacity'		: true,
				'overlayShow'	: true,
				'titlePosition'	: 'over',
				//'titlePosition'	: 'over'
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + '/' + currentArray.length + (title.length ? ': ' + title : '') + '</span>';
				}
				//'transitionIn'		: 'none',
				//'transitionOut'		: 'none'.
				//'width'				: '75%',
				//'height'			: '75%',
				//'autoScale'			: false,
				//'transitionIn'		: 'none',
				//'transitionOut'		: 'none',
				//'type'				: 'iframe',
				//'padding'			: 0,
				//'autoScale'			: false,
				//'transitionIn'		: 'none',
				//'transitionOut'		: 'none'
			});
		
			$("a.videobox").fancybox({
				'transitionIn'	: 'fade',
				'transitionOut'	: 'fade',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.5,
				'opacity'		: true,
				'overlayShow'	: true,
				'titlePosition'	: 'over',
				//'titlePosition'	: 'over'
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Video ' + (currentIndex + 1) + '/' + currentArray.length + (title.length ? ': ' + title : '') + '</span>';
				}
				//'transitionIn'		: 'none',
				//'transitionOut'		: 'none'.
				//'width'				: '75%',
				//'height'			: '75%',
				//'autoScale'			: false,
				//'transitionIn'		: 'none',
				//'transitionOut'		: 'none',
				//'type'				: 'iframe',
				//'padding'			: 0,
				//'autoScale'			: false,
				//'transitionIn'		: 'none',
				//'transitionOut'		: 'none'
			});
		
		
		$("#basicbutton a").click(function(event) { swapModules("#basicbutton", "#basic"); } );
		$("#basicplusbutton a").click(function(event) { swapModules("#basicplusbutton", "#basicplus"); } );
		$("#premiumbutton a").click(function(event) { swapModules("#premiumbutton", "#premium"); } );	
	
		$("div.lightswitch a.switch").click(function(event) { flickSwitch(event); } );
	
		if ($("div.autoswitch")) {
			autoFade();
			}
		
		});

	
	
function flickSwitch(event) {
	$(event.target).parent().parent().find('a.overlay').each(function (e) {	
		if (this.name == event.target.rel) {			
			$(this).animate({ opacity: 1 }, 400, function() { $(event.target).siblings().removeClass("currently"); });
			} else {				
			$(this).animate({ opacity: 0 }, 400, function() { $(event.target).addClass("currently"); });
      }
		});
	}

		
	
function autoFade() {
	var picker = $("div.autoswitch a:last-child");
	$(picker).css("z-index","9");
	$(picker).delay(3500).animate({ opacity: 0 }, 900, function() {
		$(picker).remove();
		$(picker).css("opacity","1");
		$(picker).css("z-index","1");
		$("div.autoswitch").prepend(picker);
		autoFade();
	});
	}	



function swapModules(caller, module) {
			$("#basic").removeClass();
			$("#basicplus").removeClass();
			$("#premium").removeClass();
			$(module).addClass("onTop");
			$("#basicbutton").removeClass();
			$("#basicplusbutton").removeClass();
			$("#premiumbutton").removeClass();
			$(caller).addClass("selected");
		}
		

