    var auto_gallery_scroll, tab_index;
    $(document).ready(function(){

	  if($('a')!=null) $('a').focus(function(){
     this.blur();
    });
    
    if($('.pagebrowser a')!=null) $(".pagebrowser a").click(
     function(){
	    location.href=this.href;
     });
    
    if($('#artikel_sortieren_2')!=null) $('#artikel_sortieren_2').animate({width: 'hide',opacity: 'hide'}, 'slow');
	  
    if($('#artikel_sortieren_1')!=null) $("a#artikel_sortieren_1").click(
     function(){
	    $('div#artikel_sortieren_div_1').animate({width: 'hide',opacity: 'hide'}, 'fast');
	    $('#artikel_sortieren_2').animate({width: 'show',opacity: 'show'}, 'slow');
     });    
    
    if($('#artikel_sortieren_2')!=null) $("#artikel_sortieren_2").click(
     function(){
	    $('#artikel_sortieren_2').animate({width: 'hide',opacity: 'hide'}, 'fast');
	    $('div#artikel_sortieren_div_1').animate({width: 'show',opacity: 'show'}, 'slow');
     });     
    
    
     if($('.artikel_next_pic')!=null) $(".artikel_next_pic").click(function(text){
      $('#artikel_pic').fadeOut("fast",function(){$('#gallery_content').html(text);
      $('#artikel_pic').fadeIn("slow");              
     });});
     
     if($('.artikel_last_pic')!=null) $(".artikel_last_pic").click(function(text){
      $('#artikel_pic').fadeOut("fast",function(){$('#gallery_content').html(text);
      $('#artikel_pic').fadeIn("slow");              
     });});    
     
     if($('.artikel_pic')!=null) $("#artikel_pic").click(function(text){
      $('#artikel_pic').fadeOut("fast",function(){$('#gallery_content').html(text);
      $('#artikel_pic').fadeIn("slow");              
     });});
 
        
    function clear_menue(){
     for(var a=1;a<=6;a++){
      if($('#subnav'+a)!=null) $('#subnav'+a).css("display", "none");
     }             
    }
    
    function menue_corners(){
     if(menuindex=='4' || hover_menuindex=='4'){
      if($('.sub_corner_right')!=null) $('.sub_corner_right').css("display", "none");
     }else{
      if($('.sub_corner_right')!=null) $('.sub_corner_right').css("display", "block");
     }   
     if(menuindex=='1' || hover_menuindex=='1'){
      if($('.sub_corner_left')!=null) $('.sub_corner_left').css("display", "none");
     }else{
      if($('.sub_corner_left')!=null) $('.sub_corner_left').css("display", "block");
     }        
    }
    function display_menue(index){
     clear_menue();
     if($('#subnav'+index)!=null) $('#subnav'+index).css("display", "block");
     menue_corners();                   
    }
     
    function de_mark_menue(){
     display_menue(menuindex); 
     if($('#nav'+menuindex)!=null) $('#nav'+menuindex).attr("src", "images/template/navigation/button_"+menuimage+".jpg");
    }
         
    function mark_menue(){
     display_menue(menuindex); 
     if($('#nav'+menuindex)!=null) $('#nav'+menuindex).attr("src", "images/template/navigation/button_"+menuimage+"_hover.jpg");
     menue_corners();
     for(var a=1;a<=6;a++){
      if(a!=menuindex){
       if($('#navtab'+a)!=null) $('#navtab'+a).css("z-index", "1");
      }else{
       if($('#navtab'+a)!=null) $('#navtab'+a).css("z-index", "8");
      } 
     }                    
    }
    
    mark_menue();
    
    function clear_top_menue(){
    
     $('#nav1').attr("src", "images/template/navigation/button_lokales.jpg");
     $('#nav2').attr("src", "images/template/navigation/button_kommunen.jpg");
     $('#nav3').attr("src", "images/template/navigation/button_sport.jpg");
     $('#nav4').attr("src", "images/template/navigation/button_mein_oa.jpg");
     $('#nav5').attr("src", "images/template/navigation/button_meinung.jpg");
     $('#nav6').attr("src", "images/template/navigation/button_service.jpg");
    }
    
    function change_tab(){
     clear_top_menue();
     $('#nav'+hover_menuindex).attr("src", "images/template/navigation/button_"+hover_menuimage+"_hover.jpg");
     $('#nav'+menuindex).attr("src", "images/template/navigation/button_"+menuimage+"_hover.jpg");
     display_menue(hover_menuindex); 
     menue_corners();      
    }
     
   if($('.subnavigation')!=null) $('.subnavigation').mouseover(function(){
    clear_top_menue();
    mark_menue();
    //change_tab();
   });
      
   if($('#verticalmenue')!=null) $('#verticalmenue').mouseout(function(){
     clear_top_menue();
     $('#nav'+menuindex).attr("src", "images/template/navigation/button_"+menuimage+"_hover.jpg");
     display_menue(menuindex); 
    });   
    
   if($('.clear_menue')!=null) $('.clear_menue').mouseover(function(){
     hover_menuindex=menuindex;   
     hover_menuimage=menuimage;
     menue_corners();      
    });          
    
                
    if($('#nav1')!=null) $('#nav1').mouseover(function(){
     $('#nav1').attr("src", "images/template/navigation/button_lokales_hover.jpg"); 
     display_menue('1');
     $('.sub_corner_left').css("display", "none");
     hover_menuindex='1';   
     hover_menuimage='lokales';
     menue_corners();      
     if(hover_menuindex!="1"){        
      change_tab();
     }     
    });
    if($('#nav1')!=null) $('#nav1').click(function(){
     de_mark_menue();
     menuindex='1';
     menuimage='lokales';
     display_menue(menuindex);
     mark_menue();        
    });    
        
    if($('#nav2')!=null) $('#nav2').mouseover(function(){
     $('#nav2').attr("src", "images/template/navigation/button_kommunen_hover.jpg");
     display_menue('2');
     hover_menuindex='2';
     hover_menuimage='kommunen'; 
     menue_corners();      
     if(hover_menuindex!="2"){        
      change_tab();
     }     

    });
    if($('#nav2')!=null) $('#nav2').click(function(){
     de_mark_menue();    
     menuindex='2';
     menuimage='kommunen';
     display_menue(menuindex); 
     mark_menue();       
    });       
    
    if($('#nav3')!=null) $('#nav3').mouseover(function(){
     $('#nav3').attr("src", "images/template/navigation/button_sport_hover.jpg");
     display_menue('3');  
     hover_menuindex='3';  
     hover_menuimage='sport'; 
     menue_corners();        
     if(hover_menuindex!="3"){        
      change_tab();
     }     
          
    });
    if($('#nav3')!=null) $('#nav3').click(function(){
     de_mark_menue();    
     menuindex='3';
     menuimage='sport';     
     display_menue(menuindex);
     mark_menue();        
    });       
/*
    if($('#nav4')!=null) $('#nav4').mouseover(function(){
     $('#nav4').attr("src", "images/template/navigation/button_mein_oa_hover.jpg");
     display_menue('4');     
     $('.sub_corner_right').css("display", "none");
     hover_menuindex='4';    
     hover_menuimage='mein_oa'; 
     menue_corners(); 
     if(hover_menuindex!="4"){        
      change_tab();
     }              
    });

    if($('#nav4')!=null) $('#nav4').click(function(){
     de_mark_menue();    
     menuindex='4';
     menuimage='mein_oa';     
     display_menue(menuindex); 
     mark_menue();       
    });
*/
    
    if($('#nav5')!=null) $('#nav5').mouseover(function(){
     $('#nav5').attr("src", "images/template/navigation/button_meinung_hover.jpg");
     display_menue('5');   
     hover_menuindex='5';
     hover_menuimage='meinung';  
     menue_corners();      
     if(hover_menuindex!="5"){        
      change_tab();
     }     
                   
    });
    if($('#nav5')!=null) $('#nav5').click(function(){
     de_mark_menue();    
     menuindex='5';
     menuimage='meinung';     
     display_menue(menuindex); 
     mark_menue();       
    });       
    
    if($('#nav6')!=null) $('#nav6').mouseover(function(){
     $('#nav6').attr("src", "images/template/navigation/button_service_hover.jpg");
     display_menue('6');   
     hover_menuindex='6';  
     hover_menuimage='service';
     menue_corners();        
     if(hover_menuindex!="6"){        
      change_tab();
     }     
      
    });
    if($('#nav6')!=null) $('#nav6').click(function(){
     de_mark_menue();    
     menuindex='6';
     menuimage='service';     
     display_menue(menuindex);
     mark_menue();        
    });         
    
    if($('.tab')!=null) $('.tab').click(function(){
     $('#tab_1').addClass("tab"); $('#tab_1').removeClass("tab_selected");
     $('#tab_2').addClass("tab"); $('#tab_2').removeClass("tab_selected");
     $('#tab_3').addClass("tab"); $('#tab_3').removeClass("tab_selected");                    
     $('#tab_4').addClass("tab"); $('#tab_4').removeClass("tab_selected");
      
     $(this).addClass("tab_selected"); $(this).removeClass("tab");
     
     if($(this).attr("id")=="tab_1"){tab_index="1";}
     if($(this).attr("id")=="tab_2"){tab_index="2";}
     if($(this).attr("id")=="tab_3"){tab_index="3";}
     if($(this).attr("id")=="tab_4"){tab_index="4";}

     $.post("includes/php/small_gallery.php",{ tab: $(this).attr("id") }, function(text){
     $('#gallery_content').fadeOut("fast",function(){$('#gallery_content').html(text);$('#gallery_content').fadeIn("slow");              
     });});});

     if($('.gallery_collector')!=null) $('.gallery_collector').mouseover(function(){
      auto_gallery_scroll=false;        
     });      
      
     if($('.gallery_collector')!=null) $('.gallery_collector').mouseout(function(){
      auto_gallery_scroll=true;        
     });      
            
    if($('#tab_1')!=null)  $('#tab_1').click();
     auto_gallery_scroll=true;
     tab_index="1";
       
     $.timer(4500, function(timer){
     if(auto_gallery_scroll){
  	  tab_index=1+1*tab_index;
  	  if(tab_index>=5){
  	   tab_index="1";
       }
  		$("#tab_"+tab_index).click();  			
  		timer.reset(4500);
  	 }        
    });
  });    
  
function start() {
	time();
	window.setInterval("time()", 1000);

	var rightHeight=document.getElementById("left_middle_height").offsetHeight;
	var leftHeight=document.getElementById("left").offsetHeight;
	var middleHeight=document.getElementById("middle").offsetHeight;
	var innerBoxHeight=document.getElementById("inner_box").offsetHeight;
	var sky=null
  if(document.getElementById("wallpaper")) sky=document.getElementById("wallpaper").offsetWidth;

  if(navigator.appName.indexOf("Explorer") != -1){
  	document.getElementById("main_shadow_right_one_color").style.height=eval(innerBoxHeight-560)+"px";
  	document.getElementById("main_shadow_right_one_color_second").style.height=eval(innerBoxHeight-800)+"px";

    if(leftHeight>middleHeight) document.getElementById("middle").style.height=eval(leftHeight+100)+"px";
  }
  else {
  	document.getElementById("main_shadow_right_one_color").style.height=eval(innerBoxHeight-543)+"px";
  	document.getElementById("main_shadow_right_one_color_second").style.height=eval(innerBoxHeight-545)+"px";

    if(leftHeight>middleHeight) document.getElementById("middle").style.height=eval(leftHeight+100)+"px";
  }

  if(document.getElementById("wallpaper"))
  {
    document.getElementById("wallpaper").style.width=eval(sky-970)+"px";
    document.getElementById("wallpaper").style.height=innerBoxHeight+"px";
  }

}

function time() {
	var now = new Date();
	hours = now.getHours();
	minutes = now.getMinutes();
	seconds = now.getSeconds();

	thetime = (hours < 10) ? "0" + hours + ":" : hours + ":";
	thetime += (minutes < 10) ? "0" + minutes + ":" : minutes + ":";
	thetime += (seconds < 10) ? "0" + seconds : seconds;

	element = document.getElementById("time");
	element.innerHTML = thetime+" Uhr";
}

function datumAnzeige() {
  var TheFontFace  = "Arial";
  var TheFontColor = "#0000000";
  var TheFontSize  = "1";
  var TheFontStyle = "blod";
  var TheSeparator = ".";
  var ShowDay ="yes";


  var Days = new Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");
  var TheDate = new Date();

  var TheWeekDay = TheDate.getDay();
  var Day ="";
  if (ShowDay == "yes"){
      Day = Days[TheWeekDay];}

  var TheMonth = TheDate.getMonth() + 1;
  if (TheMonth < 10) TheMonth = "0" + TheMonth;

  var TheMonthDay = TheDate.getDate();
  if (TheMonthDay < 10) TheMonthDay = "0" + TheMonthDay;

  var TheYear = TheDate.getYear();
  if (TheYear < 1000) TheYear += 1900;

  var FontTagLeft  = "";
  var FontTagRight = "";

  if (TheFontStyle == "bold"){
      FontTagLeft = "<"+"b"+">";
      FontTagRight ="<"+"/"+"b"+">";}

  if (TheFontStyle == "italic"){
      FontTagLeft = "<"+"i"+">";
      FontTagRight ="<"+"/"+"i"+">";}

  if (TheFontStyle == "bolditalic"){
      FontTagLeft = "<"+"b"+">"+"<"+"i"+">";
      FontTagRight = "<"+"/"+"i"+">"+"<"+"/"+"b"+">";}

  var D = "";
  D += Day+", der "+TheMonthDay+TheSeparator+TheMonth+TheSeparator+TheYear+FontTagRight;
  document.getElementById("strtimedate").innerHTML = D;
}

function bannerJS(zoneid)
{
   var m3_u = (location.protocol=='https:'?'https://adserver3.oberberg.net/www/delivery/ajs.php':'http://adserver3.oberberg.net/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   var script=null;

   if (!document.MAX_used) document.MAX_used = ',';
   script="<scr"+"ipt type='text/javascript' src='"+m3_u;
   script+="?zoneid=" + zoneid;
   script+='&amp;cb=' + m3_r;
   if (document.MAX_used != ',') script+="&amp;exclude=" + document.MAX_used;
   script+=document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : '');
   script+="&amp;loc=" + escape(window.location);
   if (document.referrer) script+="&amp;referer=" + escape(document.referrer);
   if (document.context) script+="&context=" + escape(document.context);
   if (document.mmm_fo) script+="&amp;mmm_fo=1";
   script+="'><\/scr"+"ipt>";
   
   return script;
}
