function reloadPage(init) { // netscape resize fix
  if (init==true) with (navigator) {if ((appName=="Netscape")&&((parseInt(appVersion)==4)||(parseInt(appVersion)==6))) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function validateAlpha(strValue) {
	var objRegExp  = /(^[a-zA-Z',.\-\ ]+$)/;
	return objRegExp.test(strValue);
}
function validateAlphaNum(strValue) {
	var objRegExp = /(^[a-zA-Z0-9'\-\., ]+$)/;
	return objRegExp.test(strValue);
}

function  validateNum( strValue ) {
var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
return objRegExp.test(strValue);
}

function validateFullDate(strValue){
var objRegExp = /(^[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/;
return objRegExp.test(strValue);
}

function validateMonth(strValue) {
var objRegExp = /(^[0-9]{2})$/;
return objRegExp.test(strValue);
}
function validateDate(strValue) {
var objRegExp = /(^[0-9]{2})$/;
return objRegExp.test(strValue);
}
function validateYear(strValue) {
var objRegExp = /(^[0-9]{4})$/;
return objRegExp.test(strValue);
}


function validateEmail(strValue) {
	var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	return objRegExp.test(strValue);
}

function validateState(strValue) {
var objRegExp = /^(AL|al|Al|AK|ak|Ak|AZ|az|Az|AR|ar|Ar|CA|ca|Ca|CO|co|Co|CT|ct|Ct|DC|dc|Dc|DE|de|De|FL|fl|Fl|GA|ga|Ga|HI|hi|Hi|ID|id|Id|IL|il|Il|IN|in|In|IA|ia|Ia|KS|ks|Ks|KY|ky|Ky|LA|la|La|ME|me|Me|MD|md|Md|MA|ma|Ma|MI|mi|Mi|MN|mn|Mn|MS|ms|Ms|MO|mo|Mo|MT|mt|Mt|NE|ne|Ne|NV|nv|Nv|NH|nh|Nh|NJ|nj|Nj|NM|nm|Nm|NY|ny|Ny|NC|nc|Nc|ND|nd|Nd|OH|oh|Oh|OK|ok|Ok|OR|or|Or|PA|pa|Pa|PR|pr|Pr|RI|ri|Ri|SC|sc|Sc|SD|sd|Sd|TN|tn|Tn|TX|tx|Tx|UT|ut|Ut|VT|vt|Vt|VA|va|Va|VI|vi|Vi|WA|wa|Wa|WV|wv|Wv|WI|wi|Wi|WY|wy|Wy)$/i; 
return objRegExp.test(strValue);
}

function validateZip( strValue ) {
	var objRegExp  = /(^[0-9]{5})$/;
	return objRegExp.test(strValue);
}

function openWin(url,name,w,h,scroll)
{
   var x, y, settings, myWin;
   
   settings = "width="+w+",height="+h+",scrollbars="+scroll+",resizable=1,status=0";
   x = screen.availWidth/2 - (w/2);
   y = screen.availHeight/2 - (h/2);
   
   myWin = window.open(url,name,settings);
   myWin.moveTo(x,y);
}


function open_window_default_size(url) { 
	mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
} 

function open_window(url) { 
	mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=350');
} 

function openWindowSize(mylink, windowname, winWidth, winHeight)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;

var leftpos = 0;
var toppos = 0;

if (screen) {
	leftpos = (screen.width - winWidth) / 2;
	toppos = (screen.height - winHeight) / 2;
}
   
window.open(href, windowname, 'toolbar=yes,status=yes,width='+winWidth+',height='+winHeight+',left='+leftpos+',top='+toppos+',scrollbars=yes');
return false;
}

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;

var leftpos = 0;
var toppos = 0;
var winWidth = 400;
var winHeight = 350;

if (screen) {
	leftpos = (screen.width - winWidth) / 2;
	toppos = (screen.height - winHeight) / 2;
}
   
window.open(href, windowname, 'width='+winWidth+',height='+winHeight+',left='+leftpos+',top='+toppos+',scrollbars=yes');
return false;
}

function popupSize(mylink, windowname, winWidth, winHeight)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;

var leftpos = 0;
var toppos = 0;

if (screen) {
	leftpos = (screen.width - winWidth) / 2;
	toppos = (screen.height - winHeight) / 2;
}
   
window.open(href, windowname, 'width='+winWidth+',height='+winHeight+',left='+leftpos+',top='+toppos+',scrollbars=yes');
return false;
}

// Start Breadcruumb
function capitalize(word) {
	firstLetter = word.substring(0,1);
	remainder = word.substring(1,word.length);
	newWord = firstLetter.toUpperCase() + remainder;
	
	switch (newWord) {
		case "About":			newWord = "About Us";
								break;
		case "Wellness":		newWord = "&amp; Wellness Programs";
								break;
		case "Worksite": 		newWord = "Voluntary Products";
								break;
		case "Rx": 				newWord = "Prescription Drug Program";
								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 "Hcp":				newWord = "Health Care Professionals";
								break;
		case "Education and Guidance":			newWord = "Education & Guidance";
								break;
		case "Dm":				newWord = "Disease Management";
								break;
		case "Stoploss":		newWord = "Stop Loss";
								break;
		case "Medicaresupplementinsurance":		newWord = "Medicare Supplement Insurance";
								break;
		case "24hour":		newWord = "24-Hour Plan Access";
								break;
		case "Medicarepartd":		newWord = "Medicare Part D";
								break;
		case "Healthcareprofessionals":		newWord = "Providers";
								break;
		case "Providers":		newWord = "Providers";
								break;
		case "Members":			newWord = "Members";
								break;
		case "Employers":		newWord = "Employers";
								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 "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 "Archdiocese":		newWord = "Omaha Archdiocese";
									break;
		case "Rrc":		newWord = "RRC Home";
									break;
		case "Wellcare":		newWord = "WellCare Home";
									break;
		case "Of":		newWord = "of";
									break;
		case "The":		newWord = "the";
									break;
		case "Perm":		newWord = "Permanent";
									break;
									
	}
	return newWord;
}

function getBreadcrumb() {
	var p = location.pathname;
	var directories = p.split("/");
	var count = 0;
	var root = "http://" + location.host;
	var up ="/";
	var cwd = "./";
	var dirString = "";
	var indexLevel = false;
	var home = "";
	
	var separator = "&nbsp;&nbsp;>&nbsp;&nbsp;";
	var path = root;
	var writeHome = true;
	
	home = "<a href=\"" + root + "/index.html\" title=\"Home\" target=\"_top\">Home</a>";
	
	//alert(path);
	
	if (writeHome) {
		document.write(home);
	}
	
	if (p.indexOf("index.") >= 0 || p.indexOf(".html") < 0) {
		indexLevel = true;
	}
	
	for (i = 0; i < directories.length; i++) {	
		if (i < directories.length-1) {
				// 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 = "";
					}
				} else {
					path += "/" + directories[i];
					separator = "&nbsp;&nbsp;>&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

// This function returns a full URL that can be used to load the relative URL passed as 
// a secured page under the current domain
function buildSecureURL(urlref) {

	return "https://" + window.location.host + urlref;
}

// This function loads the relative URL passed as a secure page under the current domain
function loadSecurePage(urlref) {

	window.location.href = buildSecureURL(urlref);
	return false;
}

// This function returns a full URL that can be used to load the relative URL passed as 
// an unsecured page under the current domain
function buildUnsecureURL(urlref) {

	return "http://" + window.location.host + urlref;
}

// This function loads the relative URL passed as an unsecure page under the current domain
function loadUnsecurePage(urlref) {

	window.location.href = buildUnsecureURL(urlref);
	return false;
}

// This function adds the secure application domain that corresponds to the current domain to 
// the relative URL passed
function addAppDomain(urlref) {

	var currHost = window.location.host;
	var appHost = currHost;
	
	// If on test public site, point to CAT for secure apps
	if (window.location.host == "cvtyitg.mutualofomaha.com") {
		appHost = "www10.chcne-m.com";
	} else {
		appHost = "www.chcne-m.com";
	}
	
	return appHost + urlref;
}

// This function returns a full URL that can be used to load the relative URL passed as a 
// secure page under the secure application domain corresponding to the current domain
function buildSecureAppURL(urlref) {

	return "https://" + addAppDomain(urlref);
}

// This function loads the relative URL passed as a secure page under the secure application 
// domain corresponding to the current domain
function loadSecureAppPage(urlref) {

	window.location.href = buildSecureAppURL(urlref);
	return false;
}

// This function returns a full URL that can be used to load the relative URL passed as an 
// unsecure page under the secure application domain corresponding to the current domain
function buildUnsecureAppURL(urlref) {

	return "http://" + addAppDomain(urlref);
}

// This function loads the relative URL passed as an unsecure page under the secure application 
// domain corresponding to the current domain
function loadUnsecureAppPage(urlref) {

	window.location.href = buildUnsecureAppURL(urlref);
	return false;
}

// automatically updates the copyright
function copyright() {
	var year="";
	mydate = new Date();
	myyear= mydate.getFullYear();
	year = myyear;
	if (year < 2000)
	year = year + 1900;
	var year = ("&nbsp; &copy; " + year);
	document.write(year);
}


