jQuery(document).ready(function($) {
	
	$('html').addClass('js');
	/*	--------------------------------------
		Hauptnavigation
		--------------------------------------	*/

		onNaviOver = function(){
			$('header nav > ul > li > ul').not($('ul',this)).hide();
			$('ul', this).show();
			return false;
		}
		onNaviLeave = function(){
			$('header nav> ul > li > ul').not($('li.active ul',this)).hide();
			$('header nav > ul > li.active ul').show();
			return false;
		}
		$('header nav > ul > li').live("mouseover", onNaviOver);
		//$('#kontaktleiste').mouseover(onNaviLeave);
		$('header nav').mouseleave(onNaviLeave);

	
	/*	--------------------------------------
		HeaderBereich
		--------------------------------------	*/

	$(".ss-container .slidetabs").tabs(".ss-container .slideshow > a", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		fadeInSpeed: 600,
		fadeOutSpeed: 600,
		// start from the beginning after the last tab
		rotate: true
	
	// use the slideshow plugin. It accepts its own configuration
	}).slideshow({autoplay: true, interval: 5000, clickable: false});

	$(".steps .slidetabs").tabs(".steps .slideshow > a", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		fadeInSpeed: 600,
		fadeOutSpeed: 600,
		// start from the beginning after the last tab
		rotate: true
	
	// use the slideshow plugin. It accepts its own configuration
	}).slideshow({autoplay: true, interval: 5000, clickable: false});


	/*
		Referenzen-Tabs
	*/
	$("#accordion .ref").css('display','none');

/*	$("#accordion").tabs(".ref", {
		tabs: '.sec-ref-header', 
		effect: 'slide', 
		initialIndex: 0});	
*/
	//
	// Headerbild auf Referenzseite
	//
		// Standardbild setzen
		var standardImg = '/fileadmin/templates/img/headerbild.jpg';
		var hb = $('#p7 .ss-container');
		if (hb.html() != null) {
			var img1 = $('<img />').attr({
			  src: standardImg,
			  id: 'himg'
			});
			img1.appendTo(hb);
			hb.css('background-image','none');
		}

		// Bildaustausch
		changeHeader = function(a) {
			var imgN = a.next('span');
			imgN = ($('img',imgN).attr('src'));
			if(!imgN) {imgN = standardImg;}
			$("#himg").animate({opacity: 0.0}, "slow",function()
				{	
				$('#himg').attr("src", imgN)
				 .load(function()
					{
					$('#himg').animate({opacity: 1.0}, 1000);                      
					}); 
				});
		}

  var api = $("#accordion").tabs(".ref", {
	api: true,
	tabs: '.sec-ref-header', 
	effect: 'slide',
	initialIndex: -1
	}), 
      lhash = window.location.hash; 
	if (lhash) { 
		  ($('a[href*="'+lhash+'"]')).click(); 
		  changeHeader($('a[href*="'+lhash+'"]'));
	} else {
		
	}
	
		

	$('.sec-ref-header a').click(function() {
		changeHeader($(this));
		});
	$('a[data-rel]').each(function() {
		$(this).attr('rel', $(this).data('rel'));
	});

	$("a[rel^='lB']").prettyPhoto({
			animation_speed: 'fast', /* fast/slow/normal */
			slideshow: false,//5000, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 1, /* Value between 0 and 1 */
			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			default_width: 500,
			default_height: 344,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			horizontal_padding: 40, /* The padding on each side of the picture */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){}, /* Called when prettyPhoto is closed */
			ie6_fallback: true,
			markup: '<div class="pp_pic_holder"> \
						<div class="ppt">&nbsp;</div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"><a class="pp_close" href="#">Close</a></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">next</a> \
											<a class="pp_previous" href="#">previous</a> \
										</div> \
										<div id="pp_full_res"></div> \
										<div class="pp_details"> \
											<p class="pp_description"></p> \
											{pp_social} \
										</div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"><div class="shadow"><div class="shadow-main"><div class="shadow-left"></div><div class="shadow-right"></div></div></div></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>',
			gallery_markup: '<div class="pp_gallery"> \
								<a href="#" class="pp_arrow_previous">Previous</a> \
								<div> \
									<ul> \
										{gallery} \
									</ul> \
								</div> \
								<a href="#" class="pp_arrow_next">Next</a> \
							</div>',
			image_markup: '<img id="fullResImage" src="{path}" />',
			flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
			quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
			iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
			inline_markup: '<div class="pp_inline">{content}</div>',
			custom_markup: '',
			social_tools: false
			/*,social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' /* html or false to disable */
		});




	// Deaktivierte Links nicht klickbar machen
	$("a.disabled").click(function() {
			return false;
	});
	
	//	---------------------------------------------------------------------
	//	
	//	DL-Toggle
	//	
	//	---------------------------------------------------------------------
	$('.dltoggle dd').hide();
	// Erstes Öffnen
	$('.dltoggle dt:first').addClass('open').next().slideDown();
	$('.dltoggle dt').toggle(function() {
		$(this).addClass('open');
		$(this).next().slideDown();
		}, function() {
			$(this).next().slideUp('normal',function() {
				$(this).prev().removeClass('open') // class is added in the callback to chain events
			});
	});

//	Facebook Fan Box
	$('.box.facebook section').html('<fb:fan profile_id="109100769177595" height="328" width="250" connections="0" stream="true" header="false" css="http://new.innovapps.de/fileadmin/templates/css/facebook.css?1"></fb:fan>');
	FB.init({xfbml : true});
});   



