/* Page name: navigation.js
 * Purpose: Inserts appropriate navigation tabs onto each pages of drjengdds.com.
 * Author: Johnny Lam (jlam@spedeweb.com)
 * Date Created: 09/19/01
 * Last Modified: 09/19/01
 */


// Detect current page.
var thepath = document.location.pathname;
var aboutus_page = /about_us.php/gi;
var visitus_page = /visit.php/gi;
var faq_page = /faq.php/gi;
var invisalign_page = /invisalign.php/gi;
var implants_page = /implants.php/gi;

var content="";

// Initialize arrays variables to be used to draw each tabs.
var navArray = new Array("Home","About Us","Invisalign<sup>&reg;</sup>","Dental Implants","Visit Us","FAQ");
var navfileArray = new Array("index.php","about_us.php","invisalign.php","implants.php","visit.php","faq.php");
var tabcolorArray = new Array();
var tabactiveArray = new Array();
var secondbarArray = new Array();

//Initialize lower bar underneath each tabs.
var blankbar = '<td height="2" width="80" bgcolor="#FFFFFF">' +
		'<table width="80" height="2" cellspacing="0" cellpadding="0" border="0">' +
		'	<tr>' +
		'		<td width="2" height="2" bgcolor="#9900CC"><img src="images/spacer.gif" width="2" height="2" border="0"></td>' +
		'		<td width="76" height="2" bgcolor="#FFFFFF"><img src="images/spacer.gif" width="76" height="2" border="0"></td>' +
		'		<td width="2" height="2" bgcolor="#9900CC"><img src="images/spacer.gif" width="2" height="2" border="0"></td>' +
		'	</tr>' +
		'</table>' +
		'</td>';

var lastblankbar = '<td height="2" width="78" bgcolor="#FFFFFF" align="left">' +
			'<table width="78" height="2" cellspacing="0" cellpadding="0" border="0">' +
			'<tr>' +
			'	<td width="2" height="2" bgcolor="#9900CC"><img src="images/spacer.gif" width="2" height="2" border="0"></td>' +
			'	<td width="76" height="2" bgcolor="#FFFFFF"><img src="images/spacer.gif" width="76" height="2" border="0"></td>' +
			'</tr>' +
			'</table>' +
		    '</td>';

var regularbar = '<td height="2" width="80" bgcolor="#9900CC"><img src="images/spacer.gif" height="2" width="80" border="0"></td>';

var lastbar = '<td height="2" width="78" bgcolor="#9900CC"><img src="images/spacer.gif" height="2" width="78" border="0"></td>';

// Insert values based on the current page.
if (aboutus_page.test(thepath)){
	tabcolorArray = new Array("#9900CC","#FFFFFF","#9900CC","#9900CC","#9900CC","#9900CC");
	tabactiveArray = new Array("navdormant","navactive","navdormant","navdormant","navdormant","navdormant");
	secondbarArray = new Array(regularbar,blankbar,regularbar,regularbar,regularbar,lastbar);
}else if (invisalign_page.test(thepath)){
	tabcolorArray = new Array("#9900CC","#9900CC","#FFFFFF","#9900CC","#9900CC","#9900CC");
	tabactiveArray = new Array("navdormant","navdormant","navactive","navdormant","navdormant","navdormant");
	secondbarArray = new Array(regularbar,regularbar,blankbar,regularbar,regularbar,lastbar);
}else if (implants_page.test(thepath)){
	tabcolorArray = new Array("#9900CC","#9900CC","#9900CC","#FFFFFF","#9900CC","#9900CC");
	tabactiveArray = new Array("navdormant","navdormant","navdormant","navactive","navdormant","navdormant");
	secondbarArray = new Array(regularbar,regularbar,regularbar,blankbar,regularbar,lastbar);
}else if (visitus_page.test(thepath)){
	tabcolorArray = new Array("#9900CC","#9900CC","#9900CC","#9900CC","#FFFFFF","#9900CC");
	tabactiveArray = new Array("navdormant","navdormant","navdormant","navdormant","navactive","navdormant");
	secondbarArray = new Array(regularbar,regularbar,regularbar,regularbar,blankbar,lastbar);
}else if (faq_page.test(thepath)){
	tabcolorArray = new Array("#9900CC","#9900CC","#9900CC","#9900CC","#9900CC","#FFFFFF");
	tabactiveArray = new Array("navdormant","navdormant","navdormant","navdormant","navdormant","navactive");
	secondbarArray = new Array(regularbar,regularbar,regularbar,regularbar,regularbar,lastblankbar);
}else{
	tabcolorArray = new Array("#FFFFFF","#9900CC","#9900CC","#9900CC","#9900CC","#9900CC");
	tabactiveArray = new Array("navactive","navdormant","navdormant","navdormant","navdormant","navdormant");
	secondbarArray = new Array(blankbar,regularbar,regularbar,regularbar,regularbar,lastbar);
}

var i;
var islast;

// Build first row of tabs
for (i=0;i < navArray.length;i++){
	if (i == (navArray.length - 1)){
		islast = '<td colspan="2" valign="bottom" width="80" align="right">';
	}else{
		islast = '<td valign="bottom" width="80" align="right">';
	}
	content = content +	islast +
		'<table width="80" height="20" cellspacing="0" cellpadding="0" border="0">' +
		'<tr>' +
			'<td width="2" height="2">' +
				'<table cellspacing="0" cellpadding="0" border="0" width="2" height="2">' +
					'<tr>' +
						'<td colspan="2" height="1" width="2"><img src="images/spacer.gif" width="2" height="1" border="0"></td>' +
					'</tr>' +
					'<tr>' +
						'<td width="1" height="1"><img src="images/spacer.gif" height="1" width="1"></td>' +
						'<td width="1" height="1" bgcolor="#9900CC" valign="bottom"><img src="images/spacer.gif" height="1" width="1"></td>' +
					'</tr>' +
				'</table>' +
			'</td>' +
			'<td width="76" height="2" bgcolor="#9900CC"><img src="images/spacer.gif" width="76" height="2" border="0"></td>' +
			'<td width="2" height="2">' +
				'<table cellspacing="0" cellpadding="0" border="0" width="2" height="2">' +
					'<tr>' +
						'<td colspan="2" height="1" width="2"><img src="images/spacer.gif" width="2" height="1" border="0"></td>' +
					'</tr>' +
					'<tr>' +
						'<td width="1" height="1" bgcolor="#9900CC" valign="bottom"><img src="images/spacer.gif" height="1" width="1"></td>' +
						'<td width="1" height="1"><img src="images/spacer.gif" height="1" width="1"></td>' +
					'</tr>' +
				'</table>' +
			'</td>' +
		'</tr>' +
		'<tr>' +
			'<td width="2" height="18" bgcolor="#9900CC"><img src="images/spacer.gif" width="2" height="18" border="0"></td>' +
			'<td width="76" height="18" bgcolor="' + tabcolorArray[i] + '" valign="middle" align="center"><a href="' + navfileArray[i] + '" class="' + tabactiveArray[i] + '">'+ navArray[i] +'</a></td>' +
			'<td width="2" height="18" bgcolor="#9900CC"><img src="images/spacer.gif" width="2" height="18"border="0"></td>' +
		'</tr>' +
		'</table>' +
	'</td>';

	if (i != (navArray.length - 1)){
		content = content + '<td><img src="images/spacer.gif" width="5" height="1" border="0"></td>';
	}
}
content = content + '</tr>' +
	'<tr>' +
		'<td width="2" height="2" align="right" valign="bottom">' +
		'	<table cellspacing="0" cellpadding="0" border="0" width="2" height="2">' +
		'		<tr>' +
		'			<td colspan="2" height="1" width="2"><img src="images/spacer.gif" width="2" height="1" border="0"></td>' +
		'		</tr>' +
		'		<tr>' +
		'			<td width="1" height="1"><img src="images/spacer.gif" height="1" width="1"></td>' +
		'			<td width="1" height="1" bgcolor="#9900CC"><img src="images/spacer.gif" height="1" width="1"></td>' +
		'		</tr>' +
		'	</table>' +
		'</td>' +
'<td height="2" bgcolor="#9900CC"><img src="images/spacer.gif" height="2" border="0"></td>';

var j;

// Build second rows underneath the tabs.
for (j=0;j < secondbarArray.length; j++){
	content = content + secondbarArray[j];

	if (j != (secondbarArray.length-1)){
		content = content + '<td height="2" width="5" bgcolor="#9900CC"><img src="images/spacer.gif" height="2" width="5" border="0"></td>';
	}else{
		content = content + '<td bgcolor="#9900CC" width="2"><img src="images/spacer.gif" width="2" border="0"></td>';
	}
}

document.write(content);
