function maxWindow() {
    window.moveTo(0, 0);


    if (document.all) {
        top.window.resizeTo(screen.availWidth, screen.availHeight);
    }

    else if (document.layers || document.getElementById) {
        if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
            top.window.outerHeight = screen.availHeight;
            top.window.outerWidth = screen.availWidth;
        }
    }
}

window.onload = maxWindow;

function Map (id, loc) {
  
	this.mapElement = document.getElementById(id);
	var myOptions = { zoom: 1  , center: loc, mapTypeId: google.maps.MapTypeId.TERRAIN, mapTypeControl: false, streetViewControl: false, minZoom: 3 };
  var gmap = new google.maps.Map(this.mapElement, myOptions);

  google.maps.event.addListener(gmap, 'dragstart', this.size );  
  google.maps.event.addListener(gmap, 'zoom_changed', this.size );
  google.maps.event.addListener(gmap, 'dragend', this.size );
  google.maps.event.addListener(gmap, 'projection_changed', this.size );
  
  var tvLogo = new Image();
  tvLogo.src = "images/tv_bug.png";
  tvLogo.style.padding = '14px';
  tvLogo.index = 1;
  tvLogo.style.zIndex = 200;
  gmap.controls[google.maps.ControlPosition.TOP_RIGHT].push(tvLogo);

  this.gmap = gmap;
  this.overlay = new MyOverlay(gmap);
  this.size();
  
  $(window).resize(this.size);
}

Map.prototype.size = function () {
  var w = $(window).width() + 'px';
	$('#map').css({width: w, height: $(window).height() - $('#controls').height() - 9 + 'px'});
  $('#controls').css({width: w});
  if (this.overlay) this.overlay.clear();
  $('.infoWindow').remove();
  $('.thumbnail').remove();
  Tweet.updatingDisplay = true;
  if (this.resizeTimer) clearTimeout(this.resizeTimer);
  this.resizeTimer = setTimeout(function () {
      Tweet.updatingDisplay = false;
      $('#controls').fadeIn(300);
      if (Tweet.map && Tweet.map.overlay) {
        Tweet.map.overlay.draw();
      }
      Tweet.startStream();
    }, 500);
}

