$(document).ready(function(){   

  $(function() {
    $('.gallery #main ul a').lightBox();
  });   
  
  $(function() {
    $('ul#impressionen a').lightBox();
  });
  
  $('#scroller').jScrollPane({
    scrollbarWidth: 6
  });   
  $('#text_scroller').jScrollPane({
    scrollbarWidth: 6,
    scrollbarMargin: 20
  }); 
  
  var $fahrbewilligung_form = $("#fahrbewilligung_form")
  if($fahrbewilligung_form.length > 0){ 
    $fahrbewilligung_form.validate({
      //set the rules for the fild names
      rules: {   
        'attendee[category]'  : { required: true },
        'attendee[category_2]': { required: true },
        'attendee[name]'      : { required: true },
        'attendee[first_name]': { required: true },
        'attendee[birthday]'  : { required: true },
        'attendee[street]'    : { required: true },
        'attendee[plz]'       : { required: true, number: true },
        'attendee[city]'      : { required: true },
        'attendee[mobile]'    : { required: true, phone: true },
        'attendee[email]'     : { required: true, email: true },
        'agbs'                : { required: true }
      },
      //set messages to appear inline
      messages: {   
        'attendee[category]'  : 'Bitte Automarke eingeben',
        'attendee[category_2]': 'Bitte Kontrollschild eingeben',
        'attendee[name]'      : 'Bitte Ihren Namen eingeben',  
        'attendee[first_name]': 'Bitte Ihren Namen eingeben',  
        'attendee[birthday]'  : 'Bitte Ihren Geburtstag eingeben',
        'attendee[mobile]'    : 'Bitte nur Ziffern eingeben',
        'attendee[street]'    : 'Bitte Adresse eingeben',
        'attendee[city]'      : 'Bitte Stadt eingeben',
        'attendee[plz]'       : 'Bitte PLZ eingeben',
        'attendee[email]'     : 'Bitte Ihre E-Mail eingeben',
        'agbs'                : 'Bitte ABGs zustimmen' 
      }
    });   
  }

  var $sm_form = $("#sm_2010_form");
  if($sm_form.length > 0){ 
    $sm_form.validate({
      //set the rules for the fild names
      rules: {    
        'attendee[name]'      : { required: true },
        'attendee[first_name]': { required: true },
        'attendee[license]'   : { required: true },
        'attendee[uci_code]'  : { required: true },
        'attendee[team]'      : { required: true },
        'attendee[birthday]'  : { required: true },
        'attendee[street]'    : { required: true },
        'attendee[plz]'       : { required: true, number: true },
        'attendee[city]'      : { required: true },
        'attendee[mobile]'    : { required: true, phone: true },
        'attendee[email]'     : { required: true, email: true },
        'agbs'                : { required: true }
      },
      //set messages to appear inline
      messages: {   
        'attendee[name]'      : 'Bitte Ihren Namen eingeben',  
        'attendee[first_name]': 'Bitte Ihren Namen eingeben',  
        'attendee[license]'   : 'Bitte Lizenznummer eingeben',
        'attendee[uci_code]'  : 'Bitte UCI Code eingeben',
        'attendee[team]'      : 'Bitte Team eingeben',
        'attendee[birthday]'  : 'Bitte Ihren Geburtstag eingeben',
        'attendee[mobile]'    : 'Bitte nur Ziffern eingeben',
        'attendee[street]'    : 'Bitte Adresse eingeben',
        'attendee[city]'      : 'Bitte Stadt eingeben',
        'attendee[plz]'       : 'Bitte PLZ eingeben',
        'attendee[email]'     : 'Bitte Ihre E-Mail eingeben',
        'agbs'                : 'Bitte ABGs zustimmen' 
      }
    });   
  }
  

  $("#sm_2010_form").submit(function(){
    var cat_1 = $(this).find('#attendee_category').attr('value');
    var cat_2 = $(this).find('#attendee_category_2').attr('value');
    if(cat_1 == ' ' && cat_2 == ' '){
      $('#select_errors').html("Bitte Kategorie Auswählen");
      return false;
    }
  });

  $('#attendee_category, #attendee_category_2').change(function(){
    var cat_1 = $('#attendee_category').attr('value');
    var cat_2 = $('#attendee_category_2').attr('value');
    $('#select_errors').html(' ');
    if(cat_1 == ' ' && cat_2 == ' '){
      $('#select_errors').html("Bitte Kategorie Auswählen");
    }
  });
  
  var $form = $("#register")
  if($form.length > 0){ 
    $form.validate({
      //set the rules for the fild names
      rules: {    
        'attendee[name]'      : { required: true },
        'attendee[first_name]': { required: true },
        'attendee[birthday]'  : { required: true },
        'attendee[street]'    : { required: true },
        'attendee[plz]'       : { required: true, number: true },
        'attendee[city]'      : { required: true },
        'attendee[mobile]'    : { required: true, phone: true },
        'attendee[email]'     : { required: true, email: true },
        'agbs'                : { required: true }
      },
      //set messages to appear inline
      messages: {   
        'attendee[name]'      : 'Bitte Ihren Namen eingeben',  
        'attendee[first_name]': 'Bitte Ihren Namen eingeben',  
        'attendee[birthday]'  : 'Bitte Ihren Geburtstag eingeben',
        'attendee[mobile]'    : 'Bitte nur Ziffern eingeben',
        'attendee[telephone]' : 'Bitte nur Ziffern eingeben',
        'attendee[street]'    : 'Bitte Adresse eingeben',
        'attendee[city]'      : 'Bitte Stadt eingeben',
        'attendee[plz]'       : 'Bitte PLZ eingeben',
        'attendee[email]'     : 'Bitte Ihre E-Mail eingeben',
        'agbs'                : 'Bitte ABGs zustimmen'
      }
    });   
  }    
  
  $('a[href^=http]').click(function(){
    window.open( $(this).attr('href') );
    return false;
  });
               
  
});
