function mOvr(src,clrOver) {
	if (!src.contains(event.fromElement))
		src.style.cursor = 'hand'; src.bgColor = clrOver;
}

function mOut(src,clrIn) {
	if (!src.contains(event.toElement))
		src.style.cursor = 'default'; src.bgColor = clrIn;
}

function navTo(who) {
	if(who) {
		if(who.type == 'select-one') {
			if (who.options[who.selectedIndex].value != '')
				document.location.href = who.options[who.selectedIndex].value;
		}
	}
}

function displayCalendar() {
	var iMyWidth;
	var iMyHeight;
	//gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - (122 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - (27 + 50); //half the screen height minus half the new window height (plus title and status bars).
	top.newWin = window.open("calendar.html","cal","height=180,width=226,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
	top.newWin.focus();
}

function IsEmpty (val) {
//Description:	Checks whether a value passed in is empty or not
	var re = /[\S]{1,}/; //At least one non space character
	return !re.test(val);
}

function btnActiveColor(e) 
{
	// Set background color for element with focus
	//e.style.backgroundColor='#999966';
	//e.style.border='#999966 thin outset';
	e.style.backgroundColor='#ADAD85';
	e.style.border='#ADAD85 thin outset';
					
} // end btnActiveColor
function btnDefaultColor(e)  
{
	// Set background color for other elements 
	e.style.backgroundColor='#008080';
	e.style.border='#008080 thin outset';
	
} // end btnDefaultColor

//function lnkbtnUsageTips_onclick()
//{
    
//}

//allSpacesChk function checks field to see if it is all spaces. An empty field is not considered spaces.
function allSpacesChk(val)  {
  var checkStr = val;
  if (checkStr.length == 0)  {
     return false;
  }
  for (i = 0;  i < checkStr.length;  i++)  {
    ch = checkStr.charAt(i);
    if (ch != " ")  {
       return false;
       break;
    }
  } // end of for
  return true;
} // end of funtion

//Trim function using regular expressions (from www.breakingpar.com): 
//First, leading and trailing spaces are removed from the string in a 
//couple of statements. Build a regular expression statement that will
//find one or more starting white space characters (space, tab, form 
//feed, or line feed), then any character (\W\w ends up being anything),
//then one or more ending white spaces after a word boundary. If that 
//pattern is found in the input string, maintain only the middle 
//characters (the \W\w part). 

//To trim interior consecutive spaces, set up the regular expression object to hold two spaces (var obj = /  /g; has 2 spaces). While 2 spaces is somewhere in the string, replace all consecutive spaces with a single space. This only does one pass through, so if there were 3 consecutive spaces, it would replace the first 2 with a single space and end up with 2 spaces still. So the while loop is necessary. 
function trim(value) {
   //This function trims leading and trailing spaces.
   //This function also trims interior consecutive spaces to single spaces.
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   //var obj = /  /g;   //This line and the line below would trim interior consecutive spaces to single spaces.
   //while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}

//A new function is needed if you only want to trim the leading and trailing
//spaces and get rid of interior consecutive spaces. For this, functionality,
//activate the second instance where "obj" is set, and the while loop. 

function addErrorMsg(strNewError, intErrorNumber)
{

  if (intErrorNumber == 0)
  {  //Clear old submit's errors.
     intErrorCount = 0;
     strErrorText = "";
  }

  intErrorCount++;
  strErrorText = strErrorText + intErrorCount + ". " + strNewError + "<br><br>";
}

function addMessageMsg(strNewError, intMessageNumber)
{

  if (intMessageNumber == 0)
  {  //Clear old submit's errors.
     intMessageCount = 0;
     strMessageText = "";
  }

  intMessageCount++;
  strMessageText =  strMessageText + intMessageCount + ". " + strNewError + "<br><br>";
}

function writeErrorPage(strErrorText, strFocusElement, strPageName) 
{
    strHeader = "<b>Web Eligibility Management / " + strPageName 
	strHeader = strHeader + "<BR>Input Error Count: " + intErrorCount + " </b><BR><BR>";
	//strFullMsg = strHeader + "<ol>" + strErrorText + "</ol>";
	strFullMsg = strHeader + strErrorText;
	re=/\|/gi;
	strFullMsg = strFullMsg.replace(re,":");
	windowOpener(strFullMsg, strFocusElement);
	return (false);
}

function writeMessagePage(strMessageText, strFocusElement, strPageName) 
{
    strHeader = "<b>Web Eligibility Management / " + strPageName 
	strHeader = strHeader + "<BR>Explanation Notes: " + intErrorCount + " </b><BR><BR>";
	//strFullMsg = strHeader + "<ol>" +  strMessageText + "</ol>";
	strExplFullMsg = strHeader +  strMessageText;
	re=/\|/gi;
	strExplFullMsg = strExplFullMsg.replace(re,":");
	windowOpener(strExplFullMsg, strFocusElement);
	return (false);
}

function windowOpener(msg, strFocusElement, persistent) {


   //msgWindow=window.open("MsgWindow.html","displayWindow","scrollbars=auto,resizable=1,width=400,height=400,left=100,top=100,alwaysRaised=1");
   msgWindow=window.open("MsgWindow.html","displayWindow","scrollbars=auto,resizable=1,width=400,height=400,left=100,top=100");
   msgWindow.document.open();

   if (persistent) {
      if (persistent == 1)
         msgWindow.document.write("<html><head><Title>Delta Dental Insurance Company</Title></head><body bgcolor=#efefef onBlur=window.focus() onLoad=\"window.focus()\"><font size=2 face=Verdana, Arial, Helvetica, sans-serif color=#333366>");
      else
         msgWindow.document.write("<html><head><Title>Delta Dental Insurance Company</Title></head><body bgcolor=#efefef onLoad=\"window.focus()\"><font size=2 face=Verdana, Arial, Helvetica, sans-serif color=#333366>");
   }
	else{
	   msgWindow.document.write("<html><head><Title>Delta Dental Insurance Company</Title></head><body bgcolor=#efefef onBlur=window.close() onLoad=\"window.focus()\"><font size=2 face=Verdana, Arial, Helvetica, sans-serif color=#333366>");
   }

   msgWindow.document.write(msg);
    
   msgWindow.document.write("<table width='100%'><row><td width='100%' align='center'><INPUT type='button' align='center' name='btnClose' color='#333366' value='Close' class='button' onClick='window.close();'></td></tr><table>");
     
   strFocusElement.focus();	
   msgWindow.document.close();
}

//Open window functions:

// Use the following customised function in the place of the window.open method that 
// checks to see whether or not a window of that name is already open. If so, then it
// will call focus on it so that it is returned to the foreground.
// Provided by http://www.codestore.net/store.nsf/unid/DOMM-4PYJ3S?OpenDocument
function windowOpener2(url, name, args)
{
  if (typeof(popupWin) != "object")
  {
    popupWin = window.open(url, name, args);
  } 
  else 
  {
    if (!popupWin.closed)
    { 
      popupWin.location.href = url;
    } 
    else 
    {
      popupWin = window.open(url, name, args);
    }
  }
popupWin.focus();
}

//Simplified version of above
function windowOpener2(url, name, args) {

if(typeof(popupWin) != "object" || popupWin.closed) {
popupWin = window.open(url,name,args);
} else {
popupWin.location.href = url;
}

popupWin.focus();
return popupWins;  //spelling?
} 

//Variation with close window 
function windowOpener(url, name, args) {

//if(typeof(popupWin) != "object" || popupWin.closed) {
if(typeof(popupWin) != "object" || popupWin.closed) {
popupWin = window.open(url,name,args);
} else {
popupWin.location.href = url;
//popupWin.close();
//popupWin = window.open(url,name,args);
}

//popupWin.focus();
if (window.focus) {popupWin.focus()}
} 

var pop //create global variable without assigning a value so that its value is null

function popUp(url, name, args)
{
	if(pop!=null && !pop.closed)
	{ 
		// if popUp has been opened, and popUp hasn't already been closed
		// close it in order to re-assign properties
		pop.close() 
	}

	pop = window.open(url, name, args)

	pop.focus() 
}


function open_window_center0(url) {
//True window center (locked if window is already open)
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 500)/2, yOffset = (yMax - 300)/2;
    window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=540,height=300,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

function open_winCopyright(url) {
//window centered
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    //var xOffset = (xMax - 500)/2, yOffset = (yMax - 300)/2;
    var xOffset = (xMax - 550)/2, yOffset = (yMax - 300)/2;
    winCopyright = window.open(url,"winCopyright",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=540,height=300,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
    winCopyright.focus();
}

function open_winLinkFullSize(url) {
if (document.all)
	var xMax = screen.width, yMax = screen.height;
else
	if (document.layers)
		var xMax = window.outerWidth, yMax = window.outerHeight;
	else
		var xMax = 640, yMax=480;
//var xOffset = (xMax - 500)/2, yOffset = (yMax - 300)/2;
var xOffset = 15, yOffset = 20;
var winProposalRpt = window.open(url,"winProposalRpt",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=650,height=440,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
winProposalRpt.focus();
}

function open_winLinkSmall(url) {
if (document.all)
	var xMax = screen.width, yMax = screen.height;
else
	if (document.layers)
		var xMax = window.outerWidth, yMax = window.outerHeight;
	else
		var xMax = 630, yMax=240;
//var xOffset = (xMax - 500)/2, yOffset = (yMax - 300)/2;
var xOffset = 15, yOffset = 20;
var winProposalRpt = window.open(url,"winProposalRpt",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=630,height=240,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
winProposalRpt.focus();
}

//var winDoc1 //create global variable without assigning a value so that its value is null
function open_winDoc1(url) 
{
	//window centered
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    //var xOffset = (xMax - 500)/2, yOffset = (yMax - 300)/2;
    var xOffset = (xMax - 550)/2, yOffset = (yMax - 300)/2;
    
    //if(pop!=null && !pop.closed)
    //{
    //   winDoc1 = popUp(url,'winDoc1','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=540,height=300,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
    //}
    
    winDoc1 = popUp(url,'winDoc1','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=540,height=300,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
    //winDoc1 = windowOpener(url,'winDoc1','width=540,height=300');
    
    //May try setting the width and height property of popupWin after you've opened the new page in it. i.e:

	//popupWin.open(...);
	//popupWin.width=XXX;
	//popupWin.height=XXX;
    
    winDoc1.focus();
}

var newWin = null;
function open_window_New(url, name, args) {
// This does not recognize the existence of a previously opened pdf file windows. As an alternative
// to failing to reuse a window, this function opens a new window each time.
    var n=new Date();
    
    //alert("newWin = " + newWin);
    //alert("url = " + url);
	newWin = window.open(url, name+n.getTime(), args);
	newWin.focus();
}

var useWin = null;
function open_window_Use(url, name, args) {
// Use with html file windows. Reuses the window.
    
    //alert("newWin = " + newWin);
    alert("url = " + url);
	var useWin = window.open(url, name, args);
	useWin.focus();
}
   
function open_window_center1(url) 
{
    //Used for Quick Reference Guide
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 600)/2, yOffset = (yMax - 300)/2;
    winQuickRefGuide = window.open(url,"winQuickRefGuide",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=740,height=300,top=50,right=125');
    winQuickRefGuide.focus();
}

function open_window_center1a(url) 
{
    //Used for Adobe Acrobat Download
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 600)/2, yOffset = (yMax - 300)/2;
    winAdobe = window.open(url,"winAdobe",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=740,height=300,top=50,right=125');
    winAdobe.focus();
}

function open_window_center2(url) {
    //Used for Contact Us and Privacy Stmt and Copyright Stmt
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 600)/2, yOffset = (yMax - 300)/2;
    winMultiUse1 = window.open(url,"winMultiUse1",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=635,height=300,top=50,right=125');
    winMultiUse1.focus();
}

function open_window_center3(url) {
    //Used for DDIC Main Site
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 635, yMax=480;
    var xOffset = (xMax - 535)/2, yOffset = (yMax - 300)/2;
    winDDICMain = window.open(url,"winDDICMain",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=635,height=300,top=50,right=125');
    winDDICMain.focus();
}
function open_window_center4(url)
{
    //Used for DDIC Benefits & Eligibility Site
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 635, yMax=480;
    var xOffset = (xMax - 550)/2, yOffset = (yMax - 400)/2;
    winBenElig = window.open(url,"winBenElig",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=550,height=400,top=50,right=125');
    winBenElig.focus();
}

//open window functions below not in use, but kept for reference
function selectWin(source,h1,w1){
 newWin = window.open(source,'','height=' + h1 + ',width=' + w1 + ',top=10,left=0');
}
function selectWinRight(source,h1,w1){
 newWin = window.open(source,'','height=' + h1 + ',width=' + w1 + ',top=0,right=0');
}
function open_window1(url) {
window.open(url,"Help",'toolbar=yes,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=1,width=600,height=300');
}
function open_window2(url) {
window.open(url,"Help",'toolbar=yes,location=0,directories=0,status=0,menubar=yes,scrollbars=yes,resizable=1,width=300,height=300');
}
//open window functions above not in use, but kept for reference
