/*-  M+H scripts
----------------------------------------------------------------------*/
addLoadEvent(function() {
	addPopups("calc", {
		width: 700,
		height: 500,
		resizable: 1,
		scrollbars: 1
	});
});

/*
	Attach popup functionality to links with a certain "rel" attribute
*/
function addPopups(rel, params) {
	if (document.getElementsByTagName) {
		var links = document.getElementsByTagName("a");
		if (links) {
			var length = 0;
			for (var j in params) {
				length++;
			}

			for (var i = 0; i < links.length; i++) {
				var thisLink = links[i];
				var thisRel = links[i].getAttribute("rel");
				if (thisRel && findWord(rel, thisRel)) {
					var str = "";
					var count = 0;

					for (var j in params) {
						str += j + "=" + params[j];

						if (count < (length - 1)) {
							str += ", ";
						}
						count++;
					}

					thisLink.onclick = function() {
						window.open(this.href, rel, str);
						return false;
					}
				}
			}
		}
	}
}

/*-  Utility functions
----------------------------------------------------------------------*/
/*
	Add Load Event
*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/*
	Find full word (needle) in a string (haystack)
*/
function findWord(needle, haystack) {
	return haystack.match(needle + "\\b");
}



/* FastFind Voodoo Script
--------------------------------------------------------------------*/

var fastfind_hide = new Array(5);
var fastfind_options = [
                      [  0, 'looking for...',							1, 1, 1, 1, 1, 1 ],
						[  1, 'Accounts Planning', 			    		0, 1, 0, 0, 0, 0 ],
						[  2, 'Audit & Assurance Help',         		0, 1, 0, 0, 0, 0 ],
						[  3, 'Long-term Growth Assisstance',			0, 1, 0, 0, 0, 0 ],
						[  4, 'Accounting Services',	  				0, 1, 0, 0, 0, 0 ],
						[  5, 'Mercer & Hole Locations',				0, 1, 0, 0, 0, 0 ],
						[  6, 'Contact Information',					0, 1, 1, 1, 1, 1 ],
						[  7, 'Company News',							0, 1, 0, 0, 0, 1 ],
						[  8, 'Moving on Assistance',					0, 1, 0, 0, 0, 0 ],
						[  9, 'Turnaround & Recovery Help',				0, 1, 0, 0, 0, 0 ],
						[ 10, 'Doing Business Overseas',       			0, 1, 0, 0, 0, 1 ],
						[ 11, 'National Insurance',						0, 1, 0, 0, 0, 0 ],
						[ 12, 'Important Announcements',	   		 	0, 1, 0, 0, 0, 0 ],
						[ 13, 'Mercer & Hole Partners',		   			0, 1, 0, 0, 0, 0 ],
						// [ 14, 'Contact Information',					0, 1, 0, 0, 0, 0 ],
						[ 14, 'Partnership Services',		   	 		0, 1, 0, 0, 0, 0 ],
						[ 15, 'Payroll Services',						0, 1, 0, 0, 0, 0 ],
						[ 16, 'Personal Insolvency Advice',	   	 		0, 1, 0, 0, 0, 0 ],
						[ 17, 'News & Business Publications',			0, 1, 0, 0, 0, 0 ],
						[ 18, 'Taxation Services',						0, 1, 0, 0, 0, 0 ],
						[ 19, 'Tax Return Assistance',					0, 1, 0, 0, 0, 0 ],
						[ 20, 'VAT (value added tax)',		    		0, 1, 0, 0, 0, 0 ],
						[ 21, 'Accountancy Services',		   	 		0, 0, 1, 1, 1, 0 ],
						[ 22, 'Company Tax Planning Service',			0, 0, 1, 0, 0, 0 ],
						[ 23, 'Audit Services',		    				0, 0, 1, 0, 0, 0 ],
						[ 24, 'Company Auditing Services',				0, 0, 1, 1, 1, 1 ],
						[ 25, 'Sustainable Financial Wealth',			0, 0, 1, 0, 0, 0 ],
						[ 26, 'Charitable affairs',		    			0, 0, 1, 1, 1, 1 ],
						// [ 28, 'Contact Information',		    		0, 0, 1, 1, 1, 0 ],
						[ 27, 'Business News',				    		0, 0, 1, 1, 1, 0 ],
						[ 28, 'Family Planning - Inheritance (IHT)', 	0, 0, 1, 0, 0, 0 ],
						[ 29, 'Business Insolvency Assistance',		 	0, 0, 1, 1, 1, 0 ],
						[ 30, 'International Trade Relations',		  	0, 0, 1, 0, 0, 0 ],
						[ 31, 'International Rescue',		   	 		0, 0, 1, 0, 0, 0 ],
						[ 32, 'NI (National Insurances) Assistance',   	0, 0, 1, 1, 1, 1 ],
						[ 33, 'Important Announcement',		    		0, 0, 1, 1, 1, 0 ],
						[ 34, 'Mercer & Hole Partner Information',	0, 0, 1, 1, 1, 1 ],
						// [ 37, 'Contact Information',		   	 		0, 0, 1, 0, 0, 0 ],
						[ 35, 'PAYE Assistance',		    			0, 0, 1, 1, 1, 1 ],
						[ 36, 'Personal Insolvency Assistance',			0, 0, 1, 0, 0, 1 ],
						[ 37, 'News & Business Publications',			0, 0, 1, 1, 1, 1 ],
						[ 38, 'Tax on Sole Traders',		    		0, 0, 1, 1, 1, 0 ],
						[ 39, 'Specialist Assurance Assistance', 		0, 0, 1, 1, 1, 1 ],
						[ 40, 'Personal Tax Planning Service',	 		0, 0, 1, 0, 0, 0 ],
						[ 41, 'VAT Help',							 	0, 0, 1, 1, 1, 1 ],
						[ 42, 'Company Accounts Planning ',				0, 0, 0, 1, 1, 1 ],
						[ 43, 'Auditing Assistance',					0, 0, 0, 1, 1, 1 ],
						// [ 47, 'Charitable Affairs',						0, 0, 0, 1, 0, 1 ],
						[ 44, 'Mercer & Hole Partner Locations',    0, 0, 0, 1, 1, 1 ],
						[ 45, 'Personal IHT Guidance',					0, 0, 0, 1, 1, 1 ],
						[ 46, 'International Trade & Industry Help',	0, 0, 0, 1, 1, 0 ],
						[ 47, 'Worldwide Service Options',				0, 0, 0, 1, 1, 0 ],
						[ 48, 'Personal Insolvency Assistance',			0, 0, 0, 1, 1, 0 ],
						[ 49, 'Company Tax Planning Help',				0, 0, 0, 1, 1, 1 ],
						[ 50, 'Future Proofing',						0, 0, 0, 1, 1, 0 ],
						[ 51, 'Partnership Tax Guidance',				0, 0, 0, 0, 1, 1 ],
						// [ 56, 'News & Business Publications',		0, 0, 0, 0, 1, 0 ],
						[ 52, 'Accountancy Assistance',					0, 0, 0, 0, 0, 1 ],
						[ 53, 'Long-term planning',						0, 0, 0, 0, 0, 1 ],
						[ 54, 'Company Insolvency Issues',				0, 0, 0, 0, 0, 1 ],
						[ 55, 'International Services',					0, 0, 0, 0, 0, 1 ],
						[ 56, 'Tomorrow\'s News',						0, 0, 0, 0, 0, 1 ],
						[ 57, 'Business Taxation Services',				0, 0, 0, 0, 0, 1 ]
                   ];

function fastfind_changed( entity )
{
  var i;
  var service;
  var count;
  var opt;

  entity = parseInt( entity );

  service = document.fastfind_form.elements['service'];

  service.options.length = 0;
  count = 0;

  for ( i = 0; i < fastfind_options.length; i++ )
  {
    if ( fastfind_options[i][entity+2] )
    {
      opt = new Option;
      opt.text = fastfind_options[i][1];
      opt.value = fastfind_options[i][0];

      service.options[count++] = opt;
    }
  }
}
                                                          