﻿function preparePopUp()
{
    if (document.getElementsByTagName)
    {
        // create an array of objects of each link in the document
        var popuplinks = document.getElementsByTagName("a");

        // loop through each of these links (anchor tags)
        for (var i = 0; i < popuplinks.length; i++)
        {
            // if the link has a id of "popup-mailinglist"...
            if (popuplinks[i].getAttribute("id") == "popup-mailinglist")
            {
                // add an onclick event on the fly to pass the href attribute of the link to our second function, openPopUp
                popuplinks[i].onclick = function ()
                {
                    openPopUp("/popup-mailinglist.aspx");
                    return false;
                }
            }
        }
    }
}

function openPopUp(linkURL)
{
    window.open(linkURL, 'popup', 'width=280px,height=370px')
}

function addLoadEvent(func)
{
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    }
    else
    {
        window.onload = function ()
        {
            if (oldonload)
            {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(preparePopUp);
