//this script page used for general text and button manipulation

//test for the ENTER key
//go to the correct button and submit
function EnterKey(txtButtonID) 
	{    
		if (event.keyCode == 13) 
		{       
		//alert(event.keyCode); 
		event.cancelBubble = true;
		event.returnValue = false;
		document.getElementById(txtButtonID).click();
		}
	}
	
//SCR9650 - JRW - clear the criteria field that does not apply
function ClearCriteriaField(txtButtonID)
{   //clear the boxes based on selection
	//alert(txtButtonID); 
	document.getElementById(txtButtonID).value="";
	//if(txtNextCtrlID != "")
			//eval("document." + strFormName + "." + strNextFieldName + ".focus();");
	//		eval("document.forms[0]." & txtNextCtrlID & ".focus();");
	event.cancelBubble = true;
	event.returnValue = false;
	
}


//*******************************************************************************
// Function:	AutoTab
// Inputs:		strCurrentFieldID, strNextFieldID, intFieldLength
// Output:		N/A
//*******************************************************************************
function AutoTab(strCurrentFieldID, strNextFieldID, intFieldLength)
{
	var strCurrentVal=document.getElementById(strCurrentFieldID).value;
	var	intLength = strCurrentVal.length;
	
	//alert("strCurrentVal:" + strCurrentVal)
	
	if(intLength == intFieldLength)
	{
		document.getElementById(strNextFieldID).focus();
	}
}


//*******************************************************************************
// Function:	ValidatePregnancy
// Inputs:		intReasonID, strFieldID
// Output:		boolean
//*******************************************************************************
function ValidatePregnancy(strFieldID)
{
//prompt to ensure pregnancy
	var intReasonID = 0;
	var intIndex = 0;
	var strReason = ""; 
		
	var strReason = document.getElementById(strFieldID).value;
		
	intIndex = strReason.indexOf("|",0);
	intReasonID = strReason.slice(0,intIndex); 
	
	//alert(intReasonID);
	if (intReasonID==101){
		if (!confirm("Select OK if you are sure this member is pregnant."))
		{
			alert("TOTAL OB CARE can only be selected if the member is pregnant.  Select a different Referral Reason.");
			document.getElementById(strFieldID).focus();
			//document.getElementById(strTextFieldID).value="false";
			//return false; 
			event.cancelBubble = true;
			event.returnValue = false;
			return false;
		} 
	}
}

//test for the ENTER key
//go to the correct CONTROL
function MoveOnEnter(txtButtonID) 
	{    
		if (event.keyCode == 13) 
		{       
		//alert(event.keyCode); 
		event.cancelBubble = true;
		event.returnValue = false;
		document.getElementById(txtButtonID).focus();
		}
	}