<!-- 
//
// Generic function to add the domain to the URL if required
// sSiteURL is a global JS variable
function genURL(url) {
	var sTmpURL = '';
	if (typeof sSiteURL == "undefined") {
		return url;
	}
	if ( sSiteURL.length > 0 && url.indexOf("http") == -1) {
		// need to append the domain to the urls
		sTmpURL = sSiteURL;
		if ( url.indexOf("/") != 0 ) {
			sTmpURL = sTmpURL + "/";
		}
	} 
	sTmpURL = sTmpURL + url;
	return sTmpURL;	
}

// Popup shortcuts window
function shortcuts() {
	var winheight = screen.availHeight;
	var winwidth = screen.availWidth;
    var popwidth = 370;
	popup('/AIAdotNET/shortcuts.aspx','shortcuts','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=325,height=400,top=72,left='+(winwidth-popwidth));

} 


// Popup new window for login
function popup_login(url){
	var winwidth = screen.availWidth;
    var popwidth = 450;
	features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+popwidth+",height=350,top=175,left="+((winwidth-popwidth)/2);
	loc = url;
	popup (loc, "login", features);
	return false;
}



// Generic function to open new window; If sSiteURL is set, use full URLs
function popup(loc,winName,features){
	var sTmpURL = genURL(loc);
	window.open(sTmpURL,winName,features);
}

function test(){

window.open('/AIAdotNET/shortcuts.aspx','shortcuts','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=325,height=400,top=72,left=100');
}



// For use with login and shortcuts
function gotoURL(url){
	window.opener.window.location=url;
	self.close();
}
	
// Popup new window for glossary terms
function glossary(term){
	if (term == "") {
		alert ("The glossary function must be passed a glossary term");
		return;
	}
	features = "toolbar=no,directory=no,status=no,menubar=no,location=no,scrollbars=yes,resize=0,width=325,height=275";
	loc = "/LinksResources/General/glossary_popup.asp?Term=" + escape(term);
	winName = "glossary";

	popup (loc, winName, features);
	return false;
}


// Popup new window for PDF, Word, etc. documents
function showDocument(targetURL, winName){
	if (targetURL == "") {
		alert ("Please pass a URL to the showDocument function.");
		return;
	} 
	features = "toolbar=yes,directory=no,status=no,menubar=no,location=no,scrollbars=yes,resize=0,width=325,height=275";
	if (winName == "") {
		winName = "AIA Documents";
	}

	popup (loc, winName, features);
	return false;
}


// Checks a date to ensure it is valid.  
// dDesc = description of the date for error messages.
function checkdate(dDate, dDesc){
	var err=0
	if (dDate) {
	} else {
		return true;
	}

	if (!dDesc) {
		dDesc = "";
	} else {
		if (dDesc.length > 0) {
			dDesc = dDesc + ": ";
		}
	}

	if (dDate.length < 1) {
		return true;
	}

	if (dDate.length > 10) {
		alert(dDesc + 'Length is greater than 10.');
		return false;
	}
	dash1 = dDate.indexOf("/")
	if (dash1 == -1) {
		alert(dDesc + 'Does not have any slashes (/).');
		return false;
	}
	dash2 = dDate.indexOf("/", dash1 + 1)
	if (dash2 == -1) {
		alert(dDesc + 'Has only one slash (/).');
		return false;
	}

	d_month = dDate.substring(0, dash1)// month
	d_day = dDate.substring(dash1 + 1, dash2)// day
	d_year = dDate.substring(dash2 + 1, 10)// year

	//basic error checking
	if (d_month<1 || d_month>12) {
		alert(dDesc + 'Month must be between 1 and 12.');
		return false;
	}
	if (d_day <1 || d_day >31) {
		alert(dDesc + 'Day must be between 1 and 31.');
		return false;
	}
	if (d_year <2000 || d_year >9999) {
		alert(dDesc + 'Invalid year.');
		return false;
	}

	//advanced error checking

	// months with 30 days
	if (d_month==4 || d_month==6 || d_month==9 || d_month==11){
		if (d_day==31) {
			alert(dDesc + 'This month does not have 31 days.');
			return false;
		}
	}

	// february, leap year
	if (d_month==2){
		// feb
		var g=parseInt(d_year/4)
		if (isNaN(g)) {
			err=1
		}

		if (d_day>29) {
			alert(dDesc + 'February can not have more than 29 days.');
			return false;
		}

		if (d_day==29 && ((d_year/4)!=parseInt(d_year/4))) {
			alert(dDesc + 'This is not a leap year.  February only has 28 days.');
			return false;
		}
	}

	if (err==1){
		alert(dDesc + 'Invalid Date.  Use Format Indicated.');
		return false
	}
	else{
		return true;
	}

}
//-----------------------------------------------------------------------
// MENU FUNCTIONS
//-----------------------------------------------------------------------

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var menu = new Array();

// Hide the select lists
if (typeof bHideForm != "boolean") {
	bHideForm = false;
}
function clearSelects(which){ 
	for(x=0;x<document.forms.length;x++){ 
		for(i=0;i<document.forms[x].length;i++){ 
			var tempobj=document.forms[x].elements[i]; 
			if (tempobj.type.substring(0,6) == "select"){ 
				if(which == "hidden") 
					tempobj.style.visibility = "hidden"; 
				else 
					tempobj.style.visibility = "visible"; 
				} 
		} 
	} 
}

function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}
function getSty(id) {
	return (isNS4 ? getRef(id) : getRef(id).style);
} 
// Hide timeout.
var popTimer = 0;
// Array showing highlighted menu items.
var litNow = new Array();

function popOver(menuNum, itemNum) {
	clearTimeout(popTimer);
	hideAllBut(menuNum);
	litNow = getTree(menuNum, itemNum);
	changeCol(litNow, true);
	targetNum = menu[menuNum][itemNum].target;
	if (targetNum > 0) {
		thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
		thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
		with (menu[targetNum][0].ref) {
		left = parseInt(thisX + menu[targetNum][0].x);
		top = parseInt(thisY + menu[targetNum][0].y);
		visibility = 'visible';
      }
   }
//code to keep the rollover image on
if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 1) || (menu[menuNum][0].parentMenu == 1) || (targetNum == 1)  )
   {
   	document.about.src=sSiteURL+"/images/b_about_over.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	if (bHideForm) {
		clearSelects("hidden");
	}
   }
   else
   {
   if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 2) || (menu[menuNum][0].parentMenu == 2) || (targetNum == 2) )
   {
   	document.about.src=sSiteURL+"/images/b_about.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues_over.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	if (bHideForm) {
		clearSelects("hidden");
	}
   }
    else
   {
   if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 3) || (menu[menuNum][0].parentMenu == 3) || (targetNum == 3) )
   {
   	document.about.src=sSiteURL+"/images/b_about.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork_over.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	clearSelects("hidden");
   }
   else
   {
   if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 4) || ((menu[menuNum][0].parentItem == 4) && (menu[menuNum][0].parentMenu == 4)) || (targetNum == 4) )
   {
   	document.about.src=sSiteURL+"/images/b_about.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices_over.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	if (bHideForm) {
		clearSelects("hidden");
	}
   }
   else
   {
   if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 5) || (menu[menuNum][0].parentMenu == 5) || (targetNum == 5) )
   {
   	document.about.src=sSiteURL+"/images/b_about.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources_over.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	if (bHideForm) {
		clearSelects("hidden");
	}
   }
    else
   {
   if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 6) || (menu[menuNum][0].parentItem == 6) || (targetNum == 6) )
   {
   	document.about.src=sSiteURL+"/images/b_about.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom_over.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	if (bHideForm) {
		clearSelects("hidden");
	}
   }
    else
   {
   if ( (menu[menuNum][0].parentMenu == 0 && menu[menuNum][0].parentItem == 7) || (menu[menuNum][0].parentItem == 7) || (targetNum == 7) )
   {
   	document.about.src=sSiteURL+"/images/b_about.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.access.src=sSiteURL+"/images/b_access_over.gif";
	if (bHideForm) {
		clearSelects("hidden");
	}
   }
}
}
}
}
}
}
   
}


function popOut(menuNum, itemNum) {
if ((menuNum == 0) && !menu[menuNum][itemNum].target)
	hideAllBut(0)
else
popTimer = setTimeout('hideAllBut(0)', 500);
}

function getTree(menuNum, itemNum) {

// Array index is the menu number. The contents are null (if that menu is not a parent)
// or the item number in that menu that is an ancestor (to light it up).
itemArray = new Array(menu.length);

while(1) {
itemArray[menuNum] = itemNum;
// If we've reached the top of the hierarchy, return.
if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
   }
  
}

// Pass an array and a boolean to specify colour change, true = over colour.
function changeCol(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
// Change the colours of the div/layer background.
with (menu[menuCount][changeArray[menuCount]].ref) {
if (isNS4) 
bgColor = newCol;
else
backgroundColor = newCol;
         }
      }
   }
}
function hideAllBut(menuNum, itemNum) {
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count]){
menu[count][0].ref.visibility = 'hidden';
changeCol(litNow, false);
	document.about.src=sSiteURL+"/images/b_about.gif";
	document.access.src=sSiteURL+"/images/b_access.gif";
	document.atWork.src=sSiteURL+"/images/b_atWork.gif";
	document.indIssues.src=sSiteURL+"/images/b_indIssues.gif";
	document.linksResources.src=sSiteURL+"/images/b_linksResources.gif";
	document.newsroom.src=sSiteURL+"/images/b_newsroom.gif";
	document.prodServices.src=sSiteURL+"/images/b_prodServices.gif";}
	if (bHideForm) {
		clearSelects("visible");
	}
}


// *** MENU CONSTRUCTION FUNCTIONS ***

function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, regClass, grayedOut) {
// True or false - a vertical menu?
this.isVert = isVert;
// The popout indicator used (if any) for this menu.
this.popInd = popInd;
// Position and size settings.
this.x = x;
this.y = y;
this.width = width;
// Colours of menu and items.
this.overCol = overCol;
this.backCol = backCol;
// The stylesheet class used for item borders and the text within items.
this.borderClass = borderClass;
this.regClass = regClass;
this.grayedOut = grayedOut;
// Parent menu and item numbers, indexed later.
this.parentMenu = null;
this.parentItem = null;
// Reference to the object's style properties
this.ref = null;
}

function Item(text, href, frame, length, spacing, target, prot) {
    this.text = text;
    this.href = href;
    this.frame = frame;
    this.length = length;
    this.spacing = spacing;
    this.target = target;
    this.prot = prot;
    // Reference to the object's style properties
    this.ref = null;
}

function writeMenus() {
    if (!isDOM && !isIE4 && !isNS4) return;

    for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
        // Variable for holding HTML for items and positions of next item.
        var str = '', itemX = 0, itemY = 0;

        for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
            var itemID = 'menu' + currMenu + 'item' + currItem;

            var w = (isVert ? width : length);
            var h = (isVert ? length : width);


            // Create a div or layer text string with appropriate styles/properties.
            if (isDOM || isIE4) {
                str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
                if (backCol) str += 'background: ' + backCol + '; ';
                str += '" ';
            }
            if (isNS4) {
                str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
                if (backCol) str += 'bgcolor="' + backCol + '" ';
            }
            if (borderClass) str += 'class="' + borderClass + '" ';

            // mouseover handlers and div/layer.
            str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ') " >';

			//if this section not permitted to user, gray out and make non-link
            if (prot > 0) {
                str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 2 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + '<font class="' + grayedOut + '">' + text + '</font></td>';
            } else {
                str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 2 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + '<a class="' + regClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + ' </a></td>';
            }

            if (target > 0) {
                // Set target's parents to this menu item.
                menu[target][0].parentMenu = currMenu;
                menu[target][0].parentItem = currItem;
                // Add a popout indicator.
                if (popInd) str += '<td valign="center" align="right">' + popInd + '</td>';
            }
            str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
            if (isVert) itemY += length + spacing;
            else itemX += length + spacing;
        }
        if (isDOM) {
            var newDiv = document.createElement('div');
            document.getElementsByTagName('body').item(0).appendChild(newDiv);
            newDiv.innerHTML = str;
            ref = newDiv.style;
            ref.position = 'absolute';
            ref.visibility = 'hidden';
        }

        // Insert a div tag to the end of the BODY with menu HTML in place for IE4.
        if (isIE4) {
            document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
            ref = getSty('menu' + currMenu + 'div');
        }

        // In NS4, create a reference to a new layer and write the items to it.
        if (isNS4) {
            ref = new Layer(0);
            ref.document.write(str);
            ref.document.close();
        }

        for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
            itemName = 'menu' + currMenu + 'item' + currItem;
            if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName);
            if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
        }
    }
    with(menu[0][0]) {
        ref.left = x;
        ref.top = y;
        ref.visibility = 'visible';
    }
}


// These two lines handle the window resize bug in NS4. See <body onResize="...">.
var popOldWidth = window.innerWidth;
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');


// This is a quick snippet that captures all clicks on the document and hides the menus
//commented the 2 lines below by stk on 04/16/2005. to avoid the post back when clicking the document.
//if (isNS4) document.captureEvents(Event.CLICK);
//document.onclick = clickHandle;

function clickHandle(evt){
	if (isNS4) document.routeEvent(evt);
	hideAllBut(0);
	document.onclick = clickHandle;
}

// This is just the moving command for the example.
function moveRoot() {
	with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
}

//  End -->
