/****************************************
|
| London Home Builders' Association
| Created by: Kevin Biskaborn
| Copyright 2008 ScriptReaction
| http://www.scriptreaction.com
|
****************************************/

var navTabs = {
	set: function (action,start){
		navTabs.action = action; //action function id
		navTabs.start = start - 1; //first tab = array[0];
		
		var subNavHolder = document.getElementById("bdy_subNav");
		if(subNavHolder == null) subNavHolder = document.getElementById("bdy_subNav_split");
		
		var subNavItems = subNavHolder.getElementsByTagName("li");
		var subNavHrefs = subNavHolder.getElementsByTagName("a");
		
		navTabs.names = new Array();
		
		for(var itemCount=0; itemCount<subNavItems.length; itemCount++){
			var whichItem = subNavItems[itemCount];
			var whichHref = subNavHrefs[itemCount];
			
			if(whichHref.name){
			
				whichItem.value = itemCount;
				navTabs.names.push(whichHref.name);
				whichHref.id = "navTab" + itemCount;
				
				whichItem.onclick = function (){
					navTabs.ck(this.value);	
				}
				
				whichHref.onclick = function (){
					this.blur();
					return false;
				}
				
			}
		}
	},
	launch: function (){
		if(typeof(navTabs.start) != "undefined") navTabs.ck(navTabs.start);
	},
	menuOn: -1,
	ck: function (x){ //tab click
		if(x != navTabs.menuOn){
			navTabs.menuOn = x; 
			navTabs.rs();
			var thetab = document.getElementById("navTab" + x);
			with(thetab){
				with(style){
					color 				= "#fff";
					fontWeight			= "bold";
					textDecoration		= "none";
					backgroundColor 	= "#669966";
					borderBottom		= "1px solid #669966";
					if(!(shell.browser == "ie" && shell.browserVersion == 6)){
						lineHeight 		= "26px";
					}
					cursor 				= "default";
				}
			blur();
			}
			eval('navTabs.doAction' + navTabs.action + '("' + x + '")');
		}
	},
	rs: function (){ //tab reset
		for(var i=0; i<navTabs.names.length; i++){
			var thetab = document.getElementById("navTab" + i);
			with(thetab.style){
				color 			= "";
				fontWeight		= "";
				textDecoration	= "";
				backgroundColor = "";
				borderBottom	= "";
				lineHeight		= "";
				cursor 			= "";
			}
			var thePage = document.getElementById("tabItem_" + navTabs.names[i]);
			with(thePage.style){
				display = "none";
			}
		}
	},
	
	<!-- specific click actions -->
	doAction1: function (x){
		document.getElementById("tabItem_" + navTabs.names[x]).style.display = "block";
	}
}

/********** nav tabs init **********/
global.addEvent(window, "load", navTabs.launch);
