function loadApplication(location,title,features) {
	if(location!= null && title!=null && features!=null) {
		loadNewWindow(location,title,features);
		closeWindow();
	}				
}

function loadNewWindow(location,title,features) {
	var sourceWindow;

	sourceWindow=window.open(location,title,features);
	sourceWindow.focus();
}

function loadhelp(location)
  {
  loadNewWindow(location,'pophelp','width=400, height=300, scrollbars=1, location=0, status=1, menubar=0, resizable=0, toolbar=0');
  }

function loadNews(location)
  {
  loadNewWindow(location,'popnews','width=610, height=450, scrollbars=1, location=0, status=1, menubar=1, resizable=1, toolbar=1');
  }

function loadPrint()
  {
  window.print();
  closeWindow();
  }

function closeWindow() {
	var thisWindow; 
	thisWindow = window.self;
	thisWindow.opener = window.self;
	thisWindow.close();
}

var barNCPDP,barPharmacy,barAddress,barCity,barState,barZip,barPhone,barCounty;
var	_oXml, _oLastGlow, _iLastRowIndex;
var _oPop = "";
var _o = null;

// gets appropriate bar image for column headers
function selectBar(pStrId) {
	var container = document.getElementById(pStrId);
	
	clearBars();
	container.style.visibility = 'visible';								
}

function clearBars() {
	document.frmLocator.barPharmacy.style.visibility = 'hidden';
	document.frmLocator.barAddress1.style.visibility = 'hidden';
	document.frmLocator.barCity.style.visibility = 'hidden';
	document.frmLocator.barState.style.visibility = 'hidden';
	document.frmLocator.barZip.style.visibility = 'hidden';
	document.frmLocator.barPhone.style.visibility = 'hidden';
	document.frmLocator.barCounty.style.visibility = 'hidden';
}

// uses regular expression to match drop list with search textbox param
function findText(finder_textbox, finder_selectbox) {
	var searchStr = finder_textbox.value;
	
	var myExp = new RegExp(("^" + searchStr), "i");
	var foundResult = false;
	var i=0;
		
	while ((foundResult = false) || (i < finder_selectbox.length)) {
		if( myExp.test(finder_selectbox.options[i].text)) {
			finder_selectbox.options[i].selected = true;
			foundResult = true;
			i=99999;
		}
		i++;		
	}
}
	
// causes drop list to become visible and calls findText()
function selectList(searchId,listId,spanId) {
	document.getElementById(spanId).style.visibility='visible';
	findText(document.getElementById(searchId),document.getElementById(listId));
}

// causes search textbox value to equal selected drop list value
function matchSearch(searchId,listId,spanId) {
	if (document.getElementById(listId).options.length > 0) {
		document.getElementById(searchId).value = document.getElementById(listId).options[document.getElementById(listId).selectedIndex].value;
	}
	
	clearAddressSection();

	if ( (document.getElementById(searchId).name == 'txtState') ) {
		document.frmLocator.txtCity.value = "";
		document.frmLocator.txtCounty.value = "";
		document.frmLocator.txtPharmacy.value = "";
	}
	
	document.getElementById(spanId).style.visibility='hidden';
	submitForm();
}

function setCityFocus(blnFocus) {
	if (blnFocus == true) {
		frmLocator.txtCity.focus();
	} else {
		frmLocator.txtCity.blur();
	}
}

function setCountyFocus(blnFocus) {
	if (blnFocus == true) {
		frmLocator.txtCounty.focus();
	} else {
		frmLocator.txtCounty.blur();
	}
}

function setPharmacyFocus(blnFocus) {
	if (blnFocus == true) {
		frmLocator.txtPharmacy.focus();
	} else {
		frmLocator.txtPharmacy.blur();
	}
}

function setAddressFocus(blnFocus) {
	if (blnFocus == true) {
		frmLocator.txtAddress.focus();
	} else {
		frmLocator.txtAddress.blur();
	}
}

function clearList(spanId) {				
	if (spanId != 'spnStateList') {
		spnStateList.style.visibility='hidden';
	}
	
	if (spanId != 'spnCityList') {
		spnCityList.style.visibility='hidden';
	}
	
	if (spanId != 'spnCountyList') {
		spnCountyList.style.visibility='hidden';
	}
	
	if (spanId != 'spnPharmacyList') {
		spnPharmacyList.style.visibility='hidden';
	}				
}

function clearAll() {
	spnStateList.style.visibility='hidden';
	spnCityList.style.visibility='hidden';
	spnCountyList.style.visibility='hidden';
	spnPharmacyList.style.visibility='hidden';
}

function clearSearchSection() {
	document.frmLocator.txtState.value = "";
	document.frmLocator.txtCity.value = "";
	document.frmLocator.txtCounty.value = "";
	document.frmLocator.txtPharmacy.value = "";
	
	return false;
}

function clearAddressSection() {
	document.frmLocator.txtAddress.value = "";
	document.frmLocator.txtAreaCode.value = "";
	document.frmLocator.txtPrefix.value = "";
	document.frmLocator.txtSuffix.value = "";
	
	return false;
}

function gridBarOn(pStrId) {
	
	var container = document.getElementById(event.srcElement.id);
	
	if (container.style.backgroundImage != "url(images/grid_BarBkOn.gif)") {
		container.style.backgroundImage = "url(images/grid_BarBkOn.gif)";
	}
}

function gridBarOff(pStrId) {
	
	var container = document.getElementById(event.srcElement.id);
	
	if (container.style.backgroundImage == "url(images/grid_BarBkOn.gif)") {	 
		container.style.backgroundImage = "url(images/bar_bk_top.gif)";
	}
}

function gridColOn() {
	if (_oPop && _oPop.isOpen) return;
	if (_oLastGlow) gridColOff();
	
	_oLastGlow = event.srcElement;
	while (_oLastGlow.tagName != "TR") {
		_oLastGlow = _oLastGlow.parentElement;
	}
	_oLastGlow.runtimeStyle.backgroundColor = "#FEFCE7";
}

function gridColOff() {
	if (_oPop && _oPop.isOpen) return;
	if (_oLastGlow) {
		_oLastGlow.runtimeStyle.backgroundColor = "";
		_oLastGlow = null;
	}
}

function applyStyle(o, sClass) {
	var i = 0;
	var ii = o.cells.length;
	
	if (sClass=="gridresults") {
		for ( var d = 0; d < o.cells.length; d += 2 ) {
			o.cells[d].className = sClass;
		}
		for ( var e = 1; e < o.cells.length; e += 2 ) {
			o.cells[e].className = "gridspacer";
		}	
	} else {
		while (i < ii)
		{
			o.cells[i].className = sClass;
			i++;
		}
	}
}

function refreshOpenerWin(ncpdp) {
	window.returnValue = ncpdp;
	window.close();
}

function sort() {
	document.frmLocator.hidSortField.value = event.srcElement.id;
	submitForm();
}

function btnPDS()
  {
  document.SSForm.method = "post"
	document.SSForm.action = "pricing_step1.aspx"
	document.SSForm.submit();
  }
  
function submitLogin()
	{
	document.SSForm.method = "post"
	document.SSForm.action = "process_login.aspx"
	document.SSForm.submit();
	}
	
function btnSubmitClicked() {
	submitForm();
}

function btnSubmitClicked_PS() {
	document.PSForm.method = "post"
	document.PSForm.action = "pharm_search.aspx"
	document.PSForm.submit();
}

function btnSubmitClicked_CH() {
	document.SSForm.method = "post"
	document.SSForm.action = "claims.aspx?"
	document.SSForm.submit();
}

function btnSubmitClicked() {
	document.SSForm.method = "post"
	document.SSForm.action = "pharm_search.aspx"
	document.SSForm.submit();
}

function btnNoSearchClicked() {
	document.SSForm.hidNoSearchClicked.value = "true";
}

function btnNoSearchClicked_PS() {
	document.PSForm.hidNoSearchClicked.value = "true";
}

function btnSubmitClickedS() {
	submitForm();
}

function btnNoSearchClicked() {
	document.SSForm.hidNoSearchClicked.value = "true";
}

function submitForm() {
	document.SSForm.method = "post"
	document.SSForm.action = "pharm_search.aspx"
	document.SSForm.submit();
}






//Menu and rollover
function show_menu(mname)
  {
  document.getElementById(mname).style.visibility = "visible";
  }
  
function hide_menu(mname)
  {
  document.getElementById(mname).style.visibility = "hidden";
  }
  
function rover(roname, rocolor)
  {
  document.getElementById(roname).style.backgroundColor = rocolor;
  }
  
function rout(roname, rocolor)
  {  
  document.getElementById(roname).style.backgroundColor = rocolor;
  }
  
function rover_root(roname, rocolor, photo_show, photo_hide)
  {
  d = document;
  dps = d.getElementById(photo_show);
  dph = d.getElementById(photo_hide);
  
  d.getElementById(roname).style.backgroundColor = rocolor;
  dps.style.visibility = "visible";
  dps.style.display = "inline";
  dph.style.visibility = "hidden";
  dph.style.display = "none";
  }
  
function rout_root(roname, rocolor, photo_hide, photo_show)
  {
  d = document;
  dps = d.getElementById(photo_show);
  dph = d.getElementById(photo_hide);
  
  d.getElementById(roname).style.backgroundColor = rocolor;
  dph.style.visibility = "hidden";
  dph.style.display = "none";
  dps.style.visibility = "visible";
  dps.style.display = "inline";
  }
  
function getObjRow(ID)
  {
  var tr
  tr = eval("document.all." + ID + ".style")
  return tr;
  }

function highlightrow(ID, color)
  {
  var tr
  tr = getObjRow(ID)
  tr.backgroundColor = color;
  tr.border = '1px solid #000000'
  }
  
function showDiv(divname, linkid)
	{
	
	dn = document.getElementById(divname)
	dl = document.getElementById(linkid)
	dn.style.display = 'inline';
	dn.style.visibility = 'visible';
	dl.innerText = '<< Hide Details';
	dl.href = 'javascript:hideDiv(\'' + divname + '\', \'' + linkid + '\');';
	}
function hideDiv(divname, linkid)
	{
	dn = document.getElementById(divname)
	dl = document.getElementById(linkid)
	dn.style.display = 'none';
	dn.style.visibility = 'hidden';
	dl.innerText = 'Show Details >>';
	dl.href = 'javascript:showDiv(\'' + divname + '\', \'' + linkid + '\');';
	}
