
	
	sRootPath = "/main/GLOBAL/en/";				
	
	//Constants to keep track of the current 'site location'
	CURRENT_TOPNAV = '0';
	CURRENT_SUBNAV = '0';

				
	SELECTED_STYLE = 'background-color:#ffffff;color:#FF9900;font-family:Verdana,Sans-serif;font-size:10px;font-weight:bold;text-decoration:none;';
	UNSELECTED_STYLE = 'color:#666666;font-family:Verdana,Sans-serif;font-size:10px;font-weight:bold;text-decoration:none;';
				
	function navObj(caption, url, tid, sid, sArray, pop, width, height, scroll, status, menubar, toolbar, location, directories) {
		this.c = caption;
		this.u = url;
		this.topid = tid;
		this.subid = sid;
		this.subarr = sArray;
		this.style = UNSELECTED_STYLE;
		this.mover = '';
		this.mout = '';
		this.php = '';
		this.width = width;
		this.height = height;
		this.pop = pop;
		this.scroll = scroll;
		this.status = status;
		this.menubar = menubar;
		this.toolbar = toolbar;
		this.location = location;
		this.directories = directories;
										
		if (pop=="yes") {
			this.u = 'javaScript:openWin(\''+this.u+'\',\''+width+'\',\'' +height+'\',\'' +scroll+'\',\'' +status+'\',\'' +menubar+'\',\'' +toolbar+'\',\'' +location+'\',\'' +directories +'\')';
		}
					
		this.setHtml = navObj_setHtml;
	}
				
	function navObj_setHtml(current, tid) {//tid boolean
		
		spacerwidth='8'
		
		if(tid) {
			spacerwidth='13'
		}
		if(current && tid) {
			spacerwidth='12'
		}
			
		this.php = '<td';
		this.php += this.mover;
		this.php += this.mout;
		this.php += ' style="' + this.style + '" nowrap>';
					
		if(current){
			this.php += '<img src="/main/image/p_cccccc.gif" width="1" height="25" border="0"/>'
				+ '<img src="/main/image/spacer.gif" width="' + spacerwidth + '" height="25" border="0"'
					+ this.mover + this.mout + '/></td><td';
		} else {
			this.php += '<img src="/main/image/spacer.gif" width="' + spacerwidth + '" height="25" border="0"'
				+ this.mover + this.mout + '/></td><td';
		}
					
		this.php += this.mover;
		this.php += this.mout;
		this.php += ' style="' + this.style + '" nowrap>';
					
		this.php += '<a style="' + this.style + '" href="' + this.u + '"';
		this.php += this.mover;
		this.php += this.mout;
		this.php += '>';
		this.php += this.c;
		this.php += '</a>';
		this.php += '</td>';
		this.php += '<td';
		this.php += this.mover;
		this.php += this.mout;
		this.php += ' style="' + this.style + '" nowrap>';
					
		if(current){
			this.php += '<img src="/main/image/spacer.gif" width="' + spacerwidth + '" height="25" border="0"'
				+ this.mover + this.mout + '/><img src="/main/image/p_cccccc.gif" width="1" height="25" border="0"/></td>';
		} else {
			this.php += '<img src="/main/image/spacer.gif" width="' + spacerwidth + '" height="25" border="0"'
				+ this.mover + this.mout + '/></td>';
		}
		
					
					
	}
				

				
	//loop trough mainnav.php and create navObjects...
	function navObjects() {
		navArr = new Array();
				
				
		secondlevelArr0 = new Array();
					
			secondlevelArr0[0] = new navObj("Model Overview",sRootPath+"modeloverview.php", 1, 1, "null", "no");
							
			secondlevelArr0[1] = new navObj("9-3 Sport Sedan",sRootPath+"model/93_S/", 1, 8, "null", "no");
							//model_intro.php?modelcode=93_S
			secondlevelArr0[2] = new navObj("9-3 Convertible",sRootPath+"model/93_CONV/", 1, 3, "null", "no");
			secondlevelArr0[3] = new navObj("9-3 SportCombi",sRootPath+"model/93_WAGON/", 1, 4, "null", "no");			
							
			//secondlevelArr0[4] = new navObj("9-5 Sedan",sRootPath+"model_intro.php?modelcode=95", 1, 5, "null", "no");
			secondlevelArr0[4] = new navObj("9-5 Sedan",sRootPath+"model/95/", 1, 5, "null", "no");					
			//secondlevelArr0[5] = new navObj("9-5 Wagon",sRootPath+"model_intro.php?modelcode=95_WAGON", 1, 6, "null", "no");
			secondlevelArr0[5] = new navObj("9-5 Wagon",sRootPath+"model/95_WAGON/", 1, 6, "null", "no");
			secondlevelArr0[6] = new navObj("Build your Saab",sRootPath+"dyc.php", 1, 7, "null", "no");				
			//secondlevelArr0[5] = new navObj("Build your Saab","dyc.php", 1, 7, "null", "no");
							
					
						
		navArr[0] = new navObj("CARS","Javascript: void(null);", 1, null, secondlevelArr0);
				
				
		secondlevelArr1 = new Array();
					
			secondlevelArr1[0] = new navObj("Business",sRootPath+"business.php", 2, 2, "null", "no");
			secondlevelArr1[1] = new navObj("International & Diplomat Sales",sRootPath+"ids_intro.php", 2, 3, "null", "no");
			secondlevelArr1[2] = new navObj("Saab Expressions",sRootPath+"saab_expressions.php", 2, 4, "null", "no");			
							
		navArr[1] = new navObj("OUR SERVICES","Javascript: void(null);", 2, null, secondlevelArr1);
				
		secondlevelArr2 = new Array();
			secondlevelArr2[0] = new navObj("About Saab",sRootPath+"company.php", 3, 0, "null", "no");
			secondlevelArr2[1] = new navObj("About Trans Eurokars&nbsp;",sRootPath+"eurokars.php", 3, 2, "null", "no");
			secondlevelArr2[2] = new navObj("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;","", 3, 4, "null", "no");			
			secondlevelArr2[3] = new navObj("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;","", 3, 4, "null", "no");			
			secondlevelArr2[4] = new navObj("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;","", 3, 4, "null", "no");						

			
/*
			secondlevelArr2[0] = new navObj("History","historical.php", 3, 2, "null", "no");
			secondlevelArr2[1] = new navObj("Awards","awards_93s.php", 3, 4, "null", "no");
			secondlevelArr2[2] = new navObj("Saab Environment","environment.php", 3, 5, "null", "no");
			secondlevelArr2[3] = new navObj("Company Information","company.php", 3, 6, "null", "no");
			//secondlevelArr2[4] = new navObj("Saab Salomon","events_saab_salomon_intro.php", 3, 7, "null", "no");
			secondlevelArr2[4] = new navObj("Concept Cars","concept_cars.php", 3, 9, "null", "no");
							*/
					
						
		navArr[2] = new navObj("ABOUT US","Javascript: void(null);", 3, null, secondlevelArr2);
				
				
			secondlevelArr3 = new Array();
					
			secondlevelArr3[0] = new navObj("Local News",sRootPath+"newsletter.php", 4, 4, "null", "no");
			secondlevelArr3[1] = new navObj("International News",sRootPath+"news.php?id=1", 4, 1, "null", "no");
			secondlevelArr3[2] = new navObj("Press Releases",sRootPath+"pressreleases.php?id=1&type=recent", 4, 2, "null", "no");							
			secondlevelArr3[3] = new navObj("Saab i","http://www.saab.com/main/GLOBAL/en/saabi_about.shtml", 4, 3, "null", "no");
							
/*			
			secondlevelArr3[1] = new navObj("News","news.php?id=1", 4, 1, "null", "no");
							
			secondlevelArr3[2] = new navObj("News Archive","news_archive.php", 4, 3, "null", "no");
							
			secondlevelArr3[3] = new navObj("Press Releases","pressreleases.php?id=1&type=recent", 4, 2, "null", "no");
*/					
						
		navArr[3] = new navObj("NEWS","Javascript: void(null);", 4, null, secondlevelArr3);
				
	}
				


	htmlstring = '';
	
	function clearNav() {
		htmlstring = '';
	}
				
	function initNav() {
		setVisibility("navhider", "visible");
		clearNav();
		writeFirstNav(CURRENT_TOPNAV);
		writeSecondNav(CURRENT_TOPNAV, CURRENT_SUBNAV);
	}
				
	function resetDefaultState() {
		doNavAction(CURRENT_TOPNAV, CURRENT_SUBNAV);
	}
				
	function doNavAction(tid, sid) {
		clearNav();
		
		if(!sid | sid==null | sid == 0){
			writeFirstNav(tid);
		}
		writeSecondNav(tid, sid);
	}
		
	function writeFirstNav(tid) {
	
		TABLE_START = '<table border="0" cellpadding="0" cellspacing="0"><tr>';
		TABLE_END = '</tr></table>\n';
		
		htmlstring += TABLE_START;
		
		for(var i=0;i<navArr.length;i++) {
			
			if(navArr[i].topid==tid) {
						
				navArr[i].style = SELECTED_STYLE + "cursor: default;";
				navArr[i].mover=' onmouseover="setOverTd(\'top\',1);"';
				navArr[i].mout=' onmouseout="setOverTd(\'top\',0);"';
				navArr[i].setHtml(true, tid);
			}
			else {

				navArr[i].style = UNSELECTED_STYLE + "cursor: default;";
				navArr[i].mover=' onmouseover="setOverTd(\'top\',1);doNavAction(' + navArr[i].topid + ',' + navArr[i].subid + ');"';
				navArr[i].mout=' onmouseout="setOverTd(\'top\',0);"';
				navArr[i].setHtml(false, tid);
			}
						
			htmlstring += navArr[i].php;
		}
		htmlstring += TABLE_END;
		reWriteLayer('topnav', htmlstring);
		htmlstring = "";
	}
				
	function writeSecondNav(tid, sid) {
		
		var align = (tid == navArr[0].topid  ||  tid == navArr[1].topid) ? "left" : "center";

		TABLE_START = ''
			+ '<table border="0" cellpadding="0" cellspacing="0" width="721">'
			+ '<tr>'
			+ '<td align="' + align + '" '
			+ 'onmouseover="setOverTd(\'sub\',1)" '
			+ 'onmouseout="setOverTd(\'sub\',0);"'
			+ '>'
			+ '<table border="0" cellpadding="0" cellspacing="0">'
			+ '<tr>';
		TABLE_END = ''
			+ '</tr>'
			+ '</table>'
			+ '</td>'
			+ '</tr>'
			+ '</table>\n';

		htmlstring += TABLE_START;
			
		for(var i=0;i<navArr.length;i++) {
			if(navArr[i].topid == tid) {
				for(var j=0;j<navArr[i].subarr.length;j++){
					if(navArr[i].subarr[j].subid==sid) {
						navArr[i].subarr[j].style = SELECTED_STYLE;
						navArr[i].subarr[j].mover=' onmouseover="setOverTd(\'sub\',1);"';
						navArr[i].subarr[j].mout=' onmouseout="setOverTd(\'sub\',0);"';
					}
					else {
						navArr[i].subarr[j].style = UNSELECTED_STYLE;
						navArr[i].subarr[j].mover=' onmouseover="setOverTd(\'sub\',1);doNavAction(' + navArr[i].subarr[j].topid + ',' + navArr[i].subarr[j].subid + ');"';
						navArr[i].subarr[j].mout=' onmouseout="setOverTd(\'sub\',0);"';
					}
					navArr[i].setHtml();
					navArr[i].subarr[j].setHtml();
					htmlstring += navArr[i].subarr[j].php;
				}
			}
		}
		htmlstring += TABLE_END;
		reWriteLayer('secondnav', htmlstring);
	}
				
	var topMenuOverTd = 0;
	var subMenuOverTd = 0;
	var menuCheckOver = 0;



	function setOverTd (type, b)
	{
		eval (type + "MenuOverTd = " + b);
		menuCheckOver = 1;
	}


	setInterval ("testNavReset()", 250);

	function testNavReset()
	{
		if ((yMousePos > 50  ||  xMousePos > 772)
			&&  menuCheckOver == 1)
		{
			menuCheckOver = 0;
			setTimeout ("doNavReset()", 500)
		}
	}

	function doNavReset ()
	{
		if (yMousePos > 50  ||  xMousePos > 772)
		{
			initNav ();
		}
	}
