$(document).ready(function(){
	$("ul.css-tabs").tabs("div.css-panes > div");
	
	$("img[rel]").css({
			'cursor': 'pointer'
		});
		
		$("img[rel]").overlay({
			mask: '#000',
			left: 'center',
			top: 'center'
		});
		
		itemsPerPage = 4;
		paginatorStyle = 1;
		paginatorPosition = 'both';
		
		if($('.tx-powermail-pi1').length == 0){
			$('#portal-page').pagination();
		}

		
		$("#main_wrap").css({
			'minHeight' : $(window).height() + 5			
		});
		$("ul.css-tabs").tabs("div.css-panes > div");
		
		$("#flowpanes").scrollable({ vertical: true, speed: 700, circular: true, mousewheel: true }).navigator({
			navi: "#flowtabs",
			naviItem: 'a',
			activeClass: 'current'
		});
		
		$(".accordion").tabs(".pane", {tabs: 'h2', effect: 'slide', initialIndex: 0});
		
		
		$('#footer').css({opacity: 0.30});
	
		$('#footer').hover(
			function() {
				$(this).stop().animate({'opacity': '1'}, 'slow');
			},
			function() {
				$(this).stop().delay(1000).animate({'opacity': '0.30'}, 'slow');
			}
		);
		
		$(".webinar-list-container").tabs(".webinar-list-container div.pane", {tabs: 'h3', effect: 'slide', initialIndex: 0});
		
		$('.webinar-list-container h3').unbind('click');

		// add new click handler
		$('.webinar-list-container h3').click(function (){
			 // First make other panes hidden
			 $(this).siblings('h3').removeClass();
			 $(this).siblings('div').slideUp('slow');
			 // Test if clicked on current
			 if(!$(this).hasClass("current")){
				 //If not, then make me current
				 //preserving Toggle feature
				 $(this).addClass("current");
				 $(this).next().slideDown('slow')
			   } else {
				 //If so, then close me too
				 $(this).removeClass();
				 $(this).next().slideUp('slow')
			   }
			}
		 );
		
		$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: 0});
		
		$('#accordion h2').unbind('click');

		// add new click handler
		$('#accordion h2').click(function (){
			 // First make other panes hidden
			 $(this).siblings('h2').removeClass();
			 $(this).siblings('div').slideUp('slow');
			 // Test if clicked on current
			 if(!$(this).hasClass("current")){
				 //If not, then make me current
				 //preserving Toggle feature
				 $(this).addClass("current");
				 $(this).next().slideDown('slow')
			   } else {
				 //If so, then close me too
				 $(this).removeClass();
				 $(this).next().slideUp('slow')
			   }
			}
		 );
		
		$('.show_webinar_info').overlay({
			left: 'center',
			top: 'center',
			mask: {
				color: '#555',
				opacity: 0.8
			}
		});	
		
		$('.webinar_form_trigger').overlay({
			left: 'center',
			top: 'center',
			fixed: false,
			mask: {
				color: '#555',
				opacity: 0.8
			},
			onBeforeLoad : function(){
				
			},
			onClose : function(){
				$('div.error').remove();	
			}
		});
		
		$('.webinar-form-overlay .tx_powermail_pi1_form').submit(function() {
			
			var parentID = $(this).parents('.webinar-form-overlay').attr('id');
			$.ajax({
				url: $(this).attr('action'),
				cache: false,
				data: $(this).serialize(),
				type: 'POST',
				success: function(data) {
					$('#'+parentID +' .tx-powermail-pi1').empty().append(jQuery(".tx-powermail-pi1_thx", data).html());
				},
				error: function(){
					alert("Bei Ihrer Anmeldung ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut oder setzen Sie sich über unser Kontaktformular mit uns in Verbindung.");
				}
			});					
			
	  		return false;
		});
		
		
		$('#pilotsuite-1').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [20,-160],
			delay: 0
		});
		
		$('#pilotsuite-2').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			position: ['bottom','center'],
			offset: [-50,0],
			delay: 0
		});
		
		$('#pilotsuite-3').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [40,170],
			delay: 0
		});
		
		$('#pilotsuite-4').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [20,0],
			delay: 0
		});
		
		$('#pilotsuite-5').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [20,0],
			delay: 0
		});
		
		$('#pilotsuite-6').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [40,0],
			delay: 0
		});
		
		$('#pilotsuite-7').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [50,0],
			delay: 0
		});
		
		$('#pilotsuite-8').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [65,0],
			delay: 0
		});
		
		$('#pilotsuite-9').tooltip({
			relative:true,
			effect: 'fade',
			fadeInSpeed: 0,
			fadeOutSpeed: 0,
			offset: [50,0],
			delay: 0
		});
	
});

