//
// support code for MIT Museum site
//

// patronmail signup
function patronmail() {
  newWin=window.open('http://www.patronmail.com/pmailweb/PatronSetup?oid=778','patron_signup','height=500,width=640,scrollBars=1,resizable=0' );
	newWin.focus();
	return false;
}


// Dreamweaver functions
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_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_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];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// function checks if PNGs need to be fixed, and if so,
// calls correctPNG()
// (see pngfix.js)
function fixpng() {
  if (typeof needtofixpng != 'undefined' && needtofixpng)
    correctPNG();
}


//
// Random background/logo colors
//
var site_root = "/museum/";  // set to path of site

var randomcolors = new Array(
    { css: "styles/gradient1.css", img: "img/logo_blue.gif" },
    { css: "styles/gradient2.css", img: "img/logo_orange.gif" },
    { css: "styles/gradient3.css", img: "img/logo_green.gif" },
    { css: "styles/gradient4.css", img: "img/logo_red.gif" },
    { css: "styles/gradient5.css", img: "img/logo_red.gif" }
  );

var irandomcolor = Math.floor(Math.random()*randomcolors.length);

function write_random_background() {
  document.writeln("<link rel='stylesheet' href='"+site_root+randomcolors[irandomcolor].css+"' type='text/css' media='all' />");
}
function load_random_logo() {
  var obj = MM_findObj('imgmuseumlogo');
  if (obj && obj.src)
    obj.src = site_root+randomcolors[irandomcolor].img;
}


//
// menu code
// This is a very simple click-on, click-off menu, and could be used
// for any number of things.
// Sample code:
//  <p><a href="exhibitions/index.html" onclick="return showmenu('exhibitions')">Exhibitions</a></p>
//  <ul id="menu_exhibitions">
//    <li><a href="exhibitions/one.html">Exhibition 1</a></li>
//    <li><a href="exhibitions/two.html">Exhibition 2</a></li>
//  </ul>
//
// 2/08 - NO LONGER USED on Museum site
//
var currentmenu = '';

function showmenu(newmenu) {

  // clicking on the same
  if (currentmenu == newmenu) {
    // hide menu
    var obj1 = MM_findObj('menu_'+currentmenu);
    if (obj1 && obj1.style)
      obj1.style.display = 'none';

    // save new menu
    currentmenu = '';
  }

  // clicking on a different link
  else {
    // hide old menu
    var obj1 = MM_findObj('menu_'+currentmenu);
    if (obj1 && obj1.style)
      obj1.style.display = 'none';

    // show new menu
    var obj2 = MM_findObj('menu_'+newmenu);
    if (obj2 && obj2.style)
      obj2.style.display = 'block';

    // save new menu
    currentmenu = newmenu;
  }
  return false;  // prevent hyperlink
}
