﻿var oCurrentList;
function expandList(sID)
{
	collapseList(oCurrentList);
	if(document.getElementById(sID) != undefined){
		var liTag = (document.getElementById(sID).parentElement) ? document.getElementById(sID).parentElement.parentElement : document.getElementById(sID).parentNode.parentNode;
		liTag.className = (liTag.className == "Expanded" ) ? "" :  "Expanded";
	}
	
	oCurrentList = document.getElementById(sID);
}

function collapseList()
{
	if(!oCurrentList) return;
	
	var liTag = (oCurrentList.parentElement) ? oCurrentList.parentElement.parentElement : oCurrentList.parentNode.parentNode;
	
	liTag.className = (liTag.className == "Expanded" ) ? "" :  "Expanded";
}



/***** MASKING *****/
function isNumber(field) 
{
	var re = /^[0-9-'.'-',']*$/;
	if (!re.test(field.value))
	{
		alert('Value must be all numberic charcters, including "." or "," non numerics will be removed from field!');
		field.value = field.value.replace(/[^0-9-'.'-',']/g,"");
	}
}

function getKeyCharCode(event) 
{
	var key = null;
	if (window.event) {
		//ie
		key = window.event.keyCode;
	} else if (event.which) {
		key = event.which;
	}
	return key;
}
function keyPressed(event, charCode) 
{
	var keyPressed = false;
    if (getKeyCharCode(event) == charCode) 
    {
    	keyPressed = true;
    }

	return keyPressed;
}
function isNumeric(event) 
{
	// get the ASCII key code of the onKeyPress event
	
	var isMozilla = false;
	if (!window.event && event.which) 
	{
		isMozilla = true;
	}
	var key = getKeyCharCode(event);
	var isNumeric = false;	
	if (key != null) 
	{
		if (key >= 48 && key <= 57)	 
		{
			// key is numeric
			isNumeric = true;
		} 
		else if (key == 46) 
		{
			// key is a decimal point
			isNumeric = true;
		} 
		else if (key == 13) 
		{
			//13 is a return
			isNumeric = true;
		} 
		else if (key == 8 && isMozilla) 
		{
			//8 is a backspace with mozilla
			isNumeric = true;
		}
	} 
	else 
	{
		isNumeric = true;
	}
	return isNumeric;
}

