var enableCalloutClickThrough = function()
{
    if(document.getElementById)
    {
        var container = document.getElementById("callouts");
        if(container!=null)
        {
            var callouts = container.getElementsByTagName("div");
            for(var i=0; i<callouts.length; i++)
            {
                var callout = callouts[i];
                if(callout.className.indexOf("callout") > -1)
                {
                    // enable mouse pointer
                    callout.style.cursor = "pointer";
                    // hide all hyperlinks in callout contents
                    var anchors = callout.getElementsByTagName("a");
                    for(var j=0; j<anchors.length; j++)
                    {
                        var anchor = anchors[0];
                        anchor.style.display = "none";
                    }
                    // attach onclick event that mimics the hyperlink
                    callout.onclick = function()
                    {
                        // at onclick, navigate to the first hyperlink in the callout
                        var anchors = this.getElementsByTagName("a");
                        if(anchors.length > 0)
                        {
                            var href = anchors[0].href;
                            document.location.href = href;
                        }
                    }
                }
            }
        }
    }
    return(true);
}
var enableHintText = function(field)
{
    if(document.getElementById)
    {
        if(field!=null && field.type && field.type.toLowerCase() == "text")
        {
            var valueattr = field.attributes["value"];
            if(valueattr !=null)
            {
                var origvalue = valueattr.nodeValue;
                field.onfocus = function() { if(this.value == origvalue) { this.value = '' }; }
                field.onblur = function() { if(this.value == "") { this.value = origvalue }; }
            }
        }
    }
    return(true);
}
var enableHintTextForSearch = function()
{
    if(document.getElementById)
    {
        var globalsearch = document.getElementById("queryGlobal");
        var localsearch = document.getElementById("query");
        enableHintText(globalsearch);
        enableHintText(localsearch);
    }
    return(true);
}
var enableMSIEDropdowns = function()
{
    if(document.all && document.getElementById)
    {
        // toggle CSS class name at mouseover and mouseout
        var primarynav = document.getElementById("primaryNav");
        if(primarynav!=null)
        {
            var items = primarynav.getElementsByTagName("li");
            for(var i=0; i<items.length; i++)
            {
                var node = items[i];
                node.onmouseover = function() 
                {
                    this.className += " over";
                }
                node.onmouseout = function()
                {
                    this.className = this.className.replace(" over", "");
                }
                node = null;
            }
            items = null;
        }
        primarynav = null;
    }
    return(true);
}
var enableTrueTopOfPageLink = function() 
{
    if(document.getElementById)
    {
        // replace regular top of link anchor with javascript scroll function
        var paragraphs = document.getElementsByTagName("p");
        for(var i=0; i<paragraphs.length; i++)
        {
            var p = paragraphs[i];
            if(p.className.indexOf("top") > -1)
            {
                var anchors = p.getElementsByTagName("a");
                for(var j=0; j<anchors.length; j++)
                {
                    var a = anchors[j];
                    a.onclick = function()
                    {
                        window.scrollTo(0,0);
                        return(false);
                    }
                    a = null;
                }
                anchors = null;
            }
            p = null;
        }
    }
    return(true);
}
var initialize = function()
{
    enableCalloutClickThrough();
    enableHintTextForSearch();
    enableMSIEDropdowns();
    enableTrueTopOfPageLink();
    return(true);
}
window.onload=initialize;
