function resizeContainer() {
    if ($('#container').height() < $(window).height()) {
        $('#container').height($(window).height());
    }
}
$(document).ready(function() { 
  $('#searchForm #searchBtn').click(function(){
    document.searchForm.submit();
  })

    $('#leftNavigation li.open:last').addClass('active');
    $('#mainNavigation ul li.right:first, #mainNavigation ul li.left:last, #mainNavigation ul ul li:last').css({'border': 'none'});
    $('#print-version a').click(function() {
        print = window.open(window.location.pathname, 'Print', '');
        return false;
    })
    
    //$('body, #footer').css('border', '1px #000 solid');
    resizeContainer();
    if (window.name == "Print") {
        $('*:not(logo)').css('background', 'none');
        $('#top, #topNavigation, #mainNavigation, #mainImage, #leftNavigation, #leftSubNavigation, #leftSubSubNavigation, #blueBox').hide();
        var date = new Date();
        date = date.getDate() + '.' + date.getMonth() + '.' + date.getFullYear() + '.' + date.getHours() + "." + date.getMinutes() + ":" + date.getSeconds();
        $('.main').prepend('<div id="logo" style="position: static; height: 40px;">&nbsp;</div><br /><strong>Eduard Hueck GmbH & Co. KG</strong><hr />')
                 .append('<hr style="clear: both;" /><strong>&nbsp;&nbsp;' + date + '</strong>')
                 .css({'padding': '20px'});
    }
    $('#a-search-button').click(function() {
        if ($('#a-search-form input:checked').attr('value') == 'fenster') {
            $('#a-search-content').html($('#a-search-windows').html());
        }
        else if ($('#a-search-form input:checked').attr('value') == 'industrie') {
            $('#a-search-content').html($('#a-search-profiles').html());
        }
    })
    $('.references-popup a').click(function() {
        window.open($(this).attr('href'), 'Plan', 'width=700,height=600');
        return false;
    })
/* External urls and files open in new window */
    $('a').each(function() {
      var result = $(this).attr('href').match(/([^\.]*)\.(pdf|xls|doc|zip|exe|jpg|gif)/);
      if ((result !== null) || (this.href.indexOf(location.hostname) == -1)) {
        $(this).attr('target', '_blank');
      }
    })
    if ($('h1.main').html() == '&nbsp;') {
        $('h1.main').remove();
    }
    $('.searchQuery')
        .focusin(function() {
            $(this).css('background', '#fff');
        })
        .focusout(function() {
            $(this).css('background', '#E5E7EE');
    })
    $('.content-module.sitemap ul:not(:has(li))').remove();
    // Home scroller
    if ($('#news-ticker').length) {
        $jScroller.add("#nt-container","#nt-wraper","left",5,true);
        $jScroller.start();
    }

  if ($("#leftSubNavigation ul").children().length != 0) {
    $("#leftSubNavigation").show();
  }
    $('#mainNavigation ul.main li').not('#mainNavigation ul.main li li').each(function() {
        //Container width 1000
        pos = $(this).position();
        //alert(pos.left);
        menuOverflow = (pos.left + 200) - 1000;
        if (menuOverflow > 0) {
            $(this).find('ul').css('left', (menuOverflow * (-1) - 10) + 'px'); //800px + 200px menu width = align to right
        }
    })
    $('#mainNavigation ul.main li').not('#mainNavigation ul.main ul li').hover(
        function() {
            $(this).find('ul').stop(true, true).show();
        },
        function() {
            $(this).find('ul').stop(true, true).hide();
        }
    );
    $('#mainNavigation ul.main ul li').hover(
        function() {
            $(this).css('background', '#B1C6E1');
        },
        function() {
            $(this).css('background', '#DEE7F2');
        }
    );
})
 
$(window).resize(function(){
    resizeContainer();
})
/* For contact form */ 
function noenter() {
  return !(window.event && window.event.keyCode == 13); }
