﻿ID = 0;
var navGroup = new Array();

var topID = new Array();
var navEl = 1;
var subCount = 0;
function navObj(url,label,nodePath,type,src,w,h,state){
	this.url = url;
	this.label = label;
	this.type = type;
	this.nodePath = nodePath;
	this.findLevels();
	this.ID = ID;
	this.state = state;
	this.y = 0;
	this.h = 19;
	this.subDivH = 0;
	
	if(this.level.length==1 && this.level[0]>0){
		navGroup[navEl] = this.level[0];
		topID[navEl] = this.ID;
		if(this.type=="img"){
			if(navEl>1){
				this.endcap = (this.state==0) ? "leftNav_blackCapRt" : "leftNav_blackCapTop";
			}
			else if(navEl==1){
				this.endcap = "spacer";
			}
		}
		navEl++;		
	}
	if(this.level.length==2){
		if(this.level[0]>0){
			if(subCount>0 && this.level[0]==nav[lastID].level[0]){
				eval("subNav" + (navEl-1) + "[" + subCount + "] = this.ID");
				lastID = this.ID
				subCount++;
			}
			else{
				subCount = 0;
			}
			if(subCount==0){
				eval("subNav" + (navEl-1) + " = new Array()");
				eval("subNav" + (navEl-1) + "[" + subCount + "] = this.ID");
				lastID = this.ID;
				subCount++;
			}
		}
	}
	if(this.type=="img"){
		this.src = src;
		this.w = w;
		this.imgH = h;
		this.h = parseInt(h)
		this.alt = this.label;
	}	
	ID++;	
}


function findLevels(){
	this.level = new Array();
	if(this.nodePath.indexOf(".")!=-1){
		this.level = this.nodePath.split(".");
	}
	else{
		this.level[0] = this.nodePath;
	}
}

navObj.prototype.findLevels = findLevels;

var nav = new Array();
// START OBJECT CREATION FROM BACKEND //
nav[0] = new navObj("/index.html","Hem","1","txt","x","x","x", 1);
nav[1] = new navObj("/secure/GeneralContent/migraine/migraine_info.html","Fakta om migr&auml;n","1.1","txt");
nav[2] = new navObj("/secure/GeneralContent/migraine/isit_migraine.html","&Auml;r det migr&auml;n?","1.2","txt");
nav[3] = new navObj("/secure/GeneralContent/migraine/migraine_info_yourself.html","Hj&auml;lp dig sj&auml;lv","1.3","txt");
nav[4] = new navObj("/secure/GeneralContent/migraine/treatment.html","Behandling","1.4","txt");
nav[5] = new navObj("/secure/GeneralContent/migraine/talk.html","Hos l&auml;karen","1.5","txt");
nav[6] = new navObj("/secure/GeneralContent/migraine/diary.html","Huvudv&auml;rksdagbok","1.6","txt");
nav[7] = new navObj("/secure/GeneralContent/migraine/our_products.html","L&auml;kemedel vid migr&auml;n","1.7","txt");

nav[8] = new navObj("index.html","Home","0","txt");
nav[9] = new navObj("javascript:MM_openBrWindow('/secure/GeneralContent/survey/take_survey.html','','scrollbars=yes,width=490,height=500');","Ge oss din åsikt","0.3","img","/images/survey.gif","125","20");
nav[10] = new navObj("javascript:openNew('/secure/GeneralContent/global/send_to_friend.html');","Tipsa en vän","0.4","img","/images/tipsa.gif","125","20");
nav[11] = new navObj("javascript:openNew('/secure/GeneralContent/global/contact_us.html');","Kontakta oss","0.5","img","/images/contact.gif","125","20");
nav[12] = new navObj("#","spacer","0.6","img","/images/mellanrum.jpg","125","20");
nav[13] = new navObj("javascript:MM_openBrWindow('/secure/GeneralContent/migraine/migrantest3.swf','','scrollbars=yes,width=572,height=400');","Migräntest","0.7","img","/images/migrantest.jpg","134","40");
// END OBJECT CREATION //

var sHTML = "";
var styleStr = "";
var subStr = "";
var subDivY = new Array();
var subDivH = new Array();
var sdCount = 0;
var subNum = new Array();
var activeRow = "";
var anchorStr = "";
var selParentID = null;
//alert("about to set parentID null");
parentID = null;
function initNav(){
divY = 0;
parentID = null;

//if(parentID==null){
//	alert("parentID null!");
//}


	sHTML = "";
	sHTML += '<table cellspacing="0" cellpadding="0" border="0" width="170" class="navBrdr">';
	var topEl = "";
	var selImg = "";
	//alert("navgroup length: "+navGroup.length);
	for(x=1;x<navGroup.length;x++){
		var thisTopEl = eval(nav[topID[x]]);
		//alert("top of x loop; x="+x+", thisTopEl.label="+thisTopEl.label+", thisTopEl.state="+thisTopEl.state);
		if(thisTopEl.type=="img"){
			topEl = '<img src="' + thisTopEl.src + '" width="' + thisTopEl.w + '" height="' + thisTopEl.imgH + '" alt="' + thisTopEl.alt + '" border="0"/>';
		}
		else if(thisTopEl.type=="txt"){
			topEl = thisTopEl.label;
		}
		//sHTML += '<tr>';
		if(thisTopEl.state==0 || thisTopEl.ID==0){
			//sHTML += '<td class="subnavBG"><img src="/images/spacer.gif" width="16" height="1"></td>';
			//sHTML += '<td width="144" height="26" valign="middle" class="subnavBG">';
			//sHTML += '<a href="' + thisTopEl.url + '" class="subnavBG">' + topEl + '</a>';
			//sHTML += '<td class="subnavBG"><img src="/images/spacer.gif" width="10" height="1"></td>';
		}
		else{
			//sHTML += '<td width="170" colspan="3" class="navHeadTxt">';
			//sHTML += topEl;
		}
		//sHTML += '</td>';
		//sHTML += '</tr>';
		//sHTML += '<tr><td colspan="3" class="bigpageBrdr"><img src="/images/spacer.gif" width="140" height="1"></td></tr>';
		//if(thisTopEl.state==0){
		//	sHTML += "<tr><td class='whiteBG' colspan='6'><img src='/images/spacer.gif' width='1' height='1' border='0'/></td></tr>";
		//}
		//if this page's top level nav matches the current navgroup
		genToolNav();
		if(pageID!=null && x==nav[pageID].level[0]){
			//cycle through all nav objects
			for(y=0;y<nav.length;y++){
				//alert("top of y loop for x="+x+", y="+y+", nav.length="+nav.length+", label: "+nav[y].label);
				//alert("sHTML length is "+sHTML.length+", value: "+sHTML);
				if(y+1<nav.length){
					nextObj = eval(nav[y+1]);
				}
				// if this nav obj's first level = the current group number
				if(nav[y].level[0] == x){
					// if the current nav obj is deeper than first level
					if(nav[y].level.length>=1){
					// cycle through each node's level identifiers
						for(z=1;z<=nav[y].level.length;z++){
							//alert("top of z loop; z="+z+", nav[y].level.length="+nav[y].level.length);
							// if the obj is a member of the selected node's path, render it's selected state
							if(nav[y].level.length==z && nav[y].level[z-1]==nav[pageID].level[z-1]){
								if(z==1){
									//alert("inside z=2 if");
									selParentID = y;
									selImg = (nav[pageID].level.length==z && nav[pageID].level[z]==nav[y].level[z]) ? 'leftNav_arrowSub1' : 'spacer';
									//bg = (nav[pageID].level[1]==nav[y].level[1]) ? 'Sel' : '';
									if (nav[pageID].level[1]==nav[y].level[1]) {
										bg = 'Sel';
										arrow_html = '<img src="/images/nav_arrow.gif" width="16" height="15">';
									} else {
										bg ='';
										arrow_html = '&nbsp;';
									}
									
									
									sHTML += '<tr>';
									sHTML += '<td width="16" class="subnav' + bg + 'BG1" valign="top">'+arrow_html+'</td>';
									sHTML += '<td width="144" class="subnav' + bg + 'BG1">';
									sHTML += '<a href="' + nav[y].url + '" class="subnav' + bg + 'Txt1">' + nav[y].label + '</a></td>';
								
									//if(y+1<nav.length){										
										//var curSub = eval("subNav"+x);
										//var cornerImg = (nav[y].level[1]==curSub.length && nextObj.level[0]!=nav[y].level[0]) ? "leftnav_botCornerLtGreen" : "spacer";
									//}
									sHTML += '<td width="10"class="subnav' + bg + 'BG1"><img src="/images/spacer.gif" width="10" height="26"></td>';
									sHTML += '</tr>';
									sHTML += '<tr><td colspan="5" class="bigpageBrdr"><img src="/images/spacer.gif" width="152" height="1" vspace="0" hspace="0" border="0"/></td></tr>';									
								}								
								
								
								
							}
							if(nav[y].level.length==z && nav[y].level[z-1]==nav[pageID].level[z-1]){
								if(z==2){
									//alert("inside z=2 if");
									selParentID = y;
									selImg = (nav[pageID].level.length==z && nav[pageID].level[z]==nav[y].level[z]) ? 'leftNav_arrowSub1' : 'spacer';
									bg = (nav[pageID].level[1]==nav[y].level[1]) ? 'Sel' : '';
									
									sHTML += '<tr>';
									sHTML += '<td width="16" class="subnav' + bg + 'BG" valign="top"><img src="/images/nav_arrow.gif" width="16" height="15"></td>';
									sHTML += '<td width="144" class="subnav' + bg + 'BG">';
									sHTML += '<a href="' + nav[y].url + '" class="subnav' + bg + 'Txt">' + nav[y].label + '</a></td>';
								
									//if(y+1<nav.length){										
										//var curSub = eval("subNav"+x);
										//var cornerImg = (nav[y].level[1]==curSub.length && nextObj.level[0]!=nav[y].level[0]) ? "leftnav_botCornerLtGreen" : "spacer";
									//}
									sHTML += '<td width="10"class="subnav' + bg + 'BG"><img src="/images/spacer.gif" width="10" height="26"></td>';
									sHTML += '</tr>';
									sHTML += '<tr><td colspan="5" class="bigpageBrdr"><img src="/images/spacer.gif" width="152" height="1" vspace="0" hspace="0" border="0"/></td></tr>';									
								}								
								
								
								
							}
							
							// else, if current object is not a member of the selected node's path, render it's unselected state
							else if(nav[y].level[z-1]!=nav[pageID].level[z-1] && z-1<= nav[pageID].level.length){
								//alert("inside unselected; y="+y+", z="+z+", thisTopEl.state="+thisTopEl.state);
								if(nav[y].level.length==2 && thisTopEl.state==1){
									//alert("about to gen rollover for depth2 item");
									genRolloverNav();
								}								
								else if(nav[y].level.length==3){									
									if(nav[y].level[1]==nav[pageID].level[1]){
										sHTML += '<tr>';
										sHTML += '<td width="17" colspan="3" class="subnav_lev2BG"><img src="/images/spacer.gif" width="17" height="1" vspace="0" hspace="0" border="0"/></td>';
										sHTML += '<td width="113" colspan="2" class="subnav_lev2BG"><a href="' + nav[y].url + '" class="subnavLev2Txt">' + nav[y].label; + '</a></td>';
										if(nextObj.ID<nav.length){
											 var cornerImg = (nextObj.level[0]!=nav[y].level[0]) ? "leftnav_botCornerXLtGreen" : "spacer";
										}
										sHTML += '<td width="11" class="subnav_lev2BG"><img src="/images/menu/' + cornerImg + '.gif" width="11" height="19" vspace="0" hspace="0" border="0"/></td>';
										sHTML += '</tr>';
										sHTML += '<tr><td class="whiteBG" colspan="6"><img src="/images/spacer.gif" width="152" height="1" vspace="0" hspace="0" border="0"/></td></tr>';
										break;
									}									
								}
								else if(nav[y].level.length==4){									
									if(nav[y].level[2]==nav[pageID].level[2] && nav[y].level[1]==nav[pageID].level[1]){
										sHTML += '<tr>';
										sHTML += '<td width="17" class="whiteBG" colspan="3"><img src="/images/spacer.gif" width="17" height="19" vspace="0" hspace="0" border="0"/></td>';
										sHTML += '<td width="7" class="whiteBG"><img src="/images/spacer.gif" width="7" height="9" alt="" border="0"/></td>';
										sHTML += '<td width="106" class="whiteBG"><a href="' + nav[y].url + '" class="subnavLev3Txt">' + nav[y].label + '</a></td>';
										sHTML += '<td width="11" class="whiteBG"><img src="/images/spacer.gif" width="11" height="19" vspace="0" hspace="0" border="0"/></td>';
										sHTML += '</tr>';
										if(nextObj.ID<nav.length){
											 if(nextObj.level[0]!=nav[y].level[0]){
											 	sHTML += '<tr>';
												sHTML += '<td class="subnavBG" colspan="5"><img src="/images/spacer.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>';
											 	sHTML += '<td width="11" class="subnavBG"><img src="/images/menu/leftnav_botCornerGreen.gif" width="11" height="19" vspace="0" hspace="0" border="0"/></td>';
												sHTML += '</tr>';
												sHTML += '<tr><td class="whiteBG" colspan="6"><img src="/images/spacer.gif" width="152" height="1" vspace="0" hspace="0" border="0"/></td></tr>';
											 }
										}
										
										break;
									}
								}	
													
							} // end else if
							
						} // end z loop
					} // end 'if level.length>=1'
				} // end 'if level[0]==x'
			//alert("bottom of Y loop,  sHTML length is "+sHTML.length+", value: "+sHTML);
			} // end y loop			
		} // end 'if x==pageID'
	
		else if(pageID==null ||  x!=nav[pageID].level[0]){
			var parentID = null;
			for(y=0;y<nav.length;y++){
				if(y!=pageID){
					if(nav[y].level.length==2 && thisTopEl.state==1){
						//alert("at genrollovernav");
						genRolloverNav();
					}
				}
			//alert("bottom of other y loop for "+nav[y].label+", sHTML length is "+sHTML.length+", value: "+sHTML);
			}			
		}
	//alert("bottom of x loop,  sHTML length is "+sHTML.length+", value: "+sHTML);
	}	// end x loop (through nav groups)
	
	
	// CONSTANT NAV ITEMS AND OTHER HTML GO HERE //
	sHTML += '<tr><td colspan="3" class="subnavBG"><img src="/images/spacer.gif" width="1" height="3"></td></tr>';
	sHTML += '<tr><td width="16"><img src="/images/spacer.gif" width="16" height="1" vspace="0" hspace="0" border="0"/></td><td width="144"><img src="/images/spacer.gif" width="144" height="1" vspace="0" hspace="0" border="0"/></td><td width="10"><img src="/images/spacer.gif" width="10" height="1" vspace="0" hspace="0" border="0"/></td></tr>';	
	sHTML += '</table><table cellpadding="0" cellspacing="0" border="0">';
	sHTML += '<tr><td colspan="3" bgcolor="#FFFFFF"><img src="/images/spacer.gif" width="1" height="15"></td></tr>';
	sHTML += toolStr;
	// spacer row //
	sHTML += '<tr><td width="16"><img src="/images/spacer.gif" width="16" height="15" vspace="0" hspace="0" border="0"/></td><td width="144"><img src="/images/spacer.gif" width="144" height="1" vspace="0" hspace="0" border="0"/></td><td width="10"><img src="/images/spacer.gif" width="10" height="1" vspace="0" hspace="0" border="0"/></td></tr>';	
	sHTML += '</table>';
//alert("pre doc.write, sHTML length is "+sHTML.length+", final HTML value: \n"+sHTML);
	document.write(sHTML);
	document.close();
}

navObj.prototype.initNav = initNav;



function genRolloverNav(){
				//alert("in gen rollover nav")
				if(y+1<nav.length){
					nextObj = eval(nav[y+1]);
				}		
				if(nav[y].level[0] == x){
					if(nav[y].level.length==1 && nav[y].state==0){
						sHTML += '<tr><td class="whiteBG" colspan="6"><img src="/images/spacer.gif" width="152" height="100" vspace="0" hspace="0" border="0"/></td></tr>';
					}
					
					if(nav[y].level.length==2 && (nav[y].level[1]!=nav[pageID].level[1] || nav[y].level[0]!=nav[pageID].level[0])){
						if(y+1<nav.length){
							if(nav[y+1].level.length==3){				
								parentID = nav[y].ID;
							}
							var curSub = eval("subNav"+x);
							//var cornerImg = (nav[y].level[1]==curSub.length) ? "leftnav_botCornerGreen" : "spacer";
						}						
						if(is.ie || is.ns6){				
							activeRow += "<tr id='row"+y+"' class='subnavBG'";
							activeRow += " onmouseover='switchRowBG(this,\"on\")";
							//alert("before ref parentID xx");
							//alert("node: "+nav[y].level);
							//if(parentID==null){
							//	alert("parentID null!");
							//}
							if(parentID!=null && y==parentID){
								activeRow += "; showMenu(this,sub" + y + ")'";
							}
							else{
								activeRow += "; showMenu(this,null)'";
							}
							//alert("after ref parentID");
							activeRow += " onmouseout='switchRowBG(this,\"off\")'";
							if(is.ie){
								activeRow += " onclick='top.location.href=\"" + nav[y].url + "\"'";
								anchorStr = nav[y].label;
							}
							activeRow += ">";							
						}
						if(is.ns6){
							anchorStr = '<a href="' + nav[y].url + '" class="subnavTxt">' + nav[y].label + '</a>';
						}
						else if(is.ns4){
							activeRow = '<tr>';
							
							anchorStr = '<a href="' + nav[y].url + '" class="subnavTxt" onmouseover="showMenu(null,sub'+y+')">' + nav[y].label + '</a>';						
						}
						sHTML += activeRow;
						activeRow = "";
						sHTML += '<td width="16" align="right" valign="top">';
						sHTML += '<img src="/images/spacer.gif" width="16" height="15">';
						//if(is.ie){
						//	sHTML += '<div id="marker' + y + '" style="position:relative;width:1px;height:1px;"></div>';
						//}
						//else{
						//	sHTML += '<img src="/images/spacer.gif" id="marker' + y + '" name="marker' + y + '" width="10" height="1" vspace="0" hspace="0" border="0"/>';
						//}		
						sHTML += '</td>';
						sHTML += '<td width="144">';
						sHTML += anchorStr + "</td>";
						sHTML += '<td width="10"><img src="/images/spacer.gif" width="10" height="26"></td>';
						sHTML += '</tr>';
						// level 2 spacer here
						sHTML += '<tr><td colspan="3" class="bigpageBrdr"><img src="/images/spacer.gif" width="160" height="1" vspace="0" hspace="0" border="0"></td></tr>';
					} // end if length==2
					
					
					if(y+1<=nav.length && nav[y+1].level.length==3){
						genSubNav();
					}
				}
}

navObj.prototype.genRolloverNav = genRolloverNav;
var nextNav = null;
var subNavDiv = new Array();
function genSubNav(){
	var level3count = 0;
	eval("subNavDiv["+sdCount+"] = "+ y);
	
	styleStr += "\n#sub"+y+"Div{";
	styleStr += "position:absolute;visibility:hidden;";
	styleStr += "width:122px;height:0px;left:152px;top:47px;z-index:50000;";
	styleStr += "}\n";	
	
	subStr += "\n<div id='sub" + y + "Div'>\n";						
	subStr += '\n<table width="122" cellspacing="0" cellpadding="0" border="0">';
	subStr += '<tr><td width="122"><img src="/images/menu/subNav_top.gif" width="122" height="1" border="0"/></td></tr>';
	subStr += '</table>\n';
	subStr += '<table width="122" cellspacing="0" cellpadding="0" border="0">';
	
	for(t=0;t<nav.length;t++){
		if(nav[t].level.length==3 && nav[t].nodePath.substring(0,3)==nav[y].nodePath){				
			if(is.ie || is.ns6){
				if(level3count!=0){
					subStr += '<tr><td class="subnav_lftBG"><img src="/images/spacer.gif" width="2" height="1" border="0"/></td><td class="blackBG" colspan="3" width="119"><img src="/images/spacer.gif" width="5" height="1" border="0"/></td><td class="dkGrnBG" width="1"><img src="/images/spacer.gif" width="1" height="1" border="0"/></td></tr>';
				}
				subStr += "<tr class='rowOff'";
				subStr += " onmouseover='this.className=\"rowOn\"'";
				subStr += " onmouseout='this.className=\"rowOff\"'";
				subStr += " onclick='top.location.href=\"" + nav[t].url + "\"'";
				subStr += ">";
				subStr += '<td class="subnav_lftBG" width="2"><img src="/images/spacer.gif" width="2" height="1" border="0"/></td>';
				subStr += '<td width="5"><img src="/images/spacer.gif" width="5" height="20" border="0"/></td>';
				subStr += '<td width="109" class="subnavLev3Txt">' + nav[t].label + '</td>';
				subStr += '<td width="5"><img src="/images/spacer.gif" width="5" height="20" border="0"/></td>';
				subStr += '<td class="dkGrnBG" width="1"><img src="/images/spacer.gif" width="1" height="1" border="0"/></td>';
				subStr += '</tr>';
			}
			else if(is.ns4){
				if(sdCount!=0){
					subStr += '<tr><td class="blackBG" colspan="3" width="119"><img src="/images/spacer.gif" width="5" height="1" border="0"/></td></tr>';
				}
				subStr += "<tr class='rowOff'><td>";
				subStr += "<a href='"+nav[t].url+"' class='rowOff'>";
				subStr += nav[t].label;
				subStr += "</a></td></tr>";
			}
			level3count++;										
		}							
	}// end t loop

			
	subStr += "</table>\n"
	subStr += '\n<table width="122" cellspacing="0" cellpadding="0" border="0"><tr><td width="122" colspan="5"><img src="/images/menu/subNav_bot.gif" width="122" height="2" border="0"/></td></tr></table>\n';
	subStr += "\n</div>\n";
	eval("subDivY[" + sdCount + "] = 0");
	eval("subDivH[" + sdCount + "] = " + parseInt(21*(level3count+1)));
	sdCount++;
	level3count = 0;
}
navObj.prototype.genSubNav = genSubNav;

function genToolNav(){
	toolObjCount = 0;
	toolStr = "";
	for(y=0;y<nav.length;y++){				
		if(nav[y].level[0] == 0){
			selImg = (pageID==y) ? 'leftNav_arrowTools' : 'spacer';
			if(nav[y].type=="txt"){						
				var cornerImg = (toolObjCount==0) ? "leftNav_blackCapTop" : "spacer";
				var crnrImgH = (cornerImg=="spacer") ? "19" : "22";
				//toolStr += '<tr><td width="10" colspan="2" align="right"><img src="/images/menu/' + selImg + '.gif" width="7" height="9" vspace="0" hspace="0" border="0"/></td><td colspan="3" width="120"><a href="'+nav[y].url+'" class="leftnavToolsTxt">'+nav[y].label+'</a></td></tr>';
				toolStr += '<tr><td width="9"><img src="/images/spacer.gif" width="9" height="9" vspace="0" hspace="0" border="0"/></td><td width="4"><img src="/images/crtWhite.gif" width="4" height="10" vspace="0" hspace="0" border="0"/></td><td width="7"><img src="/images/spacer.gif" width="7" height="10" vspace="0" hspace="0" border="0"/></td><td width="127" valign="middle"><a href="'+nav[y].url+'" class="leftnavToolsTxt">'+nav[y].label+'</a></td></tr>';
				toolStr += '<tr><td colspan="5"><img src="/images/spacer.gif" width="9" height="3"></td></tr>';
				//<td valign="top"><img src="/images/menu/'+cornerImg+'.gif" width="11" height="' + crnrImgH + '" alt="" border="0"/></td>
				toolObjCount++;
			}
			else if(nav[y].type=="img"){
				toolStr += '<tr><td colspan="6"><a href="' + nav[y].url + '"><img src="' + nav[y].src + '" width="' + nav[y].w + '" height="' + nav[y].h + '" alt="' + nav[y].alt + '" border="0"/></a></td></tr>';
			}
			if(nav[y].level.length==1){
				toolStr = "";
				toolObjCount=0;
			}
		}
	}
}

navObj.prototype.genToolNav = genToolNav;

var pageID = null;
function getPageID(){
	var theURL = top.location.href;
	for(x=0;x<nav.length;x++){
		if(theURL.indexOf(nav[x].url)!=-1){
			pageID = x;
			break;
		} else {
			pageID = 0;
		}
	}
}	
	
function genSubStyles(){
	var subStyleStr = "";	
	subStyleStr += "\n<style>\n";
	subStyleStr += styleStr;	
	subStyleStr += "</style>";
  	document.write(subStyleStr);
  	document.close();
}

function genSubDivs(){
	document.write(subStr);
  document.close();
}


function setDivs(){
	for(d=0;d<subNavDiv.length;d++){
		var theDiv = eval("sub" + subNavDiv[d]);
		theDiv.props(152,subDivY[d],122,subDivH[d],0,122,subDivH[d],0);	
	}	
}

function initMouseEvents() {
	//document.onmousedown = mouseDown;
	document.onmousemove = mouseMove;
	//document.onmouseup = mouseUp;
	if (is.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

function genLeftNav(){	
	getPageID();
	initNav();
	genSubStyles();
	genSubDivs();
	
}


var lastSub = null;
var isShowing=false;

function getMouseX(e){
  var x = 0;

  if (is.ns4){x = e.pageX;}
  else if (is.ie){x = event.x + document.body.scrollLeft;}
  else if (is.ns6){x = e.clientX;}
  return x;
}

function getMouseY(e){
  var y = 0;

  if (is.ns4){y = e.pageY;}
  else if (is.ie){y = event.y + document.body.scrollTop;}
  else if (is.ns6){y = e.clientY;}
  return y;
}

function mouseMove(e) {
  x = getMouseX(e);
  y = getMouseY(e);
	
	if (is.ns && e.target!=document) routeEvent(e);	
	 return DynMouseMove(x,y);
}

function DynMouseMove(x,y) {
	if(lastSub==null || (lastSub!=null && lastSub.isShowing==false)){return;}	
	else if(lastSub!=null && lastSub.isShowing==true){
		if((x > 263) || (x>152 && (y<yPosition || y>(yPosition+lastSub.h))) || (x<152 && (y<yPosition || y>(yPosition+20)))){			
			reset();
		}
		if(x>152 && x<263 && y>lastSub.y && y<lastSub.y+lastSub.h){
			lastRow.className = "subnavSelBG";
		}
	}
	return true;
}

function switchRowBG(rowObj,state){
	getRowID(rowObj);
	if(state=="on"){
		rowObj.className = "subnavSelBG";
		//if(nav[rowID].level[0]==1 && nav[rowID].level[1]==1){
		//	setCurveImg("on");
		//}
	}
	else if(state=="off"){
		rowObj.className = "subnavBG";
		//if(nav[rowID].level[0]==1 && nav[rowID].level[1]==1){
		//	setCurveImg("off");
		//}
	}
}

lastRow = null;
function getRowID(rowObj){
	rowID = rowObj.id.substring(rowObj.id.indexOf("row")+3,rowObj.id.length);
	return rowID;
}

function showMenu(rowObj,which){
	if(is.mac){return}
	if(which!=null){
		getRowID(rowObj);	
		var markerImg = "marker" + rowID;	
		//if(which.y==0){			
			getY(markerImg,which);
			which.moveTo(null,yPosition);
		//}
		which.show();		
	}
	if((lastSub!=null && which!=lastSub) || (lastSub!=null && which==null)){	
		lastSub.hide();
		isShowing = false;
		if(which==null) return;
	}
	lastSub = which;
	lastRow = rowObj;
}

var yPosition = null;

function getY(marker,which) {
	yPosition = (is.ns) ? document.images[marker].y : eval("document.all." + marker + ".offsetTop");
	return yPosition;
}

function reset(){
	if(lastSub!=null){
		switchRowBG(lastRow,"off");
		lastSub.hide();
		return;
	}
}
