var j = jQuery.noConflict();

j(document).ready(function() {
  resize();
  j(window).resize(function(){ resize(); });
  j(window).load(function(){ resize(); });
  
  j.superbox.settings = {
    closeTxt: 'schließen x',
    loadTxt: '<img src="wp-content/themes/hse/images/lightbox-loading.gif" alt="" />',
    nextTxt: '<img src="wp-content/themes/hse/images/lightbox-next.jpg" alt="" />',
    prevTxt: '<img src="wp-content/themes/hse/images/lightbox-prev.jpg" alt="" />'
  }; 
  j.superbox();
});

function resize() {
  var headerHeight = 200;
  var footerTop = 200;
  var footerHeight = 27;
  var mainHeight = j('#main').height();
  var windowHeight = j(window).height();
  var windowWidth = j(window).width();
  var totalTop = headerHeight + mainHeight + footerHeight;
  var ie8 = (j.browser.msie && j.browser.version == 8 ? true : false);
  
  if(windowHeight > totalTop) {
    if(!ie8) {
      j('#footer').css('margin-top', footerTop + (windowHeight - totalTop));
    }
    else {
      var tmp = (windowHeight - totalTop - 10);
      j('#footer').css('top', (tmp < 0 ? 0 : tmp));
    }
  }
  else {
    j('#footer').removeAttr('style');
  }
  
  // superbox
  if(j('#superbox').length) {
    var w = (windowWidth - 735) / 2;
		var h = (windowHeight - 565) / 2;
    j('#superbox').css('left', w);
    j('#superbox').css('top', h);
  }
}
