// JQUERY
$(document).ready(function(){
// disable link border
  $('a').attr('onfocus', 'if(this.blur)this.blur()');
  // last li item more space
  $('ul#navigation li ul li:last').css('margin-bottom', '6px');
  //Shadowbox
  Shadowbox.init({
    language: 'en', 
    adapter:'jquery', 
    players: ['img','swf','flv']
  });


  //fragebogen -----------------------------------------------------------
  //add_info input textfields controlled by checkboxes
  $('#fragebogen .checkbox.trigger').click(function(){
    var targetInputId = $(this).attr('class').split(' ').slice(-1);
    var targetInput = $("#"+targetInputId);

    if ( $(targetInput).hasClass('hide') ) {
        $(targetInput).addClass('show');
        $(targetInput).removeClass('hide');
    } else {
        $(targetInput).addClass('hide');
        $(targetInput).removeClass('show');
        $(targetInput).val('');
    }
  });

  //add_info input textfields controlled by dropdowns
  $('#fragebogen select').change(function(){

    //find out which option of the select field was selected
    //because we use the answer index as the options value, and the first option is "empty" - some magic is needed.
    var selectValue = $(this).val();
    var clickedOption = $(this).find('option:nth-child('+(parseInt(selectValue)+1)+')');

    //first hide all add_info fields on click on every dropdown option click
    $(this).nextAll('.add_info').removeClass('show');
    $(this).nextAll('.add_info').addClass('hide');
    $(this).nextAll('.add_info').val('');

    //then show related add_info input textfield
    if ($(clickedOption).hasClass('trigger')) {
        var targetInputId = $(clickedOption).attr('class').split(' ').slice(-1);
        var targetInput = $("#"+targetInputId);
        $(targetInput).addClass('show');
        $(targetInput).siblings('.add_info').addClass('hide');
        $(targetInput).siblings('.add_info').removeClass('show');
    }
  });
});











function checkit(cbox,id){
    var source=(cbox.checked)? "/img/_bergen_/checkbox_red.gif":"/img/_bergen_/checkbox_green.gif";
    var img=document.getElementById(id);
    img.src=source;
}

function CheckTA(textarea){
    var max=255 , textinhalt;
    textinhalt=textarea.value;
    if (textinhalt.length >= max) {
        textarea.value=textinhalt.substring(0,max);
        textarea.blur();
        }
}


