/**
 * Chursächsische Veranstaltungs GmbH - JS: jquery-Funktionen
 *
 *
 * @author Danny Otto | pixelbrand.net
 * @date   2011-06
 *
 *
 */
$(document).ready(function() {
  $('html[lang=de] #f_suche, html[lang=de] #f_suche_1').blur( function() { if(this.value=='') { this.value='Suche'; } } ).focus( function () { if(this.value=='Suche') { this.value=''; } } );
  $('.lightbox').append('<img class="lightbox-icon" src="'+templatepath+'images/ico_lightbox.png" alt="">');
  $('.lightbox a, .gallery a').fancybox({'titlePosition':'inside'});
  $('#toplink').append('<a id="printlink" href=\"javascript:window.print();\"><img src="'+templatepath+'images/ico_printlink.png" alt=""> Diese Seite drucken</a>');
  /* */
  $('#start #events li div.event h3').syncHeight();
  $('#start #events li div.event').syncHeight();
  $('#start #events li div.event').css('cursor','pointer').click( function () { window.location.href = $(this).children('h3').children('a').attr('href'); } );
  /* */
  $('#event-detail .teaser .thumbnails a').click( function () {
    $('#event-detail .teaser .thumbnails a').removeClass('cur');
    $(this).addClass('cur');
    $('#event-detail .teaser #stage img').attr('src',$(this).attr('href'));
    $('#event-detail .teaser #stage img').attr('alt',$(this).children('img').attr('alt')).attr('title',$(this).children('img').attr('title'));
    return false;
  });
  $('#event-detail #nav-trail').append('<a href="javascript:history.back()" class="backlink">zurück</a>')
  
  /* Event-Locations */
  $('#event-config .locations-head input').change( function() {
    var venue = $(this).attr('id');
    if ( $(this).attr('checked') == 'checked' ) {
      $('#event-config .locations-body input.'+venue).attr('checked','checked');
    } else {
      $('#event-config .locations-body input.'+venue).attr('checked',false);
    }
  });
  $('#event-config .locations-body input').change( function() {
    var venue = $(this).attr('class');
    $('#event-config .locations-body input.'+venue).each( function() {
      if ( $(this).attr('checked') != 'checked' ) { $('#'+venue).attr('checked',false); return false; }
      $('#event-config #'+venue).attr('checked','checked');
    });
  });
  $('#event-config form div.subcolumns').css('display','none');
  $('#event-config form div.checkbox').find('.c50r').append('<div class="type-link"><a href="#" class="all">alles auswählen</a> <a href="#" class="none">nichts auswählen</a></div>');
  $('#event-config form legend').click( function() {
    $(this).toggleClass('open');
    if ($(this).hasClass('open')) {
      $(this).next('div.subcolumns').css('display','block');
    } else {
      $(this).next('div.subcolumns').css('display','none');
    }
  });
  $('#event-config form .type-link .all').click( function () { $(this).parents('.subcolumns').find('input').attr('checked','checked'); return false; });
  $('#event-config form .type-link .none').click( function () { $(this).parents('.subcolumns').find('input').attr('checked',false); return false; });
  
  /* Facebook Like-Button */
  if (navigator.platform == 'MacIntel') { $('body').addClass('MacIntel'); }
  
});
