
	/* Basis-Script */
	
	var onloadHooks = [];
			
	window.onload = function()
	{
	
		// Blurlinks
		blurlinks = $$("a");
		for(var i = 0, o; o = blurlinks[i]; i++)
		{
			o.addEvents({'focus': function(e) {
				this.blur();
			}});
		}
		
		
		// Get onload scripts
		for(i = 0; i < onloadHooks.length; i++)
		{
			onloadHooks[i]();
		}
	

		// Naviausrichtung
		main_navis = $$('*.mnp');
		var freeWidth = 969;
		for(var i = 0, o; o = main_navis[i]; i++)
		{
			freeWidth -= o.getWidth();
		};
		
		var addPadding = freeWidth / 2 / (main_navis.length - 0.5);
		
		var lastPadding = 969;
		for(var i = 0, o; o = main_navis[i]; i++)
		{	
			if (i == 0) {
				o.setStyle('padding-right', (o.getStyle('padding-right').toInt() + addPadding) + "px");
			}else if (i < main_navis.length-1) {
				oldPadding = o.getStyle('padding-right').toInt();
				o.setStyle('padding', "8px " + (o.getStyle('padding-right').toInt() + addPadding) + "px 0");
			} else {
				o.setStyle('padding', "8px " + (o.getStyle('padding-right').toInt() + addPadding) + "px 0");				
			}
		};
		

		
		if($('fade')){
			var height1 = window.innerHeight || (window.document.documentElement.clientHeight || document.body.clientHeight);
			var height2 = parseInt(getY($('copyright')))+50;
			if(parseInt(height1)<parseInt(height2)) height1 = height2;
			$('fade').style.height = height1;
		}
	}
	
	function getY (el) {
		y = el.offsetTop;
		if (!el.offsetParent) return y;
		else return (y+getY(el.offsetParent));
	}			
	
	function submit_dam_dl_browse(){
		$('dam_pointer').selectedIndex = 0;
		document.dam_dl_browse.submit();
	}

function update_search(){
	document.forms["tx_indexedsearch"].elements["tx_indexedsearch[pointer]"].value=document.forms["suche_browse"].elements["pointer"].selectedIndex;
	document.tx_indexedsearch.submit(); 	
}


onloadHooks.push(function(){ 
	init();
});


var isinsideshare = 0;
var showingsharebuttons = 0;

function init (){
	
	var wrapper = $$('.sharewrapper');
	for(var i = 0; i<wrapper.length; i++){
		wrapper[i].addEvent('mouseover', function(){
			insideshare();
		});
	}
	
	
	if($('buttonfield')){
		$('buttonfield').setStyle('display', 'none');
	}
	$$('a.download').setProperty('target', '_blank');
	//makeMenuHovers();
}
/*
function makeMenuHovers(){
	$('fschanger').getParent().setStyles({
		overflow : 'hidden',
		height		: '14px'
	});
	$('fschanger').addEvent('mouseover', function(){
		this.getParent().setStyle('overflow', 'visible');
	});
	$('fschanger').addEvent('mouseout', function(){
		this.getParent().setStyle('overflow', 'hidden');
	});
	
	
	$('cschanger').getParent().setStyles({
		overflow : 'hidden',
		height		: '14px'
	});
	$('cschanger').addEvent('mouseover', function(){
		this.getParent().setStyle('overflow', 'visible');
	});
	$('cschanger').addEvent('mouseout', function(){
		this.getParent().setStyle('overflow', 'hidden');
	});
}*/

function insideshare(){
	isinsideshare = 1;
}

function outsideshare(){
	isinsideshare = 0;
}

function hidesharebuttons(){
	if(showingsharebuttons){
		var warte = hidebuttonsdelay.delay(500);
	}
}

function hidebuttonsdelay(){
	if(!isinsideshare){
		$('buttonfield').setStyle('display', 'none');
		showingsharebuttons = 0;
			
		$('sharebutton').removeEvents();
	}
}

function showsharebuttons(){
	if(showingsharebuttons){
		$('buttonfield').setStyle('display', 'none');
		
		showingsharebuttons = 0;
	}else{
		$('buttonfield').setStyle('display', 'block');
		
		showingsharebuttons = 1;
	}
}


function checkscroll(){
	if($$('.scrolltext_outer') && $$('.scrolltext_inner')){
		var innerScroll = $$('.scrolltext_outer .scrolltext_inner');
		for(var i = 0; i < innerScroll.length; i++){
			var outerScroll = innerScroll[i].getParent();
			var innenhoehe = innerScroll[i].getStyle('height').toInt();
			var aussenhoehe = outerScroll.getStyle('height').toInt();
			if(innenhoehe > aussenhoehe){
				var innenbreite = innerScroll[i].getStyle('width').toInt();
				
				var aussenbreite = outerScroll.getStyle('width').toInt();
				innerScroll[i].setStyle('width', (aussenbreite - 15));
				var hochscroller = new Element('a', {
					'href'		: 'javascript:;',
					'styles'	: {
						'width'				: '14px',
						'height'			: '14px',
						'position'		: 'absolute',
						'top'					: '0',
						'right'				: '0',
						'background'	: 'url(fileadmin/img/btn_scroll_up.png) no-repeat top left'
					},
					'events'	: {
						'mousedown'		: function(){
							textscrolling = 1;
							scrollUP(this.getParent().getFirst());
						},
						'mouseup'		: function(){
							textscrolling = 0;
						}
					}
				});
				hochscroller.injectInside(outerScroll);
				var runterscroller = new Element('a', {
					'href'		: 'javascript:;',
					'styles'	: {
						'width'				: '14px',
						'height'			: '14px',
						'position'		: 'absolute',
						'bottom'					: '0',
						'right'				: '0',
						'background'	: 'url(fileadmin/img/btn_scroll_down.png) no-repeat top left'
					},
					'events'	: {
						'mousedown'		: function(){
							textscrolling = 1;
							scrollDOWN(this.getParent().getFirst());
						},
						'mouseup'		: function(){
							textscrolling = 0;
						}
					}
				});
				runterscroller.injectInside(outerScroll);
			}
		}
	}
}

function scrollUP(elem){
	var schrittweite = Math.round((elem.getStyle('height').toInt() - elem.getParent().getStyle('height').toInt())/10);
	if(schrittweite < 15){
		schrittweite = 15;
	}
	var maxtextscroll = 0;
	var startpunkt = elem.getStyle('top').toInt();
	var framespersecond = 30;
	var dauer = 50;
	var endpunkt = startpunkt + schrittweite;
	if(startpunkt < maxtextscroll){
		if (endpunkt*-1 > 0) {
			Scroller = new Fx.Morph(elem, {duration:dauer, transition:'linear', fps:framespersecond});
			Scroller.addEvent('complete', function(){
				if(textscrolling){
					scrollUP(elem);
				}
			});
			Scroller.start({
				'top': [startpunkt, endpunkt]
			});
		} else {
			Scroller = new Fx.Morph(elem, {duration:dauer, transition:'linear', fps:framespersecond});
			Scroller.addEvent('complete', function(){
				if(textscrolling){
					scrollUP(elem);
				}
			});
			Scroller.start({
				'top': [startpunkt, 0]
			});
		}
	}
}

function scrollDOWN(elem){
	var schrittweite = Math.round((elem.getStyle('height').toInt() - elem.getParent().getStyle('height').toInt())/10);
	if(schrittweite < 15){
		schrittweite = 15;
	}
	var maxtextscroll = elem.getParent().getStyle('height').toInt()-elem.getStyle('height').toInt();
	var startpunkt = elem.getStyle('top').toInt();
	var framespersecond = 30;
	var dauer = 50;
	var endpunkt = startpunkt - schrittweite;
	if(startpunkt >= maxtextscroll){
		if (endpunkt*-1 < maxtextscroll*-1) {
			Scroller = new Fx.Morph(elem, {duration:dauer, transition:'linear', fps:framespersecond});
			Scroller.addEvent('complete', function(){
				if(textscrolling){
					scrollDOWN(elem);
				}
			});
			Scroller.start({
				'top': [startpunkt, endpunkt]
			});
		
		} else if(endpunkt*-1 > maxtextscroll*-1) {
			Scroller = new Fx.Morph(elem, {duration:dauer, transition:'linear', fps:framespersecond});
			Scroller.addEvent('complete', function(){
				if(textscrolling){
					scrollDOWN(elem);
				}
			});
			Scroller.start({
				'top': [startpunkt, maxtextscroll]
			});
		}
	} 
}
