var browserVersion = parseInt(navigator.appVersion);
var browserType = "Unknown";
var ie = false;
var ns = false;

if (navigator.appName.indexOf("Microsoft") != -1)
{
	browserType = "ie";
	ie = true;
}
else if (navigator.appName.indexOf("Netscape") != -1)
{

	browserType = "ns";
	ns = true;

}

if (browserType == "Unknown")
{

	browserVersion = 0;

}

if (browserVersion < 4)
{
	event = " ";
}


function HideAllMenus()
{
	if (browserVersion >= 4)
	{
		for (var i=1;i<List.Menus.length;i++) 
		{
			if (List.Menus[i].autohide == true)
			{
				List.Menus[i].hide();
			}
		}
	}
}

function showMenu(menu)
{
	if (browserVersion >= 4)
	{
		HideAllMenus();
		menu.showMenu();
	}

}

function hideMenu(menu, e)
{
	if (browserVersion >= 4)
	{
		menu.hideMenu(e);
	}

}

function writeAllMenus()
{
	if (browserVersion >= 4)
	{
		for (var i=1;i<List.Menus.length;i++) 
		{
			document.write(List.Menus[i].div)
		}
	}
}

function List(x,y,width,itemH) {
	if (browserVersion >= 4)
	{
		this.name = "List"+(List.count++)
		this.id = this.name+'List'
		this.x = x
		this.left = x
		this.y = y
		this.top = y
		this.w = width
		this.width = width
		this.right = this.left + this.width
		this.bottom = this.top
 
	
		if (arguments.length==4) 
		{
			this.itemH = itemH
			this.itemHset = true
			this.h = -1
		}
		else 
		{
			this.itemH = null
			this.itemHset = false
			if (ie)
			{
				this.h = 1000
			}
			else
			{
				this.h =  -1 
			}
		}
// set up default variable for menus

		this.itemSpacing = 1
		this.fontname = 'Verdana'
		this.fontsize = 10
		this.visibility = 'inherit'

		this.color = new Object()
		this.color.textNormal = '#ffffff'
		this.color.textSelected = '#ffffff'
		this.color.bgNormal = '#0099FF'
		this.color.bgSelected = '#FFFFFF'
		this.color.bgRollover = '#003399'
		this.color.bg = '#444444'

		this.allowDeselect = false
		this.multiSelect = false
		this.preSelect = null
		this.autohide = true
		this.submenuOnSelect = false

		this.items = new Array()
		this.selectedIndex = null
		this.obj = this.name + "ListObject"
		eval(this.obj + "=this")
		List.Menus[List.count] = this

		this.add = ListAdd
		this.build = ListBuild
		this.activate = ListActivate
		this.over = ListOver
		this.out = ListOut
		this.down = ListDown
		this.select = ListSelect
		this.onSelect = ListRedirect
		this.hideMenu = ListHideMenu
		this.hide = ListForceHide
		this.showMenu = ListShowMenu
		this.bringtofront = ListBringToFront
		this.sendtoback = ListSendToBack
	}
}
function ListAdd(value,text,submenu,handcursor) 
{
	if (browserVersion >= 4)
	{
		var i = this.items.length
		this.items[i] = new Array()
		this.items[i].selected = false
		this.items[i].value = value
		this.items[i].submenu = submenu
		this.items[i].handcursor = handcursor
		this.items[i].text = text
		if (this.items[i].text == "&nbsp;")
		{
			this.items[i].Rollover = false;
		}
		else
		{
			this.items[i].Rollover = true;
		}
		this.items[i].textNormal = '<div class="'+this.name+'TextNormal">'+text+'</div>'
		this.items[i].textSelected = '<div class="'+this.name+'TextSelected">'+text+'</div>'

		if (this.itemH) 
		{
			this.h += this.itemH+this.itemSpacing
			this.items[i].y = i*this.itemH+i*this.itemSpacing
			this.bottom = this.bottom + this.itemH
		}
		else this.items[i].y = 0
	}
}
function ListBuild() 
{
	if (browserVersion >= 4)
	{
		this.css = ''
		this.css += css(this.name+'List',this.x,this.y,this.w,this.h,this.color.bg,(this.itemHset)?this.visibility:'hidden',0)
		for (var i=0;i<this.items.length;i++) 
		{
			this.css += css(this.name+'ListItem'+i,0,this.items[i].y,this.w,this.itemH,this.color.bgNormal)
			if (this.items[i].handcursor != true)
			{
				this.css += css(this.name+'ListItemC'+i,0,this.items[i].y,this.w,this.itemH)
			}
		}
		this.css += '.'+this.name+'TextNormal {font-family:"'+this.fontname+'"; font-size:'+this.fontsize+'px; color:'+this.color.textNormal+'; vertical-align: middle; background-color:transparent;}\n'+
		'.'+this.name+'TextSelected {font-family:"'+this.fontname+'"; font-size:'+this.fontsize+'pt; color:'+this.color.textSelected+'; vertical-align: middle; background-color:transparent;}\n'
	
		writeCSS(this.css)
	
		this.div = '<div id="'+this.name+'List">\n'
		for (var i=0;i<this.items.length;i++) 
		{
			this.div += '<div id="'+this.name+'ListItem'+i+'">'+this.items[i].textNormal+'</div>\n'
			if (this.items[i].handcursor != true)
			{
				this.div += '<div id="'+this.name+'ListItemC'+i+'"></div>\n'
			}
		}
		this.div += '</div>'
	}
}

function ListActivate(me,parent,parent_element) 
{
	if (browserVersion >= 4)
	{
		if (ie)
		{
			this.h -= 1001
			//this sets up the events for the whole menu (in case this is a sub-menu)
			//(Microsoft version)
			if (parent)
			{
				this.parent = parent;
				document.all[this.id].onmouseout = function() {parent.out(parent_element); me.hideMenu();}
				document.all[this.id].onmouseover =function() {parent.over(parent_element); parent.showMenu();}
			}
			// if it's not a submenu
			else
			{
				//alert(this.id)
				document.all[this.id].onmouseout = function() {me.hideMenu();}
			}

		}
		else
		{
			//this sets up the events for the whole menu (in case this is a sub-menu)
			//(Netscape version)
			if (parent)
			{
				this.parent = parent;
				document.layers[this.id].onmouseout = function(event) {parent.out(parent_element); me.hideMenu(event);}
				document.layers[this.id].onmouseover = function(event) {parent.over(parent_element); parent.showMenu(event); }
			}
			//if it's not a submenu
			else
			{
				document.layers[this.id].onmouseout = function(event) {me.hideMenu(event);}
			}	
		}
	
		for (var i=0;i<this.items.length;i++) 
		{
			this.items[i].setbg = ListSetbg
		
			//setup the events and various pointers for the individual menu items
		
			if (ie) 
			{	
		
				//Microsoft version
				if (this.items[i].handcursor != true)
				{
					this.items[i].e = document.all[this.name+'ListItemC'+i]
				}
				else
				{
					this.items[i].e = document.all[this.name+'ListItem'+i]
				}
				this.items[i].layer = document.all[this.name+'ListItem'+i]
				this.items[i].doc = document.all[this.name+'ListItem'+i].style
			
			}
			else
			{
				//Netscape version
				if (this.items[i].handcursor != true)
				{
					this.items[i].e = eval('document.'+this.id+'.document.'+this.name+'ListItemC'+i)
				}
				else
				{
					this.items[i].e = eval('document.'+this.id+'.document.'+this.name+'ListItem'+i)
				}
				this.items[i].e.captureEvents(Event.MOUSEDOWN)
				this.items[i].layer = eval('document.'+this.id+'.document.'+this.name+'ListItem'+i)
				this.items[i].doc = eval('document.'+this.id+'.document.'+this.name+'ListItem'+i+'.document')
			}
		
			this.items[i].e.onmouseover = new Function(this.obj+'.over('+i+');')
			this.items[i].e.onmouseout =  new Function(this.obj+'.out('+i+'); ')
			this.items[i].e.onmousedown = new Function(this.obj+'.down('+i+'); return false;')

		}
	}
}

function ListOver(i)
{
	if (browserVersion >= 4)
	{
		if (this.items[i].Rollover == true )
		{
			this.items[i].setbg(this.color.bgRollover)
	
			if (this.items[i].submenu && this.submenuOnSelect != true)
			{
				for (var x=0;x<this.items.length;x++)
				{
					if(this.items[x].submenu)
					{
						this.items[x].submenu.hide()
					}
				}
				this.items[i].submenu.showMenu()
			}
		}
	}
	
}

function ListOut(i) 
{
	if (browserVersion >= 4)
	{

		this.items[i].setbg(this.color.bgNormal)
	
		if (this.items[i].submenu)
		{
			this.items[i].submenu.hideMenu()
		}
	}
	
}
function ListDown(i) 
{
	if (browserVersion >= 4)
	{
			this.select(i)
			//this.items[i].setbg(this.color.bgNormal)
			if (this.submenuOnSelect == true && (this.items[i].submenu))
			{
				this.items[i].submenu.showMenu();
				this.hide();
			}
			else
			{
				this.onSelect()
			}

	}

}
function ListSelect(index) 
{
	if (browserVersion >= 4)
	{
		if (this.items[index]!=null) 
		{	
			this.selectedIndex = index
			this.value = this.items[index].value
			this.items[index].selected = true
		}
	}
}

function ListHideMenu(e)
{
	if (browserVersion >= 4)
	{
		if (navigator.appName.indexOf("Microsoft") != -1)
		{
			e = window.event;
			X = e.clientX;
			Y = e.clientY;
		}
		else
		{
			if (e)
			{
				X = e.pageX;
				Y = e.pageY;
			}
			else
			{
				//if we didn't get an event object passed to us, then someone explicitly called
				//this function, so take their word for it and hide the menu regardless
				if (this.autohide == true)
				{
					document.layers[this.name+'List'].visibility = "hide";
					return;
				}
			}
		
		}
		//alert(X);
		//alert(Y);
		if (this.autohide == true)
		{
			//only hide the menu if the mouse has moved outside of the boundary of the menu
			if (X > (this.right - 1) || X < (this.left + 1) || Y > (this.bottom- 1) ||  Y < (this.top+1))
			{
				if (ie)
				{
					document.all[this.name+'List'].style.visibility = "hidden";
				}
				else
				{
					document.layers[this.name+'List'].visibility = "hide";
	
				}

				if (this.parent)
				{
					this.parent.hideMenu();
				}
			}
		}
	}
}

function ListForceHide()
{
	if (ie)
	{
		document.all[this.name+'List'].style.visibility = "hidden";
	}
	else
	{
		document.layers[this.name+'List'].visibility = "hide";
	}
}

function ListShowMenu() 
{
	if (browserVersion >= 4)
	{
		if (ie)
		{	
			document.all[this.name+'List'].style.visibility = "visible";
		}
		else
		{
			for (var i=0; i<this.items.length; i++)
			{
				this.items[i].setbg(this.color.bgNormal)
			}
			document.layers[this.name+'List'].visibility = "show";
		}
	}

}

function ListBringToFront()
{

	for (var i=0;i<this.items.length;i++) 
	{
		if (ie)
		{
			document.all[this.name+'ListItem'+i].style.zIndex = "0";
			document.all[this.name+'ListItemC'+i].style.zIndex = "0";
			document.all[this.name+'List'].style.zIndex = "0";
		}
		else
		{
			document.layers[this.name+'List'].zIndex = "0";
		}
	}

}

function ListSendToBack()
{

	for (var i=0;i<this.items.length;i++) 
	{
		if (ie)
		{
			document.all[this.name+'ListItem'+i].style.zIndex = "1";
			document.all[this.name+'ListItemC'+i].style.zIndex = "1";
			document.all[this.name+'List'].style.zIndex = "1";
		}
		else
		{
			document.layers[this.name+'List'].zIndex = 1;
		}
	}

}

function ListRedirect() 
{
	if (browserVersion >= 4)
	{
		location.href = this.value
	}
}

function ListSetbg(color) 
{
	if (browserVersion >= 4)
	{
		if (ie) 
		{
			//Microsoft Version
			this.doc.backgroundColor = color

		}
		else
		{
			//netscape Version
			this.doc.bgColor = color

		}
	}

}




function css(id,left,top,width,height,color,vis,z,other) 
{
	if (browserVersion >= 4)
	{
		if (id=="START")
		{
			 return '<STYLE TYPE="text/css">\n'
		}
		else if (id=="END") 
		{
			return '</STYLE>'
		}
		var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
		if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
		if (arguments.length>=5 && height!=null) 
		{
			str += ' height:'+height+'px;'
			if (arguments.length<9 || other.indexOf('clip')==-1) 
			{
				str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
			}
		}
		if (arguments.length>=6 && color!=null)
		{
			if (ie)
			{
				str += ' background-color:'+color+';'
			}
			else
			{
				str += ' layer-background-color:'+color+';'
			}
		}
	
	
		if (arguments.length>=7 && vis!=null)
		{
			 str += ' visibility:'+vis+';'
		}
		if (arguments.length>=8 && z!=null)
		{
			 str += ' z-index:'+z+';'
		}
		if (arguments.length==9 && other!=null)
		{
			 str += ' '+other
		}
		str += '}\n'
		return str
	}
}
function writeCSS(str,showAlert) 
{
	if (browserVersion >= 4)
	{
		str = css('START')+str+css('END')
		document.write(str)
		if (showAlert) alert(str)
	}
}

if (browserVersion >= 4)
{
	List.count = 0
	List.Menus = new Array()
}

// set up specific menu style formatting and positioning

var Menu_Item_Height = 15;
var Menu_Item_Font_Size =10;
var Menu_Item_Color = '#ffffff';
var Menu_Item_Font_Name = 'Verdana'
var Sub_Menu_Item_bg_color = '#666666'
var Sub_Menu_Item_rollover_color = '#333333'

if (browserType == "ns") {
var About_Don_Menu_Width = 175;
var About_Don_Menu_Top = 145;
var About_Don_Menu_Left = 160;

var BTL_Menu_Width = 175;
var BTL_Menu_Top = 145;
//var BTL_Menu_Left = About_Don_Menu_Left + (About_Don_Menu_Width) + 2;
var BTL_Menu_Left = 70;

var LD_Menu_Width = 175;
var LD_Menu_Top = 145;
//var LD_Menu_Left = About_Don_Menu_Left + (About_Don_Menu_Width) + LD_Menu_Width + 4;
var LD_Menu_Left = 115;
}
else {
var About_Don_Menu_Width = 175;
var About_Don_Menu_Top = 158;
var About_Don_Menu_Left = 160;

var BTL_Menu_Width = 175;
var BTL_Menu_Top = 158;
//var BTL_Menu_Left = About_Don_Menu_Left + (About_Don_Menu_Width) + 2;
var BTL_Menu_Left = 70;

var LD_Menu_Width = 175;
var LD_Menu_Top = 158;
//var LD_Menu_Left = About_Don_Menu_Left + (About_Don_Menu_Width) + LD_Menu_Width + 4;
var LD_Menu_Left = 115;
}

function headermenu_init()
{
	if (browserVersion >= 4)
	{
		About_Don_Menu.activate(About_Don_Menu)
		LD_Menu.activate(LD_Menu)
		BTL_Menu.activate(BTL_Menu)
	}
}

if (browserVersion >= 4)
{
//Build the About Us Menu
	About_Don_Menu = new List (About_Don_Menu_Left,About_Don_Menu_Top,About_Don_Menu_Width,Menu_Item_Height)
	About_Don_Menu.add('javascript:loadHome("don/default.html")','&nbsp;&nbsp;Biographical Information')
	About_Don_Menu.add('javascript:loadHome("don/big5.html")','&nbsp;&nbsp;My Big 5')
	About_Don_Menu.add('javascript:loadHome("don/tenprinciples.html")','&nbsp;&nbsp;Ten Leadership Principles')
	About_Don_Menu.add('javascript:loadHome("archive_speeches.html")',"&nbsp;&nbsp;In Don's Own words")
	About_Don_Menu.add('javascript:loadHome("archive_news.html")','&nbsp;&nbsp;In the News')
	About_Don_Menu.add('javascript:loadHome("don/mindopening.html")','&nbsp;&nbsp;Mind Opening Exercises')
	About_Don_Menu.add('javascript:loadHome("don/insights.html")','&nbsp;&nbsp;Insights and Inspirations')
	About_Don_Menu.add('javascript:loadHome("don/books.html")',"&nbsp;&nbsp;Don's Picks")
	
	About_Don_Menu.fontsize = Menu_Item_Font_Size;
	About_Don_Menu.fontname = Menu_Item_Font_Name
	About_Don_Menu.color.textNormal  = Menu_Item_Color
	About_Don_Menu.visibility = 'hidden'
	About_Don_Menu.build()
}
else
{
	About_Don_Menu = " ";
}

if (browserVersion >= 4)
{
	
//Build the Gallery Menu
	LD_Menu = new List (LD_Menu_Left,LD_Menu_Top,LD_Menu_Width,Menu_Item_Height)
	LD_Menu.add('javascript:loadHome("ld/default.html")',"&nbsp;&nbsp;Home")
	LD_Menu.add('javascript:loadHome("archive_speeches.html")',"&nbsp;&nbsp;In Don's Own Words")
	LD_Menu.add('javascript:loadHome("archive_news.html")','&nbsp;&nbsp;News Stories')
	
	LD_Menu.fontsize = Menu_Item_Font_Size;
	LD_Menu.fontname = Menu_Item_Font_Name
	LD_Menu.color.textNormal  = Menu_Item_Color
	LD_Menu.visibility = 'hidden'
	LD_Menu.build()
}
else
{
	LD_Menu = " ";
}
//Build the Tools Menu
if (browserVersion >= 4)
{
	BTL_Menu = new List (BTL_Menu_Left,BTL_Menu_Top,BTL_Menu_Width,Menu_Item_Height)
	BTL_Menu.add('javascript:loadHome("btl/default.html")',"&nbsp;&nbsp;Home")
	BTL_Menu.add('javascript:loadHome("btl/slideshow/sld001.html")','&nbsp;&nbsp;Sailboat Analogy')
	BTL_Menu.add('javascript:loadHome("btl/process/sld001.html")','&nbsp;&nbsp;The Process')
	BTL_Menu.add('javascript:loadHome("btl/language.html")','&nbsp;&nbsp;Language Tools')
	BTL_Menu.add('javascript:loadHome("btl/examples.html")','&nbsp;&nbsp;Examples of Breakthroughs')
	BTL_Menu.add('javascript:loadHome("images/breakthroughlg.jpg")','&nbsp;&nbsp;Sailboat Handout')
	BTL_Menu.add('javascript:loadHome("btl/purpose.html")','&nbsp;&nbsp;Purpose Statement')
	BTL_Menu.add('javascript:loadHome("btl/postcards.html")','&nbsp;&nbsp;Sample Mailings')
	BTL_Menu.add('javascript:loadHome("archive_news.html")','&nbsp;&nbsp;News Stories')
	BTL_Menu.add('javascript:loadHome("archive_speeches.html")',"&nbsp;&nbsp;In Don's Own Words")
	
	BTL_Menu.fontsize = Menu_Item_Font_Size;
	BTL_Menu.fontname = Menu_Item_Font_Name
	BTL_Menu.color.textNormal  = Menu_Item_Color
	BTL_Menu.visibility = 'hidden'
	BTL_Menu.build()
}
else
{
	BTL_Menu = " ";
}


	
function loadHome(url)
{
	top.location.href=url
}


function init()
{
	//Generic Init Function
	//activate the Menu(s)
	if (browserVersion >= 4)
	{
		headermenu_init();
	}
}

var doesRollover = 0;
// -->

var doesRollover = 1;

function imageSwap(imageName,imageSrc)
{
	for (i=0;i<document.images.length;i++)
	{
		if (document.images[i].name == imageName)
		{
			document.images[i].src = imageSrc;
		}
	}
}
// -->

function rollOver(imageName,imageSrc,showString)
{
	if (doesRollover)
	{
		imageSwap(imageName,imageSrc);
	}
	window.status = showString;
	return true;
}
function preLoad(imageSrc)
{
	if (doesRollover)
	{
		var temp = new Image();
		temp.src = imageSrc;
	}
	return true;
}
// -->


function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.parent.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

