// JavaScript Document
var homePage = 'yes';

// BEGIN TOPNAV SCRIPT

// ********  creating dropdown nav  *****************

// Global Vars for nav

// initialize and give default values for dropdown menu color variables
var background = "#FFFFFF";
var bgcolor = "#7e5b9f";
var border_color = "#ecead8";
var menu_border = "#ecead8";
var hovercolor = "#ecead8";
var dividercolor = "#ecead8";
// these seem to do nothing

var submenu_x;
var submenu_y;



// Simple Browser Check
var ie = "Microsoft Internet Explorer";
var netscape = "Netscape";
var mac = "MacPPC"
var browser = navigator.appName;
var os = navigator.platform;

var No3 = (parseInt(navigator.appVersion) > 3) ? 1:0;

if (navigator.userAgent == 'Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)') { 
	No3 = 0; 
}
var layer = (document.getElementById && No3) ? "document.getElementById('L'+menu).style" : (document.all) ? "document.all['L'+menu].style" : (document.layers && No3) ? "document.layers['L'+menu]": 0;
var hideMe = (document.all || document.getElementById) ? "hidden" : "hide";
var showMe = (document.all || document.getElementById) ? "visible" : "show";
var timer;
//if (document.layers && No3) {
//	document.write('<style>.navdown {color:#000000; font-size:11px; font-family:Arial,sans-serif; font-weight:normal; text-decoration:none; padding-bottom : 3;	padding-top : 3;}</style>');
//}
//////////////////////////////////////////////

// goto main.css to find the definitions for submenubar
Layer = new Array();
// TAB 1 IS MEET CINDY STRADLING
Layer[1] = new LayerSpecs(submenu_x,submenu_y,200,'#7e5b9f','#7e5b9f','#7e5b9f'
, '<a href="http://www.awomansjourney.ca/MeetCindyStradling/Whatislifecoaching.html" class="submenubar">&nbsp;&nbsp;What is Life Coaching?</a>'
, '<a href="http://www.awomansjourney.ca/MeetCindyStradling/benefitsoflifecoaching.html" class="submenubar">&nbsp;&nbsp;Benefits of Life Coaching</a>'
, '<a href="http://www.awomansjourney.ca/MeetCindyStradling/areasoffocus.html" class="submenubar">&nbsp;&nbsp;Areas of Focus</a>'
, '<a href="http://www.awomansjourney.ca/MeetCindyStradling/coachingpkgoptions.html" class="submenubar">&nbsp;&nbsp;Coaching Package Options</a>'
, '<a href="http://www.awomansjourney.ca/MeetCindyStradling/confidentiality.html" class="submenubar">&nbsp;&nbsp;Confidentiality</a>'
);
// TAB 2 IS MISSION STATEMENT
Layer[2] = new LayerSpecs(submenu_x,submenu_y,170,'#d2e4f0','#d2e4f0','#d2e4f0'
, '<a href="http://www.awomansjourney.ca/" class="submenubar">&nbsp;&nbsp;TBD</a>'
, '<a href="http://www.awomansjourney.ca/" class="submenubar">&nbsp;&nbsp;TBD</a>'
, '<a href="http://www.awomansjourney.ca/" class="submenubar">&nbsp;&nbsp;TBD</a>'
);
// TAB 3 IS PRODUCTS / BOOKS & MEDIA
Layer[3] = new LayerSpecs(submenu_x,submenu_y,240,'#d2e4f0','#d2e4f0','#d2e4f0'
, '<a href="http://www.awomansjourney.ca/products/crossing-the-finish-line.html" class="submenubar">&nbsp;&nbsp;Crossing the Finish Line (BOOK)</a>'
, '<a href="http://www.awomansjourney.ca/products/mastering-your-inner-game.html" class="submenubar">&nbsp;&nbsp;Mastering Your Inner Game (CD)</a>'

);
// TAB 4 IS TESTIMONIALS
Layer[4] = new LayerSpecs(submenu_x,submenu_y,200,'#d2e4f0','#d2e4f0','#d2e4f0'
, '<a href="http://www.awomansjourney.ca/TBD.html" class="submenubar">&nbsp;&nbsp;TBD</a>'
, '<a href="http://www.awomansjourney.ca/TBD.html" class="submenubar">&nbsp;&nbsp;TBD</a>'
, '<a href="http://www.awomansjourney.ca/TBD.html" class="submenubar">&nbsp;&nbsp;TBD</a>'
);
// TAB 5 IS THE JOURNEY
Layer[5] = new LayerSpecs(submenu_x,submenu_y,200,'#d2e4f0','#d2e4f0','#d2e4f0'
, '<a href="http://www.awomansjourney.ca/thejourney/coachabilityquestionnaire.html" class="submenubar">&nbsp;&nbsp;Coachability Questionnaire</a>'
, '<a href="http://www.awomansjourney.ca/thejourney/discoverysession.html" class="submenubar">&nbsp;&nbsp;Discovery Session</a>'
, '<a href="http://www.awomansjourney.ca/thejourney/gettingstarted.html" class="submenubar">&nbsp;&nbsp;Getting Started</a>'
, '<a href="http://www.awomansjourney.ca/thejourney/otherresources.html" class="submenubar">&nbsp;&nbsp;Other Resources</a>'
);
// TAB 6 IS WHAT'S NEW
Layer[6] = new LayerSpecs(submenu_x,submenu_y,120,'#d2e4f0','#d2e4f0','#d2e4f0'
, '<a href="http://www.awomansjourney.ca/whatsnew/news.html" class="submenubar">&nbsp;&nbsp;News</a>'
, '<a href="http://www.awomansjourney.ca/whatsnew/newsletter.html" class="submenubar">&nbsp;&nbsp;Newsletter</a>'
, '<a href="http://www.awomansjourney.ca/subscribe.html" class="submenubar">&nbsp;&nbsp;Subscribe</a>'
);


/////////////////////////////////////////////////////////

// Loop to create master nav table(ie/nn6) or layer(nn4.x)
// bgcolor in the table sets the colour of the borders around each submenu box
for(i=1; i<Layer.length; i++) {

	if (document.getElementById && No3) { 
		document.write('<div onMouseOver="clearTimeout(timer)" onMouseOut=";Hide('+i+')" ID="L'+i+'" STYLE="position:absolute; visibility:hidden; background:'+background+'; top:'+Layer[i].top+'; left:'+Layer[i].left+';"><table border="0" cellpadding="0" cellspacing="2" bgcolor="#baa7cc">'+Layer[i].info+'</TABLE></div>'); 
	} else if (document.all && No3) {
		document.write('<SPAN onMouseOver="clearTimeout(timer);" onMouseOut="Hide('+i+')" ID="L'+i+'" STYLE="position:absolute; visibility:hidden; background:'+background+'; top:'+Layer[i].top+'; left:'+Layer[i].left+';"><table border="0" cellpadding="0" cellspacing="2" bgcolor="#baa7cc">'+Layer[i].info+'</TABLE></SPAN>'); 
	} else if (document.layers && No3) {
		document.write('<LAYER  onMouseOver="clearTimeout(timer);" onMouseOut="Hide('+i+');" ID="L'+i+'" VISIBILITY="hide" position="absolute" BGCOLOR="#baa7cc"">'+Layer[i].info+'</LAYER>'); 
		//document.write('<LAYER onMouseOver="clearTimeout(timer);showOver(\''+imgHilite+'\');" onMouseOut="Hide('+i+');showOff(\''+imgHilite+'\');" ID="L'+i+'" VISIBILITY="hide" position="absolute" BGCOLOR="#ffffff" TOP="'+Layer[i].top+'" LEFT="'+Layer[i].left+'">'+Layer[i].info+'</LAYER>'); 
	}
}


// sets the number of pixels down or to the right of the main menu item
function Show(menuNumber, submenu_id) {
	if(document.layers){
  		submenu_y += 0;  
		submenu_x += 130; 
		
	}
	else
	{
 		submenu_y += 0;  
		submenu_x += 130; 
		
	}
	

	
	if (document.layers)
	{
	
		submenu_id.left = submenu_x;
		submenu_id.top = submenu_y;

	}
	else
	{
		if(menuNumber != 0)
		{
		document.getElementById('L' + menuNumber).style.top = submenu_y + 'px';
		document.getElementById('L' + menuNumber).style.left = submenu_x + 'px';
		}
	}

	
	if(timer) { 
		clearTimeout(timer); 
	}

	for(menu=0; menu < Layer.length; menu++) {
		if(Layer[menu]) {
			eval(layer).visibility = hideMe; 
		} 
	}
	if (menuNumber > 0){
		var menu = menuNumber;
		eval(layer).visibility = showMe;
	}
	
}

function Hide(menuNumber) { timer = setTimeout("Show(0, document.L1)", 200); }


function LayerSpecs(Left,Top,Width,bgcolor,hovercolor,dividercolor) { 
	if(No3) {
		if (document.getElementById && document.all) {
			if (homePage=="yes") {
				this.left = Left;
				this.top = parseInt(Top) - 0;;
			} else {
				this.left = parseInt(Left) + 10;
				this.top = parseInt(Top) - 7;
			}
		} else if (document.getElementById && navigator.userAgent.indexOf('Gecko')) {
			if (homePage=="yes") {
				this.left = Left;
				this.top = parseInt(Top) - 0;
			} else {
				this.left = parseInt(Left) + 10;
				this.top = parseInt(Top) - 7;
			}
		} else if (document.all) {
			if (homePage=="yes") {
				this.left = Left;
				this.top = parseInt(Top) - 0;
			} else {
				this.left = parseInt(Left) + 10;
				this.top = parseInt(Top) - 7;
			}
		} else if (document.layers) { 
			// Width = Width + 10;
			if (homePage=="yes") {
				this.left = Left;
				this.top = parseInt(Top) - 0;
			} else {
				this.left = parseInt(Left) + 10;
				this.top = parseInt(Top) - 7;
			}
		}

		this.info  = "";

// initialize layer position for NN4.x
		var T = 0;

// Loop to populate master nav table/layer with content
		for(i=6; i<arguments.length; i++) {

			// check for 2 lines of content within layer and offset accordingly
			if( arguments[i].indexOf('<br>&nbsp;') != -1 ){
				var addOffset = 13;
			} else {
				var addOffset = 0;
			}

// calculates table cell height for NN6 & IE
			var cellheight = 20;
			
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CELL BACKGROUND COLOUR CAN BE CHANGED HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			if (document.all){ 
				this.info += '<tr><TD valign="middle" WIDTH="'+Width+'" height="'+cellheight+'" bgcolor="#7e5b9f" class="submenubar"><span style="line-height:103%;"><img src="images/spacer.gif" align="left" alt="" width="1" height="15" vspace="0" hspace="0"  border="0">'+arguments[i]+'</span></TD></tr>'; 
			} else if (document.getElementById){ 
				this.info += '<tr><TD valign="middle" WIDTH="'+Width+'" height="'+cellheight+'" bgcolor="#7e5b9f" class="submenubar"><img src="images/spacer.gif" align="left" alt="" width="1" height="15" vspace="0" hspace="0"  border="0">'+arguments[i]+'</TD></tr>'; 
			} else if (document.layers){ 
				this.info += '<LAYER position="absolute" bgcolor="'+bgcolor+'" WIDTH="'+Width+'" TOP="'+T+'" class="submenubar">'+arguments[i]+'</LAYER><br>'; 
			}

// increment layer position for NN4.x
			T += 13 + addOffset;
		}
	} 
}

function getOffsetLeft (el) {
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  return ol;
}
function getOffsetTop (el) {
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
   ot += el.offsetTop;
  return ot;
}

	
function getCoordinates (menu, menu_id) {
	if(document.layers){
  		submenu_x = menu_id.pageX;
		submenu_y =  menu_id.pageY
	}
	else
	{
 		submenu_x = getOffsetLeft(menu);
		submenu_y = getOffsetTop(menu);
	}	
	
}
// END TOPNAV SCRIPT