/**
 * Verkehrsverbund Vogtland - JS: jquery-Funktionen
 *
 *
 * @author Danny Otto | pixelbrand.net
 * @date   2011-07
 *
 *
 */
$(document).ready(function() {
  
  /* Suchwort */
  $('html[lang=de] #f_suche').attr('value','Suche');
  $('html[lang=de] #f_suche').blur( function() { if(this.value=='') { this.value='Suche'; } } ).focus( function () { if(this.value=='Suche') { this.value=''; } } );
  
  /* Download-Icon */
  $('a[href$=pdf]').not(':has(img)').addClass('download').prepend('<img class="jsico" src=\"'+templatepath+'images/ico_download.png\" alt=\"\" />');
  
  /* Autocomplete */
  $('#f_suche').autocomplete({ source: function(request, response) { $.getJSON('/', {'eID':'pxf_indexedsearch_autocomplete', 'search': request.term}, response); }, minLength: 2 });
  $('#f_position, #f_target').autocomplete({ source: function(request, response) { $.getJSON('/', {'eID':'pxf_ticketconsultor', 'search': request.term}, response); }, minLength: 2 });
  
  $('.col2_teaser div').css('cursor','pointer').click( function () { window.location.href = $(this).children('a').attr('href'); } );
  $('.col2_teaser div .text').syncHeight();
  $('#row_footer .sitemap ul li ul').syncHeight();
  
  $('table.ticketconsultor .infotext').before('<a href="#" class="btn-infotext"><span class="hideme">Info einblenden</span>?</a>');
  $('table.ticketconsultor .btn-infotext').click( function() {
    if ($(this).hasClass('btn-infotext-open')) {
      $('table.ticketconsultor .btn-infotext').removeClass('btn-infotext-open');
      $('table.ticketconsultor .infotext').css('display','none');
    } else {
      $('table.ticketconsultor .btn-infotext').removeClass('btn-infotext-open');
      $(this).addClass('btn-infotext-open');
      $('table.ticketconsultor .infotext').css('display','none');
      $(this).next('.infotext').css('display','block');
    }
    return false;
  });
  
  /* Lightbox */
  $('.gallery a, .lightbox a').fancybox({'titlePosition':'inside'});
  
  /* exxakt Meldungen */
  $('.exxakt-messages .item h4 a').click( function() {
    if ($(this).hasClass('open')) {
      $('.exxakt-messages .item h4 a').removeClass('open');
      $('.exxakt-messages .item .content').css('display','none');
    } else {
      $('.exxakt-messages .item h4 a').removeClass('open');
      $('.exxakt-messages .item .content').css('display','none');
      $(this).addClass('open');
      $(this).parent('h4').next('div.content').css('display','block');
    }
    return false;
  });
  
  //$('#toplink').append('<a id="printlink" href=\"javascript:window.print();\"><img src="'+templatepath+'images/ico_printlink.png" alt=""> Diese Seite drucken</a>');

});
