﻿
// main js code included in ReportStorms.Master
//
// <script type="text/javascript" src="http://adserver.lat49.com/lat49/lat49.php?ver=1.0"></script>
// where the Lat49 object exists
//

var const_adID = "367";
var const_divID = "div_lat49";
var lat49enabled = true;

var Lat49_left = 0;
var Lat49_top = 0;
//--------------------------------------------------//
// Function to let the lat49 js set up the ad cache //
//--------------------------------------------------//
function Lat49_InitAds()
  {
  if(!lat49enabled) return;
  Lat49.initAds(const_adID);
  
  var mapDiv = document.getElementById('div_VEMap');
  
  // create it
  var lat49Div = document.createElement('div');
  lat49Div.setAttribute('id', const_divID);
  lat49Div.style.width = 242;
  lat49Div.style.height = 133;
  lat49Div.style.position = "absolute";
  lat49Div.style.top = 0;
  lat49Div.style.left = 0;
  lat49Div.style.zIndex = 3;
  
  // if both exist, set the child relationship and the content of the overlay    
    if((mapDiv != null) && (lat49Div != null))
      mapDiv.appendChild(lat49Div);
  }
//----------------------------------------------------//
// Helper function called after map events (pan/zoom) //
// to load new local adds                             // 
//----------------------------------------------------//
function Lat49_UpdateAdsByLatLon(lat, lon, zoom)
  {
  if(!lat49enabled) return;
  Lat49.updateAdByLatLon(const_divID, lat, lon ,zoom);
  }
//----------------------------------------------------//
// Helper function called after a resize              //
//----------------------------------------------------//
function Lat49_Resize(mapWidth, mapHeight)
  {
  if(!lat49enabled) return;
  var lat49Div = document.getElementById(const_divID);
  var width = parseInt(lat49Div.style.width, 10);
  var height= parseInt(lat49Div.style.height, 10);

  Lat49_left = 10; //mapWidth - width - 10;
  Lat49_top = mapHeight - height - 40;
   
  lat49Div.style.left = Lat49_left;
  lat49Div.style.top = Lat49_top;
  }
//------------------------------------------------------//
// Mouse helpers, so know to block clicks to other      //
// controls and take it for the lat49 div               //
//------------------------------------------------------//
function Lat49_OverLat49Div(x, y) 
  { 
  if(!lat49enabled) return false;

  var lat49Div = document.getElementById(const_divID);
  var width = parseInt(lat49Div.style.width, 10);
  var height= parseInt(lat49Div.style.height, 10);

  if((x >= Lat49_left) && (x < Lat49_left + width) &&
     (y >= Lat49_top)  && (y < Lat49_top + height))
    {
    return true;
    }
  return false;  
  }  
  