
// 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 = false;

var Lat49_left = 0;
var Lat49_top = 0;
//--------------------------------------------------//
// Function to let the lat49 js set up the ad cache //
//--------------------------------------------------//
function Lat49_InitAds()
  {
  // PREMIUM HACK!!!
  if(!lat49enabled)
    {
    var mapDiv = document.getElementById('div_VEMap');
  
    // create it
    var lat49Div = document.createElement('div');
    lat49Div.setAttribute('id', const_divID);
    lat49Div.style.width = 200;
    lat49Div.style.height = 110;  // really 105, giving a bit of padding
    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))
        {
        // SWF
        mapDiv.appendChild(lat49Div);
        LoadSwf("pinpoint lightning 300 x 100.swf", lat49Div, '300', '100'); 
        // IMAGE
        // var img = document.createElement("IMG");
	  // img.src = "mywxcmobile2.jpg"; //"RS_PWSnow.gif";
	  // lat49Div.appendChild(img);
        }
    }    
  else
    {
    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);
    }    
  }
function LoadSwf(swfPath, parent, width, height)
  {
  var swfObject = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ";
  swfObject += "width='" + width + "' height='" + height + "' "
  swfObject += "codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'> ";
  swfObject += "<param name='movie' value='" + swfPath + "' /> ";
  swfObject += "<param name='quality' value='high' /> ";
  swfObject += "<param name='bgcolor' value='#869ca7' /> ";
  swfObject += "<param name='allowScriptAccess' value='sameDomain' /> ";
  swfObject += "<embed src='" + swfPath + "' quality='high' bgcolor='#869ca7' ";
  swfObject += "width='" + width + "' height='" + height + "' align='middle' ";
  swfObject += "play='true' ";
  swfObject += "loop='false' ";
  swfObject += "quality='high' ";
  swfObject += "allowScriptAccess='sameDomain' ";
  swfObject += "type='application/x-shockwave-flash' ";
  swfObject += "pluginspage='http://www.adobe.com/go/getflashplayer' ";
  swfObject += "wmode='opaque'> ";
  swfObject += "</embed> ";
  swfObject += "</object> ";
  parent.innerHTML = swfObject;
  }



//----------------------------------------------------//
// 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))
    {
    // redirect here
    //  var redirTarget = 'http://pmc.myweather.net/landing.asp?area=PPM_LANDINGPAGE&pageid=landing&host=PW&c=RS_PW_winter_Map&trackid=RS_PW_winter_Map';
      var redirTarget = 'http://www.myweather.com/bb.html';
    //  var newwindow = window.open();
      var newwindow = window.open(redirTarget);
      if(newwindow == null)
        window.location = redirTarget;      
      else
        {
        if (window.focus) {newwindow.focus()}
        }
    return true;
    }
  return false;  
  }  
  