$(document).ready(function(){


$("input, textarea").click(function(){
$(this).removeClass("fehler");
});

$("#deutsch #senden").click(function(){
									
$("input, textarea").removeClass("fehler");
 var fehler = "";
     if( $("#name").val()==""  ){
    fehler = 'Bitte geben Sie einen Namen an! <br>';
    $("#name").addClass("fehler").animate({opacity : 1},1000);
    }
    if( $("#vorname").val()==""  ){
    fehler = 'Bitte geben Sie einen Vornamen an! <br>';
    $("#vorname").addClass("fehler").animate({opacity : 1},1000);
    }
   var kme = $("#kme").attr("checked");
     if( kme==true ){
        if($("#emailadresse").val()=="" ){
        fehler += 'Bitte tragen Sie Ihre Email ein! <br>';
        $("#emailadresse").addClass("fehler").animate({opacity : 1},1000);
        }
    } 
     var kmt = $("#kmt").attr("checked");
     if( kmt==true ){
       if($("#telefonnummer").val()=="" ){
       fehler += 'Bitte tragen Sie Ihre Telefonnummer ein! <br>';
       $("#telefonnummer").addClass("fehler").animate({opacity : 1},1000);
       }
    } 
      
    if(fehler!=""){
      $("#nachrichtenFehler").html(fehler+"<br>");
     return false;
    }else{
    $("#nachrichtenFehler").html("");
    }
    
 
 // $("#nachrichtsenden").load("fileadmin/ltec/mail_senden.php?name="+encodeURIComponent($("#name").val())+"&email="+$("#email").val()+"&nachricht="+encodeURIComponent($("#nachricht").val()));  
  //  return false;
 });
 
 
 $("#englisch #senden").click(function(){
$("input, textarea").removeClass("fehler");
    
    var fehler = ""; 
    if( $("#vorname").val()==""  ){
      fehler += 'Please enter your first name! <br>';
      $("#vorname").addClass("fehler").animate({opacity : 1},1000);
    }
    
    if( $("#name").val()==""  ){
    fehler += 'Please enter your surname! <br>';
    $("#name").addClass("fehler").animate({opacity : 1},1000);
    }
       
     var kmt = $("#kmt").attr("checked");
     if( kmt==true ){
       if($("#telefonnummer").val()=="" ){
       fehler += 'Please enter your phonenumber! <br>';
       $("#telefonnummer").addClass("fehler").animate({opacity : 1},1000);
       }
    } 
   
    var kme = $("#kme").attr("checked");
     if( kme==true ){
        if($("#emailadresse").val()=="" ){
        fehler += 'Please enter your e-mail address! <br>';
        $("#emailadresse").addClass("fehler").animate({opacity : 1},1000);
        }
    } 
       
      if(fehler!=""){
      $("#nachrichtenFehler").html(fehler+"<br>");
     return false;
    }else{
    $("#nachrichtenFehler").html("");
    }
    
 
 //  $("#nachrichtsenden").load("fileadmin/ltec/mail_senden.php?name="+encodeURIComponent($("#name").val())+"&email="+$("#email").val()+"&nachricht="+encodeURIComponent($("#nachricht").val()));  
//    return false;
 });
 
 //Anfrageformular
$("#gleich_adress").click(
//var plz = $("#ort").val();
  function (){
     if($(this).attr("checked")){
    $("#p_strasse").val($("#strasse").val()).attr("readonly","readonly") ;
    $("#p_plz").val($("#plz").val()).attr("readonly","readonly");
    $("#p_ort").val($("#ort").val()).attr("readonly","readonly");
    $("#p_land").val($("#land").val()).attr("readonly","readonly");
    $("#p_state").val($("#state").val()).attr("readonly","readonly");
      
    }else{
    $("#p_strasse").val("").removeAttr("readonly");
    $("#p_plz").val("").removeAttr("readonly");
    $("#p_ort").val("").removeAttr("readonly");
    $("#p_land").val("").removeAttr("readonly");
    
    
    }
  }
);

$("#anfrage_senden").click(function(){
  var fehler = ""; 

    if( $("#vorname").val() == ""  ){
      fehler += 'Bitte Vorname eintragen! <br>';
      $("#vorname").addClass("fehler").animate({opacity : 1},1000);
    }
    
    if( $("#nachname").val() == ""  ){
    fehler += 'Bitte Nachname eintragen! <br>';
    $("#nachname").addClass("fehler").animate({opacity : 1},1000);
    }
    
    if( $("#email").val()==""  ){
    fehler += 'Bitte Email eintragen! <br>';
    $("#email").addClass("fehler").animate({opacity : 1},1000);
    }
  
  if(fehler!=""){
       $("#nachrichtenFehler").html(fehler+"<br>");
      return false;
    }else{
      $("#nachrichtenFehler").html("");
    }
//  $("#gesendet").load( "fileadmin/ltec/anfrage_senden.php?nachname="+encodeURIComponent($("#nachname").val())+"&per_mail="+encodeURIComponent($("#per_mail").val())+"&per_post="+encodeURIComponent($("#per_post").val())+"&firma="+encodeURIComponent($("#firma").val())+"&land="+encodeURIComponent($("#land").val())+"&vorname="+encodeURIComponent($("#vorname").val())+"&strasse="+encodeURIComponent($("#strasse").val())+"&plz="+encodeURIComponent($("#plz").val())+"&ort="+encodeURIComponent($("#ort").val())+"&p_strasse="+encodeURIComponent($("#p_strasse").val())+"&p_plz="+encodeURIComponent($("#p_plz").val())+"&p_ort="+encodeURIComponent($("#p_ort").val())+"&kurven_ja="+encodeURIComponent($("#kurven_ja").val())+"&p_land="+encodeURIComponent($("#p_land").val())+"&kurven_nein="+encodeURIComponent($("#kurven_nein").val())+"&anrede="+$("#anrede").val()+"&neigung="+encodeURIComponent($("#neigung").val())+"&differenz="+encodeURIComponent($("#differenz").val())+"&fahrbahn="+encodeURIComponent($("#fahrbahn").val())+"&einstieg_ja="+encodeURIComponent($("#einstieg_ja").val())+"&einstieg_nein="+encodeURIComponent($("#einstieg_nein").val())+"&email="+$("#email").val()+"&hinweis="+encodeURIComponent($("#hinweis").val()) );
//  return false;
  }
);


$("#anfrage_senden_eng").click(function(){
  var fehler = ""; 

  if( $("#vorname").val() == ""  ){
      fehler += 'Please enter your first name! <br>';
      $("#vorname").addClass("fehler").animate({opacity : 1},1000);
    }
    
    if( $("#nachname").val() == ""  ){
    fehler += 'Please enter your surname! <br>';
    $("#nachname").addClass("fehler").animate({opacity : 1},1000);
    }
    
    if( $("#email").val()==""  ){
    fehler += 'Please enter your e-mail address!<br>';
    $("#email").addClass("fehler").animate({opacity : 1},1000);
    }

  if(fehler!=""){
       $("#nachrichtenFehler").html(fehler+"<br>");
      return false;
    }else{
      $("#nachrichtenFehler").html("");
    }
//  $("#gesendet").load( "fileadmin/ltec/anfrage_senden.php?nachname="+encodeURIComponent($("#nachname").val())+"&per_mail="+encodeURIComponent($("#per_mail").val())+"&per_post="+encodeURIComponent($("#per_post").val())+"&firma="+encodeURIComponent($("#firma").val())+"&land="+encodeURIComponent($("#land").val())+"&vorname="+encodeURIComponent($("#vorname").val())+"&strasse="+encodeURIComponent($("#strasse").val())+"&plz="+encodeURIComponent($("#plz").val())+"&ort="+encodeURIComponent($("#ort").val())+"&p_strasse="+encodeURIComponent($("#p_strasse").val())+"&p_plz="+encodeURIComponent($("#p_plz").val())+"&p_ort="+encodeURIComponent($("#p_ort").val())+"&kurven_ja="+encodeURIComponent($("#kurven_ja").val())+"&p_land="+encodeURIComponent($("#p_land").val())+"&kurven_nein="+encodeURIComponent($("#kurven_nein").val())+"&anrede="+$("#anrede").val()+"&neigung="+encodeURIComponent($("#neigung").val())+"&differenz="+encodeURIComponent($("#differenz").val())+"&fahrbahn="+encodeURIComponent($("#fahrbahn").val())+"&einstieg_ja="+encodeURIComponent($("#einstieg_ja").val())+"&einstieg_nein="+encodeURIComponent($("#einstieg_nein").val())+"&email="+$("#email").val()+"&hinweis="+encodeURIComponent($("#hinweis").val()) );
//  return false;
  }
);


$(".inhalt_rechts li a").click(function(){
  
  $(".inhalt_rechts li a").css({
    "color" : "#626262",
    "font-weight" : "normal",
    "background" : "none"
  });
  
  $(this).css({
  "color" : "#7ab800", 
  "font-weight" : "bold",
  "background" : "url(fileadmin/ltec/bilder/list_right_subnavi.gif) no-repeat 0 2px"
  });
 
/* $(this).closest("ul").css({
  position:"fixed",
  top:20,
  "z-index":13});*/
  
  });
  
  
$(".navigation li a img").mouseenter(
function(){
    if( $(this).attr("alt") == "Technik" || $(this).attr("alt") == "Technology"){
        $(".dropdown").slideDown(10, function(){
          $(".technikmenue").slideDown(250);
        });
      }
   }
);

$(".dropdown").mouseleave(function (){
$(".technikmenue").slideUp(250,
      function(){
          $(".dropdown").slideUp(10);
      }
    );
});

//Accordion FAQ
/*$("#faq .text_inhalt h2").mouseenter(function (){
    $("#faq .text_inhalt .bodytext").slideUp(250);    
    $(this).closest("div").next("p").slideDown(250);
   }
); */
 
 
 
 $('a[href*=#],a[href="#"]').click(function() {

   // duration in ms
   var duration=1000;

   // easing values: swing | linear
   var easing='swing';

   // get / set parameters
   var newHash=this.hash;
   var target=$(this.hash).offset().top;
   var oldLocation=window.location.href.replace(window.location.hash, '');
   var newLocation=this;

   // make sure it's the same location      
   if(oldLocation+newHash==newLocation)
   {
      // animate to target and set the hash to the window.location after the animation
      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {

         // add new hash to the browser location
         window.location.href=newLocation;
      });

      // cancel default click action
      return false;
   }

});






$("#zumfilm").click(

function(){
$("#schwarz").fadeIn(250, function() {
  $("#pfilm")
  .css({
    display : "block"
  })
  .animate({
  top : 75,
  height : 361,
  width : 567
   },2000,
      function(){
       $("#close").css("display","block");
       $("#myytplayer").css("display","block");
      }
    );

   })
  }
);

$("#zumfilm2").click(

function(){
$("#schwarz").fadeIn(250, function() {
  $("#pfilm")
  .css({
    display : "block"
  })
  .animate({
  top : 75,
  height : 361,
  width : 567
   },2000,
      function(){
       $("#close").css("display","block");
       $("#myytplayer").css("display","block");
      }
    );

   })
  }
);

$("#schwarz, #close").click(

  function(){
     $("#close").css("display","none");
      $("#myytplayer").css("display","none");
      $("#pfilm")
      .css({
        display : "none"
      })
      .animate({
        top : 205,
        height : 0,
        width : 0
        },1000,
          function(){
            $("#schwarz").fadeOut(250);
          }
        )
      
      
    }
  )

// lightbox für bilder in text

$("a[t3page^=file]").click(
    function(){
    var bildurl = $(this).attr("href");
  
     loadImage(bildurl);
      return false;
        
        
    }
)


 var loadImage = function(url) {
   
    var img = new Image();
    img.onload = function() {
      
      $("#schwarz2").animate({
      width : "100%",
      height : "100%"
     },250,
     function (){
      $("#divpopup").css("display" , "block");
      $("#popupbildladen")
      .append(
      $("<img src='"+url+"' align='center'>")
      .addClass("popupbild")
      
      .click(
        function(){
        
        $(".popupbild")
        .animate({
              width : 0,
              height: 0
            },500);
        $("#divpopup").css("display","none");    
        $("#schwarz2").fadeOut(500);
        $(".popupbild").remove();
          })
        );
     })
    
    }
    img.src = url;
  }

$("#divpopup").click(
        function(){
        
        $(".popupbild")
        .animate({
              width : 0,
              height: 0
            },500);
        $("#divpopup").css("display","none");    
        $("#schwarz2").fadeOut(500);
        $(".popupbild").remove();
          });

$("#englisch #land").change(
function(){
  if($("#land").val() == "United States"){
    $(".state").css("display","block");
  }else{
    $(".state").css("display","none");
  }
})

}); 

