var oWindowBaseParent = null; //used by openBlankWindow
var BROWSER_TYPE_IE = "IE";
var BROWSER_TYPE_MOZILLA = "MOZILLA";
var ASSUMED_CONTENT_PAGE_ELEMENT_PREFIX = "ctl00_ContentPlaceHolder1";

function getBrowserType()
{
    if(document.all)
    {
        return BROWSER_TYPE_IE;
    }
    else
    {
        return BROWSER_TYPE_MOZILLA;
    }
}

function isIEBrowser()
{
    if(getBrowserType() == BROWSER_TYPE_IE)
    {
        return true;
    }
    else
    {
        return false;
    }
}


function changeElementColor(astrElementID, astrColorValue)
{
	changeElementColorWithForecolor(astrElementID, astrColorValue, "");
}

function changeElementColorWithForecolor(astrElementID, astrColorValue, astrForecolor)
{
	try
	{
	    if(astrColorValue != "")
	    {
		    document.getElementById(astrElementID).style.backgroundColor = astrColorValue;
		}
		if(astrForecolor != "")
		{
			document.getElementById(astrElementID).style.color = astrForecolor;
		}
		
	}
	catch(e)
	{}
}//end changeElementColorWithForecolor()

function changeElementClass(astrElementID, astrClassName)
{
    try
	{
	    if(astrClassName != "")
	    {
	        
    		document.getElementById(astrElementID).className = astrClassName;  
    		
	    }				
	}
	catch(e)
	{}
}

function showPopup(astrPopupCategory)
{
	
}//end showPopup

function defaultWindowClose(astrDefaultNavPage)
{
	try
	{
		var strCallingPage = getDefaultForm().CTRL_CallingPage.value;
		
				
		
		if(strCallingPage != "")
		{
			navigateToPage(strCallingPage);
		}
		else if(astrDefaultNavPage == "")
		{
			window.close();
		}
		else
		{
			navigateToPage(astrDefaultNavPage);
		}
		
	}
	catch(e)
	{
		window.close();
	}
}//end defaultWindowClose()


function openWindowWrapper(astrWinTarget, astrWinReference)
{
    if(astrWinReference == null || astrWinReference == "")
    {
        astrWinReference = "_new";
    }
    return window.open(astrWinTarget, astrWinReference);
}

function openBlankWindow(astrWinTarget, aiWidth, aiHeight)
{
	return openBlankWindowWithFullOptions(astrWinTarget, aiWidth, aiHeight, "no", "no", "popUpWindowItem", false, true);
}

function openBlankWindowWithResizable(astrWinTarget, aiWidth, aiHeight, astrResizable, astrScrollbars)
{
	return openBlankWindowWithFullOptions(astrWinTarget, aiWidth, aiHeight, astrResizable, astrScrollbars, "popUpWindowItem", false, true);
}

function openBlankWindowWithFullOptions(astrWinTarget,aiWidth,aiHeight,astrResizable,astrScrollbars,astrWinRefName, abOpenWithModal, abKeepOriginalPageName)
{ 	
	
	var strAppName = navigator.appName.toLowerCase();

	var bIsMicrosoftBrowser = (strAppName.indexOf("microsoft") != -1?true:false);
	var strArgumentList = "";
	var x = (document.body.clientWidth/2) - (aiWidth/2);
  	var y = (document.body.clientHeight/2) - (aiHeight/2);
	if (screen) {
        y = (screen.availHeight - aiHeight)/2;
        x = (screen.availWidth - aiWidth)/2;
    }

	
	var strTargetWindowRef = "popupItem";
	if(astrWinRefName)
	{
		strTargetWindowRef = astrWinRefName;
	}

	strArgumentList = "width=" + aiWidth + ",height=" + aiHeight + ",resizable=" + astrResizable + ",toolbar=no,location=no,scrollbars=" + astrScrollbars + ",top=" + y + ",left="+ x +",screenX=" + x + ",screenY="+ y;

	if(bIsMicrosoftBrowser && abOpenWithModal)
	{
		if(!abKeepOriginalPageName)
		{
			//astrWinTarget = astrWinTarget.replace(".aspx", "Frame.aspx");
			//alert(escape(astrWinTarget));
			astrWinTarget = "popLookupFrame.aspx?framePageString=" + escape(astrWinTarget);
		}
	
		strArgumentList = "dialogWidth=" + aiWidth + "px;dialogHeight=" + aiHeight + "px;resizable=" + astrResizable + ";status=no;toolbar=no;location=no;scrollbars=" + astrScrollbars + ";top=" + y + ";left="+ x +";screenX=" + x + ";screenY="+ y;
		oWindowBaseParent = window.showModalDialog(astrWinTarget, self, strArgumentList);
	}
	else
	{
	    var oSessionGuid = getSessionGuidContainer();
	    var strSessionID = "";
    	
	    if(oSessionGuid != null)
	    {
	        strSessionID = oSessionGuid.value;
	    }
        var strUrlDestination = _alterURLQueryStringValue(astrWinTarget, "sess", strSessionID, true, false);
        
 		oWindowBaseParent = window.open(strUrlDestination,strTargetWindowRef,strArgumentList);
	}
	return oWindowBaseParent;

}//end openBlankWindow()

function navigateToPage(astrUrl)
{
	navigateToPageWithTarget(astrUrl, "_self");
}

function navigateToPageWithTarget(astrUrl, astrTargetUrl)
{

	var strSessionID = getSessionID();
	
	var strUrlDestination = _alterURLQueryStringValue(astrUrl, "sess", strSessionID, true, false);
	
	
	if(astrTargetUrl == "_self" || astrTargetUrl == "" || astrTargetUrl == null)
	{
		document.location.href = strUrlDestination;
	}
	else
	{
		window.open(strUrlDestination, astrTargetUrl);
	}
	
	
}//end navigateToPageWithTarget()



function getSessionID()
{
    var oSessionGuid = getSessionGuidContainer();
    
	var strSessionID = "";
			
	if(oSessionGuid != null)
	{
	    strSessionID = oSessionGuid.value;
	}	
	
	return strSessionID;
}


function getSessionGuidContainer()
{
    var oSessionGuid = document.getElementById("sess");
   		
	if(oSessionGuid == null || oSessionGuid.value == "")
	{
	    oSessionGuid = document.getElementById("sessPersistGuid");
	}
	
	return oSessionGuid;
}



function defaultDeleteSubmit(astrProcessActionReference)
{
	var strMessage = "Are you sure you wish to delete this item?";
	if(window.confirm(strMessage))
	{
		defaultFormSubmitWithAction("DeleteItem", astrProcessActionReference);		
	}
}//end defaultDeleteSubmit()

function defaultDeleteSubmitWithID(aiID, astrDeleteIDReference, astrProcessActionReference)
{
	var strMessage = "Are you sure you wish to delete this item?";
	if(window.confirm(strMessage))
	{
	    document.getElementById(astrDeleteIDReference).value = aiID;
		defaultFormSubmitWithAction("DeleteItem", astrProcessActionReference);
		
	}
}//end defaultDeleteSubmit()

function defaultSaveSubmit(astrProcessActionReference)
{
	defaultFormSubmitWithAction("SaveItem", astrProcessActionReference);
}//end defaultSaveSubmit()

function defaultApplySubmit(astrProcessActionReference)
{
	defaultFormSubmitWithAction("SaveItemApply", astrProcessActionReference);
}//end defaultApplySubmit()

function defaultFormSubmitWithAction(astrProcessAction, astrProcessActionReference)
{
	//try
	//{
		getElementByIdWithDefaultPrefix(astrProcessActionReference).value = astrProcessAction;	
		
		getDefaultForm().submit();
		
	//}
	//catch(e)
	//{}	
}

function defaultFormSubmit()
{
	getDefaultForm().submit();
}

function getDefaultForm()
{
    if(document.aspnetForm)
	{
	    return document.aspnetForm;
	}
	else if(document.form1)
	{
	    return document.form1;
	}
	return null;
}

function _alterURLQueryStringValue(astrSourceURL, astrQueryStringItemName, astrQueryStringItemNewValue, abPreserveOtherQuerystringArguments, abRemoveSessionString)
{


		if(abRemoveSessionString)
		{
			astrSourceURL = _removeSessionString(astrSourceURL);
		}

		
		var strNewURL = "";
		var strQueryConcatenationString = _getQueryStringConcatenationValue(astrSourceURL);
		
		var strQueryStringItemConcatenationValue = "?";
		var strRawBaseURL = astrSourceURL;
			
		
		if(astrSourceURL.indexOf("?") != -1)
		{
			strRawBaseURL = astrSourceURL.substring(0, astrSourceURL.indexOf("?"));
		}
		
		if(!abPreserveOtherQuerystringArguments)
		{
			return strRawBaseURL + "?" + astrQueryStringItemName + "=" + astrQueryStringItemNewValue;
		}
					
		
		
		if(astrSourceURL.indexOf("?" + astrQueryStringItemName + "=") == -1 && astrSourceURL.indexOf("&" + astrQueryStringItemName + "=") == -1)
		{			
			strNewURL = astrSourceURL + strQueryConcatenationString + astrQueryStringItemName + "=" + astrQueryStringItemNewValue;										
			return strNewURL;
		}
		
		if(astrSourceURL.indexOf("?" + astrQueryStringItemName + "=") == -1)
		{
			strQueryStringItemConcatenationValue = "&";
		}
		else
		{
			strQueryStringItemConcatenationValue = "?";
		}
		
		
		
		//remove the parameter from the querystring...
		var strSegment = astrSourceURL.substring(astrSourceURL.indexOf(strQueryStringItemConcatenationValue + astrQueryStringItemName + "=") + 1);
		var strBaseURL = astrSourceURL.substring(0, astrSourceURL.indexOf(strQueryStringItemConcatenationValue + astrQueryStringItemName + "=") + 1);
		var strRemainderQuerystring = "";
		
	
		//if there are no other querystring params after the segment , simply return the new segment; 
		//otherwise, retrieve that segment (don't include the "&")...
		if(strSegment.indexOf("&") == -1)
		{
			strRemainderQuerystring = astrQueryStringItemName + "=" + astrQueryStringItemNewValue;
		}
		else
		{
			strRemainderQuerystring = strSegment.substring(strSegment.indexOf("&") + 1);
			strRemainderQuerystring += "&" + astrQueryStringItemName + "=" + astrQueryStringItemNewValue;
		}
		
		
		strNewURL = strBaseURL + strRemainderQuerystring;
		
		return strNewURL;
}//end _alterURLQueryStringValue()



function _removeSessionString(astrURL)
{
	var strNewURL = astrURL;
	var strSegmentToRemove = strNewURL.substring(strNewURL.indexOf("("), strNewURL.indexOf(")") + 2);
	strNewURL = strNewURL.replace(strSegmentToRemove, "");
	return strNewURL;		
}


function _getQueryStringConcatenationValue(astrURL)
{
	if(astrURL.indexOf("?") == -1)
	{
		return "?";
	}
	else
	{
		return "&";
	}
}//end _getQueryStringConcatenationValue()


var _strStartTableCode = "<table border='1' cellpadding='2' cellspacing='0'>";
var _strEndTableCode = "</table>";


function addDynamicRow(astrControlSpanID, astrTableRowGetHtmlFunctionName, astrStartTableCode, astrEndTableCode)
{
	if(astrStartTableCode == null || astrStartTableCode == "")
	{
		astrStartTableCode = _strStartTableCode;
	}
	if(astrEndTableCode == null || astrEndTableCode == "")
	{
		astrEndTableCode = _strEndTableCode;
	}
	
	try
	{
		var oSpan = document.getElementById(astrControlSpanID);
		var oSpanRowCode = document.getElementById(astrControlSpanID + "_RowCode");
		var oSpanCompleteCode = document.getElementById(astrControlSpanID + "_CompleteCode");
		var oSpanRowCount = document.getElementById(astrControlSpanID + "_RowCount");
		
		var iTableRowCounter;
		if(oSpanRowCount.value == "")
		{
			iTableRowCounter = 0;
		}
		else
		{
			iTableRowCounter = parseInt(oSpanRowCount.value);
		}
		
		var strSpanRowCodeValue = "" + oSpanRowCode.value;
		
		strSpanRowCodeValue += eval(astrTableRowGetHtmlFunctionName);
		
		oSpan.innerHTML = astrStartTableCode + strSpanRowCodeValue + astrEndTableCode;
		
		iTableRowCounter++;
		oSpanCompleteCode.value = oSpan.innerHTML;
		oSpanRowCode.value = strSpanRowCodeValue;
		
		oSpanRowCount.value = iTableRowCounter;
		
	}
	catch(e)
	{}
}//end addDynamicRow()



function _getUniqueID(astrNameValue)
{
	return astrNameValue.substring(astrNameValue.lastIndexOf("_") + 1);
}



//============== Trim function ===============================
//This will trim leading and trailing whitespace for a given string.
//The trimTarget determines which character to trim... most commonly a whitespace
// ex:  var result = trimItem("my text   ","\t");  //this will trim a tab
//      var result = trimItem("my text   ","\r");  //this will trim a linefeed 
//
function trimItem(textValue)
{
	return trimItemWithTarget(textValue, "");
}

function trimItemWithTarget(textValue, trimTarget)
{var resultText = "";
 if(trimTarget.length == 0)
   trimTarget = " ";

 resultText = textValue;

 for(i = 0; i < textValue.length; i++)
 {//=== First, check for leading whitespace
  if(resultText.charAt(0) == trimTarget)
  {//=== remove the leading target characters one at a time
   resultText = resultText.substring(1);
  }
  //=== Next, check for trailing target characters 
  else
  {lastWhiteSpace = resultText.lastIndexOf(trimTarget);
   //=== remove the trailing target characters one at a time
   if((lastWhiteSpace + 1) == resultText.length)
	{ resultText = resultText.substring(0,resultText.lastIndexOf(trimTarget));
	}
	//=== once all trailing target characters are removed, break out of the loop!
	else
	  break;	
  }
  
 }//end for

 return resultText;
}//end trimItem()




function validateTextLength(aoTextField, astrFieldNameReference, aiLengthLimit, abShowMessage, abTruncateField)
{
	try
	{
		var strText = aoTextField.value;
		if(strText.length > aiLengthLimit)
		{
			var strTruncateText = "\nYour data will be truncated.";
			if(abTruncateField)
			{
				strText = strText.substring(0, aiLengthLimit);
				aoTextField.value = strText;
			}
			
			if(abShowMessage)
			{
				window.alert("Warning! You have exceeded the maximum allowable characters for the " + astrFieldNameReference + " field.  The maximum allowable characters is " + aiLengthLimit + "." + strTruncateText);
			}			
			return false;
		}
		return true;
	}
	catch(e)
	{}
}//end validateTextLength()


//============ Generic "replace all" function
function replaceAll(astrValue, astrTargetText, astrReplacementText)
{	
	var iMaxLoop = 0;
	var strloopString = astrValue;
	if(astrTargetText != astrReplacementText)
	{	while(strloopString.indexOf(astrTargetText) != -1 && iMaxLoop < 1000)
		{
 			strloopString = strloopString.replace(astrTargetText, astrReplacementText);
 			iMaxLoop++;
 		}
	}
	return strloopString;
}//end replaceAll


function _getWindowOpener(astrIsDhtmlWindow)
{
    var oWindowOpener;
	var bIsDhtmlWindow = false;
	
	if(astrIsDhtmlWindow != null && (astrIsDhtmlWindow.toLowerCase() == "true" || astrIsDhtmlWindow.toLowerCase() == "yes" || astrIsDhtmlWindow == "1") )
	{
	    bIsDhtmlWindow = true;
	}
	
	try
	{
		if(window.dialogArguments)
		{
			oWindowOpener = window.dialogArguments;
		}
		else if(bIsDhtmlWindow)
		{		    
		   oWindowOpener = window.parent;
		    
		}
		else
		{
			oWindowOpener = window.opener;
		}
	
	}
	catch(e)
	{
	    
	}
	return oWindowOpener;

}//end _getWindowOpener()



//===================== Escape for html =========================
function htmlEncode(strValue)
{
 var strLoopString = strValue;

 while(strLoopString.indexOf("&") != -1)
 	strLoopString = strLoopString.replace("&","__amp;");

 while(strLoopString.indexOf(">") != -1)
 	strLoopString = strLoopString.replace(">","&gt;");

 while(strLoopString.indexOf("<") != -1)
 	strLoopString = strLoopString.replace("<","&lt;");

 while(strLoopString.indexOf("__amp;") != -1)
 	strLoopString = strLoopString.replace("__amp;","&amp;");

 while(strLoopString.indexOf("\"") != -1)
 	strLoopString = strLoopString.replace("\"","&quot;");
 
 return strLoopString;
}//end htmlEncode()


function validateEmail(aoEmailField) 
{
	try
	{
		var strRegularExpr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
		if (!strRegularExpr.test(aoEmailField.value)) 
		{
			return false;
		}
	}
	catch(e)
	{}	

	return true;
}


function showErrorMessage(astrErrorMessage)
{
	window.alert(astrErrorMessage);
}



function getBooleanValueFromString(astrSourceValue)
{
	if(astrSourceValue == null || astrSourceValue.length == 0)
	{
			return false;
	}
	
	astrSourceValue = astrSourceValue.toLowerCase();
	if(astrSourceValue == "yes" || astrSourceValue == "true" || astrSourceValue == "1")
	{
		return true;
	}
	else
	{
		return false;
	}
}//end GetBooleanValueFromString()

function htmlDecode(astrValue)
{
	try
	{
		astrValue = replaceAll(astrValue, "&quot;", "\"");
		astrValue = replaceAll(astrValue, "&lt;", "<");
		astrValue = replaceAll(astrValue, "&gt;", ">");
		astrValue = replaceAll(astrValue, "&amp;", "&");		
		
	}
	catch(e)
	{
	}
	return astrValue;
}


function isAlphanumeric(string, iAllowWhitespace) 
{	var strRegularExpression = "[^.a-zA-Z0-9";
	if(iAllowWhitespace) 
		strRegularExpression += "\\s";
	strRegularExpression += "_-]";

	if(string.search(strRegularExpression) != -1)
		return false;
	
	return true;  
}//end isAlphanumeric()

//================ Check generic regular expression ================
function hasPattern(string, strRegularExpression)
{	if(string.search(strRegularExpression) != -1)
		return true;
	return false
}	


function roundToDecimalPlaces(aiNumberToRound, aiDecimalPlaces)
{
	try
	{
		var iRoundFactor = 10;
		for(var iCounter = 1; iCounter < aiDecimalPlaces; iCounter++)
		{
			iRoundFactor = iRoundFactor * 10;
		}
		var iResult = Math.round(aiNumberToRound * iRoundFactor)/iRoundFactor;
		return iResult;
	}
	catch(e)
	{
		return 	aiNumberToRound;
	}
	
}


function getPaddedNumber(aiNumber, aiDecimalPlaces)
{
	var strNumber = aiNumber + "";
	if(strNumber.indexOf(".") == -1)
	{
		return strNumber + ".00";
	}
	var strDecimalSection = strNumber.substring(strNumber.indexOf(".") + 1);
	var strWholeNumberSection = strNumber.substring(0, strNumber.indexOf("."));
	var iDecimalSectionLength = strDecimalSection.length;
	if(iDecimalSectionLength >= aiDecimalPlaces)
	{
		
		return aiNumber;
	}
	else
	{
		var strZeroPadding = "";
		for(var iCounter = 0; iCounter < (aiDecimalPlaces - iDecimalSectionLength); iCounter++)
		{
			strZeroPadding += "0";
		}
		strNumber = strWholeNumberSection + "." + strDecimalSection + strZeroPadding;
	}
	
	return strNumber;
	
	
}


//Special retrieval based on prefix assumptions...
//In cases where we have a content page, the actual rendered object ID is prepended with a prefix.
//EX: <asp:TextBox ID="MyElement"/>  could evaluate to <input type="text" id="ctl00_ContentPlaceHolder1_MyElement"/>
//Based on the assumption of a content placeholder called "ContentPlaceHolder1", we can construct the correct ID.
// Defined at the top of this file is:  var ASSUMED_CONTENT_PAGE_ELEMENT_PREFIX = "ctl00_ContentPlaceHolder1";
function getElementByIdWithDefaultPrefix(astrDefinedID)
{
    return getElementByIdWithPrefix(ASSUMED_CONTENT_PAGE_ELEMENT_PREFIX, astrDefinedID);
}

function getElementNameWithPrefix(astrDefinedID)
{
    return getElementIDWithPrefix(ASSUMED_CONTENT_PAGE_ELEMENT_PREFIX, astrDefinedID);
}

function getElementByIdWithPrefix(astrPrefix, astrDefinedID)
{
    var fullID = getElementIDWithPrefix(astrPrefix, astrDefinedID);
    var oResultElement;
    
    try
    {
        oResultElement = document.getElementById(fullID);
        
        if(oResultElement == null)
        {
           oResultElement = document.getElementById(astrDefinedID);
        }
    }
    catch(e)
    {
     window.alert("Failed to retrieve element based on id: " + fullID);
    }
    return oResultElement;
}

function getElementIDWithPrefix(astrPrefix, astrDefinedID)
{
    return astrPrefix + "_" + astrDefinedID;
}



function clearDropDownValues(aoDropDown)
{
    for(var iCounter = 0; iCounter < aoDropDown.options.length; iCounter++)
    {
        aoDropDown.options[iCounter] = null;
    }
}

function _getSessionQueryString()
{
    return _getQueryStringForParam("sess");
}

function _getQueryStringForParam(astrQueryParamName)
{
    return astrQueryParamName + "=" + document.getElementById(astrQueryParamName).value;
    
}

function _statusBox(astrMessage)
{
    window.status = astrMessage;
    return true;
}


function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


function findElementPositions(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function setObjectFocus(aoObjectReference)
{
    
    try
    {
        aoObjectReference.focus();
    }
    catch(e)
    {}
    
}

function signOut()
{
    navigateToPage('signOut.aspx');
}



var _currentScrollWidth = 0;
var _currentScrollHeight = 0;
var _currentClientWidth = 0;
var _currentClientHeight = 0;
var _currentXOffset = 0;
var _currentYOffset = 0;

function standardResizeHandler()
{
    _currentScrollWidth = document.body.scrollWidth;
    _currentScrollHeight = document.body.scrollHeight;
    _currentClientWidth = document.body.clientWidth;
    _currentClientHeight = document.body.clientHeight;
   
    if(isIEBrowser())
		{
			_currentYOffset = document.body.scrollTop;
			_currentXOffset = document.body.scrollLeft;
		
		}
		else
		{
			_currentYOffset = window.pageYOffset;
			_currentXOffset = window.pageXOffset;
		}
    
}

function standardScrollHandler()
{
    _currentScrollWidth = document.body.scrollWidth;
    _currentScrollHeight = document.body.scrollHeight;
    _currentClientWidth = document.body.clientWidth;
    _currentClientHeight = document.body.clientHeight;
    
    if(isIEBrowser())
		{
		  
		    _currentYOffset = document.body.scrollTop;
			_currentXOffset = document.body.scrollLeft;
		
		}
		else
		{
			_currentYOffset = window.pageYOffset;
			_currentXOffset = window.pageXOffset;
		}
}


function setDropDownItem(aoElementReference, astrValueToCheck, abCheckText)
{	var iDropDownIndex = 0;
	
	for(iDropDownIndex = 0; iDropDownIndex < aoElementReference.options.length; iDropDownIndex++)
	{	if(abCheckText)
		{	if(aoElementReference.options[iDropDownIndex].text.toLowerCase() == astrValueToCheck.toLowerCase())
			{	aoElementReference.selectedIndex = iDropDownIndex;
				iDropDownIndex = aoElementReference.options.length + 1; //force exit of loop
			}
		}
		else
		{	if(aoElementReference.options[iDropDownIndex].value.toLowerCase() == astrValueToCheck.toLowerCase())
			{	aoElementReference.selectedIndex = iDropDownIndex;
				iDropDownIndex = aoElementReference.options.length + 1; //force exit of loop
			}
		}		
	}//end for
}//end _selectDropDownItem

function getDropDownValueFromText(aoElementReference, astrTextToCheck)
{
    var iDropDownIndex = 0;
	var strValue = "";
	for(iDropDownIndex = 0; iDropDownIndex < aoElementReference.options.length; iDropDownIndex++)
	{		
	    if(aoElementReference.options[iDropDownIndex].text.toLowerCase() == astrTextToCheck.toLowerCase())
		{	
		    strValue = aoElementReference.options[iDropDownIndex].value;
		    break;
		}
		
	}//end for
	
	return strValue;
}


function openWindowInNavigationContext(astrUrl, aiNavigationMenuID)
{
    //alert("embedding " + astrUrl);
    navigateToPage("frmEmbeddedWindow.aspx?NavigationMenuID=" + aiNavigationMenuID);
}

function isPositiveFloat(astrValue)
{
    if(astrValue == null || astrValue.length == 0 || parseFloat(astrValue) < 1 || isNaN(astrValue))
    {
        return false;
    }
    return true;
}


function isPositiveInteger(astrValue)
{
    if(astrValue == null || astrValue.length == 0 || parseInt(astrValue) < 1 || isNaN(astrValue))
    {
        return false;
    }
    return true;
}


function doNothing()
{
    //placeholder
}


function toggleRowHighlight(aoRowItem, astrColorSuggestion)
{
    var strDefaultHighlightColor = "#CAFAF4";
    
    try
    {
        //NOTE: the special astrColorSuggestion "xxx" means use whatever color we define as a default
        //in this method.
        if(astrColorSuggestion == "xxx")
        {
            aoRowItem.style.backgroundColor = strDefaultHighlightColor;
        }
        else
        {
            
             aoRowItem.style.backgroundColor = astrColorSuggestion;
        }    
    }
    catch(e)
    {
        //Don't do anything since this is non-critical.
    }    
}



//Usually called from AppBasePage.cs for list row highlighting
//We always call this method for onclick, but since it may not be defined on the page,
//we just ignore it.

//We also provide a variable called _bProcessListRowClick which can be set to true/false
//in case we need to cancel out the click event in the javascript.
//This is for situations where we want a default click action, but if the user clicks another hyperlink
//on the row the default action is disabled.  The use of this variable must be defined in the specific
//calling page.
var _bProcessListRowClick = true;
function defaultListRowClick(aoRowElement)
{
    try
    {
        listRowClick(aoRowElement);
    }
    catch(e)
    {//Do nothing as this may not be defined on the parent page.
    }
}

//Same as above, but here we are able to get a unique id if the element's DataItem
//is derived from ICoreDataEntity
function defaultListRowClickWithID(aoRowElement, aiUniqueIdentifier)
{
    try
    {
        listRowClickWithID(aoRowElement, aiUniqueIdentifier);
    }
    catch(e)
    {//Do nothing as this may not be defined on the parent page.
    }
}


//Ajax list page functionality helper
function defaultAjaxDeleteSubmitWithID(aiID, astrPageMethodRef)
{
	var strMessage = "Are you sure you wish to delete this item?";
	if(window.confirm(strMessage))
	{
        eval("PageMethods." + astrPageMethodRef + "DeleteItem(_strSess, aiID, _arr" + astrPageMethodRef + "CachedSearchCriteria, _str" + astrPageMethodRef + "SortExpression, " + astrPageMethodRef + "DeleteItem_success, " + astrPageMethodRef + "DeleteItem_fail, _arr" + astrPageMethodRef + "CachedSearchCriteria)");    
	}
}//end defaultAjaxDeleteSubmitWithID()