/* $Id: menu.js,v 1.11 2006/02/22 11:22:00 xsphere Exp $ */

/*
 * MacroMedia functions
 */
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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);
}


/*
 * Menu code
 * Chris Laird, 17.10.2003
 */

var espMenu = new Array(
  //basename of graphic, link destination, ALT text
  new Array('home', 'home.html', 'Home page'),

  new Array('biz_own_m', 'biz_owners/biz_owners.html', 'Business owners'),
  new Array('intermediaries', 'intermediaries/intermediaries.html', 'Intermediaries'),

  new Array('about_us', 'about/about_us.html', 'About us'),
  new Array('articles', 'articles/articles_1.html', 'Articles'),
  new Array('bookreview', 'links/book_review.html', 'Book Reviews'),
  new Array('brochures', 'brochures/brochures.html', 'Brochures'),
  new Array('case_st', 'case_studies/case_studies.html', 'Case Studies'),
  new Array('contact_us', 'contact/contact_us.html', 'Contact us'),
  new Array('diag', 'diagnostic/diagnostic_report.html', 'Diagnostic Report'),
  new Array('direct', 'directors/directors.html', 'Directors and Principals'),
  new Array('dispute', 'dispute/dispute.html', 'Dispute Resolution'),
  new Array('lectures','lectures/lectures.html', 'Lectures and Seminars'),
  new Array('links', 'links/biz_own_links.html', 'Links'),
  new Array('prods', 'products/products.html', 'Products and Services'),
  new Array('prog', 'programme/programme.html', 'Our programme'),
  new Array('selfdiag', 'selfdiag/selfdiag.html', 'Self Diagnostic'),
  new Array('sha', 'sha/sha.html', 'Shareholders\' Agreement')
);


function outputMenu(thisPage) {
  //work out if we are in the top level directory or a subdirectory
  //and set the directory prefix accordingly
  var dirPfx = (thisPage == 'home') ? '' : '../';

  //preload menu rollover images
  preloadMenuImages(dirPfx);

  //menu preamble
  document.write(
    '<table width="122" border="0" cellpadding="0" cellspacing="0">',
    ' <tr> ',
    '   <td colspan="3" height="20" valign="top">&nbsp;</td>',
    '   <td width="2" rowspan="23" valign="top" bgcolor="#000099"><img src="',dirPfx,'graphics/logos/spacer.gif" width="2" height="500"></td>',
    // Note: must adjust this  ^^ value when adding/removing buttons
    ' </tr>'
  );
  for (i = 0; i < espMenu.length; i++) {
    document.write('<tr><td valign="top" height="24" colspan="3">');
    //check if the button is for thisPage - if so use rollover image and no link
    if (thisPage == espMenu[i][0]) {
      document.write(
        '<img src="',dirPfx,'graphics/menus/',espMenu[i][0],'_ov.gif"',
        'width="120" height="24" alt="',espMenu[i][2],'"/>'
      );
    }
    //otherwise use plain image and link to appropriate page
    else {
      document.write('<a href="',dirPfx,espMenu[i][1],
        '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'',
        espMenu[i][0],'\',\'\',\'',dirPfx,'graphics/menus/',
        espMenu[i][0], '_ov.gif\',1)">',
        '<img name="', espMenu[i][0],'" border="0" src="',dirPfx,'graphics/menus/',
        espMenu[i][0], '_up.gif"  width="120" height="24" alt="',
        espMenu[i][2], '"></a>'
      );
    }
    document.write('</td></tr>\n\n');
  }
  //draw line under menu buttons
  document.write('<tr><td colspan="3" bgcolor="#8F8FD2"><img src="',dirPfx,'graphics/logos/transparent.gif" width="120" height="2"/></td></tr>');
  menuPostamble(dirPfx);
}


function preloadMenuImages(dirPfx) {
  for (i = 0; i < espMenu.length; i++) {
    var img = dirPfx + 'graphics/menus/' + espMenu[i][0] + '_ov.gif';
    MM_preloadImages(img);
  }
  //also preload rollover images for enquiry form and diagnostic report buttons
  MM_preloadImages(
    '../graphics/menus/enquiry_ov.gif',
    '../graphics/logos/diagnostic_report_download_ov.png',
    '../graphics/logos/dispute_download_ov.png',
    '../graphics/logos/corpserv_download_ov.png'
  );
}

function menuPostamble(dirPfx) {
  document.write(
    '<tr>',
    '  <td height="103"></td>',
    '  <td valign="top">',
    '    <br/><a href="http://www.howtobooks.co.uk/howto/display.asp?K=510000000647570&cid=web&sf_01=CAUTHOR&sort=SORT%5FTITLE&st_01=Hawkey&st_02=Sale+or+succesion&sf_02=CTITLE&sf_03=KEYWORD&sf_04=VX%5FISBN%3B%3D&m=1&dc=1" target="_blank"><img src="',dirPfx,'graphics/pictures/saleorsuccession.jpg" width="71" height="109" border="0" alt="&quot;Sale Or Succession&quot; by John Hawkey"></a>',
    '    <br/><br/><a href="http://www.gowerpub.com/TitleDetails.asp?sQueryISBN=0566084988&sPassString=Y&sKeyword1=Hawkey&sKeyword2=&sBooleanSearch=AND&sSearchFrom=Author&sSubjectCode=999&sNewTitle=999&lStartPos=1" target="_blank"><img src="',dirPfx,'graphics/logos/jh_book_fp.gif" width="71" height="103" border="0" alt="&quot;Exit Strategy Planning&quot; by John Hawkey"></a>',
    '  </td>',
    '  <td></td>',
    '</tr>',
    '<tr>',
    '  <td valign="top" colspan="2"><br/><a href="http://www.debtsolutionssouthwest.co.uk"><img src="',dirPfx,'graphics/logos/dssw_logo.jpg" width="108"  border="0" alt="Debt Solutions South West"></a></td>',
    '  <td></td>',
    '</tr>',
    '<tr>',
    '  <td valign="top" colspan="2" align="center"><br/><a href="http://www.buckmasterhawkey.com"><img src="',
        dirPfx,'graphics/logos/BH-logo.png" width=""  border="0" alt="BH"><br/><img src="',
        dirPfx,'graphics/logos/BH-letterhead.png" width="122" border="0" alt="Buckmaster Hawkey"></a></td>',
    '  <td></td>',
    '</tr>',
    '<tr>',
    '  <td height="80"></td>', //this value dictates how tall the menu is
    '  <td></td>',
    '  <td></td>',
    '</tr>',
    '</table>'
  );
}