//
// Menu functions for Consulting Overseas Website
//
// © 2004 Flipside Web Design
// Author: Richard Adams
//
// Also includes "send2friend" code
//

var stayopen = '';
var currentmenu = '';
var menuID = '';

function beenResized() {

  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  var isNS = navigator.appName.indexOf("Netscape") != -1;

  if (isIE) { w = document.body.clientWidth }
  else if (isNS) { w = window.innerWidth }
  else { w = 725 }

  var menus = new Array('home', 'news', 'aboutus', 'calculator', 'incentives', 'events', 'contactus','links');
  var posns = new Array(25, 76, 128, 206, 377, 466, 530, 605);
  for (i = 0; i < menus.length; i++) {
    var menutitle = menus[i];
    var xpos = posns[i];
    if (document.getElementById) { var menu = document.getElementById(menutitle) }
    else if (document.all) { var menu = document.all[menutitle] }
    else if (document.layers) { var menu = document.layers[menutitle] }

    if (w > 725 + 12) {
      menu.style.left = Math.floor((w - 725) / 2) + xpos - 6;
    }
    else {
      menu.style.left = xpos;
    }
  }
}

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()", 1000); 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()", 1000);
  element.stayopen = 0;
}

function closeMenu() {
  if (stayopen == 1) { setTimeout("closeMenu()", 1000); 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 printMenu() {

document.write("<table cellpadding=0 cellspacing=0 border=0 height=26>\n\n<tr><td width=26><img src=\"images/mask.gif\" alt=\"\" width=26 height=26 border=0></td>");
printMenutab('home', 'HOME', 'home.html');
printMenutab('news', 'NEWS', 'news.html');
printMenutab('aboutus', 'ABOUT US', 'aboutus.html');
printMenutab('calculator', 'EARNINGS CALCULATOR', 'taxcalculator.html');
//printMenutab('legal', 'LEGAL SECTION', 'barristersopinion.html');
printMenutab('incentives', 'INCENTIVES', 'incentives.html');
printMenutab('events', 'EVENTS', 'events');
printMenutab('contactus', 'CONTACT US', 'contact');
printMenutab('links', 'LINKS', 'links.html');
document.write("</tr></table>\n\n");

printMenustart('home', 25, 2);
printMenuitem('home.html', 'Home - welcome');
printMenuitem('sitemap.html', 'Site map');
printMenuend();

printMenustart('news', 76, 6);
printMenuitem('news.html', 'All the latest news');
printMenuitem('budget2006-index.html', 'Budget 2006 - Tax Guide');
printMenuitem('shout99-launch.html', 'Shout99 announces Consulting Overseas as Preferred Supplier');
printMenuitem('qdosapproval.html', 'Qdos insure Consulting Overseas solutions');
printMenuitem('s660a.html', 'Landmark S660 ruling - PCG Report');
printMenuitem('s660aconsequences.html', 'Consequences of S660 ruling');
printMenuend();

printMenustart('aboutus', 128, 4);
printMenuitem('aboutus.html', 'About Consulting Overseas');
printMenuitem('faq.html', 'FAQ');
printMenuitem('ir35.html', 'IR35 - What you need to know');
printMenuitem('taxexpenses.html', 'Expense guidelines');
printMenuend();

printMenustart('calculator', 206, 1);
printMenuitem('taxcalculator.html', 'Earnings calculator');
//printMenuitem('clienttestimonials.html', 'Client Testimonials');
//printMenuitem('whoourclientsworkfor.html', 'Who our clients work for');
//printMenuitem('agentsweworkwith.html', 'Agents we work with');
printMenuend();

printMenustart('incentives', 377, 4);
printMenuitem('incentives.html', 'Introductions & incentives');
printMenuitem('referral', 'Introduce a colleague');
printMenuitem('feesfree.html', 'Fees free incentive');
printMenuitem('advocate.html', 'Advocate agreement');
printMenuend();

printMenustart('events', 466, 1);
printMenuitem('events', 'Events');
//printMenuitem('oldevents', 'Previous events');
//printMenuitem('cgi-bin/news.cgi', 'Latest news');
//printMenuitem('prizewinners.html', 'Prize winners');
printMenuend();

printMenustart('contactus', 530, 3);
printMenuitem('contact', 'Contact form');
printMenuitem('contactdetails.html', 'Contact details');
printMenuitem('location.html', 'Location & map');
printMenuend();

printMenustart('links', 605, 1);
printMenuitem('links.html', 'Related web sites');
printMenuend();

}

function printMenutab(menuname, menutitle, link) {
document.write("<td onMouseOver=\"showMenu('" + menuname + "')\" onMouseOut=\"hideMenu('" + menuname + "')\" class=menutab><a href=\"cgi-bin/co.cgi?usr="+usr+"&page="+link+"\" class=menutab>" + menutitle + "</a>&nbsp;&nbsp;&nbsp;</td>");
}

function printMenustart(menuname, xpos, lines) {
ypos = 164 - (lines * 16);
document.write("<div id=\"" + menuname + "\" style=\"position: absolute; top: " + ypos + "; left: " + xpos + "; visibility: hidden; filter: alpha(opacity=85)\" onMouseOver=\"stayopen=1\" onMouseOut=\"stayopen=0\"><table cellpadding=0 cellspacing=0 border=0><tr valign=top><td><img src=\"images/boxtl2.gif\" alt=\"\" width=3 height=3 border=0></td><td background=\"images/boxt2.gif\"><img src=\"images/mask.gif\" alt=\"\" width=3 height=3 border=0></td><td rowspan=2 colspan=2><img src=\"images/boxtr12.gif\" alt=\"\" width=14 height=14 border=0></td></tr>\n\n<tr><td background=\"images/boxl2.gif\"><img src=\"images/mask.gif\" alt=\"\" width=3 height=11 border=0></td><td bgcolor=#e5e5e5><img src=\"images/mask.gif\" alt=\"\" width=100 height=3 border=0></td></tr>");
}

function printMenuitem(link, item) {
document.write("<tr><td background=\"images/boxl2.gif\"><img src=\"images/mask.gif\" alt=\"\" width=3 height=3 border=0></td><td class=nav nowrap onClick=\"top.location='co.cgi?usr="+usr+"&page=" + link + "'\" onMouseOver=\"stayopen=1; this.className='navOn'\" onMouseOut=\"this.className='nav'\">&nbsp;<a href=\"cgi-bin/co.cgi?usr="+usr+"&page=" + link + "\" class=menu>" + item + "</a></td><td bgcolor=#e5e5e5><img src=\"images/mask.gif\" alt=\"\" width=11 height=11 border=0></td><td background=\"images/boxr2.gif\"><img src=\"images/mask.gif\" alt=\"\" width=3 height=3 border=0></td></tr>\n");
}

function printMenuend() {
document.write("<tr><td><img src=\"images/boxbl2.gif\" alt=\"\" width=3 height=3 border=0></td><td background=\"images/boxb2.gif\" colspan=2><img src=\"images/mask.gif\" alt=\"\" width=3 height=3 border=0></td><td><img src=\"images/boxbr2.gif\" alt=\"\" width=3 height=3 border=0></td></tr></table></div>");
}

function send2friend() {
var loc = top.location.toString();
var pos = loc.lastIndexOf('page=');
if (pos == -1) { var link = 'home' }
else { link = loc.substr(pos + 5) }
if (loc.indexOf('cgi-bin') != -1) { var cgi = '' } else { var cgi = 'cgi-bin/' }
window.open(cgi+'send2friend.cgi?sendpage='+link, 'Send2Friend', 'width=537,height=400,status=no,scrollbars=auto,resizable=yes');
}

function linksBar() {
// Prints links bar content
// Site links
document.write('<table cellpadding=2 cellspacing=0 border=0 width=141 style="margin-top: 4px">');
document.write('<tr><td align=center><img src="images/icon_info.gif" alt="" width=8 height=14 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=sandfield" class=linksbar>Sandfield Info</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_calculator.gif" alt="" width=11 height=17 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=taxcalculator.html" class=linksbar>Earnings calculator</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_faq.gif" alt="" width=10 height=14 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=faq.html" class=linksbar>FAQ</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_introduce.gif" alt="" width=15 height=18 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=referral" class=linksbar>Introduce a colleague</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_incentives.gif" alt="" width=15 height=15 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=incentives.html" class=linksbar>Introducer payments and other incentives</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_faq.gif" alt="" width=10 height=14 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=ir35.html" class=linksbar>IR35 - what you need to know</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_printer.gif" alt="" width=16 height=15 border=0></td><td><a href="javascript:print()" class=linksbar>Print this page</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_email.gif" alt="" width=15 height=15 border=0></td><td><a href="javascript:send2friend()" class=linksbar>Send this to a friend</a></td></tr>');
document.write('<tr><td align=center><img src="images/icon_info.gif" alt="" width=8 height=14 border=0></td><td><a href="cgi-bin/co.cgi?usr='+usr+'&page=budget2006-index.html" class=linksbar>2006 Budget Report</a></td></tr>');
document.write('</table>');
// Adverts
document.write('<div align=center><img src="images/mask.gif" alt="" width=145 height=2 border=0><br><a target="_blank" href="cgi-bin/co.cgi?usr='+usr+'&page=web_www.copost.net"><img src="adverts/copost.gif" alt="" width=135 height=150 border=0 vspace=8></a></div>');
}

function printLogos() {
// Prints sidebar logos
document.write('<table cellpadding=0 cellspacing=0 border=0 widht=113>');
//document.write('<tr align=center><td><img src="images/mask.gif" alt="" width=113 height=16 border=0></td></tr>');
//document.write('<tr align=center><td><img src="images/leftbar_logo.gif" alt="" width=82 height=39 border=0></td></tr>');
document.write('<tr align=center><td><img src="images/mask.gif" alt="" width=113 height=8 border=0></td></tr>');
document.write('<tr align=center><td class=small>Approved and insured by:<br><a href="cgi-bin/co.cgi?usr='+usr+'&page=qdos.html"><img src="adverts/qdoslogo.gif" alt="" width=101 height=76 border=0></a></td></tr>');
document.write('<tr align=center><td><img src="images/mask.gif" alt="" width=113 height=16 border=0></td></tr>');
//document.write('<tr align=center><td><a target="_blank" href="cgi-bin/co.cgi?usr='+usr+'&page=web_http://www.pcg.org.uk/"><img src="images/pcglogo.gif" alt="" width=75 height=71 border=0></a></td></tr>');
//document.write('<tr align=center><td><img src="images/mask.gif" alt="" width=113 height=16 border=0></td></tr>');
document.write('<tr align=center><td class=small>Recommended by:<br><a href="cgi-bin/co.cgi?usr='+usr+'&page=shout99-launch.html"><img src="images/shout99.gif" alt="" width=72 height=50 border=0></a></td></tr>');
document.write('</table>');
}
