/*
function IsNumeric(str)
{
	var res = true;
	var i;
	
	for(i=0; i<str.length; i++)
	{
		if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 48 && str.charCodeAt(i) > 57 && str.charCodeAt(i) < 126 ) res = false;
	}
	
	return res;
}
*/


function flag(step)
{
	var count = 0;
	for (i=0; i<step; i++)
		if (document.getElementById("_id"+i) && document.getElementById("_id"+i).checked==true ) count++;
	if (count > 3) alert("You can mark for deletion no more than 3 transactions at a time!");
	else document.tableForm.submit();
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function addToCompSet(msg) {
	
	var c = document.tableForm.comps;
	
	if (c.value == -1)
	{
	
		cs = prompt("Please enter the new Comp Set name"+msg, "");
		
		
		for (i=0; i<c.length; i++)
		
		{
		
			if (c.options[i].text == cs || c.options[i].text == trim(cs))
			{
		
				addToCompSet("\nError: "+ cs + " alreasy exists in your Comp Sets");
		
				return;
		
			}
				
			if (trim(cs).length < 1 )
			{
					
				addToCompSet("\nError: Comp Set name has to be at least one character long");
		
				return;
					
			}
	
	
			if (trim(cs).match("([0-9]{" + trim(cs).length + "})")) 
			{
				addToCompSet("\nError: Comp Set name cannot contain only numbers");
					
				return;				
			}
		
			
			c.options[c.length] = new Option(trim(cs),trim(cs));
	
			c.selectedIndex = c.length-1;	
		}
	
	}
	if (c.value.length > 0) document.tableForm.submit();
	else c.selectedIndex = 0;

}

	function checkAll(val, step) {

		if (val)

			for (i=0; i<step; i++)

			{

				if (document.getElementById("_id"+i)) document.getElementById("_id"+i).checked=true;

			}

		else 

			for (i=0; i<step; i++)

			{

				if (document.getElementById("_id"+i)) document.getElementById("_id"+i).checked=false;

			}

	}
	

	function confirmSubmit(msg)
	{
		var agree = confirm(msg);
		if (agree)
			return true;
		return false;
	}

	var rowColors = new Array();
	function selectRow(rowId)
	{
		rowOb = document.getElementById('row' + rowId);
		if (!rowOb) {
			return;
		}
	
		if (rowOb.className.indexOf('selectedRow') != -1) {
			rowOb.className = rowColors[rowId];
		} else {
			rowColors[rowId] = rowOb.className;
			rowOb.className = 'selectedRow';
		}
	}
