/*
--------------------------------------
The variable [pagePath] is used to for pathing to image files.
Default is for pages in a single subfolder.
To change the value for higher/deeper folder structure, reset the value in the page itself 
in the first editable section after the call to this script.

For example: For pages in the root folder, use the template [root_about_page] which resets 
this variable to blank.
--------------------------------------
*/
var pagePath = "http://nt7413.vs.netbenefit.co.uk/";

function addLoadEvent(func) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = func;
			}
			else {
				window.onload = function() {
					oldonload();
					func();
				}
			}
		}
		
		function addEvent( obj, type, fn )
		{
			if (obj.addEventListener)
				obj.addEventListener( type, fn, false );
			else if (obj.attachEvent)
			{
				obj["e"+type+fn] = fn;
				obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
				obj.attachEvent( "on"+type, obj[type+fn] );
			}
		}
		
		function removeEvent( obj, type, fn )
		{
			if (obj.removeEventListener)
				obj.removeEventListener( type, fn, false );
			else if (obj.detachEvent)
			{
				obj.detachEvent( "on"+type, obj[type+fn] );
				obj[type+fn] = null;
				obj["e"+type+fn] = null;
			}
		}

		function onBg() {
			var thelist = document.getElementById('mainnav');
			
			var img = this.getElementsByTagName('img')[0];
			
			var al = img.src.split('/');
			var ipath = al[al.length-1];
			
				var navitem = ipath.replace('.gif','');
				thelist.style.backgroundImage = 'url(' +pagePath + '_img/'+ navitem +'-bg.gif)';
				
				
				if(navitem == 'nav-general') {
					thelist.style.backgroundPosition = '210px 0';
				}else if(navitem == 'nav-products') {
					thelist.style.backgroundPosition = '277px 0';
				}else if(navitem == 'nav-aviation') {
					thelist.style.backgroundPosition = '76px 0';
				}else if(navitem == 'nav-maritime') {
					thelist.style.backgroundPosition = '140px 0';
				}else {
					thelist.style.backgroundPosition = '4px 0';
				}
				
				img.src = pagePath+'_img/'+ navitem +'-active.gif';
			
		}
		
		
		
		
		function offBg() {
			var thelist = document.getElementById('mainnav');
			thelist.style.backgroundImage = 'none';
			var img = this.getElementsByTagName('img')[0];
			var al = img.src.split('/');
			var ipath = al[al.length-1];
			var navitem = ipath.replace('-active','');
			img.src = pagePath + '_img/'+navitem;
		}
		
		
		
		function navSetUp() {
			
			var list = document.getElementById('mainnav');
			var items = list.getElementsByTagName('li');
			
			for(i=0; i<items.length; i++) {
				if(items[i].className != 'active') {
					addEvent(items[i],'mouseover',onBg);
					addEvent(items[i],'mouseout',offBg);
				}
			}
		}
		
		addLoadEvent(navSetUp);




/* ===== NEW ===== */

function toggleDisplay(thisID) {
	// ## shows or hides specified object
	obj = document.getElementById(thisID);
	var thisState = "block";
	if(obj.style.display == "block") thisState = "none";
	obj.style.display = thisState;
}

function showpart(partid){
	// hides all other dives with an id starting "part"
	// then shows id "part"+partid
	
	for(i=1;i<10;i++){
		var t = document.getElementById('part'+i);
        if(t != null){
			off = eval("document.getElementById('part" + i +"')");
			off.style.display = "none";	
		}
	}
	on = document.getElementById('part' + partid );
	on.style.display = "block";	
}

/* --- used on client list page only  --- */
var clientLetter = "a";
function displayClientList(letter){
	// hide current list
	toggleDisplay('client_'+clientLetter);
	// show selected list
	toggleDisplay('client_'+letter);
	// set letter id to selected
	clientLetter = letter;
}
/* -------------------------------------- */


