// JavaScript Document

/*--------------------------------------------------------------------------------------------------------
JavaScript for DLD.

version:   1.0
author:    Codingpeople GmbH
email:     support@codingpeople.com
website:   http://www.codingpeople.com/
--------------------------------------------------------------------------------------------------------*/

$(document).ready(function(){
/* = accordion  
--------------------------------------------------------------------------------------------------------*/
	$(".accordion .accordioncontainer").hide();
	$(".accordion .accordioncontainer:first").show();
	$(".accordion h3").click(function(){										 
		$(this).next(".accordioncontainer").slideToggle()
		.siblings(".accordioncontainer:visible").slideUp();										
		$(this).toggleClass("accordionactive");
		$(this).siblings("h3").removeClass("accordionactive");
	});
	
	
	$(".accordion h3").hover(function(){
		$(this).addClass("accordionhover");								  
	},function(){
		$(this).removeClass("accordionhover");
	});
	

/* End accordion  
--------------------------------------------------------------------------------------------------------*/

/* = bookmarkmenu  
--------------------------------------------------------------------------------------------------------*/
	$(".bookmarkmenu li").hover(function(){
		$(this).addClass("iehover");									 
	},function(){
		$(this).removeClass("iehover");	
	});
	
/* END bookmarkmenu  
--------------------------------------------------------------------------------------------------------*/

/* = speakerScroll  
--------------------------------------------------------------------------------------------------------*/
	
	$(".speakerScroll li").hover(function(){
		$(this).addClass("speakerScrollhover");									 
	},function(){
		$(this).removeClass("speakerScrollhover");	
	});
	
/* END speakerScroll  
--------------------------------------------------------------------------------------------------------*/	
	
/* Tab  
--------------------------------------------------------------------------------------------------------*/
var tabpanel = $('#tabs > div.tabContainer'),
	tabnav = $('#tabs > #tabnav');
	
tabpanel.hide().filter('#'+tabnav.find('.active a').attr('rel')).show();
	
$('#tabs #tabnav a').click(function(){
	tabpanel.hide();
	var thisConte ="#"+ $(this).attr('rel');

	tabpanel.filter(thisConte).show();

	$('#tabs #tabnav li').removeClass('active');
	$(this).parent("li").addClass('active');

	return false;
});
	
	
$(".programAccordion .programContainer").hide();
$(".programAccordion h2.active").nextAll(".programContainer").show();
$(".programAccordion h2").click(function(){
	var checkElement = jQuery(this).nextAll(".programContainer");
		if((checkElement.is('.programContainer')) && (checkElement.is(':visible'))){
			$(this).nextAll(".programContainer").slideUp();
			$(this).removeClass("active");
		}
		else {
			$(".programAccordion h2").removeClass("active");
			$(this).addClass("active");
			$(".programContainer").slideUp();
			$(this).nextAll(".programContainer").slideDown();
			
	}
		
	return false;
});
	
/* END Tab  
--------------------------------------------------------------------------------------------------------*/

/* keyvisual-grid */
$('.keyvisual-grid li').hover(function () {
	$(this).addClass('hover');
},function () {
	$(this).removeClass('hover');
});

});

/* = ScrollPane 
--------------------------------------------------------------------------------------------------------*/

function handleSliderChange(e, ui){
  $("#scrollpanel").animate({scrollLeft: ui.value }, 1000);
}

function handleSliderSlide(e, ui){
    $("#scrollpanel").attr({scrollLeft: ui.value });
}

$(document).ready(function(){
						  
  $("#ScrollPaneTrack").slider({
	value:0,
	max: $("#scrollpanel").attr("scrollWidth") - $("#scrollpanel").width(),
	min: 0,
								  
    animate: true,
    handle: ".content-slider-handle",
    change: handleSliderChange,
    slide: handleSliderSlide
  });
});

/* END ScrollPane 
--------------------------------------------------------------------------------------------------------*/

function slideSwitch() {
	var $active = $('#slideshow a.active');
	if ( $active.length === 0 ){
		$active = $('#slideshow a:last');
	}
	// use this to pull the images in the order they appear in the markup
	var $next = $active.next().length ? $active.next() : $('#slideshow a:first');

	// uncomment the 3 lines below to pull the images in random order
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );
	$active.addClass('last-active');
	$active.css({opacity: 1.0}).animate({opacity: 0.0}, 800);
	$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 800, function() {
		$active.removeClass('active last-active');
	});
}
