﻿// Script take the email address from the field in the footer
// and stores it in a cookie to pre-populate the email address
// in the Ektron landing page form

var emailFormBtn = document.getElementById('footer-go-button');
var emailAddress = document.getElementById('footer-email-address-field');
var emailFieldValue = emailAddress.value;
emailFormBtn.onclick = setEmailAddressToCookie;
emailAddress.onclick = setFieldValue;
emailAddress.onblur= setFieldValue;

function setEmailAddressToCookie(e) {
    setCookie(emailAddress.value);
    location.replace('/bookmarketing.aspx');
    return false;
}
function setCookie(data) {
    var date = new Date();
    date.setDate(date.getDate() + 1);
    document.cookie = 'ah_lead_email' + '=' + escape(data) + ';expires=' + date.toGMTString() + ';path=/';
}
function setFieldValue() {
    if (this.value == "") {
        this.value = emailFieldValue;
    } 
    if (this.value == emailFieldValue) {
        this.value = '';
    }
}