
// ---------------------------------------------------------------------
// http://gettopup.com/documentation

TopUp.addPresets({
	".shaded": {
	 shaded: 1,
	 overlayClose: 1,
	 layout: 'dashboard',
	 resizable: 0
	}
});


TopUp.players_path = "fileadmin/templates/js/players/";
TopUp.images_path = "fileadmin/templates/js/top_up/";


// ---------------------------------------------------------------------
/* Effekte */

$(function () {

	$('a.top_of_page').click( function () {
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});

});

// ---------------------------------------------------------------------

/* Boots-Navigation */

$(function () {
	
	$('#wappen .km_zahl').click( open_bootsnavi );
	$('#wappen .ortsname').click( open_bootsnavi );
	$('.link_layer').click( open_bootsnavi );
	
	/*$(window).resize( resize_bootsnavi );*/
});

function open_bootsnavi () {
	resize_bootsnavi();
	$('#bootsnavi').css( {height:'550px'} );
	
	tell_flash('bootsnavi_swf', 'fade_in', 1 );
	$('.link_layer').fadeOut( 'fast' );
	return false;
}

function resize_bootsnavi () {
	var w = $(window).width();
	//$('#bootsnavi_flash').css( {width:w} );
}

function close_bootsnavi () {
	$('#bootsnavi').css( {height:1} );
	$('.link_layer').fadeIn( 'fast' );
}

// ---------------------------------------------------------------------


var currentid = -1;

function swop_text( html, div_id ) {
	var ref = get_reference();
	if (ref.getElementById) {
		var obj = ref.getElementById( div_id );
		obj.innerHTML = html;
	}
}

function tell_flash ( id, func, message ) {
	var obj = get_flash_movie( id );	
	if (obj != null) {
		obj[func]( message );
	}
}

function get_flash_movie( name ) {
	var ref = get_reference();
	if (ref[name]) return ref[name];
	return null;
}

function get_reference() {
	return document;
	//return (navigator.appName.indexOf("Microsoft") != -1) ? window : document;
}

function init_content() {
	var ref = get_reference();
	if (ref.getElementById) {
	
		var obj = ref.getElementById('all_hidden_content');
		
		if (obj != null) {
			obj.style.visibility = 'visible';
			obj.style.display = 'block';
		}

		var obj = ref.getElementById('year_navigation_hidden');
		
		if (obj != null) {
			obj.style.visibility = 'visible';
			obj.style.display = 'block';
		}
		
	}
}

/* ------------------------------------------------------------------------ */
// Aufklapp-Punkte für z.B. Workshops

jQuery(document).ready( function() {
	jQuery('.infos').hide();
	jQuery(".title").click( function() {
		var obj = jQuery( this ).parent().parent().find('.infos');
		
		if (obj.css('display') != 'none') {
			inhalt_ausblenden( obj );
		} else {
			inhalt_einblenden( obj );
		}
		//jQuery( this ).parent().parent().find('.infos').slideToggle( 'easeInOutQuad' );
	});
	
});


function inhalt_ausblenden ( tag, func, params ) {
	slideToggle( tag, false );
	return;
	
	tag.animate( {height:'0px', opacity:0}, {duration:1200, customEasing:{height:'easeInOutQuad', opacity:'linear'}, 
		complete:function() { 
			if (func) func.apply( this, params );
			tag.css('display', 'none');
		} 
	});
}

function inhalt_einblenden ( tag ) {
	slideToggle( tag, true );
	return;
	tag.animate( {height:'show', opacity:1}, {duration:1200, customEasing:{height:'easeOutQuad', opacity:'linear'},
		complete: function () {
			//var s = jQuery.find( tag );
			remove_filter( tag[0] );
			tag.is_there = 1;
		}
	});
}

function remove_filter ( element ) {
	if (element.style.filter && element.style.removeAttribute) {
		element.style.removeAttribute('filter');
	}
}

/* ------------------------------------------------------------------------ */
// Aufklapp-Punkte für z.B. Wissen - Einfach über "Rahmen" gelöst


jQuery(document).ready( function() {
	jQuery('.rahmen_110 .csc-textpic-text').hide();
	
	jQuery(".rahmen_110 .csc-header").click( function() {
		var obj = jQuery( this ).parent().find('.csc-textpic-text');

		if (obj.css('display') != 'none') {
			inhalt_ausblenden( obj );
		} else {
			inhalt_einblenden( obj );
		}
		//jQuery( this ).parent().parent().find('.infos').slideToggle( 'easeInOutQuad' );
	});
	
});




/* ------------------------------------------------------------------------ */
// Pop-Up-Fenster

function close_fce_popup( ref ) {
	jQuery( '.fce_popup_floater' ).parent().fadeOut();
}

function open_fce_popup( id ) {

	close_fce_popup();
	var y = jQuery( window ).scrollTop();
	var h = jQuery( window ).height();
	
	var obj = jQuery( '.'+id );
	var floater = obj.find( '.fce_popup_floater' );
	
	obj.css('height', jQuery('body').height() );
	obj.fadeIn();
	
	obj.click( function() {
		close_fce_popup(); 
	});
	
	var t = Math.round((h - floater.height())/2)-100;
	obj.css('padding-top', (t+y)+'px');

}

jQuery(document).ready( function() {
	//close_fce_popup();
});



// this is a fix for the jQuery slide effects
function slideToggle(el, bShow){
  var $el = jQuery(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
  
  if( arguments.length == 1 ) bShow = !visible;
  
  if( bShow == visible ) return false;
  
  // get the original height
  if( !height ){
    height = $el.show().height();
    $el.data("originalHeight", height);
    if( !visible ) $el.hide().css({height: 0});
  }

  if( bShow ){
    $el.show().animate({height: height}, {duration: 250});
  } else {
    $el.animate({height: 0}, {duration: 250, complete:function (){
        $el.hide();
      }
    });
  }
}




