 var clicked = false;
  jQuery(document).ready(function() {



  //------------------------------------------------------------
  //  teamoverlayer
  //------------------------------------------------------------
  jQuery('#team_overlay').css('display', 'none');


  //-- rewreite close_link 
  jQuery('#team_overlay #close_label_a').each(function(){
    var url = jQuery(this).attr('href');
    jQuery(this).attr('name', url).attr('href', '#');
  });

  jQuery('#team_overlay').fadeIn(500);
  jQuery('#team_overlay #close_label_a').click(function(){
    jQuery('#team_overlay').fadeOut();
  });
 

  //------------------------------------------------------------
  //  sendlayer
  //------------------------------------------------------------
    jQuery('#sendlayer').fadeIn(5000);
    jQuery('#sendlayer #close').click(function() {
       jQuery('#sendlayer').fadeOut();
    });

  // ContactError
    jQuery('#contactlayer').fadeIn(500,
      function()
      {
        contactClickFunction();
      }
    );

  //------------------------------------------------------------
  //  contact_layer
  //------------------------------------------------------------
    
  //at the beginning
	  jQuery('#contact_layer').css('position', 'absolute');
	  jQuery('#contact_layer').css('left', '-205px');
	  jQuery('#contact_layer #open_contact').css('display', 'block');
    //url rewrite
	  jQuery('#contact_layer a').each(function(){
		  var url = jQuery(this).attr('href');
		  jQuery(this).attr('name',url).attr('href','#');
		});
    
  //click function
    jQuery('#contact_layer a').click(function() {
      if(jQuery('#contact_layer a').hasClass('opened') == false) {
    	  jQuery('#contact_layer').animate(
           { left: '0px' }, 800, function(){ 
             jQuery('#contact_layer a').addClass('opened'); 
             }
        );
      } else {
    	  jQuery('#contact_layer').animate(
           { left: '-205px' }, 800, function(){ 
             jQuery('#contact_layer a').removeClass('opened'); 
             }
        );  
      }   	      
    });
    
    function contactClickFunction()
    {
        if(jQuery('#contact_layer a').hasClass('opened') == false) {
    	  jQuery('#contact_layer').animate(
           { left: '0px' }, 800, function(){ 
             jQuery('#contact_layer a').addClass('opened'); 
             }
        );
      } else {
    	  jQuery('#contact_layer').animate(
           { left: '-205px' }, 800, function(){ 
             jQuery('#contact_layer a').removeClass('opened'); 
             }
        );  
      }  
    }

  //------------------------------------------------------------
  //  menu
  //------------------------------------------------------------
  

	jQuery('div.welcomeMenu0 ul ul').css('display', 'none');
	   
	  jQuery('div.welcomeMenu0>ul>li').mouseover(function(){
		    //jQuery(this).children('ul').fadeIn('slow');
		     jQuery(this).children('ul').css('display', 'block');
		  });
		  jQuery('div.welcomeMenu0>ul>li').mouseleave(function(){
		    //jQuery(this).children('ul').fadeOut('slow');
			  jQuery(this).children('ul').css('display', 'none');
		  });
		  jQuery('div.welcomeMenu0>ul>li>ul>li').mouseover(function(){
		    //jQuery(this).children('ul').fadeIn('slow');
			  jQuery(this).children('ul').css('display', 'block');
		  });
		  jQuery('div.welcomeMenu0>ul>li>ul>li').mouseleave(function(){
		    //jQuery(this).children('ul').fadeOut('slow');
			  jQuery(this).children('ul').css('display', 'none');
		  });


    //------------------------------------------------------------
    //  news_and_facts
    //------------------------------------------------------------
   
    jQuery('#news_pfeile a').each(function(){
      var url = jQuery(this).attr('href');
      jQuery(this).css('cursor', 'pointer');     
      jQuery(this).attr('name',url).removeAttr('href');
    });

    // --- prev arrow ----
    var running = false;
    jQuery('#news_pfeile a#arrow_left_a').click(function() {
    	clicked= true;
        if(jQuery('#news_slider div').hasClass('part_ac1') == true && running == false) {
          running = true;
          jQuery('.news_img_1').fadeOut(function(){
              jQuery('.news_img_3').fadeIn();
              if(switchView('1', '3')==true)
                  running = false;
          });
          
        } else if(jQuery('#news_slider div').hasClass('part_ac2') == true) {
          running = true;
          jQuery('.news_img_2').fadeOut(function(){
              jQuery('.news_img_1').fadeIn();
              if(switchView('2', '1')==true) 
                  running = false;
           });

          
        } else if(jQuery('#news_slider div').hasClass('part_ac3') == true) {
          running = true;
          jQuery('.news_img_3').fadeOut(function(){
              jQuery('.news_img_2').fadeIn();
              if(switchView('3', '2')==true)
                  running = false;
          });
        }
      });
    
    // --- next arrow ----
     jQuery('#news_pfeile a#arrow_right_a').click(function() {
        clicked= true;
        if(jQuery('#news_slider div').hasClass('part_ac1') == true && running == false) {
          running = true;
          jQuery('.news_img_1').fadeOut(function(){
              jQuery('.news_img_2').fadeIn();
              if(switchView('1', '2')==true)
                  running = false;
          });
          
        } else if(jQuery('#news_slider div').hasClass('part_ac2') == true) {
          running = true;
          jQuery('.news_img_2').fadeOut(function(){
              jQuery('.news_img_3').fadeIn();
              if(switchView('2', '3')==true) 
                  running = false;
           });

          
        } else if(jQuery('#news_slider div').hasClass('part_ac3') == true) {
          running = true;
          jQuery('.news_img_3').fadeOut(function(){
              jQuery('.news_img_1').fadeIn();
              if(switchView('3', '1')==true)
                  running = false;
          });
        }
      });

     //setTimeout("left()", 2000);
     //FF jQuery('#img_leiste').css('left', "-"+jQuery('#img_leiste nobr').width());
     
     jQuery('#img_leiste').css('left', 0);
     setTimeout("left()", 2000);
   
     // --- automatically switch the parts  
     setInterval( "slide()", 5000 );
      
     
    //---- --------------------------------------------------------
    //  startpage img_switch
    //------------------------------------------------------------
    
    jQuery('#bg_img_2 img').fadeOut(0);
    jQuery('#bg_img_3 img').fadeOut(0);
    setInterval("switchImg()", 6000);
  });

  function left (){
	jQuery('#img_leiste').animate({
         left:"-"+(jQuery('#img_leiste nobr').width() - jQuery('#slider_container').width())
	 }, 35000, 'linear',  function (){ setTimeout("right()", 2000);/* right(); */} );
	
	 }
	 function right (){ 
	 jQuery('#img_leiste').animate({
         left:  0
	 }, 35000, 'linear', function (){ setTimeout("left()", 2000);/* left(); */ } );
	 } 
    
  function slideReturn()
  {
    jQuery('#img_leiste').css('left', '500');
    slideLeft();
	}
  
  function slideLeft()
  {
       jQuery('#img_leiste').animate(
               { left: '-770px' }, 10000, function(){slideReturn();}
               
             );  
	}
  
  function slide()
  {
    if(clicked != false)
        return false;
	  if(jQuery('#news_slider div').hasClass('part_ac1') == true)
	  {
		  jQuery('.news_img_1').fadeOut(function(){
              jQuery('.news_img_2').fadeIn();
              if(switchView('1', '2')==true) 
                  running = false;
           });
	  }
	  else if(jQuery('#news_slider div').hasClass('part_ac2') == true)
	  {
	      jQuery('.news_img_2').fadeOut(function(){
              jQuery('.news_img_3').fadeIn();
              if(switchView('2', '3')==true) 
                  running = false;
           });
	  }
	  else if(jQuery('#news_slider div').hasClass('part_ac3') == true)
	  {
	      jQuery('.news_img_3').fadeOut(function(){
              jQuery('.news_img_1').fadeIn();
              if(switchView('3', '1')==true) 
                  running = false;
           });
 	  }
	}

  
  function switchView(oldpart, newpart)
  {
	    jQuery('#news_slider div').removeClass('part_ac'+oldpart);
      jQuery('#news_slider div').removeClass('part_ac');
      jQuery('#news_slider div#part'+newpart).addClass('part_ac'+newpart);
      jQuery('#news_slider div#part'+newpart).addClass('part_ac');
      jQuery('#weiter a').css('display', 'none'); 
      jQuery('#weiter a#weiter'+newpart).css('display', 'block'); 
      
      jQuery('#newstext div').css('display', 'none'); 
      jQuery('#newstext div#entry'+newpart).show();

      return true; 
  }

//----------------------------------------------------------
  function switchImg()
  {
    if(jQuery('#standard_head #controls div').hasClass('ac1') == true)
    {
      jQuery('#bg_img_1 img').fadeOut(2000, function(){
        switchImgView(1, 2);
      });
    }
    else if(jQuery('#standard_head #controls div').hasClass('ac2') ==true)
    {
      jQuery('#bg_img_2 img').fadeOut(2000, function() {
        switchImgView(2,3);
      });
    }
    else if(jQuery('#standard_head #controls div').hasClass('ac3') == true)
    {
      jQuery('#bg_img_3 img').fadeOut(2000, function() {
        switchImgView(3,1);
      });
    }
  }

  function switchImgView(oldpart, newpart)
  {
    jQuery('#standard_head #controls div').removeClass('ac ac'+oldpart);
    jQuery('#standard_head #controls div#switch'+newpart).addClass('ac ac'+newpart);
    jQuery('#bg_img_'+newpart+' img').fadeIn(2000);
  }
