
/**
 *   jQuery-Zubehoer  initialisieren wenn dokument geladen
 */


$(document).ready(function(){


  /**
   *  finder-feld markieren
   */
  $('#find_place').focus(function(){
    $(this).attr('value','')
    });
  /**
   * Image-balken in Media-detail-Ansicht
   */
  /* wieviele Bilder sind da? */
    var max_img = $('#image_bar a').size(); 
    $('.equ').text(max_img);
    
  /*
  var curr = 2;
  var currid = curr-1;
    $('#image_bar a:eq('+currid+')').addClass('active');  //Nur curr wird makiert in klein
     var $active = $('.active');  
    $('.image_big img').attr('src', $active.attr('href'));
    
    $('.curr').text(eval( curr ));  // Bild nr wird angegeben
      */
 

      
      
       $('#image_bar a:first').addClass('active');
       
      
    var caption = $('a.active').attr('title');
    $('.caption').text(caption);
    
  /* Skippen des Balkens */

if (max_img > '6'){
  	$('#image_bar').jCarouselLite({
        btnPrev: ".prev",
        btnNext: ".next",
        visible: 6.0,
        speed: 800,
        scroll: 3,
        start: 0,
        mouseWheel: true,
        circular: false
    });
}
//MARCO RIEDER:
else {
	$('#image_bar').jCarouselLite({
        start: 0
    });
}



  $('#image_bar a').click(function() {
      
      var newFilename = $(this).attr("href");
      $(".image_big img").attr("src", newFilename);
      $('#image_bar a.active').removeClass('active');
      $(this).addClass('active');
      

      if ((typeof imageCaptions != "undefined") && (typeof imageCaptions[newFilename] != "undefined")) {
        $('#image_caption').html(imageCaptions[newFilename]);
      }
      else {
          $('#image_caption').html("");
      }

      if ((typeof imageDescriptions != "undefined") && (typeof imageDescriptions[newFilename] != "undefined")) {
        $('#image_description').html(imageDescriptions[newFilename]);
      }
      else {
          $('#image_description').html("");
      }
    
      var curr = eval(($('#image_bar').children("ul").children("li").children("a")).index(this)-5);
      if(curr > max_img){
        curr = eval(curr - max_img);
      }
      if(curr < 1){
        curr = eval(curr + max_img);
      }
      $('.curr').text(eval( curr ));
      return false;
  });



  $('a.big_prev').click(function(){
     var curr = parseInt($('.curr').text());

     var $prev_thumb = $('.active').parent('li').prev('li').children('a');
     
     if( curr > 1){
      $('#image_bar a.active').removeClass('active');
      $prev_thumb.addClass('active');

      var newFilename = $prev_thumb.attr('href')
      $('.image_big img').attr('src', newFilename);
      $('.curr').text(eval( curr -1 ));


      if ((typeof imageCaptions != "undefined") && (typeof imageCaptions[newFilename] != "undefined")) {
        $('#image_caption').html(imageCaptions[newFilename]);
      }
      else {
          $('#image_caption').html("");
      }

      if ((typeof imageDescriptions != "undefined") && (typeof imageDescriptions[newFilename] != "undefined")) {
        $('#image_description').html(imageDescriptions[newFilename]);
      }
      else {
          $('#image_description').html("");
      }

      return false;
     }
  });

  $('a.big_next').click(function(){
     var curr = parseInt($('.curr').text());

     var $next_thumb = $('.active').parent('li').next('li').children('a');

     if( curr < max_img){
      $('#image_bar a.active').removeClass('active');
      $next_thumb.addClass('active');

      var newFilename = $next_thumb.attr('href');
      $('.image_big img').attr('src', newFilename);
      $('.curr').text(eval( curr +1 ));


      if ((typeof imageCaptions != "undefined") && (typeof imageCaptions[newFilename] != "undefined")) {
        $('#image_caption').html(imageCaptions[newFilename]);
      }
      else {
          $('#image_caption').html("");
      }

      if ((typeof imageDescriptions != "undefined") && (typeof imageDescriptions[newFilename] != "undefined")) {
        $('#image_description').html(imageDescriptions[newFilename]);
      }
      else {
          $('#image_description').html("");
      }
      
      return false;
     }
  });

  
    
/**
 *  Mail-formular
 */
 
  $('.input > input').focus(function(){
    $('.input >input').css('border','1px solid #333');
    $('.input >textarea').css('border','1px solid #333');
    $('.input >select').css('border','1px solid #333');
    $(this).css('border','1px solid #666');
  });
  
  
  $('.input > textarea').focus(function(){
    $('.input >input').css('border','1px solid #333');
    $('.input >textarea').css('border','1px solid #333');
    $('.input >select').css('border','1px solid #333');
    $(this).css('border','1px solid #666');
  });
  $('.input > select').focus(function(){

      $('.input >input').css('border','1px solid #333');
      $('.input >textarea').css('border','1px solid #333');
      $('.input >select').css('border','1px solid #333');
      $(this).css('border','1px solid #666');
  });
  
  $('.submit > input').focus(function(){
    $('.input >input').css('border','1px solid #333');
    $('.input >textarea').css('border','1px solid #333');
    $('.input >select').css('border','1px solid #333');
  });

 
  $('.input > input').keypress(function(){
    $(this).next('.error-message').slideUp();
  });
    
  $('.input > textarea').keypress(function(){
    $(this).next('.error-message').slideUp();
  });
  $('.input > select').focus(function(){
    $(this).next('.error-message').slideUp();
  });
  
  
  
  
  
 $('.jScrollPaneContainer').focus(function(){
	$(this).blur();
 });

// $('.input > select').selectbox({debug: true});
  
 $('.column_fourth').mouseenter(function(){
     var child = $(this).children('p').children()
     $(child).css('color','#fff');
     var image = $(this).children('.img_container').children();
     $(image).children('a').children('img').css('border-color','#fff');
     $(image).children('.flash_wrapper').css('border-color','#fff');
     $(this).click(function(){});
 });
 $('.column_fourth').mouseleave(function(){
	 var child = $(this).children('p').children('a');
	 $(child).css('color','#333');
	 var image = $(this).children('.img_container').children();
	 $(image).children('a').children('img').css('border-color','#333');
	 $(image).children('.flash_wrapper').css('border-color','#333');
 });
 
 
 $('.unhide_hidden_info').mouseenter(function(){
	$(this).next('.hidden_info').fadeIn();
 });
 $('.unhide_hidden_info').mouseleave(function(){
	$(this).next('.hidden_info').fadeOut();
 });
 
 
 
});



