

////////Macromedia stuff  /////////
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//reload if NN4 resized
function ResizeReloadNN4(init)
	{ 
	if (init==true) with (navigator)
		{
		if (document.layers)
			{
			pageW = innerWidth;
			pageH = innerHeight;
			onresize = ResizeReloadNN4();
			}
		}
	else if (innerWidth != pageW || innerHeight != pageH)
		{
		history.go(0);
		}
	}
	
ResizeReloadNN4(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

////////////     navigation functions        ///////////

function hide() {
		MM_showHideLayers('globalMenu1','','hide','globalMenu2','','hide','globalMenu3','','hide','subMenu1','','hide','subMenu2','','hide','subMenu3','','hide','subMenu4','','hide','subMenu0','','hide');
}

function Nav(here) {
	hide();
	MM_showHideLayers('' + here +'','','show');
}

///////	definitions:  content for various sections  ///////////

function Make(menu) {     // (edit below if you are renaming or adding menu items) 
	
	if (menu == 'globalMenu1'){ 				//HUAM: Museums
		var pages = museumPages;
		var urls = museumUrls;
		}
		
		else if (menu == "globalMenu2"){ 		//HUAM: Research
		var pages = researchPages;
		var urls = researchUrls;
		}
		
		else if (menu == "globalMenu3"){ 		//HUAM: Information
		var pages = infoPages;
		var urls = infoUrls;
		}
		
		else if (menu == "subMenu0"){ 		//Ben Shahn at Harvard: Search 
		var pages = searchPages;
		var urls = searchUrls;
		}
				
		else if (menu == "subMenu1"){ 		//Ben Shahn at Harvard: Topics
		var pages = topicPages;
		var urls = topicUrls;
		}		
		
		else if (menu == "subMenu2"){ 		//Ben Shahn at Harvard: Exhibition Tour
		var pages = exhibitPages;
		var urls = exhibitUrls;
		}		
		
		else if (menu == "subMenu3"){ 		//Ben Shahn at Harvard: Family Guide
		var pages = guidePages;
		var urls = guideUrls;
		}
				
		else if (menu == "subMenu4"){ 		//Ben Shahn at Harvard: About this site
		var pages = aboutPages;
		var urls = aboutUrls;
		}
		
			//end definition bit 

		else{
		var pages = '0';
		var urls = '0';
		}
		
		var divider = '<img src="../po/images/divider.gif" alt=" " width="125" height="20" />';
		var menulist = ' ';
		var text = ' ';



		for (var i = 0; i < pages.length; i++) {	
			if (pages[i] == "---"){
				text = divider;
				}
			else {
				text ='<p><a href="' + urls[i] + '">' + pages[i] + '</a></p>';
			}
			menulist = menulist + text;
			}
		document.write(menulist);
	
}







//
// FUNCTIONS AND VARIABLES FOR SEARCH FORMS
//


//
// function to clear all the text fields and checkboxes on a form
// use when you want to clear a form from a graphic button
//
function clearform(f) {
  if (f) {
    var i;
    for (i = 0; i < f.elements.length; i++) {
      if (f.elements[i].type == "text") {
        f.elements[i].value = f.elements[i].defaultValue;
      }
      else if (f.elements[i].type == "checkbox") {
        f.elements[i].checked = f.elements[i].defaultChecked;
      }
	else if (f.elements[i].type == "select-one") {
	  f.elements[i].options[0].selected = true;
      } 
	  else if (f.elements[i].type == "select-multiple") {
	  f.elements[i].options[0].selected = true;
      } 
    }
  }
}

//
// variable to hold reference to the artist list popup window
//
var artistlistwin = null;

//
// open artist list popup window
// letter is the letter of the alphabet whose artists should be displayed
// e is the event object from the onClick event, or null if none
// xoffset, yoffset are used with the the mouse position in the event to get the popup's position
//
function openartistlist(letter, e, xoffset, yoffset) {
  //var url = "artists_"+letter+".html"; // url to open
  var url = "webpublisher.WebCommunication?ia=ezartist&ic=basic&letter="+letter; // url to open

  if (artistlistwin != null && !artistlistwin.closed) {
    artistlistwin.location = url;
  }
  else {
    var width = 250; // width of new window
    var height = 300;  // height of new window
    var left = 510;   // coordinates of new window
    var top = 320;
    // attempt to position relative to the mouse
    // xoffset, yoffset are button x,y indices i.e. a=(0,0), b=(1,0), etc.
    // each button is 19x19 pixels
    // the idea is to get back into the gray area of the page
    if (e != null) {
      left = e.screenX - (xoffset+3)*19 - width;
      top = e.screenY - height; // keep bottom of popup at mouse height
    }
    // otherwise attempt to position relative to browser window
    else if (window.screenTop != null) {
      top = window.screenTop + top;
      left = window.screenLeft + left;
    }
    else if (window.screenX) {
      left = window.screenX + left;
      top = window.screenY + top;
    }
    // check that the popup window isn't off the edge of the screen
    if (screen.availWidth != null) {
      if (left+width > screen.availWidth) {
        left = screen.availWidth - width;
      }
      if (top+height > screen.availHeight) {
        top = screen.availHeight - height;
      }
    }
    if (left < 0)
      left = 0;
    if (top < 0)
      top = 0;

    // now open the window
    artistlistwin = window.open(url,'artistlist','resizable=1,scrollbars=1,status=0,toolbar=0,menubar=0,directories=0,'+'width='+width+',height='+height+',left='+left+',screenX='+left+',top='+top+',screenY='+top);
    if (!artistlistwin.opener) {
      artistlistwin.opener = self;
    }
  }
}

//
// close artist list popup window if open
//
function closeartistlist() {
  if (artistlistwin != null) {
    if (!artistlistwin.closed) {
      artistlistwin.close();
    }
  }
}

//
// function used by artist list popup windows -
//  sets artist in opener window's search form, then closes self
//  call with null to close without setting artist
//
function setartist(name) {
   if (name != null) {
    if (opener) {
 	  if (opener.document.searchform) {
 	    if (opener.document.searchform.txtKeyword) {
          opener.document.searchform.txtKeyword.value = name;
        }
      }
    }
  }
  self.close();
}

//
// FUNCTIONS AND VARIABLES FOR POPUP WINDOW
//