// ---------- DO NOT REMOVE THIS CODE.  It is conditionally compiled for IE -------------
/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
@end @*/
//---------------------------------------------------------------------------------------






















var currentYear = 2009;
var currentStorm = "";
var xmlhttp = false;

var radar = false;
var clouds = false;
var models = false;
var hunter = false;
var mapType = "hybrid";
var pageLoaded = false;
var animating = false;
var mouseOverMap = false;
var atMinZoomLevel = false;
var btnNationalView_state = false;

var map;
var mode;
var stormCells;
var browser = "true";
var hostType;   //possible values: "1", "2", "3", "4", "5"   
var tileType;   //possible values: "MSVE", "MYWX"                  
var spotlightZoom;
var spotlightLat;
var spotlightLon;
var localZoom;
var localLat;
var localLon;
var minZoom;
var maxZoom;
var promptZoom;
var initialZoom;
var imageDir;
var tpSlider_n_controlWidth;
var tpSlider_n_controlHeight;
var tpSlider_n_sliderWidth;
var tpSlider_n_sliderHeight;
var tpSlider_n_pathLeft;
var tpSlider_n_pathTop;
var tpSlider_n_pathLength;

var numTabs = 5;
var tabSections = new Array();
tabSections[0] = "currentTab";
tabSections[1] = "updatesTab";
tabSections[2] = "pastTab";
tabSections[3] = "photosTab";
tabSections[4] = "helpTab";

var displayedHurricanes = new Array();
var hurricaneCnt = 0;

function OnPageLoaded()
{    
    InitPage();
    
    fadeOut("ad1a", 10000);
    fadeOut("adClose", 10000);
    
    loadYearStorms();
}


function InitPage()
{            
    HookEvents();    
    MouseWheelSetup();                                                   
    
    pageLoaded = true;               
}


function AssignMapReference()
{
    if (navigator.appName.indexOf('Microsoft') != -1)
    {map = window.InteractiveWeatherFlash;}
    else
    {map = document.InteractiveWeatherFlash;}     
}


function MouseWheelSetup()
{       
    if (window.addEventListener)
    {
        //DOMMouseScroll is for mozilla.
        window.addEventListener('DOMMouseScroll', OnMouseWheel, false);
    }

    // IE/Opera.
    window.onmousewheel = document.onmousewheel = OnMouseWheel;   
}


//Event handler for mouse wheel event.
function OnMouseWheel(event)
{
    if (mouseOverMap)
    {
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                {
                    //alert("opera");
                    //delta = -delta;
                }
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
        {
            //handleMouseWheel(delta);
            if (delta < 0)
		    {
		        //alert("ZOOMout");
		        btnZoomOut_Click()
		    }
            else
		    {
		        //alert("zoomIN");
		        btnZoomIn_Click()
		        MakeZoomPanControlsVisible(true);
			    ToggleAllViewStateButtonsOff(true);
		    }
		    
        }
                
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
	}
}


function btnZoomIn_Click()
{
    atMinZoomLevel = false;
    map.ZoomIn();    
}


function btnZoomOut_Click()
{
    atMinZoomLevel = false;
    map.ZoomOut();   
}


function HookEvents()
{
    if (document.getElementById('btnNationalView') != null)
    {
        document.getElementById('btnNationalView').onclick = btnNationalView_Click;    
        document.getElementById('btnNationalView').onmouseover = btnNationalView_MouseOver;
        document.getElementById('btnNationalView').onmouseout = UpdateAllViewStateButtonGraphics;    
    }
    
    //zoom
    if (document.getElementById('btnZoomIn') != null)
    {       
        document.getElementById('btnZoomIn').onclick = btnZoomIn_Click;
        document.getElementById('btnZoomOut').onclick = btnZoomOut_Click;
    }

    //pan
    if (document.getElementById('panToolButton_up') != null)
    {document.getElementById('panToolButton_up').onclick = panTool_ClickUp;}
    
    if (document.getElementById('panToolButton_down') != null)
    {document.getElementById('panToolButton_down').onclick = panTool_ClickDown;}
    
    if (document.getElementById('panToolButton_left') != null)
    {document.getElementById('panToolButton_left').onclick = panTool_ClickLeft;}
    
    if (document.getElementById('panToolButton_right') != null)
    {document.getElementById('panToolButton_right').onclick = panTool_ClickRight;}
       
    //radar
    if (document.getElementById('btnAnimate') != null)
    {
        document.getElementById('btnAnimate').onclick = btnAnimate_Click;    
        document.getElementById('btnAnimate').onmouseover = btnAnimate_MouseOver;
        document.getElementById('btnAnimate').onmouseout = btnAnimate_MouseOut;
    }        
      
    //interactiveRadar div
    if (document.getElementById('interactiveRadar') != null)
    {
        document.getElementById('interactiveRadar').onmouseover = interactiveRadar_MouseOver;
        document.getElementById('interactiveRadar').onmouseout = interactiveRadar_MouseOut;
    }
    
    //some event handler facilitator functions (parameters can't be passed when assigning the event handler to the control, so we do it here)
    function btnNationalView_MouseOver() {SetImageSrc('btnNationalView', 'btn_nationalview_on.gif');} 
    function panTool_ClickUp() {panTool_Click('up');}
    function panTool_ClickDown() {panTool_Click('down');}
    function panTool_ClickLeft() {panTool_Click('left');}
    function panTool_ClickRight() {panTool_Click('right');}
    function interactiveRadar_MouseOver() {OverMap(true);}
    function interactiveRadar_MouseOut() {OverMap(false);}     

    function btnTropicView_MouseOver() {SetImageSrc('btnTropicView', 'tov_b.gif');}
    function btnTropicView_MouseOut() {SetImageSrc('btnTropicView', 'tov_a.gif');}
}
                      

function ToggleModels()
{
    models = (!models);
    if (models)
    {
        SetImageSrc("chkBoxModels", "selection_checked.gif");     
        SetImageSrc("legendImg", "models_legend.png");
        document.getElementById("legend").style.display="none";
        document.getElementById("legend").style.visibility = "hidden";
        ShowLines();
    }
    else
    {
        SetImageSrc("chkBoxModels", "selection_unchecked.gif");
        SetImageSrc("legendImg", "");
        document.getElementById("legend").style.display="block";
        document.getElementById("legend").style.visibility = "visible";
        HideLines();
    }      
}

function ToggleHunter()
{
    hunter = (!hunter);
    if (hunter)
    {
        SetImageSrc("chkBoxHunter", "selection_checked.gif");   
        map.ShowGroup("hunter");  
    }
    else
    {
        SetImageSrc("chkBoxHunter", "selection_unchecked.gif");
        map.HideGroup("hunter");
        CloseWindow('hunterPopup');
    }      
}

function ToggleClouds()
{  
    clouds = (!clouds);
    if (clouds)
    {
        SetImageSrc("chkBoxClouds", "selection_checked.gif");   
        map.SectorLayer("infrared");     
    }
    else
    {
        SetImageSrc("chkBoxClouds", "selection_unchecked.gif");  
        map.SectorLayer("");
    }      
}
         
         
function ToggleLatLon()
{
    var lines = map.ToggleLatLonLines();
    if (lines)
    {
        SetImageSrc("chkBoxLatLon", "selection_checked.gif");
        SetImageSrc("chkBoxLatLonPast", "selection_checked.gif");
    }
    else
    {
        SetImageSrc("chkBoxLatLon", "selection_unchecked.gif");
        SetImageSrc("chkBoxLatLonPast", "selection_unchecked.gif");
    }
}

    
function RadarChange()
{  
    map.SectorLayer("infrared");     
}

                      
function ToggleIcons(token)
{    
    var visible;
    var id;
    var image;
    
    visible = map.ToggleIcons(token);
    
    if (visible)
    {image = "selection_checked.gif";}
    else
    {image = "selection_unchecked.gif";}
        
    switch (token)
    {
        case 'premiumlocations':
            id = "chkLocations";            
            break;
        case 'premiummileagescales':
            id = "chkMileageScales";
            break;
        case 'premiumstorms':
            id = "chkStormCells";
            break;
        case 'premiumlightnings':
            id = "chkLightning";
            break;
        case 'stormcells':
            id = "chkStormCells_ESPOnline";
            break;
        default: 
            alert("ERROR - ToggleIcon() - unknown icon type: " + token);
    }
    
    SetImageSrc(id, image);     
}      


function ShowMap()
{
    var requiredMajorVersion = 9;
    var requiredMinorVersion = 0;
    var requiredRevision = 115;        

    if ((isIE)||(DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision)))
    {
        var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();                    
        var movie = "flash/InteractiveWeather.swf?cb=" + cb;

        WriteFlash(movie, 650, 381, "InteractiveWeatherFlash");   //writing the object tag from within an external js file will get rid of the annoying "click to use" message
                  
        //NOTE: Although the following script may seem optional, it is the fix for a known IE problem. If the flash movie exists within a <form> tag, external interface calls will not work correctly without this script.
        if (navigator.appName.indexOf('Microsoft') != -1)
        {window.InteractiveWeatherFlash = document.getElementById('InteractiveWeatherFlash');}           
    }
    else
    {
        var s = "<html><body><table border='0' width='650' height='370' style='background-color:#D8DCE8; font-size:18px;font-family:arial;font-weight:bolder'><tr><td width='100%' align='center' style='padding-top:85px;padding-left:40px;padding-right:40px;'>In order to view this presentation, you will need to install a newer version of the Flash Player plug-in.  <a href='http://www.adobe.com/go/getflashplayer'>Get it here!</a>";            
        s += "<br><a href='http://www.adobe.com/go/getflashplayer'><img src='images/adobe_flash_logo.jpg' alt='Get Flash Player' title='Get Flash Player' border='0'></a></td></tr></table></body></html>";
        document.write(s);
    } 
    
     AssignMapReference();
}   
    
        
function ShowLegend()
{
    var requiredMajorVersion = 9;
    var requiredMinorVersion = 0;
    var requiredRevision = 115;        
    if ((isIE)||(DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision)))
    {
        var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();                    
        var movie = "flash/htTrack.swf?cb=" + cb;
        
        WriteFlash(movie, 400, 45, "legend");   //writing the object tag from within an external js file will get rid of the annoying "click to use" message
                  
        //NOTE: Although the following script may seem optional, it is the fix for a known IE problem. If the flash movie exists within a <form> tag, external interface calls will not work correctly without this script.
        if (navigator.appName.indexOf('Microsoft') != -1)
        {window.InteractiveWeatherFlash = document.getElementById('legend');}           
    }
//    else
//    {
//        var s = "<html><body><table border='0' width='650' height='20' style='background-color:#D8DCE8; font-size:18px;font-family:arial;font-weight:bolder'><tr><td width='100%' align='center' style='padding-top:85px;padding-left:40px;padding-right:40px;'>In order to view this presentation, you will need to install a newer version of the Flash Player plug-in.  <a href='http://www.adobe.com/go/getflashplayer'>Get it here!</a>";            
//        s += "<br><a href='http://www.adobe.com/go/getflashplayer'><img src='images/adobe_flash_logo.jpg' alt='Get Flash Player' title='Get Flash Player' border='0'></a></td></tr></table></body></html>";
//        document.write(s);
//    } 
}                


function ToggleAllViewStateButtonsOff(updateGraphics)
{
    btnNationalView_state = false;

    if (updateGraphics)
    {
        UpdateAllViewStateButtonGraphics();
    }    
}


function MapZoomLevelChanged(zoomLevel, atMinZoom)
{
    atMinZoomLevel = atMinZoom;
    MakeZoomPanControlsVisible(!atMinZoom);  
}


function UpdateAllViewStateButtonGraphics()
{
    //National
    if (btnNationalView_state)
    {SetImageSrc('btnNationalView', 'btn_nationalview_on.gif');}
    else
    {SetImageSrc('btnNationalView', 'btn_nationalview_off.gif');}     
        
    //show or hide zoom & pan controls?
    MakeZoomPanControlsVisible(!btnNationalView_state);   
}


function MakeZoomPanControlsVisible(visible)
{  
    //if (atMinZoomLevel){visible = false;}
    
    var display = "none";
    var visibility = "hidden";
    
    if (visible)
    {   
        display = "inline";
        visibility = "visible";       
    }
    
    document.getElementById('zoomBG').style.display = display;
    document.getElementById('zoomBG').style.visibility = visibility;
    document.getElementById('zoomIn').style.display = display;
    document.getElementById('zoomIn').style.visibility = visibility;
    document.getElementById('zoomOut').style.display = display;
    document.getElementById('zoomOut').style.visibility = visibility;
    document.getElementById('panTool').style.display = display;
    document.getElementById('panTool').style.visibility = visibility;
    
}


function WriteFlash(movie, width, height, id)
{
    //running this script in an external script file to write the flash movie will eliminate the annoying "Click to activate ..." popup
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" id="' + id + '" width="' + width + ' " height="' + height + '">\n');
    document.write('<param name="allowScriptAccess" value="always" />\n');
    document.write('<param name="allowNetworking" value="all" />\n');
    document.write('<param name="movie" value="' + movie + '" />\n');
    document.write('<param name="wmode" value="transparent" />\n');
    document.write('<param name="quality" value="high" />\n');
    document.write('<param name="bgcolor" value="#FFFFFF" />\n');
    document.write('<embed src="' + movie + '" name="' + id + '" quality="high" wmode="transparent" scale="exactfit" bgcolor="#FFFFFF" width="' + width + '" height="' + height + '" allowScriptAccess="always" allownetworking="all" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />\n');
    document.write('</object>\n');
}
   
        
function panTool_Click(direction)
{
    if (!btnNationalView_state)
    {
    
        ToggleAllViewStateButtonsOff(true);
        
        if (navigator.appName.indexOf('Microsoft') != -1)
        {window.InteractiveWeatherFlash.PanRequest(direction);}
        else
        {document.InteractiveWeatherFlash.PanRequest(direction);}       
        
    }
}         


function RadarAnimationStoppedByMovie()
{
    if (animating)
    {
        animating = false;
        SetAnimationGuiDisplay();
    }    
}


function btnAnimate_Click()
{
    animating = (!animating);
        
    if (animating)
    {SetAnimationGuiDisplay();}
    else
    {btnAnimate_MouseOver();}
    
    map.AnimateRadar(animating);
}


function btnAnimate_MouseOver()
{
    if(!animating)
    {SetImageSrc("btnAnimate", "btn_animate_off_over.gif");}    
}


function btnAnimate_MouseOut()
{
    if(!animating)
    {SetImageSrc("btnAnimate", "btn_animate_off.gif");}    
}


function SetAnimationGuiDisplay()
{
    if (animating)
    {
        SetImageSrc("btnAnimate", "btn_animate_on.gif");        
    }
    else
    {
        SetImageSrc("btnAnimate", "btn_animate_off.gif");    
    }        
}


function ToggleMapType(newMapType)
{
    if (mapType == newMapType)
    {return;}        
   
    mapType = newMapType;
    
    if (mapType == "hybrid")
    {
        SetImageSrc("chkHybridMap", "selection_radio_on.gif");
        SetImageSrc("chkRoadMap", "selection_radio_off.gif");
        
        if (navigator.appName.indexOf('Microsoft') != -1)
        {window.InteractiveWeatherFlash.ShowHybridMap();}
        else
        {document.InteractiveWeatherFlash.ShowHybridMap();}        
    }
    else
    {
        SetImageSrc("chkRoadMap", "selection_radio_on.gif");
        SetImageSrc("chkHybridMap", "selection_radio_off.gif");    
        
        if (navigator.appName.indexOf('Microsoft') != -1)
        {window.InteractiveWeatherFlash.ShowRoadMap();}
        else
        {document.InteractiveWeatherFlash.ShowRoadMap();}     
    }            
}


function btnNationalView_Click()
{
    ToggleAllViewStateButtonsOff(false);
    btnNationalView_state = true;
    UpdateAllViewStateButtonGraphics();
   
    map.ShowNationalView();
}


function RadarOpacity_Changed(value)
{
    document.getElementById('radarOpacitySliderLabel').innerHTML =  value + "%";
    
    if (pageLoaded)
    {
        map.SetRadarOpacity(Math.abs(value - 100) / 100);
    }
}


function CreateOpacitySlider()
{
    var A_TPL = {
                'b_vertical' : false,
                'b_watch': true,
                'n_controlWidth': tpSlider_n_controlWidth,
                'n_controlHeight': tpSlider_n_controlHeight,
                'n_sliderWidth': tpSlider_n_sliderWidth,
                'n_sliderHeight': tpSlider_n_sliderHeight,
                'n_pathLeft' : tpSlider_n_pathLeft,
                'n_pathTop' : tpSlider_n_pathTop,
                'n_pathLength' : tpSlider_n_pathLength,
                's_imgControl': null,
                's_imgSlider': imageDir + '/opacity_slider.gif',
                'n_zIndex': 1
                }
    var A_INIT = {
                's_form' : 0,
                's_name': 'radarOpacity',
                'n_minValue' : 0,
                'n_maxValue' : 100,
                'n_value' : 39,
                'n_step' : 1
                }
           
    new slider(A_INIT, A_TPL, RadarOpacity_Changed);
}


function displayPageFromFlash(url, xPos, yPos, width, height)
{   
    height = 95;
    yPos += 15;
	document.getElementById('popup').style.display = "block";
	document.getElementById('popup').style.width = width + 'px';
	document.getElementById('popup').style.height = height + 'px';
	document.getElementById('popup').style.left = xPos + 'px';
	document.getElementById('popup').style.top = yPos + 'px';

	var html = '<iframe frameborder="0" allowtransparency="true" scrolling="no" src="' + url + '" width="' + width + '" height="' + height + '"></iframe>';
    
	document.getElementById('popup').innerHTML = html;
	
}


function hidePageFromFlash()
{
	document.getElementById('popup').style.display = 'none';
	document.getElementById('hunterPopup').style.display = 'none';
}		


function OverMap(over)
{
    mouseOverMap = over;
}
   
function SetInitialValues(hosttype, minzoom, maxzoom,  initialzoom, promptzoom, spotlightzoom, spotlightlat, spotlightlon, localzoom, locallat, locallon, stormcells, tiletype)
{
    hostType = hosttype;
    minZoom = minzoom;
    maxZoom = maxzoom;
    initialZoom = initialzoom;
    promptZoom = promptzoom;
    spotlightZoom = spotlightzoom;
    spotlightLat = spotlightlat;
    spotlightLon = spotlightlon;
    localZoom = localzoom;
    localLat = locallat;
    localLon = locallon;
    stormCells = stormcells;    
    tileType = tiletype;
   
    imageDir = "images/";
    
    //transparency slider setup
    tpSlider_n_controlWidth = 71;
    tpSlider_n_controlHeight = 6;
    tpSlider_n_sliderWidth = 9;
    tpSlider_n_sliderHeight = 18;
    tpSlider_n_pathLeft = 108;
    tpSlider_n_pathTop = 37;
    tpSlider_n_pathLength = 64;       
}


function SetImageSrc(id, image)
{
    if (document.getElementById(id) != null)
    {
         document.getElementById(id).src = imageDir + image;
    }   
}


function SetInnerText(id, text)
{
    if (document.getElementById(id) != null)
    {
        if(document.all)
        {
            document.getElementById(id).innerText = text;
        } 
        else
        {
            document.getElementById(id).textContent = text;
        }         
    }       
}


function RemoveAllHurricanes()
{
    var hurricaneCount = map.RemoveAllHurricanes();    
}


function LoadActiveStorms()
{
    var oDoc = null;
    var stormXml = "<root>{storm.forxml}</root>";
    
    try
    {
        oDoc = new ActiveXObject("Microsoft.XMLDOM");
        oDoc.async = false;
        oDoc.loadXML(stormXml);
    } //try
    catch(e)
    {
        try
        {
            parser = new DOMParser();
            oDoc = parser.parseFromString(stormXml, "text/xml");
        }
        catch(e)
        {}
    } //catch
    
    try
    {
        if ((map == null) || (map == 'undefined')) AssignMapReference();
    }
    catch(e)
    {
        AssignMapReference();
    }

    try
    {
        var hurricane = null;
        var stormId = new Array();
        var stormCnt = 0;
        var stormNode = oDoc.getElementsByTagName("activestorms");
        var lastID = "";
        var totalNodes = stormNode.length;
        for (var i = 0; i < totalNodes; i++)
        {
            var propertyNodes = stormNode[i].childNodes;
            var id = GetElementValue(propertyNodes[1]);
            var name = GetElementValue(propertyNodes[3]);
            var year = GetElementValue(propertyNodes[5]);
            if (id != lastID) //next hurricane
            {
                if (hurricane != null)  //add hurricane before moving on to next one
                {
                    stormCnt = map.AddHurricane(hurricane);
                }
                hurricane = new Hurricane();
                hurricane.stormid = id;
                hurricane.stormname = name;
                hurricane.year = year;
                stormId[stormCnt] = id;
                lastID = id;
            }
            var observation = new HurricaneObservation();
            observation.stormid = id;
            observation.advisorynumber = GetElementValue(propertyNodes[2]);
            observation.stormname = name;
            observation.stormtype = GetElementValue(propertyNodes[4]);
            observation.year = year;
            observation.month = GetElementValue(propertyNodes[6]);
            observation.day = GetElementValue(propertyNodes[7]);
            observation.hour = GetElementValue(propertyNodes[8]);
            observation.status = GetElementValue(propertyNodes[9]);
            observation.lat = GetElementValue(propertyNodes[10]);
            observation.lon = GetElementValue(propertyNodes[11]);
            observation.direction = GetElementValue(propertyNodes[12]);
            observation.speed = GetElementValue(propertyNodes[13]);
            observation.maxwind = GetElementValue(propertyNodes[14]);
            observation.gusts = GetElementValue(propertyNodes[15]);
            observation.centralpressure = GetElementValue(propertyNodes[16]);
            observation.ne34 = GetElementValue(propertyNodes[17]);
            observation.se34 = GetElementValue(propertyNodes[18]);
            observation.sw34 = GetElementValue(propertyNodes[19]);  
            observation.nw34 = GetElementValue(propertyNodes[20]);
            observation.ne50 = GetElementValue(propertyNodes[21]);
            observation.se50 = GetElementValue(propertyNodes[22]);
            observation.sw50 = GetElementValue(propertyNodes[23]);
            observation.nw50 = GetElementValue(propertyNodes[24]);
            observation.ne64 = GetElementValue(propertyNodes[25]);
            observation.se64 = GetElementValue(propertyNodes[26]);
            observation.sw64 = GetElementValue(propertyNodes[27]);
            observation.nw64 = GetElementValue(propertyNodes[28]);
            observation.pressuredatareported = GetElementValue(propertyNodes[29]);
            observation.winddatareported = GetElementValue(propertyNodes[30]);
            observation.windgustsreported = GetElementValue(propertyNodes[31]);
            observation.windradiireported = GetElementValue(propertyNodes[32]);
            observation.windradiineverreported = GetElementValue(propertyNodes[33]);
            observation.source = GetElementValue(propertyNodes[34]);
            //observation.forecastRadius = GetElementValue(propertyNodes[35]);
           
            var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString(); 
            if (observation.status == "ACTUAL")
            {
                observation.url = "http://hurricanetracker.myweather.net/ht2/obs.html?nm=" + observation.stormname + "&typ=" + observation.stormtype + "&year=" + observation.year + "&month=" + observation.month + "&day=" + observation.day + "&hour=" + observation.hour + "&wind=" + observation.maxwind + "&pres=" + observation.centralpressure + "&lat=" + observation.lat + "&lon=" + observation.lon + "&id=" + observation.stormid + "&cb=" + cb;
            }
            else
            {
                observation.url = "http://hurricanetracker.myweather.net/ht2/forecast.html?nm=" + observation.stormname + "&typ=" + observation.stormtype + "&year=" + observation.year + "&month=" + observation.month + "&day=" + observation.day + "&hour=" + observation.hour + "&wind=" + observation.maxwind + "&lat=" + observation.lat + "&lon=" + observation.lon + "&id=" + observation.stormid + "&cb=" + cb;
            }   
            hurricane.AddObservation(observation);
            
            if (i == (totalNodes-1)) //add last hurricane before exiting loop
            {
                stormCnt = map.AddHurricane(hurricane);
            }

        } //for i
    
        map.ViewHurricane(stormId, false)
 
        if (stormCnt == 0)
        {
            document.getElementById("stormStatusBkg").style.display = "block";
            document.getElementById("stormStatus").innerHTML = "There are currently no active storms.";
        }
        else
        {
            document.getElementById("stormStatusBkg").style.display = "none";
            document.getElementById("stormStatus").innerHTML = "";
        }
    } //try
    catch(e) {}
} //LoadActiveStorms
   
        
function LoadPastStorm()
{
    GetXML("http://hurricanetracker.myweather.net/ht2/singlestorm.xml?year=" + currentYear + "&stormname=" + currentStorm, Loader);
}


function Loader(stormXml)
{
    var oDoc = null;
    try
    {
        oDoc = new ActiveXObject("Microsoft.XMLDOM");
        oDoc.async = false;
        oDoc.loadXML(stormXml);
    } //try
    catch(e)
    {
        try
        {
            parser = new DOMParser();
            oDoc = parser.parseFromString(stormXml, "text/xml");
        }
        catch(e)
        {}
    } //catch
    
    try
    {
        if ((map == null) || (map == 'undefined')) AssignMapReference();
    }
    catch(e)
    {
        AssignMapReference();
    }

    try
    {
        var stormNode = oDoc.getElementsByTagName("table");
        var hurricane = new Hurricane();
        var obsNodes = stormNode[0].childNodes;
        for(j = 0; j < obsNodes.length; j++)
        {
            var propertyNodes = obsNodes[j].childNodes;
            var status = GetElementValue(propertyNodes[8]);
            if (status == "ACTUAL")
            {
                var observation = new HurricaneObservation();
                observation.stormid = GetElementValue(propertyNodes[0]);
                hurricane.stormid = observation.stormid;  
                observation.advisorynumber = GetElementValue(propertyNodes[1]);
                observation.stormname = GetElementValue(propertyNodes[2]);
                hurricane.stormname = observation.stormname;
                observation.stormtype = GetElementValue(propertyNodes[3]);
                observation.year = GetElementValue(propertyNodes[4]);
                hurricane.year = observation.year;
                observation.month = GetElementValue(propertyNodes[5]);
                observation.day = GetElementValue(propertyNodes[6]);
                observation.hour = GetElementValue(propertyNodes[7]);
                observation.status = status;
                observation.lat = GetElementValue(propertyNodes[9]);
                observation.lon = GetElementValue(propertyNodes[10]);
                observation.direction = GetElementValue(propertyNodes[11]);
                observation.speed = GetElementValue(propertyNodes[12]);
                observation.maxwind = GetElementValue(propertyNodes[13]);
                observation.gusts = GetElementValue(propertyNodes[14]);
                observation.centralpressure = GetElementValue(propertyNodes[15]);
                observation.ne34 = GetElementValue(propertyNodes[16]);
                observation.se34 = GetElementValue(propertyNodes[17]);
                observation.sw34 = GetElementValue(propertyNodes[18]);  
                observation.nw34 = GetElementValue(propertyNodes[19]);
                observation.ne50 = GetElementValue(propertyNodes[20]);
                observation.se50 = GetElementValue(propertyNodes[21]);
                observation.sw50 = GetElementValue(propertyNodes[22]);
                observation.nw50 = GetElementValue(propertyNodes[23]);
                observation.ne64 = GetElementValue(propertyNodes[24]);
                observation.se64 = GetElementValue(propertyNodes[25]);
                observation.sw64 = GetElementValue(propertyNodes[26]);
                observation.nw64 = GetElementValue(propertyNodes[27]);
                observation.pressuredatareported = GetElementValue(propertyNodes[28]);
                observation.winddatareported = GetElementValue(propertyNodes[29]);
                observation.windgustsreported = GetElementValue(propertyNodes[30]);
                observation.windradiireported = GetElementValue(propertyNodes[31]);
                observation.windradiineverreported = GetElementValue(propertyNodes[32]);
                observation.source = GetElementValue(propertyNodes[33]);
                var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();
                observation.url = "http://hurricanetracker.myweather.net/ht2/obs.html?nm=" + observation.stormname + "&typ=" + observation.stormtype + "&year=" + observation.year + "&month=" + observation.month + "&day=" + observation.day + "&hour=" + observation.hour + "&wind=" + observation.maxwind + "&pres=" + observation.centralpressure + "&lat=" + observation.lat + "&lon=" + observation.lon + "&id=" + observation.stormid + "&cb=" + cb;
                hurricane.AddObservation(observation);
            } //if ACTUAL
        } //for j
        
        hurricaneCnt = map.AddHurricane(hurricane);
        displayedHurricanes[hurricaneCnt] = hurricane.stormid;
        map.ViewHurricane(displayedHurricanes, false);
        
    } //try
    catch(e) {}
} //Loader


function GetElementValue(nd)
{
    var valu = "";
    try
    {
        valu = nd.firstChild.nodeValue + '';
    }
    catch(e)
    {
        valu = "";
    }
    return (valu);
}


function GetDefaultIRParams(paramSchema)
{
    // actionscript passes in an array which you can loop through to view the array schema if you would like
    // or you could just ignore the paramSchema array
    //alert(paramSchema.toString());    //view array schema

    var params = new Array();
    params[0] = stormCells;     
    params[1] = "";                         //no clouds   
    params[2] = parseInt(hostType);                   
    params[3] = "MYWX";                  
    params[4] = parseInt(minZoom);         
    params[5] = parseInt(maxZoom);        
    params[6] = parseInt(initialZoom);   
    params[7] = parseInt(promptZoom);
    params[8] = parseInt(4);      
    params[9] = parseFloat(25.562265);
    params[10] = parseFloat(-89.912109);
    params[11] = true;
    params[12] = false;                     //lat-lon lines off
    params[13] = "http://hurricanetracker.myweather.net/tiles/";
    params[14] = "logo";                    //logo or copyright or nothing
    params[15] = false;                     //watchboxes
    params[16] = "";                        //watchbox data url
    params[17] = false;                     //lightning
    params[18] = "";                        //lightning data url
    params[19] = false;                     //routecast?
    params[20] = "";                        //routecast data url
    params[21] = "{host}";                  //host
    params[22] = 2;                         //msve tiletype
    params[23] = "MapEventHandler";         //IR event callback handler
    params[24] = false;  //drawMyLocation, boolean
    params[25] = null;   //myLocationLat, number
    params[26] = null;   //myLocationLon, number
    params[27] = null;   //myLocationZoom, number
    params[28] = null;   //liveLocalRadarUrl, string
    params[29] = false;  //liveLocalRadar, boolean
    params[30] = false;  //watchboxesDefault, boolean
    params[31] = false;  //countyOverlays, boolean
    params[32] = false;  //countyOverlaysDefault, boolean

    //alert(params.toString());
    return params;
}

function MapEventHandler(token)
{
    switch (token)
    {
        case 'HideCalloutWindow':
            hidePageFromFlash();
            break;
            
        case "InitialLoadComplete":
            LoadModels();
            break;
            
        default:
            break;
    } //switch
   
}

function InitialIRLoadComplete()
{
    map.UpdateHurricaneForecastCircleSizeMultiplier(.625);
    LoadActiveStorms();

    map.LoadIconsFromXML("http://hurricanetracker.myweather.net/ht2/hunterObs.xml", "activehunter", "image", "lat", "lon", false, "OnHunterClick", "", "", 1, 20, "hunter", true, false, 1);
}

function CatchIRLatLon(lat, lon)
{
    //this event handler is called from actionscript
    //the lat lon position of the mouse is passed in
    //alert(lat.toString() + ", " + lon.toString());    
   
    lat = Math.round(lat*100)/100;
    lon = Math.round(lon*100)/100;
    document.getElementById("pointerCurrent").innerHTML = lat + " / " + lon;
    document.getElementById("pointerPast").innerHTML = lat + " / " + lon;
}

 
function fadeOut(id, ms)
{
      setTimeout('opacity("' + id + '",100,0,800);',ms);
}
 

function opacity(id, opacStart, opacEnd, millisec) 
{
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}


//change the opacity for different browsers
function changeOpac(opacity, id) 
{
    if(document.getElementById(id) == null)
    {
      return;
    }
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";

    //wes 12-3-07 - kill the div so the flash movie can register click events at the div location
    if (opacity <= 0)
    {              
        //document.getElementById(id).style.visibility = 'hidden';    
        document.getElementById(id).style.display = 'none'; 
    }
} 

function switchTab(divId)
{     
    for (var i=0; i<numTabs; i++)
    {
        if (divId != tabSections[i]) 
        {
            document.getElementById(tabSections[i]).style.display = 'none';
            document.getElementById(tabSections[i]).style.visibility = 'hidden';
        }
        else 
        {
            document.getElementById(tabSections[i]).style.display = 'block';
            document.getElementById(tabSections[i]).style.visibility = 'visible';
        }
    }
} //switchTab


function loadYearStorms()
{
    try
    {
        currentYear = document.getElementById("selectYear").value;
    }
    catch(e)
    {
        currentYear = 2009;
    }

      
    var sXml = "";
    switch (currentYear)
    {
        case '2000':
            sXml =  "";
            break;
            
        case '2001':
            sXml =  "";
            break;
        
        case '2002':
            sXml =  "";
            break;
            
        case '2003':
            sXml =  "<option value=ANA>ANA</option><option value=ANDRES>ANDRES</option><option value=BILL>BILL</option><option value=BLANCA>BLANCA</option><option value=CARLOS>CARLOS</option><option value=CLAUDETTE>CLAUDETTE</option><option value=DANNY>DANNY</option><option value=DOLORES>DOLORES</option><option value=ENRIQUE>ENRIQUE</option><option value=ERIKA>ERIKA</option><option value=FABIAN>FABIAN</option><option value=FELICIA>FELICIA</option><option value=FOURTEEN>FOURTEEN</option><option value=GRACE>GRACE</option><option value=GUILLERMO>GUILLERMO</option><option value=HENRI>HENRI</option><option value=HILDA>HILDA</option><option value=IGNACIO>IGNACIO</option><option value=ISABEL>ISABEL</option><option value=JIMENA>JIMENA</option><option value=JUAN>JUAN</option><option value=KATE>KATE</option><option value=KEVIN>KEVIN</option><option value=LARRY>LARRY</option><option value=LINDA>LINDA</option><option value=MARTY>MARTY</option><option value=MINDY>MINDY</option><option value=NICHOLAS>NICHOLAS</option><option value=NINE>NINE</option><option value=NORA>NORA</option><option value=ODETTE>ODETTE</option><option value=OLAF>OLAF</option><option value=ONE-C>ONE-C</option><option value=PATRICIA>PATRICIA</option><option value=PETER>PETER</option><option value=SEVEN>SEVEN</option><option value=SIX>SIX</option><option value=THREE>THREE</option><option value=TWO>TWO</option>";
            break;
            
        case '2004':
            sXml =  "<option value=AGATHA>AGATHA</option><option value=ALEX>ALEX</option><option value=BLAS>BLAS</option><option value=BONNIE>BONNIE</option><option value=CELIA>CELIA</option><option value=CHARLEY>CHARLEY</option><option value=DANIELLE>DANIELLE</option><option value=DARBY>DARBY</option><option value=EARL>EARL</option><option value=ESTELLE>ESTELLE</option><option value=FRANCES>FRANCES</option><option value=FRANK>FRANK</option><option value=GASTON>GASTON</option><option value=GEORGETTE>GEORGETTE</option><option value=HERMINE>HERMINE</option><option value=HOWARD>HOWARD</option><option value=ISIS>ISIS</option><option value=IVAN>IVAN</option><option value=JAVIER>JAVIER</option><option value=JEANNE>JEANNE</option><option value=KARL>KARL</option><option value=KAY>KAY</option><option value=LESTER>LESTER</option><option value=LISA>LISA</option><option value=MATTHEW>MATTHEW</option><option value=NICOLE>NICOLE</option><option value=NINE-E>NINE-E</option><option value=OTTO>OTTO</option><option value=SIXTEEN>SIXTEEN</option><option value=SIXTEEN-E>SIXTEEN-E</option><option value=TEN>TEN</option>";
            break;
         
        case '2005':
            sXml =  "<option value=ADRIAN>ADRIAN</option><option value=ALPHA>ALPHA</option><option value=ARLENE>ARLENE</option><option value=BEATRIZ>BEATRIZ</option><option value=BETA>BETA</option><option value=BRET>BRET</option><option value=CALVIN>CALVIN</option><option value=CINDY>CINDY</option><option value=DELTA>DELTA</option><option value=DENNIS>DENNIS</option><option value=DORA>DORA</option><option value=EMILY>EMILY</option><option value=EPSILON>EPSILON</option><option value=EUGENE>EUGENE</option><option value=FERNANDA>FERNANDA</option><option value=FRANKLIN>FRANKLIN</option><option value=GAMMA>GAMMA</option><option value=GERT>GERT</option><option value=GREG>GREG</option><option value=HARVEY>HARVEY</option><option value=HILARY>HILARY</option><option value=IRENE>IRENE</option><option value=IRWIN>IRWIN</option><option value=JOSE>JOSE</option><option value=JOVA>JOVA</option><option value=KATRINA>KATRINA</option><option value=KENNETH>KENNETH</option><option value=LEE>LEE</option><option value=LIDIA>LIDIA</option><option value=MARIA>MARIA</option><option value=MAX>MAX</option><option value=NATE>NATE</option><option value=NINETEEN>NINETEEN</option><option value=NORMA>NORMA</option><option value=ONE-C>ONE-C</option><option value=OPHELIA>OPHELIA</option><option value=OTIS>OTIS</option><option value=PHILIPPE>PHILIPPE</option><option value=RITA>RITA</option><option value=SIXTEEN-E>SIXTEEN-E</option><option value=STAN>STAN</option><option value=TAMMY>TAMMY</option><option value=TEN>TEN</option><option value=TWENTY-TWO>TWENTY-TWO</option><option value=VINCE>VINCE</option><option value=WILMA>WILMA</option><option value=ZETA>ZETA</option>";
            break;
            
        case '2006':
            sXml =  "<option value=ALBERTO>ALBERTO</option><option value=ALETTA>ALETTA</option><option value=BERYL>BERYL</option><option value=BUD>BUD</option><option value=CARLOTTA>CARLOTTA</option><option value=CHRIS>CHRIS</option><option value=DANIEL>DANIEL</option><option value=DEBBY>DEBBY</option><option value=EIGHTEEN-E>EIGHTEEN-E</option><option value=EMILIA>EMILIA</option><option value=ERNESTO>ERNESTO</option><option value=FABIO>FABIO</option><option value=FLORENCE>FLORENCE</option><option value=FOUR-C>FOUR-C</option><option value=GILMA>GILMA</option><option value=GORDON>GORDON</option><option value=HECTOR>HECTOR</option><option value=HELENE>HELENE</option><option value=ILEANA>ILEANA</option><option value=IOKE>IOKE</option><option value=ISAAC>ISAAC</option><option value=JOHN>JOHN</option><option value=KRISTY>KRISTY</option><option value=LANE>LANE</option><option value=MIRIAM>MIRIAM</option><option value=NORMAN>NORMAN</option><option value=OLIVIA>OLIVIA</option><option value=PAUL>PAUL</option><option value=ROSA>ROSA</option><option value=SERGIO>SERGIO</option><option value=THREE-C>THREE-C</option><option value=TWENTY-E>TWENTY-E</option><option value=TWO-C>TWO-C</option><option value=TWO-E>TWO-E</option><option value=ZETA>ZETA</option>";
            break;
            
        case '2007':
            sXml =  "<option value=ALVIN>ALVIN</option><option value=ANDREA>ANDREA</option><option value=BARBARA>BARBARA</option><option value=BARRY>BARRY</option><option value=CHANTAL>CHANTAL</option><option value=COSME>COSME</option><option value=DALILA>DALILA</option><option value=DEAN>DEAN</option><option value=ERICK>ERICK</option><option value=ERIN>ERIN</option><option value=FELIX>FELIX</option><option value=FIFTEEN>FIFTEEN</option><option value=FIVE-E>FIVE-E</option><option value=FLOSSIE>FLOSSIE</option><option value=FOUR-E>FOUR-E</option><option value=GABRIELLE>GABRIELLE</option><option value=GIL>GIL</option><option value=HENRIETTE>HENRIETTE</option><option value=HUMBERTO>HUMBERTO</option><option value=INGRID>INGRID</option><option value=IVO>IVO</option><option value=JERRY>JERRY</option><option value=JULIETTE>JULIETTE</option><option value=KAREN>KAREN</option><option value=KIKO>KIKO</option><option value=LORENZO>LORENZO</option><option value=MELISSA>MELISSA</option><option value=NOEL>NOEL</option><option value=OLGA>OLGA</option><option value=TEN>TEN</option><option value=THIRTEEN-E>THIRTEEN-E</option><option value=THREE-E>THREE-E</option>"; 
            break;
        
        case '2008':
            sXml =  "<option value=ALMA>ALMA</option><option value=ARTHUR>ARTHUR</option><option value=BERTHA>BERTHA</option><option value=BORIS>BORIS</option><option value=CRISTINA>CRISTINA</option><option value=CRISTOBAL>CRISTOBAL</option><option value=DOLLY>DOLLY</option><option value=DOUGLAS>DOUGLAS</option><option value=EDOUARD>EDOUARD</option><option value=ELIDA>ELIDA</option><option value=FAUSTO>FAUSTO</option><option value=FAY>FAY</option><option value=FIVE-E>FIVE-E</option><option value=GENEVIEVE>GENEVIEVE</option><option value=GUSTAV>GUSTAV</option><option value=HANNA>HANNA</option><option value=HERNAN>HERNAN</option><option value=IKE>IKE</option><option value=ISELLE>ISELLE</option><option value=JOSEPHINE>JOSEPHINE</option><option value=JULIO>JULIO</option><option value=KARINA>KARINA</option><option value=KIKA>KIKA</option><option value=KYLE>KYLE</option><option value=LAURA>LAURA</option><option value=LOWELL>LOWELL</option><option value=MARCO>MARCO</option><option value=MARIE>MARIE</option><option value=NANA>NANA</option><option value=NORBERT>NORBERT</option><option value=ODILE>ODILE</option><option value=OMAR>OMAR</option><option value=PALOMA>PALOMA</option><option value=POLO>POLO</option><option value=SEVENTEEN-E>SEVENTEEN-E</option><option value=SIXTEEN>SIXTEEN</option>";
            break;
            
        case '2009':
            sXml =  "<option value=ANA>ANA</option><option value=ANDRES>ANDRES</option><option value=BILL>BILL</option><option value=BLANCA>BLANCA</option><option value=CARLOS>CARLOS</option><option value=CLAUDETTE>CLAUDETTE</option><option value=DANNY>DANNY</option><option value=DOLORES>DOLORES</option><option value=EIGHT>EIGHT</option><option value=ENRIQUE>ENRIQUE</option><option value=ERIKA>ERIKA</option><option value=FELICIA>FELICIA</option><option value=FRED>FRED</option><option value=GRACE>GRACE</option><option value=GUILLERMO>GUILLERMO</option><option value=HENRI>HENRI</option><option value=HILDA>HILDA</option><option value=IDA>IDA</option><option value=IGNACIO>IGNACIO</option><option value=JIMENA>JIMENA</option><option value=KEVIN>KEVIN</option><option value=LANA>LANA</option><option value=LINDA>LINDA</option><option value=MAKA>MAKA</option><option value=MARTY>MARTY</option><option value=NEKI>NEKI</option><option value=NINE-E>NINE-E</option><option value=NORA>NORA</option><option value=OLAF>OLAF</option><option value=ONE>ONE</option><option value=ONE-E>ONE-E</option><option value=PATRICIA>PATRICIA</option><option value=RICK>RICK</option><option value=TWO-C>TWO-C</option>";
            break;
            
        case '2010':
            sXml =  "";
            break;
            
        case '2011':
            sXml =  "";
            break;
        
        case '2012':
            sXml =  "";
            break;
        
        case '2013':
            sXml =  "";
            break;
        
        case '2014':
            sXml =  "";
            break;
            
        case '2015':
            sXml =  "";
            break;
            
        default:
            break;
    }
    
    document.getElementById("stormList").innerHTML = "<select name='selectStorm' id='selectStorm' size='1' onChange='loadStorm()'><OPTION>STORM NAME</OPTION>" + sXml;
}
	
	
function loadStorm()
{
    try
    {
        currentStorm = document.getElementById("selectStorm").value;
    }
    catch(e)
    {
        currentStorm = "";
    }
} //loadStorm


function GetXML(url, func)
{ 
    try
    {
        Remote();
        xmlhttp.open("GET", url, true);
        xmlhttp.onreadystatechange=function() 
	    {
		    if (xmlhttp.readyState==4)
		    {
		        if (func)
		        {
		            func(xmlhttp.responseText);
		        }
		    }
	    }
	    xmlhttp.send(null);
	}
	catch(e)
	{}
} //GetXML


function GetURL(url, id)
{
    try
    {
	    Remote();
	    xmlhttp.open("GET", url, true);
	    xmlhttp.onreadystatechange=function() 
	    {
		    if (xmlhttp.readyState==4)
	        {
		        document.getElementById(id).innerHTML = xmlhttp.responseText;
				alert(xmlhttp.responseText);
		    }
	    }
	    xmlhttp.send(null);
	}
	catch(e)
	{}
} //GetURL


function Remote()
{
    try
    {
	    if ((!xmlhttp) && (typeof XMLHttpRequest!='undefined')) 
	    {
		    xmlhttp = new XMLHttpRequest();
	    }
	}
	catch(e)
	{}
} //Remote
	
	
function ClearMap()
{
    try
    {
        map.RemoveAllHurricanes();
        map.SectorLayer("");
        SetImageSrc("chkBoxClouds", "selection_unchecked.gif");
        
        hunter = true;
        ToggleHunter();
        
        models = true;
        ToggleModels();
      
        for (var i=0; i<= hurricaneCnt; i++)
        {
            displayedHurricanes[i] = null;
        }
        hurricaneCnt = 0;
    }
    catch(e)
    {}
} //ClearMap


function SetView(zoom, lat, lon)
{
     map.SetView(zoom, lat, lon);
     MakeZoomPanControlsVisible(true); 
}


function photoPopup() 
{
    window.open("http://content.myweather.net/hurricane_tracker/photo/phototab/photoCheck.html", "SubmitPhotoWindow", "status = 1, height = 270, width = 500, resizable = 0");
}


function ShowSearchResults()
{
    try
    {
        var query = document.getElementById('searchQuery').value;
        if (query.length > 0)
        {
            var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();   
            var oSrch = document.getElementById("searchResults");
            oSrch.style.display="block";
            oSrch.style.visible="visible";
            oSrch.innerHTML = "<div id='searchWait'><img src='images/loader.gif' /></div>";    
            document.body.style.cursor = "wait";
            GetXML("http://hurricanetracker.myweather.net/ht2/search/search.aspx?q=" + query + "&cb=" + cb, SearchResults);
        }
    }
    catch(e)
    {}
}

function SearchResults(rslt)
{
    document.getElementById("searchResults").innerHTML = rslt;
    document.body.style.cursor = "default";
}

function CloseWindow(id)
{
    document.getElementById(id).style.display="none";
    //document.getElementById(id).style.visibility = "hidden";
}

function switchCursor(id)
{
    document.getElementById(id).style.cursor="pointer";
}

function SearchPastStorm(year, storm)
{
    var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();   
    GetXML("http://hurricanetracker.myweather.net/ht2/singlestorm.xml?year=" + year + "&stormname=" + storm + "&cb=" + cb, Loader);
    document.getElementById("selectYear").value = year;
    loadYearStorms();
    document.getElementById("selectStorm").value = storm;
    currentYear = year;
    currentStorm = storm;
    document.getElementById(storm).style.color="#FF0000";
}

function SearchHistoricalStorm(stormId)
{
    var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();   
    GetXML("http://hurricanetracker.myweather.net/ht2/history/history.aspx?id=" + stormId + "&cb=" + cb, Loader);
} 


function OnHunterClick(icon)
{
    var divXY = map.DrawCalloutTail(icon.lat, icon.lon, 200, 135);
    var x = Math.round(divXY.x) + 5;
    var y = Math.round(divXY.y) + 20; 
    var oHunter = document.getElementById("hunterPopup");
    oHunter.style.display = "block";
    oHunter.style.visibility = "visible";
    oHunter.style.left = x + "px";
    oHunter.style.top = y + "px";
    var html = "<div style='position:absolute; left:9px; top:8px; font-family:arial; font-size:10pt;'>";
    html += "<div style='border:0px;'> Aircraft: <b>" + icon.aircraft_id + "</b></div>";
    html += "<div style='border:0px;'> Time: <b>" + icon.ob_time + "</b></div>";
    html += "<div style='border:0px;'> Lat/Lon: <b>" + icon.lat + " / " + icon.lon + "</b></div>";
    html += "<div style='border:0px;'> Flight Level Winds: <b>" + icon.max_wind_speed_mph + " MPH</b></div>";
    html += "<div style='border:0px;'> Surface Winds: <b>" + icon.max_sfc_wind_speed_mph + " MPH</b></div>";
    html += "<div style='border:0px;'> Aircraft Pressure: <b>" + icon.aircraft_pressure_mb + " mb</b></div>";
    html += "<div style='border:0px;'> Surface Pressure: <b>" + icon.surface_pressure_mb + " mb</b></div>";
    oHunter.innerHTML = html;
    document.body.style.cursor = "default";
} 

function HideLines()
{
    map.HideLines();
}

function ShowLines()
{
    map.ShowLines();
}

function LoadModels()
{
    var cb = Math.floor(Math.random() * 100000).toString() + "." + Math.floor(Math.random() * 100000).toString();   
    GetXML("http://hurricanetracker.myweather.net/ht2/modelObs.xml&cb=" + cb, LoadSpaghetti);
} 

function LoadSpaghetti(stormXml)
{
    var oDoc = null;
    try
    {
        oDoc = new ActiveXObject("Microsoft.XMLDOM");
        oDoc.async = false;
        oDoc.loadXML(stormXml);
    } //try
    catch(e)
    {
        try
        {
            parser = new DOMParser();
            oDoc = parser.parseFromString(stormXml, "text/xml");
        }
        catch(e)
        {}
    } //catch
    
    try
    {
        var lastModel = "";
        var lastLat = 0;
        var lastLon = 0;
        var modelNode = oDoc.getElementsByTagName("root");
        var obsNodes = modelNode[0].childNodes;
        for(j = 0; j < obsNodes.length; j++)
        {
            var propertyNodes = obsNodes[j].childNodes;
            var model = GetElementValue(propertyNodes[0]);
            var lat = GetElementValue(propertyNodes[3]);
            var lon = GetElementValue(propertyNodes[4]);
            var color = GetElementValue(propertyNodes[5]);
            var penwidth = GetElementValue(propertyNodes[6]);
            
            if (lastModel != model)
            {
                lastLat = 0;
                lastLon = 0;
            }
            
            if ((lastLat != 0) && (lastLon != 0)) map.DrawLine(lastLat, lastLon, lat, lon, color, penwidth);
            lastModel = model;
            lastLat = lat;
            lastLon = lon;
        } //for j

        HideLines();
    } //try
    catch(e) {}
} 

function ClearQuery()
{
    document.getElementById("searchQuery").value = "";
}

function CloseAd()
{
    document.getElementById("adClose").style.display = "none";
    document.getElementById("adClose").style.visibility = "hidden";
    document.getElementById("ad1a").style.display = "none";
    document.getElementById("ad1a").style.visibility = "hidden";
}

function CloseMessage()
{
    document.getElementById("stormStatus").style.display="none";
    document.getElementById("stormStatus").style.visibility = "hidden";
    document.getElementById("stormStatusBkg").style.display="none";
    document.getElementById("stormStatusBkg").style.visibility = "hidden";
}