function showProcessingMsg(pStrId) {
	document.getElementById(pStrId).style.visibility='hidden';
	document.getElementById(pStrId).style.display='none';
	document.getElementById('divProcessingMsg').style.visibility='visible';
	document.getElementById('divProcessingMsg').style.display='inline';
}
var timerID = null;
var timerRunning = false;
var timeValue = 400;
var count = 0;
var finish = false;
//load up the images for the progress bar
image00 = new Image(); image00.src='images/image-00.gif';
image01 = new Image(); image01.src='images/image-01.gif';
image02 = new Image(); image02.src='images/image-02.gif';
image03 = new Image(); image03.src='images/image-03.gif';
image04 = new Image(); image04.src='images/image-04.gif';
image05 = new Image(); image05.src='images/image-05.gif';
image06 = new Image(); image06.src='images/image-06.gif';
image07 = new Image(); image07.src='images/image-07.gif';
image08 = new Image(); image08.src='images/image-08.gif';
image09 = new Image(); image09.src='images/image-09.gif';
image10 = new Image(); image10.src='images/image-10.gif';
image11 = new Image(); image11.src='images/image-11.gif';
image12 = new Image(); image12.src='images/image-12.gif';


function increment() {
	count += 1;
	if (count == 0) {document.images.bar.src=image00.src;}
	if (count == 1) {document.images.bar.src=image01.src;}
	if (count == 2) {document.images.bar.src=image02.src;}
	if (count == 3) {document.images.bar.src=image03.src;}
	if (count == 4) {document.images.bar.src=image04.src;}
	if (count == 5) {document.images.bar.src=image05.src;}
	if (count == 6) {document.images.bar.src=image06.src;}
	if (count == 7) {document.images.bar.src=image07.src;}
	if (count == 8) {document.images.bar.src=image08.src;}
	if (count == 9) {document.images.bar.src=image09.src;}
	if (count == 10) {document.images.bar.src=image10.src;}
	if (count == 11) {document.images.bar.src=image011.src;}
	//repeat the bar continuously:
	//if (count == 12) {document.images.bar.src=image012.src; count=-1;}
	//stop repeating the bar:
	if (count == 12) {document.images.bar.src=image012.src; end();}
}

function stopclock() {
	if (timerRunning)
		clearInterval(timerID);
	timerRunning = false;	
}

function end() {
	if (finish == true) {
		stopclock();
		window.close();
	}
	else {
		finish = true; 
	}
}

function startclock() {		
	stopclock();
	timerID = setInterval("increment()", timeValue);
	timerRunning = true;
	document.images.bar.src=image00.src;
}

function Send_onclick(frmSubmit) {
	startclock();
	frmSubmit.submit();			
}

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 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 btnSubmitClicked() {
	submitForm();
}

function btnSubmitPricing() {
	submitFormPricing();
}

function btnNoSearchClicked() {
	document.frmEnroll.hidNoSearchClicked.value = "true";
}

function submitForm() {
	document.frmEnroll.submit();
}

function btnSubmitClickedS() {
	document.frmLocatorS.submit()
}

function btnSubmitClicked_751() {
	document.frmLocator.submit()
}

function btnSubmitClicked_100() {
	document.frmLocator.submit()
}

function submitaspnetForm() {
	document.aspnetForm.method = "post"
	document.aspnetForm.action = "pharmacy_search.aspx"
	document.aspnetForm.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;
  //document.getElementByID('td_photo').style.backgroundImage = url(../images/photo
  }
  
function rout(roname, rocolor)
  {
  document.getElementById(roname).style.backgroundColor = rocolor;
  //document.getElementByID('td_photo').style.backgroundPosition = pos;
  }
  
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
  }
  
function FilterKeys()
  {
  if (8==window.event.keyCode)
    {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false; return false;
    }
  }
  
//use onchange="runcheck()" in srcElement
function runcheck(){
	var element = event.srcElement;
	var n = event.srcElement.value;
	//var pattern = '(xxx)xxx-xxxx';
	var pattern = 'xxx-xxx-xxxx';
	var tstr = "" + n;
	var Findex = 0;
	var Nindex = 0;
	var rex = /[ A-Za-z\+\(\)\-]/;
	var parts = tstr.split(rex);
	
	strProcessed = parts.join("");
	var formatted = "";
	while(Nindex < strProcessed.length){
		if(formatted.length == pattern.length) break;
		while(pattern.charAt(Findex) != "x"){
			formatted += pattern.charAt(Findex++);}
		Findex++;
		formatted += strProcessed.charAt(Nindex++);}
	element.value = formatted;
	}

	
function selectRad(index) {
    //alert(index);
    if (document.getElementById('ctl00_BloomContentHolder_radQuantities_0')) {
        var rad0 = document.getElementById('ctl00_BloomContentHolder_radQuantities_0');
    }
    if (document.getElementById('ctl00_BloomContentHolder_radQuantities_1')) {
        var rad1 = document.getElementById('ctl00_BloomContentHolder_radQuantities_1');
    }
    if (document.getElementById('ctl00_BloomContentHolder_radQuantities_2')) {
        var rad2 = document.getElementById('ctl00_BloomContentHolder_radQuantities_2');
    }
    if (document.getElementById('ctl00_BloomContentHolder_radQuantities_3')) {
        var rad3 = document.getElementById('ctl00_BloomContentHolder_radQuantities_3');
    }
    if (index == 3) {
        rad0.checked = false
        rad1.checked = false
        rad2.checked = false
        rad3.checked = true
    }
    if (index == 2) {
        rad0.checked = false
        rad1.checked = false
        rad2.checked = true
    }
    if (index == 1) {
        rad0.checked = false
        rad1.checked = true
    }
}

function clearBox(index) {
    document.getElementById('ctl00_BloomContentHolder_txtDrugQty').value = "";
}