var is_win = (navigator.userAgent.toLowerCase().indexOf("mac") == -1);

var gMainNav = new Array(12);
var theRoot = '';
for (var i=0; i<gMainNav.length; i++) {
	gMainNav[i] = new Array(3);
}
gMainNav[0][0] = 'SuccessStories';
gMainNav[0][1] = theRoot + 'images/MainNav_success-rest.gif';
gMainNav[0][2] = theRoot + 'images/MainNav_success-over.gif';
gMainNav[1][0] = 'theProgram';
gMainNav[1][1] = theRoot + 'images/MainNav_program-rest.gif';
gMainNav[1][2] = theRoot + 'images/MainNav_program-over.gif';
gMainNav[2][0] = 'theProcedures';
gMainNav[2][1] = theRoot + 'images/MainNav_procedures-rest.gif';
gMainNav[2][2] = theRoot + 'images/MainNav_procedures-over.gif';
gMainNav[3][0] = 'theDoctors';
gMainNav[3][1] = theRoot + 'images/MainNav_doctors-rest.gif';
gMainNav[3][2] = theRoot + 'images/MainNav_doctors-over.gif';
gMainNav[4][0] = 'thestaff';
gMainNav[4][1] = theRoot + 'images/MainNav_staff-rest.gif';
gMainNav[4][2] = theRoot + 'images/MainNav_staff-over.gif';
gMainNav[5][0] = 'Media';
gMainNav[5][1] = theRoot + 'images/MainNav_media-rest.gif';
gMainNav[5][2] = theRoot + 'images/MainNav_media-over.gif';
gMainNav[6][0] = 'Seminars';
gMainNav[6][1] = theRoot + 'images/MainNav_seminars-rest.gif';
gMainNav[6][2] = theRoot + 'images/MainNav_seminars-over.gif';
gMainNav[7][0] = 'MorbidObesity';
gMainNav[7][1] = theRoot + 'images/MainNav_morbidObesity-rest.gif';
gMainNav[7][2] = theRoot + 'images/MainNav_morbidObesity-over.gif';
gMainNav[8][0] = 'InsuranceIssues';
gMainNav[8][1] = theRoot + 'images/MainNav_insurance-rest.gif';
gMainNav[8][2] = theRoot + 'images/MainNav_insurance-over.gif';
gMainNav[9][0] = 'Questions';
gMainNav[9][1] = theRoot + 'images/MainNav_questions-rest.gif';
gMainNav[9][2] = theRoot + 'images/MainNav_questions-over.gif';
gMainNav[10][0] = 'ContactUs';
gMainNav[10][1] = theRoot + 'images/MainNav_contact-rest.gif';
gMainNav[10][2] = theRoot + 'images/MainNav_contact-over.gif';
gMainNav[11][0] = 'QuizUs';
gMainNav[11][1] = theRoot + 'images/MainNav_quiz-rest.gif';
gMainNav[11][2] = theRoot + 'images/MainNav_quiz-over.gif';

var lContentWidth	= 700;
var lLeftPadding	= 10;
var lMainMenuWidth	= 109;
var lSubNavLeft;
var lPageWidth;

var onLayer;
var onLayer_Parent;
var timeOn			= null;
var menuActive		= 0;
var UDholder		= 0;
var whereAt			= 0;
var myTime			= 0;

var gParentOn;

var gDefault;
var gDefaulParent;

var gSubNavPlaced = false;
var gIndexSubNavOffset = 283;

function gShowDefault () {
	var lLocArray		= document.location.toString().split('/');
	var lPage			= lLocArray[lLocArray.length-1];
	if (lPage.toLowerCase().indexOf('program_') == 0 || lPage.toLowerCase().indexOf('program.cfm') == 0) {
		gDefault	= 'subNav_theProgram';
		gDefaultParent	= 'theProgram';
	} else if (lPage.toLowerCase().indexOf('procedures_') == 0 || lPage.toLowerCase().indexOf('procedures.cfm') == 0) {
		gDefault	= 'subNav_theProcedures';
		gDefaultParent	= 'theProcedures';
	} else if (lPage.toLowerCase().indexOf('doc_') == 0 || lPage.toLowerCase().indexOf('Doc.cfm') == 0) {
		gDefault	= 'subNav_theDoctors';
		gDefaultParent	= 'theDoctors';
	} else if (lPage.toLowerCase().indexOf('staff_') == 0 || lPage.toLowerCase().indexOf('staff_all.cfm') == 0) {
		gDefault	= 'subNav_thestaff';
		gDefaultParent	= 'thestaff';
	} else if (lPage.toLowerCase().indexOf('mo_') == 0 || lPage.toLowerCase().indexOf('mo.cfm') == 0) {
		gDefault	= 'subNav_MorbidObesity';
		gDefaultParent	= 'MorbidObesity';
	} else if (lPage.toLowerCase().indexOf('success_') == 0 || lPage.toLowerCase().indexOf('success.cfm') == 0) {
		gDefault	= 'subNav_SuccessStories';
		gDefaultParent	= 'SuccessStories';
	} else if (lPage.toLowerCase().indexOf('insurance_') == 0 || lPage.toLowerCase().indexOf('insurance.cfm') == 0) {
		gDefault	= 'subNav_InsuranceIssues';
		gDefaultParent	= 'InsuranceIssues';
	} else if (lPage.toLowerCase().indexOf('faq_') == 0 || lPage.toLowerCase().indexOf('faq.cfm') == 0) {
		gDefault	= 'subNav_Questions';
		gDefaultParent	= 'Questions';
	} else if (lPage.toLowerCase().indexOf('contact_') == 0 || lPage.toLowerCase().indexOf('contact.cfm') == 0) {
		gDefault	= 'subNav_ContactUs';
		gDefaultParent	= 'ContactUs';
	} else if (lPage.toLowerCase().indexOf('quiz_') == 0 || lPage.toLowerCase().indexOf('quiz.cfm') == 0) {
		gDefault	= 'subNav_QuizUs';
		gDefaultParent	= 'QuizUs';
	}
	if (typeof gDefault != 'undefined') {
		gShowSubNav(gDefault, gDefaultParent);
		gMainNavOver(gDefaultParent);
	}

	if ((lPage.toLowerCase().indexOf('index.cfm') == 0 || lPage.toLowerCase() == '') && !gSubNavPlaced) {
		if (document.all) {
			document.all.subNav_theProgram.style.top = parseInt(document.all.subNav_theProgram.style.top) + gIndexSubNavOffset;
			document.all.subNav_theProcedures.style.top = parseInt(document.all.subNav_theProcedures.style.top) + gIndexSubNavOffset;
			document.all.subNav_theDoctors.style.top = parseInt(document.all.subNav_theDoctors.style.top) + gIndexSubNavOffset;
			document.all.subNav_thestaff.style.top = parseInt(document.all.subNav_thestaff.style.top) + gIndexSubNavOffset;
			document.all.subNav_MorbidObesity.style.top = parseInt(document.all.subNav_MorbidObesity.style.top) + gIndexSubNavOffset;
			document.all.subNav_InsuranceIssues.style.top = parseInt(document.all.subNav_InsuranceIssues.style.top) + gIndexSubNavOffset;
			document.all.subNav_Questions.style.top = parseInt(document.all.subNav_Questions.style.top) + gIndexSubNavOffset;
			document.all.subNav_ContactUs.style.top = parseInt(document.all.subNav_ContactUs.style.top) + gIndexSubNavOffset;
			document.all.subNav_SuccessStories.style.top = parseInt(document.all.subNav_SuccessStories.style.top) + gIndexSubNavOffset;
			document.all.subNav_QuizUs.style.top = parseInt(document.all.subNav_QuizUs.style.top) + gIndexSubNavOffset;
		} else if (document.getElementById) {
			document.getElementById('subNav_theProgram').style.top = parseInt(document.getElementById('subNav_theProgram').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_theProcedures').style.top = parseInt(document.getElementById('subNav_theProcedures').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_theDoctors').style.top = parseInt(document.getElementById('subNav_theDoctors').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_thestaff').style.top = parseInt(document.getElementById('subNav_thestaff').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_MorbidObesity').style.top = parseInt(document.getElementById('subNav_MorbidObesity').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_InsuranceIssues').style.top = parseInt(document.getElementById('subNav_InsuranceIssues').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_Questions').style.top = parseInt(document.getElementById('subNav_Questions').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_ContactUs').style.top = parseInt(document.getElementById('subNav_ContactUs').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_SuccessStories').style.top = parseInt(document.getElementById('subNav_SuccessStories').style.top) + gIndexSubNavOffset;
			document.getElementById('subNav_QuizUs').style.top = parseInt(document.getElementById('subNav_QuizUs').style.top) + gIndexSubNavOffset;
		}
		gSubNavPlaced = true;
	}
}

function gHideDefault (pParentName) {
	if (typeof gDefaultParent != 'undefined') {
		if (gDefaultParent != pParentName) {
			gHideOnLayer();
		}
	}
}

function gSetLeft () {
	if (document.all) {
		lPageWidth = document.all.blankWidthImage.width;
	} else if (document.getElementById) {
		lPageWidth = document.getElementById('blankWidthImage');
	}
	lSubNavLeft = parseInt( ((lPageWidth - lContentWidth) / 2) + lLeftPadding + lMainMenuWidth );
	if (lSubNavLeft < (lLeftPadding + lMainMenuWidth)) {
		lSubNavLeft = lLeftPadding + lMainMenuWidth;
	}
}

function gMainNavOver (pName) {
	gParentOn = pName;
	for (var i=0; i<=gMainNav.length; i++) {
		if (gMainNav[i][0] == pName) {
			if (document.all) {
				eval("document.all." + pName).src = gMainNav[i][2];
			} else if (document.getElementById) {
				document.getElementById(pName).src = gMainNav[i][2];
			}
			i = gMainNav.length+1;
		}
	}
}

function gMainNavOut (pName) {
	if (gParentOn != '' && gParentOn != null) {
		for (var i=0; i<=gMainNav.length; i++) {
			if (gMainNav[i][0] == pName) {
				if (document.all) {
					eval("document.all." + pName).src = gMainNav[i][1];
				} else if (document.getElementById) {
					document.getElementById(pName).src = gMainNav[i][1];
				}
				i = gMainNav.length+1;
			}
		}
		gParentOn = '';
	}
}

function gShowSubNav (pName, pParentName) {
	if (timeOn != null) {
		clearTimeout(timeOn);
		gHideSubNav(onLayer);
		gMainNavOut(onLayer_Parent);
	}
	onLayer			= pName;
	onLayer_Parent	= pParentName;

	if (is_win) {
		gSetLeft ();
	}
	var lCurrentStatus;
	if (document.all) {
		if (is_win) {
			eval("document.all." + pName).style.left		= lSubNavLeft;
		}
		eval("document.all." + pName).style.visibility	= 'visible';
	} else if (document.getElementById) {
		document.getElementById(pName).style.left		= lSubNavLeft;
		document.getElementById(pName).style.visibility	= 'visible';
	}
}

function gHideSubNav (pName) {
	if (document.all) {
		eval("document.all." + pName).style.visibility	= 'hidden';
	} else if (document.getElementById) {
		document.getElementById(pName).style.visibility	= 'hidden';
	}

	gMainNavOut (gParentOn);
}

function gHideOnLayer_Timer () {
	timeOn = setTimeout("gHideOnLayer(); gShowDefault();",400);
}

function gHideOnLayer (layerName) {
	if (menuActive == 0) {
		gHideSubNav(onLayer);
		gMainNavOut(onLayer_Parent);
	}
}

function gSubNavOver () {
	clearTimeout(timeOn);
	menuActive = 1;
}

function gSubNavOut () {
	menuActive = 0 
	timeOn = setTimeout("gHideSubNav(onLayer); gMainNavOut(onLayer_Parent); gShowDefault();", 400)
}

