function hyperSize() {
  
  // Gather browser and current image size
  var browserwidth = $(window).width();
  var browserheight = $(window).height();
  var imagewidth = 2450;
  var imageheight = 1050;
  
  // Define ratios
  var imageratio = imageheight/imagewidth;
  var browserratio = browserheight/browserwidth;
  
  // Update variables
  window_width = $(window).width();
  window_height = $(window).height();
  
  $('#backgroundOverlay').css({
    'display': 'block'
  });
  
  $('#backgroundImage').width(browserwidth);
  $('#backgroundImage').height(browserheight);
  
  if (browserratio < imageratio){
    $("#backgroundImage img").width(browserwidth);
    $("#backgroundImage img").height(browserwidth * imageratio);
  } else {
    $("#backgroundImage img").height(browserheight);
    $("#backgroundImage img").width(browserheight / imageratio);
  }
  
  // Center
  $("#backgroundImage img").css('margin-left', (browserwidth - $("#backgroundImage img").width())/2);
  $("#backgroundImage img").css('margin-top', (browserheight - $("#backgroundImage img").height())/2);
  
};

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

$(window).resize(function(){
  if ( readCookie('background') != 0 ){
    hyperSize();
  }
});
$(document).ready(function(){
  if ( readCookie('background') != 0 ){
    hyperSize();
  }
});