$(document).ready(
  (function () {


      /* From here */

      if ($('.rip').length != 0) {
          $(".rip").rip();
      }



      if ($('.carousel').length != 0) {
          $(".carousel").jCarouselLite({
              visible: 1,
              auto: 4000,
              speed: 500,
              scroll: 1,
              vertical: false
          });
      }

      $("#buttonsearch").click(function () {
          if ($("#textboxsearch").val() != '')
          { window.location = "/search.aspx?search=" + $("#textboxsearch").val() + "&section=" + $("#searchsection").val(); }
          else
          { alert("udfyld venligst noget at søge efter!"); $("#textboxsearch").focus(); }
      });
      $("#textboxsearch").keydown(function (event) {
          /* alert('key:' + event.keyCode + '\r\nOpen Url: /search.aspx?search=' + $("#textboxsearch").val() + "&section=" + $("#searchsection").val()); */
          if (event.keyCode == '13') {
              if ($("#textboxsearch").val() != '') {
                  
                  alert('key:' + event.keyCode + '\r\nOpen Url: /search.aspx?search=' + $("#textboxsearch").val() + "&section=" + $("#searchsection").val());
//                  event.preventDefault();
//                  window.location = "/search.aspx?search=" + $("#textboxsearch").val() + "&section=" + $("#searchsection").val();
//                  event.preventDefault();
//                  return false;
                  
                  
                  /* var key = document.getElementById("buttonsearch");
                  key.click();
                  return false; */
              }
              else
              { alert("udfyld venligst noget at søge efter!"); $("#textboxsearch").focus(); }
          }

      });

      if ($('.iframe.newsletter').length != 0) {
          $(".iframe.newsletter").fancybox({
              'width': 400,
              'height': 250,
              'autoScale': false,
              'transitionIn': 'linear',
              'transitionOut': 'linear',
              'type': 'iframe'
          });
      }

      if ($('#subpagerotation').length != 0) {
          $("#subpagerotation").cycle({
              fx: 'scrollLeft',
              pause:  1,
              delay: 2000,
              before: onBefore
          });
      }

      function onBefore(curr, next, opts, fwd) {
          //get the height of the current slide
          var $ht = $(this).height();
          //set the container's height to that of the current slide
          //$(this).parent().animiate("height", $ht);
          $(this).parent().animate({
              opacity: 1,
              height: $ht
          })
      }



      //alert("ready");

      /* TO here */


  })
);
