// standard functions for the SRO website
// David Loewenstern, 2/5/04
// Modified by Paul Tukey 

// alert("This is stdFunctions.js"); //DEBUG

var isFirefox = navigator.userAgent.match(/Firefox/i)? 1 : 0;
var BaseFontSize = (isFirefox)? "1.3em" : "1.0em"; // needs work!
BaseFontSize = "12pt";
var InitString = "";
var EndString = "";
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

InitString += "<span style='font-size:"+BaseFontSize+";'>\n";
InitString += "<style>td, .td { font-size:"+BaseFontSize+";} </style>\n";
EndString   = "</span>\n";

function sroHeader(year, size) {
    size = "";
    if(year==undefined || year==null || year=="" || year.match(/[^0-9]/))
	year = "2006";
    textString = "";   // Ignore input textString.  We'll hardwire Dita & Jim instead

    var output = '<LINK REL="shortcut icon" href="/favicon.ico" type="image/x-icon" >\n';
    output += InitString;

     if(textString==undefined || textString==null || textString=="") {
	textString  = '<img src="pics/nil.gif" width=50 height=1>';
 	textString += '<a href="ditajim.html#dita">Dita Delman</a> <span class=white>- Artistic Director</span>';
 	textString += '&nbsp; &nbsp; &nbsp; ';
 	textString += '<a href="ditajim.html#jim">James Sadewhite</a> <span class=white>- Music Director</span>';
     }
    size = (size==null || size==undefined || size=="")? "" : ("size='"+size+"'");

     output += '<table cellpadding=0 cellspacing=0 border=0 align=center>';
     output += '<tr><td><img src="pics/nil.gif" width=50 height=1></td>\n';
     output += '<td valign=top><a href="http://www.njsro.com">';
     output += '<img src="SROlogo-gold-black-124x55.jpg" width=124 height=56 border=0 alt="State Repertory Opera of New Jersey">';
     output += '</a></td><td align=center><p class=normal style="margin-top:8pt;font-size:1.1em;font-weight:bold">&nbsp; -- State Repertory Opera of New Jersey</p>';
     output += '<span class=white>'+year+' Season&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
     output += '</td></tr><tr><td></td><td height=9></td></tr></table>';
     output += '<p style="margin-top:4pt;margin-bottom:10pt">';
     output += (size)? '<font '+size+'>'+textString+'</font>' : textString;
     output += '</p>';

//   document.write(output.replace(new RegExp('<','gi'),'&lt;')); //debug only
     document.write(output);
}


//for now, commented out because we are not using images in our menus.
//
//imgArry = new Array;
//
//function precacheSrc(inSrc, inIndex)
//{
//  //
//  // Precaches inSrc -- from SourceForge.
//  //
//  imgArry[inIndex] = new Image; // Make new image
//  imgArry[inIndex].src = inSrc; // Load it into invisible image
//}
//
//function toggleImage(inImg, inIndex)
//{
// //
// // Changes source
// //
//  inImg.src = imgArry[inIndex].src;
//}
//
//<img id="FOO" src="SROlogo-gold-black-124x55.jpg" onMouseOver="javascript:toggleImage(FOO,1);" onMouseOut="javascript:toggleImage(FOO,0);">


function menuItem(URL, show, selected, popup) {
  //old:  var bullet = '<span style="font-family:wingdings">&#109;</span>';
  var bullet    = '&#187;';
  var location = window.location+""
  selected = (location.match(URL+"")); 

  popup = (popup)? " target=_blank" : "";
  var button1   = '<p align="left"><nobr><a href="';
  var button2   = '" class=bare'+popup+'>'+bullet+'&nbsp;&nbsp;&nbsp;';
  var button3   = '</a></nobr></p>\n';

  var selected1 = '<p align="left"><nobr><span style="font-weight:bold;color:white';
  var selected2 = '" class=bare>'+bullet+'&nbsp;&nbsp;&nbsp;';
  var selected3 = '</span></nobr></p>\n';

  if(selected)
     return selected1 + ''  + selected2 + show + selected3;
  else
     return button1   + URL + button2   + show + button3;
}

function sroMenuBegin(itemNum,frameclass) {
  var output ='';

//  if(frameclass == undefined) {
     frameclass = 'frameleft';
//  }
  output += '<table width="100%" class=' + frameclass +'>';
  output += '<tr><td valign="top" align="left" width="150px">';

  var directions = 'direction.html';
//  var directions = 'http://www.montclair.edu/welcome/directions.html';
  var Lelisir  = "<i>L'Elisir d'Amore</i> (2006)";
  var Pasquale = "<i>Don Pasquale</i> (2007)";
  var BelCanto = "<i>Bel Canto to B'way</i>";

   output += menuItem( 'index.html',        'Home',            itemNum == 0  );
   output += menuItem( 'about.html',        'About SRO',       itemNum == 1  );
   output += menuItem( 'reviews.html',      'Reviews',         itemNum == 4  );
   output += menuItem( 'support.html',      'Support',         itemNum == 6  );
// output += menuItem( 'events.html',       'Events',          itemNum == 7  );
   output += menuItem( 'contact.html',      'Contact',         itemNum == 8  );
// output += menuItem(  directions,         'Directions',      itemNum == 9  );
   output += menuItem( 'bookings.html',     'Booking Shows',   itemNum == 10 );
   output += menuItem( 'mail.html',         'Mailing List',    itemNum == 11 );
   output += menuItem( 'bios-2007.html',     Pasquale,         itemNum == 5  );
   output += menuItem( 'lelisir.html',       Lelisir,          itemNum == 2  );
// output += menuItem( 'home-Fall2006.html', BelCanto,         itemNum == 3  );
   output += menuItem( 'gallery.html',      'Photo Gallery 1', itemNum == 12 );
   output += menuItem( 'gallery05-06/index.html', 'Photo Gallery 2', itemNum == 13 );

  if(itemNum < -1 || itemNum > 12) { // Note: -1 means show all.
    output += '\n<!-- unknown itemNum: ' + itemNum + '-->\n';
  }

  output += '</td><td width="20px"></td>';
  output += '<td>';

//  document.write(output.replace(new RegExp('<','gi'),'&lt;')); //debug only
  document.write(output);

}

function sroMenuEnd(width) {
  var output = '';

  if(width == null) {
    width = '170px'; //width of menu + spacer
  }

  output += '</td><td width="' + width + '"></td></tr></table>';

//  document.write(output.replace(new RegExp('<','gi'),'&lt;')); //debug only
  document.write(output);

}

//From Paul Tukey
function PopUp (URL,width,height) {
    if(width  == null) { width  = "500" }
    if(height == null) { height = .6*width }
    win = window.open (
	    URL, "PopUp",
	    "scrollbars,menubar,resizable," + 
	    "width=" + width + ",height=" + height );
    WinFocus(win);
}

function WinFocus(win) {
    // assume win.focus works, unless broken old msoft browser
    if ( (navigator.appName.search (/^microsoft/i) == -1) ||
         (navigator.appName == "Microsoft Internet Explorer" &&
          navigator.appVersion.indexOf("Windows", 0) != -1   &&
          navigator.appVersion.substring(0,1) >= 4) ) {
		win.focus()
    }
}


if(document['getElementById'] == null) {
  if (navigator.family == 'ie4' && navigator.version < 5) {
    document.getElementById = new Function("id", "return document.all[id];");
    }
    else if (navigator.family == 'nn4') {
      document.getElementById = nav4GetLayerById;
    }
}
var Obj  = document.getElementById;  // defines function Obj()

function sb(s){
var r=/\[([0-9A-F]{2})\]/g;s=s.replace(r,'%$1');
document.write(unescape(s))}
