﻿// Use traditional event model whilst support for event registration
// amongst browsers is poor.
window.onload = addHandlers;

function addHandlers() {
    var objAnchor = document.getElementById('newwin');

    if (objAnchor) {
        objAnchor.firstChild.data = objAnchor.firstChild.data;
        objAnchor.onclick = function(event) { return launchWindow(this, event); }
        // UAAG requires that user agents handle events in a device-independent manner
        // but only some browsers do this, so add keyboard event to be sure
        objAnchor.onkeypress = function(event) { return launchWindow(this, event); }
    }
}

function launchWindow(objAnchor, objEvent) {
    var iKeyCode, bSuccess = false;

    // If the event is from a keyboard, we only want to open the
    // new window if the user requested the link (return or space)
    if (objEvent && objEvent.type == 'keypress') {
        if (objEvent.keyCode)
            iKeyCode = objEvent.keyCode;
        else if (objEvent.which)
            iKeyCode = objEvent.which;

        // If not carriage return or space, return true so that the user agent
        // continues to process the action
        if (iKeyCode != 13 && iKeyCode != 32)
            return true;
    }

    //var strWindowFeatures = "menubar=no,location=no,resizable=no,scrollbars=no,status=no";
    bSuccess = window.open(objAnchor.href);

    // If the window did not open, allow the browser to continue the default
    // action of opening in the same window
    if (!bSuccess)
        return true;

    // The window was opened, so stop the browser processing further
    return false;
}

function showMap() {
    window.open('Contact_Us/Map', 'Map', 'width=660,height=500,toolbar=0,resizable=0,scrollbars=0,screenX=200,screenY=200,left=200,top=200');
    return false;
}

function SetFocusOnLink(itemID) {
    var item = document.getElementById(itemID);
    var att = document.createAttribute("class");
    att.value = "mainTitle";
    item.attributes.setNamedItem(att);
}
function SetUnfocusOnLink(itemID) {
    var item = document.getElementById(itemID);
    var att = document.createAttribute("class");
    att.value = "";
    item.attributes.setNamedItem(att);
}
