$(document).ready(function(e) {
	
	if( $('#news-dates').length > 0 ){
    	$('#news-dates').tabs();
	}
	
	
	if( $('#ansprechpartner-list').length > 0 ){
		
		$('div.list-item a.open-acc').click(function() {
			if( !$(this).hasClass('active') ){
				window.location.hash = $(this).attr('rel');
			}
			$(this).toggleClass('active').next().toggle('fast');
			$(this).parents('.list-item').toggleClass('active');
			
			return false;
		}).next().hide();
		
		$('div.list-item a.trigger-img-open-acc').click(function() {
			$(this).next('span').children('a.open-acc').trigger('click');
		});
		
		$('div.list-item a.trigger-name-open-acc').click(function() {
			$(this).parents('span').children('a.open-acc').trigger('click');
		});
		
		var iInitCnt = 0;
		$(window).hashchange( function(){
			if (location.hash != '' && iInitCnt == 0) {
				$('div.list-item a[rel="' + location.hash.substring(1) + '"]').trigger('click');
				iInitCnt++;
				$('#ansprechpartner-list a.anker').remove();
			} else {
				iInitCnt++;
			}
		});
		
		$(window).hashchange();
		
	}
	
	if( $('#project-cycle a').length > 1 ){
		
		$('#project-cycle').cycle({ 
			speed:  900,
			timeout: 3000
		});
	}
	
	$('ul#mainnavi li').hover(
	    function(){
	        var id = $(this).attr('id');
	        $('#images img.'+id).css('z-index',2000).show();
	    },
	    
	    function(){
	        var id = $(this).attr('id');
	        if ($(this).hasClass('selected')){
	            $('#images img.'+id).css('z-index',3000).fadeOut(function(){
    	            $('#images img.'+id).css('z-index',1000).show();
    	        });
	        }
	        else {
    	        $('#images img.'+id).css('z-index',3000).fadeOut(function(){
    	            $('#images img.'+id).css('z-index',0);
    	        });
	        }
	        
	    }
	);
	
	
	
	// fancybox
	if( $('a[rel="lightbox"]').length > 0 ){
		$('a[rel="lightbox"]').fancybox();
	}
});


function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "");
}
