function init_links()
{
    // drop out if code is unsupported
    if ( ! document.getElementsByTagName) return;

    /* Basic anchor tags...
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    var links = document.getElementsByTagName("a");

    for (var i = 0, link; link = links[i]; i++)
    {
        var therel = link.getAttribute("rel");

        if (therel == "external" || therel == "client")
        {
            // if no title exists and it isn't an anchor link, add proper title
            // todo: use DOM instead of innerHTML
            if ((link.title == '' || !link.title) && !link.name) link.title = "External link: " + link.innerHTML.substring(0,30);

            link.title += " (Opens in new window)";

            if (isIE()) link.alt = "External link: " + link.alt + " (Opens in new window)";

            if (therel == "external")
            {
                link.oldhref = link.href;
                link.href = "#";

                link.onmouseup = function()
                                 {
                                     var m = "";

                                        m += "Click OK to view in a new tab/window. \n \n";
										m += "Please ensure your popup blocker is turned off. \n";
                                        
										if(confirm(m)) window.open(this.oldhref);

                                        return false;
                                 };
            }
            else
            {
                link.setAttribute('target', "_blank");
            }
        }


        if (therel == "download")
        {
            // if no title exists and it isn't an anchor link, add proper title
            // todo: use DOM instead of innerHTML
            if ((link.title == '' || !link.title) && !link.name) link.title = "Download: " + link.innerHTML.substring(0,20);

            link.setAttribute('target', "_blank");

            if (isIE())
            {
                link.title += " (Right-click and select 'Save Target as...')";
                link.alt = "Download: " + link.alt+  " (Right-click and select 'Save Target as...')";
            }
            else
            {
                link.title += " (Right-click and select 'Save Link as...')";
            }
        }

        if (therel == "pop")
        {
            link.title = "Click here to view a larger picture";

            link.imageLoc = link.href.replace('?','&');

            //alert("href: " + link.href + "\nimageLoc: " + link.imageLoc);

            link.href = "#";

            // url, width, height, left, top, resizable, scrollable, toolbar

            link.onmouseup = function () {
                                            // alert(this.imageLoc);
                                            popwin(('view.php?p='+this.imageLoc), 1, 1, 1, 1, 1, 0, 0);
                                         };
        }

        if (therel == "popmessage")
        {
            var secDescItem = document.getElementById('securityQuestionDescription');
            var wasLinkText = link.innerHTML;

            link.title += " (Opens popup)";
            link.href = "javascript:void(0);";

            link.onmousedown = function ()
            {
                var wasClass = secDescItem.className;
                if (wasClass == 'hide')
                {
                    this.innerHTML = "Close";
                    secDescItem.className = 'show';
                } else
                {
                    this.innerHTML = wasLinkText;
                    secDescItem.className = 'hide';
                }
            }
        }
    }
}


function fixclass(e)
{
    if (document.getElementById(e))
    {
        var i = document.getElementById(e);

        if (jscss('check', i, 'missing', null))
        {
            jscss('remove', i, 'missing', null);
        }
    }

    if (document.getElementById(e+"lab"))
    {
        var l = document.getElementById(e+"lab");

        if (jscss('check', l, 'missing', null))
        {
                jscss('remove', l, 'missing', null);
        }
    }
}

function popwin(theurl, w, h, l, t, r, s, tool) // url, width, height, left, top, resizable, scrollable, toolbar
{
    var final_width = (w==0) ? screen.width - (screen.width / 2) : w;

    var final_height = (h==0) ? screen.height - (screen.height / 2) : h;

    var left = (l==1) ? (screen.width-final_width) / 2 : l;

    var top = (t==1) ? (screen.height-final_height) / 2 : t;

    var popwin = window.open(theurl,'','left='+left+',top='+top+',width='+final_width+',height='+final_height+',toolbar='+tool+',location=0,directories=0,status=0,menubar=0,scrollbars='+s+',resizable='+r);

    return false;
}

function isIE()
{
    return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}


