﻿//Callbacks
function getEmailCallback(value) 
{
    window.location.href = value;
}

function addCallback(value) {
    if (value == "" || value == null) {
        $get('spanConfirmation').innerHTML = 'You have been added to the mailing list.';
        $get('spanConfirmation').style.display = 'inline';
        $get('spanError').style.display = 'none';
        $get('txtEmail').value = '';
    }
    else {
        $get('spanConfirmation').style.display = 'none';
        $get('spanError').style.display = 'inline';
        $get('spanError').innerHTML = 'Error: ' + value;
    }
}

function cancelCallback(value) 
{
    if (value == "" || value == null) {
        $get('spanConfirmation').innerHTML = 'You have been removed from the mailing list.';
        $get('spanConfirmation').style.display = 'inline';
        $get('spanError').style.display = 'none';
        $get('txtEmail').value = '';
    }
    else {
        $get('spanConfirmation').style.display = 'none';
        $get('spanError').style.display = 'inline';
        $get('spanError').innerHTML = 'Error: ' + value;
    }
}

//Actions
function openEmail() 
{
   KruppV3.WebServices.MailingListAJAX.GetEmails(getEmailCallback);
}