// JavaScript function to display drop-down menu on Ian Wright's Wedding Photography website
// (c) 2010 Flipside Web Design
// Author: Richard Adams - r.adams@flipside.co.uk

var maxwidth=600;
var barwidth=228;
var barheight=73;

var browser = '';

// Detect browser
if (navigator.appName.indexOf('Microsoft') != -1) { browser = 'IE' }
else if (navigator.appName.indexOf('Netscape') != -1) { browser = 'Netscape' }
else { browser = 'IE' } // bit pointless
var version = navigator.appVersion;

function moveBar(andHeight) {
if (browser=='IE') { var w = document.body.clientWidth; var h = document.body.clientHeight; }
else if (browser=='Netscape') { var w = window.innerWidth - 20; var h = window.innerHeight; }
else { var w = 800; var h = 400; }

if (document.getElementById) { var photostrip = document.getElementById('photostrip') }
else if (document.all) { var photostrip = document.all['photostrip'] }
else if (document.layers) { var photostrip = document.layers['photostrip'] }

if (photostrip)
  {
  if (w-barwidth > maxwidth) { photostrip.style.left = w-barwidth }
  if (barheight) { photostrip.style.top = barheight }
  if (andHeight) { photostrip.style.height = h-barheight-12 }
  }
}

function printMenu(thispage) {
document.write('<table cellpadding=0 cellspacing=0 border=0><tr height=2><td colspan=15><img src="images/mask.gif" alt="" width=400 height=4 border=0></td></tr><tr valign=top>');

if (thispage=='home') { document.write('<td><a href="index.html"><img src="images/bhome1.gif" alt="" width=45 height=18 border=0 onMouseOver="showMenu(\'home\')" onMouseOut="hideMenu(\'home\')"></a></td>') }
else { document.write('<td><a href="index.html"><img src="images/bhome0.gif" alt="" width=45 height=18 border=0 onMouseOver="this.src=\'images/bhome1.gif\'; showMenu(\'home\')" onMouseOut="this.src=\'images/bhome0.gif\'; hideMenu(\'home\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='aboutus') { document.write('<td><a href="aboutus.html"><img src="images/baboutus1.gif" alt="" width=69 height=18 border=0 onMouseOver="showMenu(\'aboutus\')" onMouseOut="hideMenu(\'aboutus\')"></a></td>') }
else { document.write('<td><a href="aboutus.html"><img src="images/baboutus0.gif" alt="" width=69 height=18 border=0 onMouseOver="this.src=\'images/baboutus1.gif\'; showMenu(\'aboutus\')" onMouseOut="this.src=\'images/baboutus0.gif\'; hideMenu(\'aboutus\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='availability') { document.write('<td><a href="availability.html"><img src="images/bavailability1.gif" alt="" width=75 height=21 border=0 onMouseOver="showMenu(\'availability\')" onMouseOut="hideMenu(\'availability\')"></a></td>') }
else { document.write('<td><a href="availability.html"><img src="images/bavailability0.gif" alt="" width=75 height=21 border=0 onMouseOver="this.src=\'images/bavailability1.gif\'; showMenu(\'availability\')" onMouseOut="this.src=\'images/bavailability0.gif\'; hideMenu(\'availability\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='gallery') { document.write('<td><a href="cgi-bin/gallery.cgi"><img src="images/bgallery1.gif" alt="" width=53 height=21 border=0 onMouseOver="showMenu(\'gallery\')" onMouseOut="hideMenu(\'gallery\')"></a></td>') }
else { document.write('<td><a href="cgi-bin/gallery.cgi"><img src="images/bgallery0.gif" alt="" width=53 height=21 border=0 onMouseOver="this.src=\'images/bgallery1.gif\'; showMenu(\'gallery\')" onMouseOut="this.src=\'images/bgallery0.gif\'; hideMenu(\'gallery\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='weddings') { document.write('<td><a href="cgi-bin/recent.cgi"><img src="images/brecentweddings1.gif" alt="" width=116 height=21 border=0 onMouseOver="showMenu(\'weddings\')" onMouseOut="hideMenu(\'weddings\')"></a></td>') }
else { document.write('<td><a href="cgi-bin/recent.cgi"><img src="images/brecentweddings0.gif" alt="" width=116 height=21 border=0 onMouseOver="this.src=\'images/brecentweddings1.gif\'; showMenu(\'weddings\')" onMouseOut="this.src=\'images/brecentweddings0.gif\'; hideMenu(\'weddings\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='examples') { document.write('<td><a href="cgi-bin/examples.cgi"><img src="images/bexamples1.gif" alt="" width=130 height=23 border=0 onMouseOver="showMenu(\'examples\')" onMouseOut="hideMenu(\'examples\')"></a></td>') }
else { document.write('<td><a href="cgi-bin/examples.cgi"><img src="images/bexamples0.gif" alt="" width=130 height=23 border=0 onMouseOver="this.src=\'images/bexamples1.gif\'; showMenu(\'examples\')" onMouseOut="this.src=\'images/bexamples0.gif\'; hideMenu(\'examples\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='commissions') { document.write('<td><a href="commissions.html"><img src="images/bcommissions1.gif" alt="" width=90 height=15 border=0 onMouseOver="showMenu(\'commissions\')" onMouseOut="hideMenu(\'commissions\')"></a></td>') }
else { document.write('<td><a href="commissions.html"><img src="images/bcommissions0.gif" alt="" width=90 height=15 border=0 onMouseOver="this.src=\'images/bcommissions1.gif\'; showMenu(\'commissions\')" onMouseOut="this.src=\'images/bcommissions0.gif\'; hideMenu(\'commissions\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='packages') { document.write('<td><a href="packages.html"><img src="images/bpackages1.gif" alt="" width=62 height=21 border=0 onMouseOver="showMenu(\'packages\')" onMouseOut="hideMenu(\'packages\')"></a></td>') }
else { document.write('<td><a href="packages.html"><img src="images/bpackages0.gif" alt="" width=62 height=21 border=0 onMouseOver="this.src=\'images/bpackages1.gif\'; showMenu(\'packages\')" onMouseOut="this.src=\'images/bpackages0.gif\'; hideMenu(\'packages\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='guide') { document.write('<td><a href="guide.html"><a href="guide.html"><img src="images/bguide1.gif" alt="" width=44 height=18 border=0 onMouseOver="showMenu(\'guide\')" onMouseOut="hideMenu(\'guide\')"></a></a></td>') }
else { document.write('<td><a href="guide.html"><img src="images/bguide0.gif" alt="" width=44 height=18 border=0 onMouseOver="this.src=\'images/bguide1.gif\'; showMenu(\'guide\')" onMouseOut="this.src=\'images/bguide0.gif\'; hideMenu(\'guide\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='venues') { document.write('<td><a href="cgi-bin/venues.cgi"><img src="images/bvenues1.gif" alt="" width=51 height=18 border=0 onMouseOver="showMenu(\'venues\')" onMouseOut="hideMenu(\'venues\')"></a></td>') }
else { document.write('<td><a href="cgi-bin/venues.cgi"><img src="images/bvenues0.gif" alt="" width=51 height=18 border=0 onMouseOver="this.src=\'images/bvenues1.gif\'; showMenu(\'venues\')" onMouseOut="this.src=\'images/bvenues0.gif\'; hideMenu(\'venues\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

if (thispage=='portrait') { document.write('<td><a href="portrait.html"><img src="images/bportrait1.gif" alt="" width=58 height=20 border=0 onMouseOver="showMenu(\'portrait\')" onMouseOut="hideMenu(\'portrait\')"></a></td>') }
else { document.write('<td><a href="portrait.html"><img src="images/bportrait0.gif" alt="" width=58 height=20 border=0 onMouseOver="this.src=\'images/bportrait1.gif\'; showMenu(\'portrait\')" onMouseOut="this.src=\'images/bportrait0.gif\'; hideMenu(\'portrait\')"></a></td>') }
document.write('<td><img src="images/mask.gif" alt="" width=4 height=21 border=0></td>');

document.write('</tr></table>');

var currentLink=thispage;
printSubmenus();
moveBar();
}

var stayopen = '';
var currentmenu = '';
var currentLink='';
var menuID = '';
var incgi = '';
var count = 0;

function showMenu(menuID) {
  if (currentmenu != '') { stayopen = 0; closeMenu(); }
  if (document.getElementById) {
    var element = document.getElementById(menuID).style
  }
  else if (document.all) {
    var element = document.all[menuID].style
  }
  else if (document.layers) {
    var element = document.layers[menuID]
  }

  element.visibility = 'visible';
  stayopen = 1;
  currentmenu = menuID;
}

function hideMenu(menuID) {
  stayopen = 0;
  if (stayopen == 1) { setTimeout("hideMenu()", 2000); return; }
  if (document.getElementById) {
    var element = document.getElementById(menuID).style
  }
  else if (document.all) {
    var element = document.all[menuID].style
  }
  else if (document.layers) {
    var element = document.layers[menuID]
  }

  setTimeout("closeMenu()", 2000);
  element.stayopen = 0;
}

function closeMenu() {
  if (stayopen == 1) { setTimeout("closeMenu()", 2000); return; }
  if (!currentmenu) { return }

  if (document.getElementById) {
    var element = document.getElementById(currentmenu).style
  }
  else if (document.all) {
    var element = document.all[currentmenu].style
  }
  else if (document.layers) {
    var element = document.layers[currentmenu]
  }

  element.visibility = 'hidden';
  currentmenu = '';
}

function printSubmenus() {

printMenustart('home', -3);
printMenuitem('index.html', 'Home - Welcome');
printMenuitem('contactus.html', 'Contact details and form');
printMenuend();

printMenustart('aboutus', 48);
printMenuitem('aboutus.html', 'About Us');
printMenuitem('cgi-bin/iwgb.cgi?page=guestbook_view', 'View Guestbook');
printMenuitem('cgi-bin/iwgb.cgi?page=guestbook_makesign', 'Sign Guestbook');
printMenuitem('cgi-bin/links.cgi', 'Links to Related Sites');
printMenuitem('cgi-bin/contact.cgi', 'Contact Details');

printMenuend();

printMenustart('availability', 121);
printMenuitem('availability.html', 'Availability');

printMenuend();

printMenustart('gallery', 200);
printMenuitem('cgi-bin/gallery.cgi', 'Gallery of Photos');
printMenuitem('cgi-bin/gallery.cgi?sid=2', 'Portfolio 1');
printMenuitem('cgi-bin/gallery.cgi?sid=6', 'Reportage 1');
printMenuitem('cgi-bin/gallery.cgi?sid=12', 'Wedding Details');
printMenuitem('cgi-bin/gallery.cgi?sid=3', 'Black & White 1');
printMenuitem('cgi-bin/gallery.cgi?sid=5', 'Groups & Guests');
printMenuitem('cgi-bin/gallery.cgi?sid=1', 'The Bride & Groom 2');
printMenuitem('cgi-bin/gallery.cgi?sid=10', 'The Ceremony');
printMenuitem('cgi-bin/gallery.cgi?sid=4', 'Montages & Special Effects');
printMenuitem('cgi-bin/gallery.cgi?sid=13', 'Album Design Natalie and Richard');
printMenuitem('cgi-bin/gallery.cgi?sid=11', 'Victoria and Steve Snapshot');

printMenuend();

printMenustart('weddings', 256);
printMenuitem('cgi-bin/recent.cgi', 'Recent Weddings');
printMenuitem('cgi-bin/buyprints.cgi', 'Buying Prints');
printMenuitem('cgi-bin/examples.cgi', 'Wedding Examples');
printMenuitem('cgi-bin/recent.cgi?type=Event', 'Recent Events');
printMenuend();

printMenustart('examples', 380);
printMenuitem('cgi-bin/examples.cgi', 'Wedding Examples');
printMenuitem('cgi-bin/recent.cgi', 'Recent Weddings');
printMenuend();

printMenustart('commissions', 512);
printMenuitem('commissions.html', 'Commissions');

printMenuend();

printMenustart('packages', 606);
printMenuitem('cgi-bin/showpage.cgi?page=packages.html', 'Packages Outline');

printMenuitem('faq.html', 'FAQ');
printMenuitem('cgi-bin/iwgb.cgi?page=guestbook_view', 'View Guestbook');
printMenuitem('cgi-bin/iwgb.cgi?page=guestbook_makesign', 'Sign Guestbook');
printMenuend();

printMenustart('guide', 673);
printMenuitem('cgi-bin/showpage.cgi?page=guide1.html', 'An Illustrated Guide: Part 1');
printMenuitem('cgi-bin/showpage.cgi?page=guide2.html', 'An Illustrated Guide: Part 2');

printMenuend();

printMenustart('venues', 745);
printMenuitem('cgi-bin/venues.cgi', 'Reception Venues');
printMenuitem('cgi-bin/showpage.cgi?page=bishops.html', 'Bishop\'s Court, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=bor.html', 'Boringdon Hall, Plymouth');
printMenuitem('cgi-bin/showpage.cgi?page=burgh.html', 'Burgh Island, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=clovelly.html', 'Clovelly, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=combe.html', 'Combe House, Gittisham, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=escot.html', 'Escot House, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=huntsham.html', 'Huntsham Court, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=kitleyhouse.html', 'Kitley House, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=maunsel.html', 'Maunsel House, Somerset');
printMenuitem('cgi-bin/showpage.cgi?page=powderhamcastle.html', 'Powderham Castle, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=reed.html', 'Reed Hall, Exeter University');
printMenuitem('cgi-bin/showpage.cgi?page=stoodleigh.html', 'Stoodleigh Court, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=belvedere.html', 'The Haldon Belvedere, Devon');
printMenuitem('cgi-bin/showpage.cgi?page=haldon.html', 'The Lord Haldon Hotel, Devon');

printMenuend();

printMenustart('portrait', 782);
printMenuitem('portrait.html', 'Portrait');
printMenuitem('cgi-bin/showpage.cgi?page=portrait.html', 'Portrait Photography');

printMenuend();
}

function printMenustart(menuname, xpos) {
document.write("<div id=\"" + menuname + "\" style=\"position: absolute; top: 99; left: " + xpos + "; visibility: hidden; background: #8f6607; z-index: 10; border: 1px solid #000000\" onMouseOver=\"stayopen=1\" onMouseOut=\"stayopen=0\"><table cellpadding=0 cellspacing=0 border=0 bgcolor=#8f6607>");
}

function printMenuitem(link, item) {
count++;
if (link==currentLink) { document.write("<tr height=17><td class=navon nowrap>&nbsp;"+item+"</td></tr>\n") }
else { document.write("<tr height=17><td class=nav nowrap onClick=\"top.location='"+incgi+link+"'\" onMouseOver=\"stayopen=1; this.className='navHi'; tab" + count + ".className='menuhi'\" onMouseOut=\"this.className='nav'; tab" + count + ".className='menu'\">&nbsp;<a href=\""+link+"\" id='tab"+count+"' class=menu>" + item + "</a></td></tr>\n") }
}

function printMenuend() {
document.write("</table></div>");
}

// Testimonials: View at random
function testy(classname) {
if (!classname) { classname ='' }
testimonials = new Array(
'testimonial 1',
'testimonial 2',
'testimonial 3',
'testimonial 4',
'testimonial 5'
);

var testy = Math.floor(Math.random() * testimonials.length);
document.write('<div align=center><p class=testimonial'+classname+'>'+testimonials[testy]+'<br><a href="references.html">View more references</a></p></div>');
}
