$(document).ready(function() {
	
	if($('ul#stories').size() != 0){
		if(cat == "matt"){
			$('img#adc').css("display","block");
		}
		num++;
		var $number =  $('li.' + cat + ' > a:nth-child(' + num + ')').children();
		var t = $number.attr("src");
		$number.attr("src", t.substring(0,t.length-4) +"_r.jpg");
		numi = $('li.' + cat + ' > a:nth-child(' + num + ') > img');
		
		var $kati =  $('li.' + cat + ' > a:first').children();
		var l = $kati.attr("src");
		$kati.attr("src", l.substring(0,l.length-4) +"_r.jpg");
		
		$("li > a > img").mouseover(function(){
			var equ = $(this).parent().attr('href') != $number.parent().attr('href');
			if(equ){
				var txt = $(this).attr("src");
				if($(this).attr("class") != "not"){
					var gruppe = $(this).attr("class");
					if(gruppe != cat){
						$(this).parents('a').siblings(":first").children().attr("src","pics/stories_"+gruppe+"_r.jpg");
					}
				}
				txt = txt.substring(0,txt.length-4);
				if(txt.substring(txt.length-2,txt.length) == "_r") txt = txt.substring(0,txt.length-2);
				$(this).attr("src",txt +"_r.jpg");
			}
		});
		
		$("li > a > img").mouseout(function(){
			var equ =  $(this).parent().attr('href') != $number.parent().attr('href');
			if(equ){
				var txt = $(this).attr("src");
				if($(this).attr("class") != "not"){
					var gruppe = $(this).attr("class");
					if(gruppe != cat){
						$(this).parents('a').siblings(":first").children().attr("src","pics/stories_"+gruppe+".jpg");
					}
				}
				if($(this).parent().parent().attr("class") != cat || $(this).attr("class") != "not"){
					txt = txt.substring(0,txt.length-6);
					$(this).attr("src",txt +".jpg");
				}
			}
		});
	}
	
	if($('ul.news').size() != 0){		
		var $act =  $('ul.news > li > a > img#' + catNews);
		var l = $act.attr("src");
		$act.attr("src", l.substring(0,l.length-4) +"_r.jpg");
	}
	
	$('ul.news > li > a > img').hover(		
		  function () {
		  	if($(this).attr('id') != catNews){
		        var txt = $(this).attr("src");
		        txt = txt.substring(0,txt.length-4);
				$(this).attr("src",txt +"_r.jpg");
			}
	      }, 
	      function () {
	      	if($(this).attr('id') != catNews){
		        var txt = $(this).attr("src");
		        txt = txt.substring(0,txt.length-6);
				$(this).attr("src",txt +".jpg");
			}
	      }
	);
	
	$("#persona1").hide();
	$("div#navi > a > img").mouseover(function(){
		var txt = $(this).attr("src");
		if($(this).attr("class") != "not"){
			var gruppe = "stories_" + $(this).attr("class");
			if(gruppe != kat){
				$(this).parents('a').siblings(":first").children().attr("src","pics/"+gruppe+"_r.jpg");
			}
		}
		txt = txt.substring(0,txt.length-4);
		$(this).attr("src",txt +"_r.jpg");
	});
	$("div#navi > a > img").mouseout(function(){
		var txt = $(this).attr("src");
		if($(this).attr("class") != "not"){
			var gruppe = "stories_" + $(this).attr("class");
			if(gruppe != kat){
				$(this).parents('a').siblings(":first").children().attr("src","pics/"+gruppe+".jpg");
			}
		}
		txt = txt.substring(0,txt.length-6);
		$(this).attr("src",txt +".jpg");
	});

	$("#lang").toggle(function(){
  		$(this).html("<a href='#'>DEUTSCH</a>");
		$("#persona").hide();
		$("#persona1").show();
	},function(){
 		 $(this).html("<a href='#'>ENGLISH</a>");
		 $("#persona1").hide();
		 $("#persona").show();
	});

});
