(function ($) {
  $('.iconField').labelify({ text: 'label'});
  $('#site-search').labelify({ text: function(){ return 'Valfri text...';}});
  
  $('.slideDownNav .bd').superfish({
    delay:       1000,                            // one second delay on mouseout 
    animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
    speed:       'fast',                          // faster animation speed 
    autoArrows:  false,                           // disable generation of arrow mark-up 
    dropShadows: false                            // disable drop shadows
  });

  $('#companies').quicknav();
  
  //$('.normalTheme .slideUpTeaser').slideUpTeaser({ speed: 'fast'});
  
  $('.gallery').simplestSlideShow({ timeOut: 10000 });
  
  $('.childItem .label').hoverIcon();
  
  $('.date input').date_input({
    stringToDate: function(string) {
        var matches;
        if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
          return new Date(matches[1], matches[2] - 1, matches[3]);
        } else {
          return null;
        };
      },

      dateToString: function(date) {
        var month = (date.getMonth() + 1).toString();
        var dom = date.getDate().toString();
        if (month.length == 1) month = "0" + month;
        if (dom.length == 1) dom = "0" + dom;
        return date.getFullYear() + "-" + month + "-" + dom;
      }
  });
  
  if ($('#VideoPlayer').length) {
    flowplayer("VideoPlayer", "/mysite/flash/flowplayer-3.1.5.swf");
    flowplayer("VideoPlayer", "/mysite/flash/flowplayer-3.1.5.swf");
  }
})(jQuery);
