/*
	 _/\_
	_>,"<___________________________________________________
		 _  _  ___  _    _  _  ___        _
		| \| || __|/_\  | \| |/ __|    __| | ___
		| .` || _|/ _ \ | .` |\__ \ _ / _` |/ -_)
		|_|\_||_|/_/ \_\|_|\_||___/(_)\__,_|\___|

        .°~--- DeRBe SKRiPTe --- BY CENO --- 2oo9 | o5 | 13 ---~°.
        .-.-.-.-. modified by ThE CaPtAiN .-.-.-.-.-.-.-.-.-.-.-.
*/

function dotheAD() {
	$('div.titelliste ul.sortierung span').each(
		function() {
			$(this).removeClass('selected');
			if(this.getAttribute('rel')=='A-D') {
				$(this).addClass('selected');
			}
		 }
	 );
}

function showSystemSelection( doShow, referrer ) {
	systemString = $(referrer).text();

	if (doShow) {
		$('h4#system span').text('Systemauswahl: ');
		$('h4#system em').fadeOut(200);
		$('div.titelliste').fadeOut(200, function() {
			$('h4#titel').addClass('disabled');
			$('div.systeme').slideDown(500);
		});
	} else {
		$('h4#system span').text('Systemauswahl: ' + systemString);
		$('div.systeme').slideUp(200, function() {
			$('h4#titel').removeClass('disabled');
			$('h4#system em').fadeIn(200);
			$('div.titelliste').fadeIn(500);
		});
	}

	$('div.titelliste ul.sortierung span').each(
		function() {
			$(this).removeClass('selected');
			if(this.getAttribute('rel')=='A-D') {
				$(this).addClass('selected');
			}
		 }
	 );
}

function filterGames( referrer ) {
	if (!$(referrer).hasClass('selected')) {
		var cnt = 0;
		filter = $(referrer).attr('rel');

		if ((filter != 'genre')&&(filter != 'eingrenzung')) {
			switch (filter) {
				case '09': showable = '1234567890'; break;
				case 'AD': showable = 'ABCD'; break;
				case 'EL': showable = 'EFGHIJKL'; break;
				case 'MR': showable = 'MNOPQR'; break;
				case 'ST': showable = 'ST'; break;
				case 'UZ': showable = 'UVWXYZ'; break;
				default: showable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
			}
			$('div.titelliste ul.sortierung span').each( function() { $(this).removeClass('selected'); } );
			$(referrer).addClass('selected');
			//$('div.titelliste ul#eintraege li').each( function() {
				//currentTitle = $( this ).find('span.titel a').text();
				//if ( showable.indexOf( currentTitle.charAt(0).toUpperCase()) == -1 ) $(this).slideUp(500); else $(this).slideDown(500);
			//});
		} else {
			$('div.titelliste ul.sortierung span').each( function() { $(this).removeClass('selected'); } );
			showableGenre = $.trim($(referrer).val());
			//$('div.titelliste ul#eintraege li').each( function() {
			//	currentGenre = $.trim($( this ).find('span.genre').text());
			//	if ( currentGenre != showableGenre ) $(this).slideUp(500); else $(this).slideDown(500);
			//});
		}
	}
}

function expand( toExpand, referrer ) {
	if ( $('*.'+toExpand).hasClass('expanded') ) {
		$('*.'+toExpand).slideUp (300, function(){
			$('*.'+toExpand).removeClass ('expanded');
			$(referrer).addClass('disabled');
		});
	} else {
		$('*.'+toExpand).slideDown (300, function(){
			$('*.'+toExpand).addClass ('expanded');
			$(referrer).removeClass('disabled');
		});
	}
}

$(window).load(function () {
	$('div#middle .content .hardwaretests h4.topic').mouseover(function() {
		cat = $(this).attr('rel');
		if(!$('*.'+cat).hasClass('expanded')) $(this).removeClass('disabled');
	}).mouseout(function() {
		cat = $(this).attr('rel');
		if(!$('*.'+cat).hasClass('expanded')) $(this).addClass('disabled');
	}).click(function() {
		cat = $(this).attr('rel');
		expand( cat, this );
	});
});

