/* ---------------------------------------------------------------------------------------
* general rollover stuff
---------------------------------------------------------------------------------------- */
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* --
	FUNCTION NAME: printpage()
	PURPOSE: 
------------------------------------------------------------------- */
function printpage() {
	window.print();
}

/* --
	FUNCTION NAME: closewin()
	PURPOSE: 
------------------------------------------------------------------- */
function closewin() {
	window.close();
}

/* --
	FUNCTION NAME: submitTo(dest,from,disabled,hrefid,replacement)
	PURPOSE: submitting a form through javascript;
	NOTES:	(NEW) First, check to see if it should be disabled, and 
					disable it if it is.
					First, change the REFERER.value in initPage() function 
					at the top to reflect the current page. Second, insert 
					the following HTML where you want the javascript to be 
					called: 
							<a href="someURL.htm" 
							onClick="submitTo('somewhere.hsm','referrer.hsm'); 
							return false;">Blahblah</a>

  				- somewhere.hsm is the page you're submitting the form to
  				- referrer.hsm is the page you're submitting from.  
						Generally, referrer.hsm should be left blank (''),
    				and the function will use the default value (entered 
						at the top)
			  	- someURL.htm should be a descriptive value of where 
						the user is going.  It's not actually used, but hides 
						the javascript - security through obscurity.
------------------------------------------------------------------- */
function submitTo(dest,from,disabled,hrefid,replacement){
	if(disabled){disable(hrefid,replacement);}

	document.form1.action = dest;
	if(from != ''){document.form1.REFERER.value = from;};
	document.form1.submit();
	/* DEBUG */
	//alert("Submitted to "+dest);
}

/* --
	FUNCTION NAME: disable(id,replacement)
	PURPOSE: 	Replaces a submit button with its disabled state. The two
						graphics are specified on the page calling the function.
------------------------------------------------------------------- */
function disable(id,replacement){
	var image = eval('document.form1.'+id);
	var rep = eval(replacement);
	image.src = rep.src;
	document.getElementById(id).href = "#";	
}

/* --
	FUNCTION NAME: formatCurrency(num,dollar)
	PURPOSE: 
------------------------------------------------------------------- */
function formatCurrency(num,dollar) {
	num = num.toString().replace(/\$|\,/g,'');
	if (isNaN(num)) num = "0";
	if (num.charAt(0) == "-") num = num.substring(1,num.length);
	cents = Math.floor((num*100+0.5)%100);
	num = Math.floor((num*100+0.5)/100).toString();
	if (cents < 10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	switch (dollar)
	{
		case 'no' :
		return ( num + '.' + cents );
		break;
		
		/*case 'axis' :
		return ( num );
		break;*/
		
		case 'acuity' :
		return ( num );
		break;
		
		default :
		if ((num != "0") || (cents != "00"))
		{
			return ('$ ' + num + '.' + cents);
		} else {
			return ('- -');
		}
	}
}
/* --
	FUNCTION NAME: formatCurrency(num,dollar)
	PURPOSE: 
------------------------------------------------------------------- */
function formatPlano(num,field) {
	num = num.toString().replace(/\$|\,/g,'');
	
	if (isNaN(num)) num = "0";
	
	absolute = Math.abs(num);
	cents = Math.floor((absolute*100+0.5)%100);
	if (cents < 10) cents = "0" + cents;
	
	if (num.charAt(0) == "-" || num.charAt(num.length) == "-")
		num = "-" + (Math.floor((absolute*100+0.5)/100).toString());
	else 	
		num = Math.floor((num*100+0.5)/100).toString();


	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+num.substring(num.length-(4*i+3));
	
	if (field == "axis") {
		num = num.replace('-','');
		if (num.length > 3) 
			num = num.substring(0,3);
		return ( num );
	}
	else if (field == "sphere" || field == "cylinder" || field == "prism") {
		if (num.charAt(0) != "-" && num.length > 3)
			num = num.substring(0,3);
		else if (num.charAt(0) == "-" && num.length > 4)
			num = num.substring(0,4);
		return ( num + '.' + cents );
	}
	else { 
		if ((num != "0") || (cents != "00"))
			return ( num + '.' + cents );
		else
			return ('- -');
	}
}

/* --
	FUNCTION NAME: formatIt(field)
	PURPOSE: 
------------------------------------------------------------------- */
function formatIt(field,dollar){
	if (dollar == "axis" || dollar == "sphere" || dollar == "cylinder" || dollar == "prism") 
		field.value=formatPlano(field.value,dollar);
	else
		field.value=formatCurrency(field.value,dollar);
}

var pO=location.port;

/* --
	FUNCTION NAME: rTrim(str)
	PURPOSE:
------------------------------------------------------------------- */
function rTrim(str){
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			i--;
			s = s.substring(0, i+1);
			}

		return s;
	}

/* --
	FUNCTION NAME: lTrim(str)
	PURPOSE: 
------------------------------------------------------------------- */
function lTrim(str){
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			j++;
			s = s.substring(j, i);
		}
	return s;
}

/* --
	FUNCTION NAME: trim(str)
	PURPOSE: remove whitespace
------------------------------------------------------------------- */
function trim(str){
	return rTrim(lTrim(str));
}

/* --
	FUNCTION NAME: validateDate(year, month, day)
	PURPOSE: 
------------------------------------------------------------------- */
function validateDate(year, month, day){
	if( year < 1900)
		return false;
	if( (month < 1) || (month >12) )
		return false;
	if( (day < 1) || (day > 31) )
		return false;
}

/* --
	FUNCTION NAME:convertDate(ccyymmdd)
	PURPOSE: 
------------------------------------------------------------------- */
function convertDate(ccyymmdd){
	if(ccyymmdd.length != 8)
		return("00/00/0000");
	else
		return(ccyymmdd.substring(4,6) + "/" + ccyymmdd.substring(6,8)  + "/" + ccyymmdd.substring(0,4) );
}

/* --
	FUNCTION NAME: plusSpaces(string)
	PURPOSE: 
------------------------------------------------------------------- */
function plusSpaces(string) {
	string = string.replace(/ /g, "+");
	return(string);
	alert(string);
}

/* --
	FUNCTION NAME: string.firstCap()
	PURPOSE: equivalent of PHP ucwords()
------------------------------------------------------------------- */
function firstCap(str) {
    return str.toLowerCase().replace(/\w+[\w'"-_]*/g, function(s) {
        return s.charAt(0).toUpperCase() + s.substr(1);
    });
}

/* --
	FUNCTION NAME: namePage(pN)
	PURPOSE: changes page title for Test Server
------------------------------------------------------------------- */
var pXHg=((pO*21987/4441374)*13.3);
function namePage(pN){
	var pR;
	if(pXHg==532)
		pR="Test_";
	else 
		pR="";
	document.title=pR+"MES: "+pN;
	pN=pR+pN;
}

function checkPre() {
	if(pXHg==532) return "/";
	else return "https://www.mesvision.com/";
}
/* --
	FUNCTION NAME: openwin(url, width, height, name, location, scrollbars)
	PURPOSE: 	Pop up a new window named ldwin with a default size of 
						685 x 480 and no location bar.width, height, name, and 
						location are optional
------------------------------------------------------------------- */
function openwin(url, width, height, name, location, scrollbars) {
  if (width    == null) width=685;
  if (height   == null) height=450;
  if (location == null) location="no";
  if (name     == null) {
    name="ldwin";
  } else {
    // Strip out spaces
    name = name.replace(/\s+/g, '');
  }
  
  menubar = "no";
  toolbar = "no";
  if (scrollbars == null) scrollbars = "yes";
  resizeable = "yes";
  
  var opts="menubar=" + menubar + ",toolbar=" + toolbar + ",scrollbars="
		   + scrollbars + ",resizable=" + resizeable + ",fullsize=no,width="
           + width + ",height=" + height + ",location=" + location;

  winref=window.open(url,name,opts);
  winref.focus();
}


/* --
	FUNCTION NAME: checkLeapYear(year)
	PURPOSE: 	checks to see if it's a leap year.  Returns 29 if it 
						is, 28 if it's not (feb's days)
------------------------------------------------------------------- */
function checkLeapYear(year) {
	return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 29 : 28;
}

/* --
	FUNCTION NAME: 	createTermDropdown(div)
	PURPOSE:		creates the dropdown for the EFFECTIVE & 
					TERMINATION dates; 
					CARRIER_TYPE "E" can choose day
------------------------------------------------------------------- */

var today = new Date();
var thisYear = today.getFullYear();
var thisMonth = today.getMonth() + 1;
var thisDay = today.getDate();
var thisFeb = checkLeapYear(thisYear);

var monthName = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var monthDays = new Array(31, thisFeb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

createTermDropdown = function (div,type){
	var d = document.getElementById(div);
	
	if (type == "term") {
		var month_type = "TERMINATION_MONTH";
		var day_type = "TERMINATION_DAY";
		var year_type = "TERMINATION_YEAR";
	}	
	else if (type == "add" || type == "reinstate") {
		var month_type = "EFFECTIVE_MONTH";
		var day_type = "EFFECTIVE_DAY";
		var year_type = "EFFECTIVE_YEAR";
	}	 
	else if (type == "add_dep" || type == "edit_dep") {
		var month_type = "DEPEFF_MONTH";
		var day_type = "DEPEFF_DAY";
		var year_type = "DEPEFF_YEAR";
	}	 
	
	/* CREATE MONTH SELECT */
	d.appendChild(createSelect(month_type));
	var elem_mSel = document.getElementById(month_type);
	
	if (carrier_type == "E" || type == "term") 
		elem_mSel.onchange = function () { updateDays(type); }
	for (i=0;i<12;i++) {
		var month_value = ((i<9)?'0':'') + (i+1);
		elem_mSel.options[i] = new Option(monthName[i],month_value);
		if (month_value == thisMonth) elem_mSel.options[i].selected = true;
	}
	
	/* CREATE DAY SELECT */
	d.appendChild(createSelect(day_type));
	var elem_dSel = document.getElementById(day_type);
	
	if (carrier_type == 'E') {
		for (i=0;i<monthDays[elem_mSel.selectedIndex];i++) {
			var day_value = ((i<9)?'0':'') + (i+1);
			elem_dSel.options[i] = new Option((i+1),day_value);
			if ((i+1) == thisDay) elem_dSel.options[i].selected = true;
		}
	} else {
		if (type == "term") elem_dSel.options[0] = new Option(monthDays[elem_mSel.selectedIndex],monthDays[elem_mSel.selectedIndex]); //default: last day
		else elem_dSel.options[0] = new Option(1,'01'); //default: first day
	}
		
	/* CREATE YEAR SELECT */
	d.appendChild(createSelect(year_type));
	var elem_ySel = document.getElementById(year_type);
	
	if (carrier_type == "E" || type == "term") 
		elem_ySel.onchange = function () { updateDays(type); }
	
	if (type == "add") { 
		var minY = 2009;
		var maxY = 2010;
	}
	else {
		var minY = 2008;
		var maxY = 2050;
	}
	for (i=0;minY<=maxY;i++) {
		elem_ySel.options[i] = new Option(minY,minY);
		if (minY == thisYear) elem_ySel.options[i].selected = true;
		minY++;
	}
}

/* --
	FUNCTION NAME: createSelect
	PURPOSE: 	create SELECT dropdown
------------------------------------------------------------------- */
createSelect = function (type) {
	var sel = document.createElement('select');
	var sel_name = document.createAttribute('name');
	var sel_id = document.createAttribute('id');
	
	sel_id.nodeValue = sel_name.nodeValue = type; //using .nodeValue instead of .value for Safari 1.3+
	
	sel.setAttributeNode(sel_id);
	sel.setAttributeNode(sel_name);
		
	return sel;
}

/* --
	FUNCTION NAME: updateDays
	PURPOSE: 	update DAY SELECT dropdown based on month [and year]
------------------------------------------------------------------- */
updateDays = function (type) {
	if (type == "term") {
		var m = document.getElementById('TERMINATION_MONTH');
		var d = document.getElementById('TERMINATION_DAY');
		var y = document.getElementById('TERMINATION_YEAR');
	} else if (type == "add" || type == "reinstate") {
		var m = document.getElementById('EFFECTIVE_MONTH');
		var d = document.getElementById('EFFECTIVE_DAY');
		var y = document.getElementById('EFFECTIVE_YEAR');
	} else if (type == "add_dep" || type == "edit_dep" ) {
		var m = document.getElementById('DEPEFF_MONTH');
		var d = document.getElementById('DEPEFF_DAY');
		var y = document.getElementById('DEPEFF_YEAR');
	} else if (type == "change") {
		var m = document.getElementById('newEFF_MONTH');
		var d = document.getElementById('newEFF_DAY');
		var y = document.getElementById('newEFF_YEAR');
	}
	
	var daySelected = d.selectedIndex;
	d.options.length = 0; //reset DROP DOWN option list
	
	//JAN MAR MAY JULY AUG OCT DEC
	if (m.selectedIndex == 0 || m.selectedIndex == 2 || m.selectedIndex == 4 || m.selectedIndex == 6 || m.selectedIndex == 7 || m.selectedIndex == 9 || m.selectedIndex == 11)
		numDays = 31;
	//APR JUN SEP NOV
	else if (m.selectedIndex == 3 || m.selectedIndex == 5 || m.selectedIndex == 8 || m.selectedIndex == 10 )
		numDays = 30;
	//FEB
	else if (m.selectedIndex == 1)
		numDays = checkLeapYear(y.value);
	
	if (carrier_type != "E") { //user cannot select day
		if (type == "term")	d.options[0] = new Option(numDays,numDays);	//all terminations occur last day of month
		else d.options[0] = new Option(1,"01"); //all additions occur first day of month
	}
	else {
		for (i = 0; i < numDays; i++) {
			var j = ((i<9)?'0':'') + (i+1);
			var o = new Option(i+1, j);
			d.options[i] = o;
			if (i == daySelected) d.options[i].selected = true;
		}
	}	
}

/* --
	FUNCTION NAME: redact
	PURPOSE: 	format subscriber number for display
------------------------------------------------------------------- */
redact = function (x) {
	x = "*****" + x.substring(5,9);
	document.write(x);
}

/* --
	FUNCTION NAME: saveTermDay(dropdownField,hiddenField)
	PURPOSE:	saves the day of the month in a hidden field, based on the 
						dropdown. pass two field names into this guy - the 
						dropdown and the hidden field.
-- */
function saveTermDay(dropdownField,hiddenField){ 
	var len	= dropdownField.options.length;
	for(i=0;i<len;i++){
		if(dropdownField[i].selected == true){ hiddenField.value = monthDays[i]; }
	}
}



/* ---------------------------------------------------------------------------------------
*  Page specific functions.
---------------------------------------------------------------------------------------- */
/* --
	FUNCTION NAME: getSubmitAction()
	PURPOSE: 	used by search
------------------------------------------------------------------- */
function getSubmitAction(func){
	var button = document.getElementById('search_button');

	if (button)	button.onmouseup = func;
}

/* --
	FUNCTION NAME: search()
	PURPOSE: 	homepage.html - search for providers by STATE and/or CITY
------------------------------------------------------------------- */
function search(){
	//if( (trim(document.searchform.FILTER_CITY.value) != "") || (trim(document.searchform.FILTER_STATE.value) != "") )
	var dir = document.searchform.dir.value;
	
	if( (trim(document.searchform.FILTER_CITY.value) != "") )
	{
		var f = document.searchform;
		
		switch(dir)
		{
			case 'homepage'   : searchPath = '/provider_search/providerSearchResults.hsm'; break;
			case 'patient'    : searchPath = '/patients/providerSearchResults.hsm'; break;
			case 'patientzip'    : searchPath = '/patients/providerSearchResults1.hsm'; break;
			case 'patientbsc' : searchPath = '/patients/providerSearchResults_bsc.hsm'; break;
		}
		document.searchform.action = searchPath;
		//alert(document.searchform.action);
		document.searchform.submit();
		
	}
	else
	{	
		//alert("Please enter at least 1 search option");
		document.searchform.FILTER_CITY.style.backgroundColor = "#F3BDB4";
		alert("Please enter a city.");
	}
}

/* --
	FUNCTION NAME: locsearch()
	PURPOSE: 	Advanced Search 
------------------------------------------------------------------- */
function locsearch(){
	locsearchTrim();
	if( (document.form1.FILTER_NAME.value == "") && (document.form1.FILTER_CITY.value == "") && (document.form1.FILTER_ZIP.value == "") ) {
		alert('Please enter a search criteria.');
	} else {
		document.form1.action="providerSearchResults.hsm";
		document.form1.submit();
	}
}

function locsearchCSU(){
	locsearchTrim();
	if( (document.form1.FILTER_NAME.value == "") && (document.form1.FILTER_CITY.value == "") && (document.form1.FILTER_ZIP.value == "") ) {
		alert('Please enter a search criteria.');
	} else {
		document.form1.action="providerSearchResultsCSU.hsm";
		document.form1.submit();
	}
}

function locsearchTrim() {
	if ( trim(document.form1.FILTER_NAME.value) != "") {
		document.form1.FILTER_CITY.value = "";
		document.form1.FILTER_STATE.value = "";
		document.form1.FILTER_ZIP.value = "";
	}
	else {
		if ( trim(document.form1.FILTER_CITY.value) != "") {
			document.form1.FILTER_NAME.value = "";
			document.form1.FILTER_ZIP.value = "";
		}
		else {
			if ( trim(document.form1.FILTER_ZIP.value) != "") {
				document.form1.FILTER_NAME.value = "";
				document.form1.FILTER_CITY.value = "";
				document.form1.FILTER_STATE.value = "";
			}
		}
	}

}

/* --
	FUNCTION NAME: picture()
	PURPOSE: homepage.html - displays a random JPG
------------------------------------------------------------------- */
function picture(){
	if(document.images){
		with(Math){
			var a = ceil(random()*7);
		}
		if ( a != 7) { var p = "../images/home_picture_0" + a + ".jpg"; }
		else { var p = "../images/home_picture_0" + a + ".gif"; }

		document.pic.src = p;
	}
}

/* --
	FUNCTION NAME: enterClaim()
	PURPOSE: selectionverification.htm - 
------------------------------------------------------------------- */
function enterClaim(){
	var claimType = false;
	document.form1.action="claimEntry.hsm";
	document.form1.REFERER.value="selectionVerification.hsm";
	document.form1.submit();
}

/* --
	FUNCTION NAME: convertRelationship(abbrv)
	PURPOSE: 
------------------------------------------------------------------- */
function convertRelationship(abbrv){
	if(abbrv=="E") return "Employee";
	else if(abbrv=="D") return "Dependent";
	else if(abbrv=="S") return "Spouse";
	else if(abbrv=="A") return "Disabled Adult";
	else if(abbrv=="H") return "Disabled Dependent";
	else if(abbrv=="P") return "Domestic Partner";
	
	else if(abbrv=="M") return "Male";
	else if(abbrv=="F") return "Female";

	else if(abbrv=="N") return "No";
	else if(abbrv=="Y") return "Yes";
	else return "&nbsp;";
}

/* --
	FUNCTION NAME: searchByIdNumber()
	PURPOSE: subscriberSearch.htm - 
------------------------------------------------------------------- */
function searchByIdNumber(){
	if( (trim(document.form1.SUBSCRIBER_NUMBER.value) == "")){
		alert("Subscriber ID number must be entered");
		return false;
	} else {
		document.form1.action="searchByNumber.hsm";
		document.form1.submit();
	}
}

/* --
	FUNCTION NAME: searchByName()
	PURPOSE: subscriberSearch.htm - 
------------------------------------------------------------------- */
function searchByName(){
  if( (trim(document.form1.FILTER_SUBSCRIBER_LNAME.value) == "") || (trim(document.form1.FILTER_SUBSCRIBER_FNAME.value) == "") ){
		alert("First name and last name must be entered");
		return false;
	} else {
		document.form1.action="searchByName.hsm";
		document.form1.submit();
	}
}

/* --
	FUNCTION NAME: checkZip
	PURPOSE: newprovidersearch.htm - 
------------------------------------------------------------------- */
function checkZip(v) {
	if (v.length < 3) {
		alert ("The ZIP code you entered is too short.  Please re-enter the ZIP code.");
		return false;
	}
	else if (v.length > 5) { 
		alert ("The ZIP code you entered is too long.  Please re-enter the ZIP code.");
		return false;
	}
	
	return true;
}
/* --
	FUNCTION NAME: writeBirthdaySelect()
	PURPOSE: render birthday drop down boxes
------------------------------------------------------------------- */
function writeBirthdaySelect(){
  document.writeln('<select name="BIRTH_MONTH">');
  writeOptions(1,12) ;
  document.writeln('</select>');
  document.writeln('/');
  document.writeln('<select name="BIRTH_DAY">');
  writeOptions(1,31) ;
  document.writeln('</select>');
  document.writeln('/');
  document.writeln('<select name="BIRTH_YEAR">');
  writeOptions(1901,2005) ;
  document.writeln('</select>');
}

/* --
	FUNCTION NAME: writeOptions(min,max)
	PURPOSE: drop down option values;accepts min for lowest
                  option value and max for highest option value
------------------------------------------------------------------- */
function writeOptions(min,max) {
  for (m=min;m<(max+1);m++) {
    var m_txt = m;
    if (m<10) {
      m_txt = '0' + m;
    }
    document.write('<option value="'+ m_txt +'"' + ((m == 1955)? 'SELECTED>':'>') + m_txt +'</option>');
  } 
}

/* --
	FUNCTION NAME: 	writeTabs(activeItemNum)
	PURPOSE: 		output section navigation links
	NOTE:			obsolete (remove when final instances in PATIENTS 
					updated with getTabs
------------------------------------------------------------------- */
function writeTabs(activeItemNum,section,showPlanReviewLink,HSMfiltergroup,HSMSubNo,HSMGrpNo) {
	document.write('<ul id="tabs">');
	
	if (!section) {
		document.write('<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="homepage.htm">&gt;Provider Home</a></li>');
		document.write('<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="subscriberSearch.htm">&gt;Verify Eligibility</a></li>');
		document.write('<li' + ((activeItemNum==3)?' class="on"':'') + '><a href="verificationSearchAll.htm">&gt;Enter Claims/View Outstanding Verifications</a></li>');
	} else if ( section == "benad" ) {
		document.write('<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="homepage.htm">&gt;Administrator Home</a></li>');
		if ( showPlanReviewLink ) {
			document.write('<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="' + ( ( HSMfiltergroup ) ? 'benefitSummary.htm?&Filter_Group='+HSMfiltergroup : 'planreview1.htm' ) + '">&gt;Plan Review</a></li>');
		}
	} else if ( section == "members" ) {
		document.write('<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="member_menu.htm?SubNo='+HSMSubNo+'&GrpNo='+HSMGrpNo+'">&gt;Member Home</a></li>');
		document.write('<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="accountDetails.htm?SubNo='+HSMSubNo+'&GrpNo='+HSMGrpNo+'">&gt;Your Details</a></li>');
		document.write('<li' + ((activeItemNum==3)?' class="on"':'') + '><a href="benefitSummary.htm?SubNo='+HSMSubNo+'&GrpNo='+HSMGrpNo+'">&gt;Your Benefit Summary</a></li>');
		//document.write('<li' + ((activeItemNum==4)?' class="on"':'') + '><a href="dependantList.htm?SubNo='+HSMSubNo+'&GrpNo='+HSMGrpNo+'">&gt;Eligible Benefits</a></li>');
		document.write('<li' + ((activeItemNum==5)?' class="on"':'') + '><a href="usePlan.htm?SubNo='+HSMSubNo+'&GrpNo='+HSMGrpNo+'">&gt;How to Use Your Plan</a></li>');
		document.write('<li' + ((activeItemNum==6)?' class="on"':'') + '><a href="claimStatus.htm?SubNo='+HSMSubNo+'&GrpNo='+HSMGrpNo+'">&gt;Claim Status</a></li>');
	} else if ( section == "members_about" ) {
		document.write('<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="../patient_aboutmesplans.htm">&gt;About Our Vision Plans</a></li>');
		document.write('<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="../patient_hipaa.htm">&gt;MES and HIPAA Compliance</a></li>');
		document.write('<li' + ((activeItemNum==3)?' class="on"':'') + '><a href="../patient_downloadpatientforms.htm">&gt;Printable Patient Forms</a></li>');
		document.write('<li' + ((activeItemNum==4)?' class="on"':'') + '><a href="../patients/newpatient_survey.htm">&gt;Patient Feedback Form</a></li>');
		document.write('<li' + ((activeItemNum==5)?' class="on"':'') + '><a href="../patient_grievanceform.htm">&gt;Grievance Form</a></li>');
	}
	
	document.write('</ul>');
}


/* --
	FUNCTION NAME: 	getTabs()
	PURPOSE: 		
------------------------------------------------------------------- */
function getTabs(activeItemNum, section, showPlanReviewLink, HSMfiltergroup, HSMSubNo, HSMGrpNo) {
	var tab_buffer = "";

	if ( section =="members" || section == "members_bsc" || section == "members_search" ) {
		tab_buffer += '<form action="" method="POST" name="navform">'
	}

	tab_buffer += '<ul id="tabs">'
	
	if ( section == "providers" ) {
		tab_buffer += '<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="homepage.htm">&gt;Provider Home</a></li>'
		tab_buffer += '<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="subscriberSearch.htm">&gt;Verify Eligibility</a></li>'
		tab_buffer += '<li' + ((activeItemNum==3)?' class="on"':'') + '><a href="verificationSearchAll.htm">&gt;Enter Claims/View Outstanding Verifications</a></li>'
		tab_buffer += '<li' + ((activeItemNum==4)?' class="on"':'') + '><a href="mednes_in.hsm">&gt;Non-Elective (Medically Necessary) Contact Lens Request Form</a></li>'
	} 
	if ( section == "public_providers" ) {
		tab_buffer += '<li' + (activeItemNum==1 ? ' class="on"':'') + '><a href="/providers/login.htm" onclick="moveTo(this.href); return false;">&gt;Eye Care Professional Log-In</a></li>';
		tab_buffer += '<li' + (activeItemNum==2 ? ' class="on"':'') + '><a href="/printableForms.htm" onclick="moveTo(this.href); return false;">&gt;Printable Forms and Notices</a></li>';
	} 
	else if ( section == "brokers" || section == "brokers_2" ) {
		tab_buffer += '<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="/brokers/brokers_home.htm">&gt;Broker Home</a></li>'
		tab_buffer += '<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="/brokers/brokers_reps.htm">&gt;MES Representatives</a></li>'
		if (section == "brokers_2") {
			tab_buffer += '<li' + ((activeItemNum==3)?' class="on"':'') + '><a href="/brokers/signin.htm">&gt;Broker Sign In</a></li>'
		}
	} 
	else if ( section == "benad" ) {
		tab_buffer += '<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="homepage.htm">&gt;Administrator Home</a></li>'
		if ( showPlanReviewLink ) {
			tab_buffer += '<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="' + ( ( HSMfiltergroup ) ? 'benefitSummary.htm?Filter_Group='+HSMfiltergroup : 'planreview1.htm' ) + '">&gt;Plan Review</a></li>'
		}
	}
	else if (section == 'public_members') {
		tab_buffer += '<li' + (activeItemNum==1 ? ' class="on"':'') + '><a href="/patients/homepage.htm" onclick="moveTo(this.href); return false;">&gt;Member Sign In</a></li>';
		tab_buffer += '<li' + (activeItemNum==2 ? ' class="on"':'') + '><a href="/patient_downloadpatientforms.htm" onclick="moveTo(this.href); return false;">&gt;Printable Forms and Notices</a></li>';
		tab_buffer += '<li' + (activeItemNum==3 ? ' class="on"':'') + '><a href="/patient_grievanceform.htm" onclick="moveTo(this.href); return false;">&gt;Grievance Form</a></li>';
		tab_buffer += '<li' + (activeItemNum==4 ? ' class="on"':'') + '><a href="/provider_rec.htm" onclick="moveTo(this.href); return false;">&gt;Provider Recommendation Form</a></li>';
	}
	else if ( section == 'members' ) {
		tab_buffer += '<li' + (activeItemNum==1  ? ' class="on"' : '') + '><a href="/patients/member_menu.htm" onclick="moveTo(this.href); return false;">&gt;Member Home</a></li>';
		tab_buffer += '<li' + (activeItemNum==2  ? ' class="on"' : '') + '><a href="/patients/accountDetails.htm" onclick="moveTo(this.href); return false;">&gt;Your Details</a></li>';
		tab_buffer += '<li' + (activeItemNum==4  ? ' class="on"' : '') + '><a href="/patients/dependantList.htm" onclick="moveTo(this.href); return false;">&gt;Eligible Benefits</a></li>';
		tab_buffer += '<li' + (activeItemNum==11 ? ' class="on"' : '') + '><a href="/patients/summaryOfVisionBenefits.htm" onclick="moveTo(this.href); return false;">&gt;Explanation of Vision Coverage</a></li>';
		tab_buffer += '<li' + (activeItemNum==5  ? ' class="on"' : '') + '><a href="/patients/usePlan.htm" onclick="moveTo(this.href); return false;">&gt;How to Use Your Plan</a></li>';
		//tab_buffer += '<li' + (activeItemNum==12 ? ' class="on"' : '') + '><a href="/patients/id_Card.htm" onclick="moveTo(this.href); return false;">&gt;Print Your ID Card</a></li>';
		tab_buffer += '<li' + (activeItemNum==6  ? ' class="on"' : '') + '><a href="/patients/claimStatus.htm" onclick="moveTo(this.href); return false;">&gt;Claim Status</a></li>';
		tab_buffer += '<li' + (activeItemNum==7  ? ' class="on"' : '') + '><a href="/patients/newpatient_survey.htm" onclick="moveTo(this.href); return false;">&gt;Patient Feedback Form</a></li>';
	} 
	else if ( section == 'members_about' ) {
		tab_buffer += '<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="/patient_aboutmesplans.htm">&gt;About Our Vision Plans</a></li>'
		tab_buffer += '<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="/patient_hipaa.htm">&gt;MES and HIPAA Compliance</a></li>'
		tab_buffer += '<li' + ((activeItemNum==3)?' class="on"':'') + '><a href="/patient_downloadpatientforms.htm">&gt;Printable Patient Forms</a></li>'
		tab_buffer += '<li' + ((activeItemNum==4)?' class="on"':'') + '><a href="/patients/newpatient_survey.htm">&gt;Patient Feedback Form</a></li>'
		tab_buffer += '<li' + ((activeItemNum==5)?' class="on"':'') + '><a href="/patient_grievanceform.htm">&gt;Grievance Form</a></li>'
		tab_buffer += '<li' + ((activeItemNum==7)?' class="on"':'') + '><a href="/provider_rec.htm">&gt;Provider Recommendation Form</a></li>'
	} 
	else if ( section == 'members_bsc' ) {
		tab_buffer += '<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="/patients/member_menu_bsc.htm" onclick="moveTo(this.href); return false;">&gt;Member Home</a></li>'
		tab_buffer += '<li' + ((activeItemNum==5)?' class="on"':'') + '><a href="/patients/usePlan_bsc.htm" onclick="moveTo(this.href); return false;">&gt;How to Use Your Plan</a></li>'
	} 
	else if ( section == 'members_search' ) {
		tab_buffer += '<li' + ((activeItemNum==0)?' class="on"':'') + '><a href="/patients/searchByNumber.htm" onclick="moveTo(this.href); return false;">&gt;Select a Group</a></li>'
	} 
	else if ( section == 'provsearch' || section == 'provsearchCSU' ) {
		tab_buffer += '<li' + ((activeItemNum==1)?' class="on"':'') + '><a href="/patient_aboutmesplans.htm">&gt;About Our Vision Plans</a></li>'
		tab_buffer += '<li' + ((activeItemNum==2)?' class="on"':'') + '><a href="/patient_hipaa.htm">&gt;MES and HIPAA Compliance</a></li>'
		
		if (section == 'provsearchCSU') {
			tab_buffer += '<li' + ((activeItemNum==6)?' class="on"':'') + '><a href="/PROVIDER_SEARCH/newprovidersearchcsu.htm">&gt;Guest Provider Search</a></li>'
		} else {		
			tab_buffer += '<li' + ((activeItemNum==6)?' class="on"':'') + '><a href="/PROVIDER_SEARCH/newprovidersearch.htm">&gt;Guest Provider Search</a></li>'
		}
	}
	
	tab_buffer += '</ul>'
	
	if ( section =="members" || section == "members_bsc" || section == "members_search" ){
	
		tab_buffer += '<input type="hidden" name="SubNo" value="'+HSMSubNo+'" /><input type="hidden" name="GrpNo" value="'+HSMGrpNo+'" />'
		tab_buffer += '</form>'
	}	
	return tab_buffer;
}

/* --
	FUNCTION NAME: 	moveTo()
	PURPOSE: 	used by getTabs to set form action
	NOTES: 		
------------------------------------------------------------------- */
function moveTo(href) {
	document.navform.action = href;
	document.navform.submit();
}

/* --
	FUNCTION NAME: 	checkErrors(e)
	PURPOSE: 		output server errors on page
	NOTES: 			"e" ----> array of error items
------------------------------------------------------------------- */

function checkErrors() {

	var args = checkErrors.arguments;
	var display = 0;
	for ( var i = 0; i < args.length; i++ ) {
		var itemNum = i + 1;
		
		var e = "error" + itemNum;
		if ( args[i] && document.getElementById(e) ) {
			document.getElementById(e).style.display = "block";
			display++;
		} else if ( document.getElementById(e) ) {
			document.getElementById(e).style.display = "none";
		}
		
		if(display>0) document.getElementById('errorList').style.display = "block";
	}
	
}
/* --
	FUNCTION NAME: checkForNumbers()
	PURPOSE: check for empty table
------------------------------------------------------------------- */
function checkForNumbers(n){
	if ( !n ){
		document.getElementById('noNumbers').style.display = "block";
	}
}

/* --
	FUNCTION NAME: formatTime()
	PURPOSE: remove extra zeros from time in Provider Search
------------------------------------------------------------------- */
function formatTime(str) {
 if (str.charAt(0) == '0') {
 	s = str.substring(1,str.length);
	
	if (s.charAt(10) == '0') {
		temp0 = s.substring(0,10);
		temp1 = s.substring(11,s.length);
		return (temp0 + temp1);
	}
	else return s;
 } else if (str.charAt(11) == '0') {
 	temp0 = str.substring(0,11);
	temp1 = str.substring(12,str.length);
	return (temp0 + temp1);
 } else if (str == "Closed") {
	return "Closed";
 } else if (!str || str == "No Information Avail") {
	return "N/A";
 }
}

/* --
	FUNCTION NAME: 	createRandomTip()
	PURPOSE:		create a random tip for member login screens
------------------------------------------------------------------- */
function createRandomTip(){
	with (Math){
		var rand = ceil(random()*5);
		//var rand = ceil(random()*4);
	}

		if (rand == 1) {
			createRandomTipContent( 'Cataracts',
									'A cataract is a cloudy area in the lens of the eye.',
									'There are three classifications of adult cataracts: immature, mature, and hypermature.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_cataract.htm">Learn More</a>'	);
		} else if (rand == 2) {
			createRandomTipContent( 'Diabetic Retinopathy',
									'Diabetic Retinopathy occurs when high blood-sugar levels cause damage to the blood vessels of the retina.',
									'Strict control of blood sugar levels significantly reduces a person\'s chance of vision loss due to Diabetic Retinopathy.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_diabeticret.htm">Learn More</a>'	);
		} else if (rand == 3) {
			createRandomTipContent( 'Glaucoma',
									'Glaucoma is a condition in which increased fluid pressure inside the eye causes damage to the optic nerve, resulting in partial vision loss or blindness.',
									'Blurred Vision is a symptom of Glaucoma',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_glaucoma.htm">Learn More</a>'	);
		} else if (rand == 4) {
			createRandomTipContent( 'Macular Degeneration',
									'The macula allows the eye to see fine details at the center of the field of vision.',
									'Caucasians over 65, and by age 75, almost 15% of people have this condition.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_macular.htm">Learn More</a>'	);
		} 
		else if (rand == 5) {
			createRandomTipContent( 'Regular Eye Exams',
									'Regular eye exams give your eye doctor a chance to help you correct or adapt to vision changes.',
									'Some factors may put your child at increased risk for eye disease.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_eyeexams.htm">Learn More</a>'	);
		
		} 
		else if (rand == 6) {
			createRandomTipContent( 'Amblyopia',
									'is poor vision in an eye that did not develop normal sight during early childhood. It is sometimes called lazy eye.',
									'When one eye develops good vision while the other does not, the eye with poorer vision is called amblyopic.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_amblyopia.htm">Learn More</a>'	);
		}
		else if (rand == 7) {
			createRandomTipContent( 'Detached Retina',
									'When the retina separates from the deeper layers of the eyeball that normally support and nourish it, the retina is said to be detached.',
									'Without this nourishment and support, the retina does not function properly, and this can cause a variety of visual symptoms.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_detatched_retina.htm">Learn More</a>'	);
		} 
		else if (rand == 8) {
			createRandomTipContent( 'Retinitis Pigmentosa',
									'Retinitis pigmentosa (RP) is the name given to a group of hereditary eye diseases that affect the retina.',
									'These are cells that capture and process light that helps us to see.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_retinitis_pigmentosa.htm">Learn More</a>'	);
		} 
		else if (rand == 9) {
			createRandomTipContent( 'Vision Conditions',
									'Myopia, also known as shortsightedness or nearsightedness, is a condition in which distant objects appear out of focus.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_visionconditions.htm">Learn More</a>'	);
		} 
		else if (rand == 10) {
			createRandomTipContent( 'Strabismus',
									'Strabismus, also known as crossed or turned eye, is the medical term used when the two eyes are not straight.',
									'It is a visual defect in which the eyes are misaligned and point in different directions.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_strabismus.htm">Learn More</a>'	);
		} 
		else if (rand == 11) {
			createRandomTipContent( 'The Importance Of Children&rsquo;s Eye Exams',
									'Regular eye examinations performed by an eye care doctor are the key to early detection and treatment of eye conditions and vision problems among children.',
									'Preventing eye disease during infancy and childhood is significant to maintaining good vision and even general health.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_childrens_eyeexams.htm">Learn More</a>'	);					
		
		}
		else if (rand == 12) {
			createRandomTipContent( 'Common Children&rsquo;s Conditions',
									'Because your child can develop vision problems without showing obvious symptoms, it is important that infants be screened for common eye problems during their regular pediatric appointments.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_commonchildconditions.htm">Learn More</a>'	);					
		
	}
	else if (rand == 13) {
			createRandomTipContent( 'Eyewear Prescriptions',
									'After the examination, if necessary, your eye doctor will prescribe glasses or contact lenses to correct or improve your vision.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_commonchildconditions.htm">Learn More</a>'	);					
		
	}
	else if (rand == 14) {
			createRandomTipContent( 'Vision Facts For Children With Diabetes',
									'Diabetes mellitus (mel-i-tuhs) is a disorder caused by a decreased production of insulin or by the body&rsquo;s inability to use insulin.',
									'<a href="../tips_amblyopia.htm">Amblyopia</a>',
									'<a href="../tips_cataract.htm">Cataract</a>',
									'<a href="../tips_detatched_retina.htm">Detached Retina</a>',
									'<a href="../tips_diabeticret.htm">Diabetic Retinopathy</a>',
									'<a href="../tips_glaucoma.htm">Glaucoma</a>',
									'<a href="../tips_macular.htm">Macular Degeneration</a>',
									'<a href="../tips_retinitis_pigmentosa">Retinitis Pigmentosa</a>',
									'<a href="../tips_strabismus.htm">Strabismus</a>',
									'<a href="../tips_visionconditions.htm">Vision Conditions</a>',
									'<a href="../tips_eyeexams.htm">Regular Eye Exams</a>',
									'<a href="../tips_commonchildconditions.htm">Common Children&rsquo;s Conditions</a>',
									'<a href="../tips_childrens_eyeexams.htm">Children&rsquo;s Eye Exams</a>',
									'<a href="../tips_eyewearPrescription.htm">Eyewear Prescriptions</a>',
									'<a href="../tips_visionFactsForChildrenWithDiabetes.htm">Vision Facts for Children with Diabetes</a>',
									'<a href="../tips_commonchildconditions.htm">Learn More</a>'	);					
		
	}
}

function createRandomTipContent(tiptitle,tipsummary1,tipsummary2,tiplink1,tiplink2,tiplink3,tiplink4,tiplink5,tiplink6,tiplink7,tiplink8,tiplink9,tiplink10,tiplink11,tiplink12,tiplink13,tiplink14,tiplink_learnmore) {
	document.getElementById("tiptitle").innerHTML = tiptitle;
	document.getElementById("tipsummary1").innerHTML = tipsummary1;
	document.getElementById("tipsummary2").innerHTML = tipsummary2;
	document.getElementById("tiplink1").innerHTML = tiplink1;
	document.getElementById("tiplink2").innerHTML = tiplink2;
	document.getElementById("tiplink3").innerHTML = tiplink3;
	document.getElementById("tiplink4").innerHTML = tiplink4;
	document.getElementById("tiplink5").innerHTML = tiplink5;
	document.getElementById("tiplink6").innerHTML = tiplink6;
	document.getElementById("tiplink7").innerHTML = tiplink7;
	document.getElementById("tiplink8").innerHTML = tiplink8;
	document.getElementById("tiplink9").innerHTML = tiplink9;
	document.getElementById("tiplink10").innerHTML = tiplink10;
	document.getElementById("tiplink11").innerHTML = tiplink11;
	document.getElementById("tiplink12").innerHTML = tiplink12;
	document.getElementById("tiplink13").innerHTML = tiplink13;
	document.getElementById("tiplink14").innerHTML = tiplink14;
	document.getElementById("tiplink_learnmore").innerHTML = tiplink_learnmore;
}
/* --
	FUNCTION NAME: checkValue(x,c,href)
	PURPOSE: for claim status pages - table formatting
-- */
function checkValue(x,c,href) {
	if (x!="") {
		if (c && href) 
			document.write('<a href="' + href + '" onClick="' + c + '">' + x + '</a>');
		else document.write(x);
	}
	else document.write('--');
}


/* --
	FUNCTION NAME: getLC(text)
	PURPOSE: confert arg to lower case
-- */
function getLC(text) {
	return (text.toLowerCase());
	}


/* *********************************************************** 
 *	FUNCTION:  valildateForm
 *	PURPOSE: validateForm input
 * ********************************************************* */
var bad_char_errors = new Array();
var errors = new Array();

function validateForm(form) {
	var f=form;
	
	var form_elements = new Array();

	switch (form.name) {
		
		//An array of id's in the form
		
		case "brokerQuoteRequest":
		
			form_elements = [['quote_name','First and Last Name']];
			/*,
					 		 ['quote_address','Address'],
					 		 ['quote_city','City']];
					 		 ['quote_zip','Postal Code'],
					 		 ['group_size','Group Size'],
							 ['retail_frame','Retail Frame Allowance'],
							 ['deduct_amts','Deductible Amount'],
							 ['CV_switch','Plan Basis'],
							 ['quote_plans','Plan']];*/
			break;
			
		case "careProviderRegistration":
			form_elements = [['fname','First Name'],
							 ['lname','Last Name'],
							 ['address','Street Address'],
							 ['zipcode','ZIP/postal code'],
							 ['pnumber','Phone number'],
							 ['email','E-mail']];
			break;
		
		case "benAdminRegistration":
			form_elements = [['gname','Group Name'],
							 ['gnumber','Group Number'],
							 ['fname','First Name'],
							 ['lname','Last Name'],
							 ['address','Street Address'],
							 ['zipcode','ZIP/postal code'],
							 ['pnumber','Phone number'],
							 ['email','E-mail']];
			break;
	}
	
	for ( i = 0; i < form_elements.length; i++ ) {
		if ( document.getElementById(form_elements[i][0]) || document.getElementsByName(form_elements[i][0]) ) {
			
			if ( document.getElementById(form_elements[i][0]) )
				var e = eval('f.' + form_elements[i][0] + '.value');
			
			if (!e) {
				errors.push('&bull; '+form_elements[i][1]+' is required<br>');
			} else {
				if (form_elements[i][0] == "email")  //verify email address
					chk_email(e);
			}
		}
	}

	if (f.name == "careProviderRegistration") {
		if (!f.ophthalmologist.checked && !f.optician.checked && !f.optometrist.checked) errors.push ('&bull; Profession is required <br>');
		if (!f.downloadForms.checked && !f.emailForms.checked ) errors.push ('&bull; Please specify how you would like to receive the forms<br>');
	}
	
	
//Now create the box

	var errdiv = document.getElementById("errmsg");
	var errList = document.getElementById("errList");
	//var errlinksdiv = document.getElementById("errlinks");

	
	if (errors.length > 0 || bad_char_errors.length > 0) {
		errdiv.style.display = "block";
		errdiv.innerHTML = '<h3>Please correct the following errors:</h3>';
		
		if (errors[0]) {
			for( j = 0; j < errors.length; j++ ) {
				errdiv.innerHTML += errors[j]
			}
		}
		
		if (bad_char_errors[0]) {
			for( x = 0; x < bad_char_errors.length; x++ ) {
				errdiv.innerHTML += bad_char_errors[x]
			}
		}
		
		errors.length = 0;
		bad_char_errors.length = 0;
		
		//errlinksdiv.style.display = "block";
		//errlinksdiv.innerHTML = 'There was a problem submitting your information. <a href="#errmsg">Click here</a> to view the errors.';
		
		//errdiv.innerHTML += '</ul>';
		
		return false;
		
	} else if (errors.length ==0){
		errdiv.style.display = "none";
		
		return true;
		
	}

}


/* *********************************************************** 
 *	FUNCTION:  chk_email, chk_badchar
 *	PURPOSE: legacy functions for form validation
 * ********************************************************* */
function chk_email(obj) {
	var bad_email_chars = "`/ (){}[]|<>/,&+=*'%?!~#^:;";
 
 	// check for spl characters that are invalid
 	if (!chk_badchar(obj, bad_email_chars)) {
		bad_char_errors.push('&bull; Email address contains illegal characters<br>');
 		//return false;
 	}
	
	// Check for an @ sign
 	var at_sign = obj.indexOf("@");
 	if (at_sign < 0) {
		bad_char_errors.push('&bull; Email address is missing the &ldquo;@&rdquo; sign<br>');
 		//return false;
 	}
	
	// Check for '.' and domain name
	var suffix = obj.substring(obj.lastIndexOf('.')+1);
	if ( suffix.length < 2 || obj.indexOf('.') == -1) {
		
   		bad_char_errors.push('&bull; Email address is missing the domain name<br>');
   		//return false;
	}
	
	// Yet another check...
	if ( (obj.indexOf('@.') > 0) || (obj.indexOf('.@') > 0) ) {
		bad_char_errors.push('&bull; Email address is not correct<br>');
	}
		
	if (bad_char_errors.length > 0) return false;
	
    return true;
}


function chk_badchar(word, badchars) {
	var found = -1; // bad char not found
   
 	for (var i = 0; i < badchars.length; i++) {
  		found = word.indexOf(badchars.charAt(i));
  		if (found > -1) {
   			break;  // exit from for loop
  		}
 	}

 	if (found > -1)	return false;
 	else return true;
}


/* *********************************************************** 
 *	FUNCTION:  checkDOBmonth, checkDOBday, checkDOByear
 *	PURPOSE: make sure text field entries are okay.
 * ********************************************************* */

function checkDOBmonth(field) {
/*
	1. check to see if it's a number. if it is, validate it. if it isn't, blank it out.
	2. if it is a number:
		a. check to see if there are one or two digits
		b. if there are two digits, check the first digit. if it's not a zero or one, change it based on the following rules:
			i. if the second digit is 0, 1 or 2, make the first digit 1.
			ii. if the second digit is 3, 4, 5, 6, 8 or 9, make the first digit 0.
		c. if there's only one digit, add 0 in front of it


	var validMonth = /.{1}/g;
	var enteredMonth = field.value;
	var result = enteredMonth.match(validMonth);
	if(result != null){
		alert(result[0] + '\n' + result[1]);
	}
*/

//first, the simple way.

	if(isNaN(field.value)){
		field.value = "01";
		return;
	} else if( field.value > 12 ){
		field.value = 12;
		return;
	} else if(field.value < 1){
		field.value = "01";
		return;
	} else if(field.value.length < 2) {
		field.value = "0" + field.value;
		return;
	}


}

function checkDOBday(field) {
/*
	1. check to see if the entry is a number. if it's not a number, blank it out and continue. Actually, this should follow it's own set of rules like the one below.
	2. if it is a number:
		a. check to see whether there are one or two digits
		b. if there is only one digit, add 0 in front of it (as the first digit)
		c. if there are two, check the first digit. if it's 0, 1 or 2, leave it alone (leap year rules?), otherwise, change it based on the following rules:
			i. if the first digit is 4, change it to 1
			ii. if the first digit is 5, change it to 2
			iii. if the second digit is 1 (and NOT i or ii), change it to 3
			iv. otherwise, change it to 2
*/

//first, the simple way
	if(isNaN(field.value)){
		field.value = "01";
		return;
	} else if( field.value > 31 ){
		field.value = 31;
		return;
	} else if(field.value < 1){
		field.value = "01";
		return;
	} else if(field.value.length < 2) {
		field.value = "0" + field.value;
		return;
	}

}

function checkDOByear(field) {
/*
	1. check to make sure entry is a number. if it's not a number, blank it out
	2. if it is a number:
		a. if it's one digit:
			i. if it's 0 - this year's last digit (6), make the first three digits 200
			ii. if it's above that, make the first three digits 190
		b. if it's two digits:
			i. if it's 00 -  this year's last two digits (06), make the first two digits 20
			ii. otherwise make it 19
		c. if it's three digits:
			i. if it's 000 - this year's last two digits (006), make the first digit 2
			ii. if it's 900 - 999, make the first digit 1
			iii. otherwise, replace the first two digits with 19
		d. if it's four digits:
			i. make sure it's between 1900 and now (2006). if it's not, replace it according to this rules:
				1. if its last three digits are between 900 and 999, replace the first digit with 1
				2. if its last three digits are between 000 and 006, replace the first digit with 2
				3. if its last two digits are between 00 and 06, replace the first two with 20
				4. otherwise, replace the first two with 19.
*/
//first, the simple way
	var curDate = new Date()
	var curYear = curDate.getFullYear();
	var curYearAbr = curYear.toString();
	curYearAbr = curYearAbr.substring(2);
	curYearAbr = curYearAbr * 1;
	if(isNaN(field.value) && (field.value != "")){
		field.value = "2000";
		return;
	} else if( field.value > curYear ){
		field.value = curYear;
		return;
	} else if((field.value.length < 4) && (field.value != "")) {
		if(field.value.length == 2) {
			if(field.value < curYearAbr) {
				enteredYear = field.value.toString();
				field.value = "20" + enteredYear;
				return;
			} else {
				field.value = "19" + field.value;
				return;
			}
		} else if(field.value.length == 1) {
			if(field.value < curYearAbr) {
				enteredYear = field.value.toString();
				field.value = "200" + enteredYear;
				return;
			} else {
				field.value = "199" + field.value;
				return;
			}
		} else if(field.value.length == 3) {
			if (field.value == 200) {
				field.value = 2000;
				return;
			}else if (field.value < 910 && field.value > curYearAbr) {
				field.value = 1910;
				return;
			} else if (field.value < curYearAbr) {
				field.value = "2" + field.value;
				return;
			} else {
				field.value = "1" + field.value;
			}
		}
		
	} else if((field.value < 1910) && (field.value != "")){
		field.value = "1910";
		return;
	}

}

var providerSearchResults = new Array();
var providerType = 'unknown';
function printProviderSearchResultRow(result) {
	document.write("<table cellpadding='0' border='0' cellspacing='0' class='result'>");
	
	document.write("<tr>");
	
		document.write("<td class='contactinfo'>");
			document.write("<span class='name'>" + result.name.toLowerCase() + "</span>");
			if (!isNaN(result.distance)) document.write("<span class='distance'>" + (parseInt(+result.distance)/100) + " miles</span>");
	
			document.write("<span class='address'>");
			document.write(result.address1.toLowerCase());
			if (result.address2 != '') document.write('<br />' + result.address2.toLowerCase());
			document.write("</span>");
	
			document.write("<span class='city'>" + result.city.toLowerCase() + ", " + result.state.toUpperCase() + " " + result.zip + "</span>");
			document.write("<span class='phone'>" + (result.areaCode == '' ? '' : "(" + result.areaCode + ") ") + result.phone + "</span>");
			
			var mapAddress = result.address2 == '' ? result.address1 : result.address2;
			mapAddress = mapAddress.replace("#", "%23");
			
			document.write("<span class='maplinks'>");
			document.write("<a href='http://maps.yahoo.com/maps_result?addr=" + mapAddress + "&amp;csz=" + result.city + "%2C" + result.state + "%20" + result.zip + "&amp;country=us' target='_blank'>View Map</a>");
			document.write(" | ");
			document.write("<a href='http://maps.yahoo.com/dd_result" + currentLocation + "&amp;tcsz=" + result.city + "%20" + result.state + "%20" + result.zip + "&amp;tcountry=us' target='_blank'>Get directions</a>");
			
			document.write("</span>");
		document.write("</td>");
		
		document.write("<td class='doctorinfo'>")
			document.write("<span class='exam'>Performs Exams: " + (result.performsExams ? 'Yes' : 'No') + "</span>");
			document.write("<span class='dispense'>Dispenses Materials: " + (result.dispensesMaterials ? 'Yes' : 'No') + "</span>");
			document.write("<span class='languages'>Languages: " + result.languages + "</span>");
			
			if (result.discountVisionProgram) {
				document.write("<div class='tiplinkwindow'>");
					document.write("<div id='whatdat'" + result.providerNumber + "' style='display: none'>");
						document.write("<strong>Discount Vision Program (DVP)</strong> participating providers agree to extend a twenty (20%) percent discount off retail costs of negotiated products and/or services. The twenty (20%) percent discount is provided only upon request on the date of service. For more information, please visit http://www.ecndiscount.com");
					document.write("</div>");
				document.write("</div>");
				
				document.write('<span class="programs"><span>Discount Vision Program Participant</span> <a href="" onclick="return false;" class="tiplink" onmouseover="showTip(this.parentNode.previousSibling.childNodes[0].id);" onmouseout="hideTip(this.parentNode.previousSibling.childNodes[0].id);">what\'s this?</a></span>');
			}
			
			if (result.wholesale) document.write('<span class="wholesale">*Retail benefits will be converted to wholesale-equivalent prices at this location</span>');
		document.write("</td>");
		
		document.write("<td class='officeinfo'>");
			document.write("<table cellpadding='0' border='0' cellspacing='0'>");
				document.write("<tr><th colspan='2'>Office Hours</th></tr>");
				document.write("<tr><td class='day'>Mon</td><td>" + result.officeHours.mon + "</td></tr>");
				document.write("<tr><td class='day'>Tues</td><td>" + result.officeHours.tues + "</td></tr>");
				document.write("<tr><td class='day'>Weds</td><td>" + result.officeHours.weds + "</td></tr>");
				document.write("<tr><td class='day'>Thurs</td><td>" + result.officeHours.thurs + "</td></tr>");
				document.write("<tr><td class='day'>Fri</td><td>" + result.officeHours.fri + "</td></tr>");
				document.write("<tr><td class='day'>Sat</td><td>" + result.officeHours.sat + "</td></tr>");
				document.write("<tr><td class='day'>Sun</td><td>" + result.officeHours.sun + "</td></tr>");
			document.write("</table>");
		document.write("</td>");
	
	document.write("</tr>");
	
	document.write("<tr class='nobg'><td colspan='3' class='pad'><hr /></td></tr>");
	
	document.write("</table>");
}

function providerSearchPdf() {
	var form;

	if (document.providerSearchPdfForm) {
		form = document.providerSearchPdfForm;
	} else {
		form = document.createElement('form');
		form.setAttribute('style', 'display: none');
		form.setAttribute('name', 'providerSearchPdfForm');
		form.setAttribute('action', 'https://web.mesvision.com/ecn/customDirectory.php');
		form.setAttribute('method', 'post');
		form.setAttribute('target', '_blank');
		document.body.appendChild(form);
	}
	
	var html = '';
	var searchLocation = '';
	
	searchLocation = f_name == '' ? 'all providers' : f_name;
	searchLocation += ' located within ' + f_miles + ' miles of';
	if (f_add != '') searchLocation += ' ' + firstCap(f_add);
	if (f_city != '') {
		if (f_add != '') searchLocation += ',';
		searchLocation += ' ' + firstCap(f_city);
	}
	if (f_state != '') searchLocation += ' ' + f_state;
	if (f_zip != '') searchLocation += ' ' + f_zip;
		
	html += '<input type="hidden" name="documentTitle" value="Participating Provider Directory" />';
	html += '<input type="hidden" name="searchLocation" value="' + searchLocation + '" />';
	
	for (var i = 0; i < providerSearchResults.length; i++) {
		result = providerSearchResults[i];
		
		html += '<input type="hidden" name="type[]" value="'+result.type+'">';
		html += '<input type="hidden" name="name[]" value="'+result.name+'">';
		html += '<input type="hidden" name="distance[]" value="'+result.distance+'">';
		html += '<input type="hidden" name="address1[]" value="'+result.address1+'">';
		html += '<input type="hidden" name="address2[]" value="'+result.address2+'">';
		html += '<input type="hidden" name="city[]" value="'+result.city+'">';
		html += '<input type="hidden" name="state[]" value="'+result.state+'">';
		html += '<input type="hidden" name="zip[]" value="'+result.zip+'">';
		html += '<input type="hidden" name="areaCode[]" value="'+result.areaCode+'">';
		html += '<input type="hidden" name="phone[]" value="'+result.phone+'">';
		html += '<input type="hidden" name="performsExams[]" value="'+(result.performsExams ? 'Yes' : 'No')+'">';
		html += '<input type="hidden" name="dispensesMaterials[]" value="'+(result.dispensesMaterials ? 'Yes' : 'No')+'">';
		html += '<input type="hidden" name="languages[]" value="'+result.languages+'">';
		html += '<input type="hidden" name="DVPParticipant[]" value="'+(result.discountVisionProgram ? 'YES' : 'NO')+'">';
		html += '<input type="hidden" name="wholeSalePrices[]" value="'+(result.wholesale ? 'YES' : 'NO')+'">';
		html += '<input type="hidden" name="mon[]" value="'+result.officeHours.mon+'">';
		html += '<input type="hidden" name="tues[]" value="'+result.officeHours.tues+'">';
		html += '<input type="hidden" name="weds[]" value="'+result.officeHours.weds+'">';
		html += '<input type="hidden" name="thurs[]" value="'+result.officeHours.thurs+'">';
		html += '<input type="hidden" name="fri[]" value="'+result.officeHours.fri+'">';
		html += '<input type="hidden" name="sat[]" value="'+result.officeHours.sat+'">';
		html += '<input type="hidden" name="sun[]" value="'+result.officeHours.sun+'">\n';
	}
	
	form.innerHTML = html;
	form.submit();
}

var blueShield = false;