function putImage(imgDocID,imgObjName) {
  // imgDocID - the name or number of the document image to be replaced
  // imgObjName - the name of the image object to be swapped in
  document.images[imgDocID].src = eval(imgObjName + ".src")
  return true
}

 //used to switch a class for an obj
 function switchIt(objID) { 
   var cname="active";
   if (objID.className) { objID.className=cname; }
   else if (document.getElementById(objID)) { document.getElementById(objID).className=cname; }
 }

function emailFriend() {
    script_uri.replace(/&/g, "%26");
    var loc = "/Email_Friend/index.pl?url=" + script_uri;
    //if (script_uri.indexOf("marrow-donor") > 0) { loc = "http://www.marrow.org" + loc; }
    makeNewWindow(loc,"Email",600,640);
}

function checkSignup(f) {
   if (f.s_email.value.indexOf("@") > 0) { return true; }
   else { alert("Please provide your E-mail address"); }
   return false;
}

function printerFriendly() { makeNewWindow(script_uri,"print",700); }          

function makeNewWindow(url,name,winW,winH) {
  if (!(winH)) { winH = (screen.availHeight) ? screen.availHeight - 300 : 400; }
  if (!(winW)) { winW = (screen.availWidth) ? screen.availWidth - 200 : 600; }
  var options = "resizable,titlebar,scrollbars,location,menubar,personalbar,status,toolbar,height=" + winH + ",width=" + winW;
  if (name == "Email") {
    options = "resizable,titlebar,scrollbars,height=" + winH + ",width=" + winW; 
  }
  var newWindow = window.open("", name, options);
 if (newWindow.focus) { newWindow.focus(); }
 newWindow.location = url;
}

if (window.name && window.name == "print") {
   document.write('<link rel="stylesheet" id="print" type="text/css" href="/includes/print.css">');
}

// ***** SIDE NAV SCRIPT ****** //
// This function creates asset Node objects
function Node(id, name, shortname, url, level, parent) {
	this.id = id;
	this.name = name;
	this.url = url;
	this.level = level;
    this.shortname = shortname;
//		this.children = children;
	this.parent = parent;
}

// This function creates breadcrumb objects
function breadcrumbNode(id, parent) {
	this.id = id;
	this.parent = parent;
}

// this function draws the side navigation menu
function displayNodeLevel(thisLevel) {
    var inBreadcrumb = 0;
    
    if (nodeList.length == 0) {
      return;
    }
    
    // Loop through all the nodes in the array, to check if content exists for this level
    var isSideNav = 0;
    for(var j=0; j < nodeList.length; j++) {	
      if (nodeList[j].level == thisLevel) { isSideNav=1; break; }
    }
    
    if (isSideNav == 0) { 
      //nothing for this level. leave
      return thisLevel-1;
    } 

    //start a new level    

    if (thisLevel > 1) {
      document.write('<ul>');
    }
    
    for(var j=0; j < nodeList.length; j++) {	// Loop through all the nodes in the array
 
      // If the node is in the breadcrumb, set flag
      if (nodeList[j].level == thisLevel) { 
        
	    for(var c=0, inBreadcrumb = 0; c < crumbLevel; c++) { 
           if ((nodeList[j].id == breadcrumb[c].id)) { inBreadcrumb = 1; }
        }
        var active = ""; // set to active if current page is node to be displayed
        if (nodeList[j].id == breadcrumb[crumbLevel-1].id) { active = 'class="active"'; }
        
        var theName = (nodeList[j].shortname != "") ? nodeList[j].shortname : nodeList[j].name;
        document.write('<li><a href="' + nodeList[j].url + '" ' + active + '>' + theName + '</a>');
            
        if (inBreadcrumb == 1) {
          var showLevel = thisLevel + 1;
          thisLevel = displayNodeLevel(showLevel);
        }
        
        document.write('</li>');
      
        } // end if correct level
	  }
      
      //end level
     if (thisLevel > 1) {
      document.write('</ul>');
     }

      return thisLevel-1;
} // end function
// ***** END SIDE NAV SCRIPT ****** //

function dsp(loc){
   if(document.getElementById){
      var foc=loc.firstChild;
      foc=loc.firstChild.innerHTML?
         loc.firstChild:
         loc.firstChild.nextSibling;
      foc.innerHTML=foc.innerHTML=='+'?'-':'+';
      foc=loc.parentNode.nextSibling.style?
         loc.parentNode.nextSibling:
         loc.parentNode.nextSibling.nextSibling;
      foc.style.display=foc.style.display=='block'?'none':'block';
	}
}  