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);
}

//RDJ new functions below

//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>Benefits/Eligibility " + 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 writeErrorPagePersistent(strErrorText, strFocusElement, strPageName) 
{
    strHeader = "<b>Benefits/Eligibility " + strPageName; 
	strHeader = strHeader +  " </b><BR><BR>";
	strFullMsg = strHeader + strErrorText;
	re=/\|/gi;
	strFullMsg = strFullMsg.replace(re,":");
	windowOpener2(strFullMsg, strFocusElement, 1);
	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=300,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();
}

function windowOpener2(msg, strFocusElement, persistent) {

   //msgWindow=window.open("MsgWindow.html","displayWindow","scrollbars=auto,resizable=1,width=400,height=300,left=100,top=100,alwaysRaised=1");
   msgWindow=window.open("MsgWindow.html","displayWindow","scrollbars=yes,resizable=1,width=550,height=280,left=25,top=125",alwaysRaised=1);
   msgWindow.document.open();

   if (persistent) {
      if (persistent == 1)
         msgWindow.document.write("<html><head><Title>Delta Dental Insurance Company</Title></head><body bgcolor=#ededed 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%' style='{margin-top: 0pt; margin-bottom: 3pt;}'><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:

function open_window_center0(url) {
//True window center
    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_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_center1b(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=580;
    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();
}
function UnivTXSupplIDCardRequest()
{
    var strFocusElement = "none";
    var PageNameVal = "";
    var Msg = "<B>Benefits/Eligibility ID Card Request</B>";
    Msg = Msg + "<BR><BR><P align=justify style='{margin-top: 0pt; margin-bottom: 5pt;}'><font face='MS Sans Serif' size='2' color='#333366'>";
    //Msg = Msg + "You should have received an ID Card in the mail but if you need an additional card you may request it at the link below. Please include your name, address and phone number in the request.";
    Msg = Msg + "You should have received an ID Card in the mail but if you need an additional card you may request it by contacting us at 1-800-893-3582.";
    /*
    Msg = Msg + "<BR><BR><div align='center'><A HREF='https://secure1.ddpdelta.org/ddpca_secure/ddic/!ddic_service_request.asp'>Customer Service Secure Form</A></div>";
    Msg = Msg + "<BR><BR>";
    Msg = Msg + "</font><div align='center'><font face='MS Sans Serif' size='2' color='#333366'>Or you may call customer service at 1-800-893-3582.</strong></div>";
    Msg = Msg + "</font></p>";
    */
    //msgWindow=window.open("MsgWindow.html","displayWindow","scrollbars=yes,resizable=1,width=550,height=280,left=25,top=125",alwaysRaised=1);
    msgWindow=window.open("MsgWindow.html","displayWindow","scrollbars=yes,resizable=1,width=501,height=155,left=10,top=180",alwaysRaised=1);
    msgWindow.document.open();
    msgWindow.document.write("<html><head><Title>Delta Dental Insurance Company</Title></head><body bgcolor=#FFFFFF onLoad=\"window.focus()\"><font size=2 face=Verdana, Arial, Helvetica, sans-serif color=#333366>");
    msgWindow.document.write(Msg);
    msgWindow.document.write("<BR><BR><BR>");
    msgWindow.document.write("<table width='100%' style='{margin-top: 0pt; margin-bottom: 3pt;}'><row><td width='100%' align='center'><INPUT type='button' align='center' name='btnPrint' color='#333366' value=' Print ' class='button' onClick='javascript:window.print();'>&nbsp;&nbsp;&nbsp<INPUT type='button' align='center' name='btnClose' color='#333366' value='Close' class='button' onClick='window.close();'></td></TR></table>");
    msgWindow.document.close();
    return (false);
}

//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

