
var weatherAlertPopup;
var currentWeatherAlert=0;
var numWeatherAlerts=0;

function OnWeatherAlertPopupLoaded(sender)
{
    weatherAlertPopup = sender.findName("WeatherAlertPopup");
}

function ShowWeatherAlertPopup(sender, args)
{
    weatherAlertPopup.opacity = 1;
    weatherAlertPopup.IsHitTestVisible=true;
    weatherAlertPopup.findName("ShowWeatherAlertAnim").begin();    
}

function HideWeatherAlertPopup(sender, args)
{
    acknowledgeAlert();
    weatherAlertPopup.opacity = 1;
    weatherAlertPopup.IsHitTestVisible=false;
    weatherAlertPopup.findName("HideWeatherAlertAnim").begin();    
}

function OnPreviousWeatherAlert(sender, args)
{
    if(currentWeatherAlert > 0)
    {
        currentWeatherAlert--;
        updateWeatherAlert(currentWeatherAlert);
    }
}

function OnNextWeatherAlert(sender, args)
{
    if(currentWeatherAlert < (numWeatherAlerts - 1))
    {
        currentWeatherAlert++;
        updateWeatherAlert(currentWeatherAlert);
    }
}

function hideWeatherAlertNavigation()
{
    weatherAlertPopup.findName("WeatherAlertNavigation").Visibility = "Collapsed";
}

function showWeatherAlertNavigation()
{
    weatherAlertPopup.findName("WeatherAlertNavigation").Visibility = "Visible";
}

function updateWeatherAlert(alertIdx)
{
    var navText = (currentWeatherAlert + 1) + ' of ' + numWeatherAlerts;
    weatherAlertPopup.findName("WeatherAlertCounter").text = navText;
    navUpdateAlert(alertIdx);
}