var body_height_cache;
$(document).ready(function() {
  $(active_categories_selector).addClass('active')
  
  
  setTimeout(function(){
    $('.submenu').css('top', ($('.menu a.active').offset().top - 13) +'px').fadeIn();
    $('.submenu a.active').siblings('ul').show();
    body_height_cache = $('body').outerHeight();
    compute_height();
    $(window).resize(function(){
      compute_height();
    })
  }, 100);
  $('.launch-gallery').click(function(){
    $(this).siblings('.gallery-holder').find('a:first').click();
    return false;
  })
  $('.gallery-holder a').lightBox(
    {
      imageLoading: lb_ico_loading,
      imageBtnPrev: lb_btn_prev,
      imageBtnNext: lb_btn_next,
      imageBtnClose: lb_btn_close,
      imageBlank: lb_blank
    }
  )
  $('.map').jmap('init', {'mapType':'hybrid','mapCenter':[45.813083, 15.966375], 'mapZoom': 17});
  $('.map').jmap('AddMarker', {
		'pointLatLng': [45.813083, 15.966375],
		'pointHTML': '<strong>Biovega</strong><br /><strong>Ilica 72</strong>'})
  $('.required').focus(function(){
    $(this).addClass('activeinput')
  }).blur(function(){
    $(this).removeClass('activeinput')
    if($(this).val() != '')
      $(this).removeClass('error')
  })
  $('#jobboard').submit(function(){
    var submit = true;
    $('.errorstate').hide();
    $('.error').removeClass('error');
    $(this).find('.required').each(function(){
      if($(this).val() == '')
      {
        $(this).addClass('error');
        submit = false;
      }
    })
    if(!submit)
      $('.errorstate').show();
    return submit;
  })
});
function compute_height(){
  var height = body_height_cache;
  if($(window).height() > height)
    height = $(window).height();
  if($(document).height() > height)
    height = $(document).height();
  console.log($(window).height())
  console.log(body_height_cache)
  $('.main-image .submenu-image-holder').height(height);
}
if (! ("console" in window) || !("firebug" in console)) {
  var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
  window.console = {};
  for (var i = 0; i <names.length; ++i) window.console[names[i]] = function() {};
}
