// JavaScript Document


// Start Breadcruumb
function capitalize(word) {
	firstLetter = word.substring(0,1);
	remainder = word.substring(1,word.length);
	newWord = firstLetter.toUpperCase() + remainder;
	
// THIS DOES NOT WORK - CHANGE IN COMMON.JS


	switch (newWord) {
		case "Spreadtheword":	newWord = "Spread the Word";
								break;
		case "Brokers":			newWord = "Brokers &amp; Consultants";
								break;
		case "About":			newWord = "About Us";
								break;
		case "Wellness":		newWord = "&amp; Wellness Programs";
								break;
		case "Dental":			newWord = "Dental Products";
								break;
		case "Worksite": 		newWord = "Voluntary Products";
								break;
		case "Rx": 				newWord = "Prescription Drug Program";
								break;
		case "Eap":				newWord = "EAP";
								break;
		case "Ppo":				newWord = "PPO";
								break;
		case "Pos":				newWord = "POS";
								break;
		case "Hmo":				newWord = "HMO";
								break;
		case "Tcm":				newWord = "TCM";
								break;
		case "Chp":				newWord = "CDHP";
								break;
		case "Hdhp":			newWord = "HDHP/HSA";
								break;
		case "401k":			newWord = "401(k)";
								break;
		case "Insurance":		newWord = "Products";
								break;
		case "Nylife":			newWord = "Life Products (New York)";
								break;
		case "Findagent":		newWord = "Find a Local Sales Office";
								break;
		case "Press":			newWord = "Press Releases";
								break;
		case "Tabs":			newWord = "Total Access Benefits Service";
								break;
		case "Hcp":				newWord = "Health Care Professionals";
								break;
		case "Dplan":			newWord = "Dental Plan";
								break;
		case "Education and Guidance":
								newWord = "Education & Guidance";
								break;
		case "Dm":				newWord = "Disease Management";
								break;
		case "Usaswim":			newWord = "USA Swimming";
								break;
		case "Rpd":				newWord = "Retirement Plans";
								break;
		case "Dcp":				newWord = "Drive, Chip and Putt Junior Challenge";
								break;
		case "Stoploss":		newWord = "Stop Loss";
								break;
		case "Specialrisk":		newWord = "Special Risk";
								break;						
		case "Medicaresupplementinsurance":		newWord = "Medicare Supplement Insurance";
								break;
		case "Longtermcareinsurance":		newWord = "Long Term Care Insurance";
								break;
		case "Lifeinsurance":	newWord = "Life Insurance";
								break;
		case "24hour":			newWord = "24-Hour Plan Access";
								break;
		case "Investmentselectionprocess":		newWord = "<br />Investment Selection Process";
								break;	
		case "Disabilityinsurance":		newWord = "Disability Insurance";
								break;
		case "Criticalillnessinsurance":		newWord = "Critical Illness Insurance";
								break;
		case "Medicarepartd":	newWord = "Medicare Part D";
								break;
		case "Healthcareprofessionals":		newWord = "Health Care Professionals";
								break;
		case "Std":				newWord = "Short-Term Disability";
								break;
		case "Ltd":				newWord = "Long-Term Disability";
								break;
		case "Misc":			newWord = "Miscellaneous Company News";
								break;
	    case "Sales":			newWord = "Sales Careers";
								break;
		case "Hospitalincome":	newWord = "Hospital Income";
								break;
		case "Provider":		newWord = "Find a Provider";
								break;	
		case "Search":			newWord = "Online Provider Search";
								break;	
		case "Directory":		newWord = "Create a Provider Directory";
								break;
		case "Voltl":			newWord = "Voluntary Term Life";
								break;
		case "Vstd":			newWord = "Voluntary Short-Term Disability";
								break;
		case "Vltd":			newWord = "Voluntary Long-Term Disability";
								break;
		case "Iradvantage":		newWord = "IRAdvantage";
								break;
		case "Healthydirections":		newWord = "Disease Management";
								break;
		case "Epic":			newWord = "Epic Home";
								break;
		case "Epicdirect":		newWord = "Epic Direct Home";
								break;
		case "Plantools":		newWord = "Plan Tools Home";
								break;
		case "Mois":			newWord = "MOIS";
								break;
		case "Ta":				newWord = "TA Home";
								break;
		case "Keepthemoney":	newWord = "Keep The Money in Your Plan";
									break;
		case "Archdiocese":		newWord = "Omaha Archdiocese";
									break;
		case "Rrc":		newWord = "RRC Home";
									break;
		case "Nnsecu":		newWord = "NNSECU Home";
									break;
		case "Createweb":		newWord = "Web site Creator";
									break;
		case "Afm":		newWord = "American Financial Marketing, Inc.";
									break;
		case "Wellcare":		newWord = "WellCare Home";
									break;
		case "Dultmeier":		newWord = "Dultmeier Home";
									break;
		case "Hlc":		newWord = "HLC Home";
									break;
		case "Reserverfp":		newWord = "Financing Redundant Reserve";
									break;
		case "Of":		newWord = "of";
									break;
		case "The":		newWord = "the";
									break;
		case "Nmc":		newWord = "NMC Home";
									break;
		case "Perm":		newWord = "Permanent";
									break;
		case "Retire":		newWord = "Retirement Services";
									break;
		case "Bayport":		newWord = "BayPort";
									break;
		case "Reachforyourdreams":	newWord = "Reach for Your Dreams";
									break;	
									
	}
	return newWord;
}

function getBreadcrumb() {
	var p = location.pathname;
	var directories = p.split("/");
	var count = 0;
	//var root = location.protocol + "//" + location.host;
	var root = "http://" + location.host;
	var up ="/";
	var cwd = "./";
	var dirString = "";
	var indexLevel = false;
	var home = "";
	
	var separator = "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
	var path = root;
	var writeHome = true;
	
	if (directories[1] == "individual_products") {
		home = "<a href=\"" + root + "/index.html\" title=\"Home\" target=\"_top\">Home</a>" +  separator + "<a href=\"" + root + "/products/index.html\" title=\"Products\" target=\"_top\">Products</a>";
	} else if (directories[1] == "annuities" || directories[1] == "criticalillnessinsurance" || directories[1] == "disabilityinsurance" || directories[1] == "hospitalincome" || directories[1] == "investments" || directories[1] == "lifeinsurance" ||  directories[1] == "longtermcareinsurance" || directories[1] == "medicarepartd" || directories[1] == "medicaresupplementinsurance") {
		home = "<a href=\"" + root + "/index.html\" title=\"Home\" target=\"_top\">Home</a>" +  separator + "<a href=\"" + root + "/products/index.html\" title=\"Products\" target=\"_top\">Products</a>" +  separator + "<a href=\"" + root + "/individual_products/index.html\" title=\"Individual Products\" target=\"_top\">Individual Products</a>";
	} else {
		home = "<a href=\"" + root + "/index.html\" title=\"Home\" target=\"_top\">Home</a>";
	}
	
	//alert(path);
	
	if (directories[1] == "epic" || directories[1] == "epicdirect" || directories[1] == "plantools" || directories[1] == "archdiocese" || directories[1] == "ta" || directories[1] == "nnsecu" || directories[1] == "rrc" || directories[1] == "wellcare" || directories[1] == "kaufman" || directories[1] == "mainline" || directories[1] == "nmc" || directories[1] == "dultmeier" || directories[1] == "hlc" || directories[1] == "nwa" || directories[1] == "association_example" || directories[1] == "bayport") {
		writeHome = false;
	}
	
	
	if (writeHome) {
		document.write(home);
	}
	
	if (p.indexOf("index.") != -1 || (p.indexOf(".html") == -1 && p.indexOf(".ph") == -1)) { //index., .html, .phtml or .php
		indexLevel = true;
	}
	
	for (i = 0; i < directories.length; i++) {	
		if (i < directories.length-1) {
			
			if (directories[i] != "calculators") { //leave the directories listed here out of the breadcrumb
				
				// take out underscores, replace with spaces
				if (directories[i].indexOf("_") >= 0) {
					var newString = "";
					eachPiece = directories[i].split("_");
					for (j = 0; j < eachPiece.length; j++) {
						temp = eachPiece[j];
						temp2 = capitalize(temp);
						eachPiece[j] = temp2;
					}
					n = eachPiece.join(" ");
					linkName = n;
				} else { //no underscores
					linkName = capitalize(directories[i]);
				}
				
				//adding the forward slash between directories
				if (i == 0) {
					path += directories[i];
					if (!writeHome) {
						//separator should be blank for first iteration if inside /epic, /epicdirect or /plantools
						separator = "";
					}
				} else {
					path += "/" + directories[i];
					separator = "&nbsp;&nbsp;&#187;&nbsp;&nbsp;";
				}
				
				//if the page being viewed is index level, the last directory of the bc trail is not a link
				if (i == directories.length-2 && indexLevel) {
					//do nothing
					//document.write(getPageTitle());
				} else {
					//alert(path);
					if (directories[1] != "legal") {
						document.write("<a href=\"" + path + "/index.html\" title=\"" + linkName + "\" target=\"_top\">" + linkName + "</a>" + separator);
						
					} else if (directories[2] == "participants") {
						document.write("<a href=\"" + path + "/index.html\" title=\"" + linkName + "\" target=\"_top\">" + linkName + "</a>" + separator);
					} else {
						if (i==1) {
							document.write(separator);
						}
					}
				}
			}
		} else { //The actual web page currently being viewed in the breadcrumb trail
			//do nothing
		}
	}
	dirString += "/" + directories[i];
}
// End Breadcrumb


// Start Tab Rollovers
home = new Image();
home.src = location.protocol + "//" + location.host + "/images/layout/tabs/home_over.jpg";

products = new Image();
products.src = location.protocol + "//" + location.host + "/images/layout/tabs/products_over.jpg";

cs = new Image();
cs.src = location.protocol + "//" + location.host + "/images/layout/tabs/customer_service_over.jpg";

tools = new Image();
tools.src = location.protocol + "//" + location.host + "/images/layout/tabs/tools_over.jpg";

aboutus = new Image();
aboutus.src = location.protocol + "//" + location.host + "/images/layout/tabs/about_over.jpg";

careers = new Image();
careers.src = location.protocol + "//" + location.host + "/images/layout/tabs/careers_over.jpg";

employees = new Image();
employees.src = location.protocol + "//" + location.host + "/images/retire/prsa/tabs/w-employees-over.gif";

owner = new Image();
owner.src = location.protocol + "//" + location.host + "/images/retire/prsa/tabs/owner-only-over.gif";

// End Tab Rollovers

// start getTabs() function
function getTabs() {
	var url = document.location.href;
	var searchPage = false;
	if ((url.indexOf(":8765") != -1) || (url.indexOf("mooquery.html") != -1)) {
		searchPage = true;
	}
	var urlDivided = url.split("/");
	var urlPieces = urlDivided.length-3;
	var isIndexLevel = false;
	var isHomePage = false;
	var tabs_array = new Array("home", "products", "customer_service", "tools", "about", "careers");
	var alt_array = new Array("Home", "Products", "Customer Service", "Tools", "About Us", "Careers");
	var img_width_array = new Array(111, 119, 119, 119, 119, 115);
	var currentSection = urlDivided[3];
	var tabs = "";
	
	
	if ((urlPieces == 1) || (urlPieces == 2 && (urlDivided[urlDivided.length-1] == "index.html") || (urlDivided[urlDivided.length-1] == ""))) {
		isIndexLevel = true;
	}
	
	if (urlDivided.length < 5) { //5 means that there will be at least one directory in the URL
		//if filename contains 'index' or filename doesn't exist it must be the homepage
		if (urlDivided[urlDivided.length-1].indexOf("index") != -1 || urlDivided[urlDivided.length-1] == "") {
			isHomePage = true;
		}
	}
	
	if (currentSection == "annuities" || currentSection == "criticalillnessinsurance" || currentSection == "disabilityinsurance" || currentSection == "hospitalincome" || currentSection == "investments" || currentSection == "lifeinsurance" || currentSection == "longtermcareinsurance" || currentSection == "medicaresupplementinsurance" || currentSection == "medicarepartd" || (currentSection == "employers" && urlDivided[4] == "products") || currentSection == "individual_products" || urlDivided[3] == "retire"){
		currentSection = "products";
	}
	
	for (var i=0;i<tabs_array.length;i++) {
		if (searchPage) {
			tabs = "<a href=\"http://www.mutualofomaha.com/\" onmouseover=\"home.src='http://www.mutualofomaha.com/images/layout/tabs/home_over.jpg';\" onmouseout=\"home.src='http://www.mutualofomaha.com/images/layout/tabs/home_off.jpg';\" title=\"Home\" target=\"_top\"><img src=\"http://www.mutualofomaha.com/images/layout/tabs/home_off.jpg\" alt=\"Home\" name=\"home\" width=\"111\" height=\"30\" border=\"0\" /></a>";
			tabs += "<a href=\"http://www.mutualofomaha.com/products/index.html\" onmouseover=\"products.src='http://www.mutualofomaha.com/images/layout/tabs/products_over.jpg';\" onmouseout=\"products.src='http://www.mutualofomaha.com/images/layout/tabs/products_off.jpg';\" title=\"Products\" target=\"_top\"><img src=\"http://www.mutualofomaha.com/images/layout/tabs/products_off.jpg\" alt=\"Products\" name=\"products\" width=\"119\" height=\"30\" border=\"0\" /></a>";
			tabs += "<a href=\"http://www.mutualofomaha.com/customer_service/index.html\" onmouseover=\"customer_service.src='http://www.mutualofomaha.com/images/layout/tabs/customer_service_over.jpg';\" onmouseout=\"customer_service.src='http://www.mutualofomaha.com/images/layout/tabs/customer_service_off.jpg';\" title=\"Customer Service\" target=\"_top\"><img src=\"http://www.mutualofomaha.com/images/layout/tabs/customer_service_off.jpg\" alt=\"Customer Service\" name=\"customer_service\" width=\"119\" height=\"30\" border=\"0\" /></a>";
			tabs += "<a href=\"http://www.mutualofomaha.com/tools/index.html\" onmouseover=\"tools.src='http://www.mutualofomaha.com/images/layout/tabs/tools_over.jpg';\" onmouseout=\"tools.src='http://www.mutualofomaha.com/images/layout/tabs/tools_off.jpg';\" title=\"Tools\" target=\"_top\"><img src=\"http://www.mutualofomaha.com/images/layout/tabs/tools_off.jpg\" alt=\"Tools\" name=\"tools\" width=\"119\" height=\"30\" border=\"0\" /></a>";
			tabs += "<a href=\"http://www.mutualofomaha.com/about/index.html\" onmouseover=\"about.src='http://www.mutualofomaha.com/images/layout/tabs/about_over.jpg';\" onmouseout=\"about.src='http://www.mutualofomaha.com/images/layout/tabs/about_off.jpg';\" title=\"About Us\" target=\"_top\"><img src=\"http://www.mutualofomaha.com/images/layout/tabs/about_off.jpg\" alt=\"About Us\" name=\"about\" width=\"119\" height=\"30\" border=\"0\" /></a>";
			tabs += "<a href=\"http://www.mutualofomaha.com/careers/index.html\" onmouseover=\"careers.src='http://www.mutualofomaha.com/images/layout/tabs/careers_over.jpg';\" onmouseout=\"careers.src='http://www.mutualofomaha.com/images/layout/tabs/careers_off.jpg';\" title=\"Careers\" target=\"_top\"><img src=\"http://www.mutualofomaha.com/images/layout/tabs/careers_off.jpg\" alt=\"Careers\" name=\"careers\" width=\"115\" height=\"30\" border=\"0\" /></a>";
		} else {
			if (currentSection == tabs_array[i]) {
				if (isIndexLevel) {
					if (urlDivided[3] == "products") {
						tabs += "<img src=\"http://www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_on.jpg\" alt=\"" + alt_array[i] + "\" name=\"" + tabs_array[i] + "\" width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" />";
					} else {
						//tabs += "<img src=\"http://www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_on.jpg\" alt=\"" + alt_array[i] + "\" name=\"" + tabs_array[i] + "\" width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" /></a>";
						tabs += "<a href=\"/" + tabs_array[i] + "/index.html\" title=\"" + alt_array[i] + "\" target=\"_top\"><img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_on.jpg\" alt=\"" + alt_array[i] + "\" name=" + tabs_array[i] + " width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" /></a>";
					}
				} else {
					if ((tabs_array[i] == tabs_array[0]) || (tabs_array[i] == "")) { //Home
						tabs += "<a href=\"/index.html\" title=\"" + alt_array[i] + "\" target=\"_top\"><img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_on.jpg\" alt=\"" + alt_array[i] + "\" name=" + tabs_array[i] + " width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" /></a>";
					} else {
						tabs += "<a href=\"/" + tabs_array[i] + "/index.html\" title=\"" + alt_array[i] + "\" target=\"_top\"><img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_on.jpg\" alt=\"" + alt_array[i] + "\" name=" + tabs_array[i] + " width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" /></a>";
					}
				}
			} else {
				//First condition displays BLANK tabs
				if (urlDivided[4] == "participants" || currentSection == "epicdirect" || currentSection == "epic" || currentSection == "plantools" || currentSection == "enrollhelp" || currentSection == "ta" || currentSection == "nnsecu" || currentSection == "rrc" || currentSection == "webenrollment" || currentSection == "archdiocese" || currentSection == "afm" || currentSection == "annuitybrokers" || currentSection == "dominion" || currentSection == "henrico_fop" || currentSection == "wellcare" || currentSection == "kaufman" || currentSection == "mainline" || currentSection == "a3x_3xrfp" || currentSection == "nmc" || currentSection == "dultmeier" || currentSection == "hlc" || currentSection == "nwa" || currentSection == "association_example" || currentSection == "bayport") { //Display Blank Tabs
					tabs += "<img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_blank.jpg\" alt=\"\" name=" + tabs_array[i] + " width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" />";
				} else if (isHomePage && i < 1) {
					tabs += "<img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/home_on.jpg\" alt=\"Home\" name=\"home\" width=\"111\" height=\"30\" border=\"0\" />";
				} else if ((tabs_array[i] == tabs_array[0]) || (tabs_array[i] == "")) { //Home
					tabs += "<a href=\"/\" onmouseover=\"" + tabs_array[i] + ".src='" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_over.jpg';\" onmouseout=\"" + tabs_array[i] + ".src='" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_off.jpg';\" title=\"" + alt_array[i] + "\" target=\"_top\"><img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_off.jpg\" alt=\"" + alt_array[i] + "\" name=" + tabs_array[i] + " width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" /></a>";
				} else { //Not currentSection or Home
					tabs += "<a href=\"/" + tabs_array[i] + "/index.html\" onmouseover=\"" + tabs_array[i] + ".src='" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_over.jpg';\" onmouseout=\"" + tabs_array[i] + ".src='" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_off.jpg';\" title=\"" + alt_array[i] + "\" target=\"_top\"><img src=\"" + location.protocol + "//www.mutualofomaha.com/images/layout/tabs/" + tabs_array[i] + "_off.jpg\" alt=\"" + alt_array[i] + "\" name=" + tabs_array[i] + " width=\"" + img_width_array[i] + "\" height=\"30\" border=\"0\" /></a>";
				}
			}
		}
	}
	document.write(tabs);
} // end getTabs() function
