//  common06.js - Common JavaScript functions for AIAA SF -- 2006
//
//  This is the first generation set of common JavaScript functions to
//  support the AIAA SF website.  It is expected to grow significantly
//  during the year and should be replaced by an improved set in 2007.
//
//  This code is intended to support the W3C HTML 4.01 Strict standard;
//  it attempts to move away from the deprecated Transitional features,
//  e.g., explicit frame targets.
//

// win_open()
//  Open new browser window for given URL.
//  Multiple calls should re-use the same window; example:
//      <a href=".....html"
//        onclick="win_open(this.href,targname,600,400,'');">
//        text </a>
//  To use with externallinks(),
//      <a href=".....html"
//        onclick="win_open(this.href,this.rel,600,400,'');">
//        text </a>
//
function win_open(url, target, w, h, addl_props)
{
    var dimen = 'width='+w+',height='+h;        // dimensions
    var dflts = 'resizable=1,scrollbars=yes';   // defaults
    var props = dimen+','+dflts+','+addl_props;
    var wobj = window.open(url, target, props);
}

// externallinks()
//  Assign targets which are external to current frame (or page).
//  according to "rel" attributes within anchors.  This allows
//  cross-linking HTML frames to conform to 4.01 Strict DTD via W3C DOM
//  with ECMAScript (JavaScript).  (Previous version in linkrefs.js.)
//  The targets below are recognized names that will create only a
//  single page in spite of going backward and forward in the browser.
//  Some recommended anchor targets:
//      aiaasf_2        secondard AIAA SF info page
//      aiaa_natl       national AIAA pages
//      space2006       AIAA Space 2006
//      svec            Silicon Valley Engineering Coucil
//      lmco            Lockheed Martin
//      nasa_ames       NASA Ames Research Center
//      nasa            NASA
//
function externalLinks() {
    if (!document.getElementsByTagName)
	return;
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href")) {

            // rel attribute value
            rel = anchor.getAttribute("rel");

	    // page frames -- bantop (banner/top) remains constant
            if ((rel=="main") || (rel=="sidebar")) {
		anchor.target = rel;

            // external pages
            } else if ((rel=="external") || (rel=="_blank")) {
		anchor.target = "_blank";       // force new page
            } else if ((rel=="lmco") || (rel=="lmms")) {
		anchor.target = "lmco";
            } else {
		anchor.target = rel;
            }
        }
    }
} 

window.onload = externalLinks;

