window.addEvent('domready', function(){

	var zahlungsStatus = new Hash.Cookie('zahlungsStatus');
	if(!zahlungsStatus.get('status')){
		zahlungsStatus.set('status', 'bank');
	}
	
	if(zahlungsStatus.get('status') == 'bank'){
		if($('kontoinformationen')){
			$('kontoinformationen').setStyle('display', 'block');
			$('Zahlung-bank').setProperty('checked',true);
		}
	}else if(zahlungsStatus.get('status') == 'rechnung'){
		if($('kontoinformationen')){
			$('kontoinformationen').setStyle('display', 'none');
			$('Zahlung-Rechnung').setProperty('checked',true);
			clearInputs($('kontoinformationen'),'leer');
		}
	}
	
	if($('Zahlung-bank')){
		$('Zahlung-bank').addEvent('click', function(e) {
			if($('kontoinformationen')){
				$('kontoinformationen').setStyle('display', 'block');
				clearInputs($('kontoinformationen'),'');
				zahlungsStatus.set('status', 'bank');
			}
		});
	}
	
	if($('Zahlung-Rechnung')){
		$('Zahlung-Rechnung').addEvent('click', function(e) {
			if($('kontoinformationen')){
				$('kontoinformationen').setStyle('display', 'none');
				clearInputs($('kontoinformationen'),'leer');
				zahlungsStatus.set('status', 'rechnung');
			}
		});
	}
	
	function clearInputs(element,value){
		element.getChildren('input').each(function(el){
			el.value = value;
		})
	}
	
	
	/*
	*	TIPP Datenbank / Übersicht
	*/
	try{
		var maxHeight = 0;
		$$('div.tips-cat-content-el-challenge').each(function(slideWrap, i) {
			if (slideWrap.getCoordinates().height > maxHeight) maxHeight = slideWrap.getCoordinates().height;
			if (i > 0) slideWrap.setStyle('display', 'none');
		});
		
		$$('div.tips-cat-content-el-challenge').each(function(slideWrap, i) {
			slideWrap.setStyle('height', maxHeight);
		});
		
		$$('div.tips-cat-content-el').each(function(el, i) {
			el.addEvent('mouseenter', function(e) {
				$$('div.tips-cat-content-el-challenge').each(function(slideWrap, i) {
					slideWrap.setStyle('display', 'none');
				});
				el.getElement('div.tips-cat-content-el-challenge').setStyle('display', 'block');
				
			});
		});
	}catch(e){}
	
});

/*
*	MAG Datenbank / Logger
*/
function ajaxhandler(mode,uid,hash, link){
	/*
	if ($defined(downloadArticleButtonIsClicked)
		&& downloadArticleButtonIsClicked) {
		return;
	}

	if ($defined(link)) {
		downloadArticleButtonIsClicked = true;
	}
	*/
	try{
		var url = 'index.php?eID=tx_commagdb_ajaxhandler&action=' +mode+ '&uid=' +uid+ '&hash=' +hash;;
		var loaderbox = $('ajaxloader');
		loaderbox.setStyles({
			padding: '0px 6px'
		});
		
		new Ajax(url, {
			method: 'get',
			onRequest: function(){
				loaderbox.setStyles({
					background: 'url(fileadmin/templates/gfx/ajax-loader.gif) no-repeat right top',
					width: 20,
					height: 20,
				});
			},
			onComplete: function(response){
				loaderbox.setStyles({
					background: 'none'
				});
			}  
		}).request();
	}catch(e){}
}