function uf_RemoveComma(sTextVal) {
	var re = /,/g
	newTextVal = sTextVal.replace(re, "");
	//alert ("Before = " + sTextVal + "    After = " + newTextVal);
	return newTextVal; 
}

function uf_RemoveFormatting(sTextVal) {
    newTextVal = "";
    startNum = 0;
    if (sTextVal.charAt(0) == "-"){
        startNum = 1;
        newTextVal = "-"
    }
	for (i=startNum; i < sTextVal.length; i++)	
	{
	    if (!(isNaN(parseInt(sTextVal.charAt(i))))){
	        newTextVal = newTextVal + sTextVal.charAt(i);
	    
	    }else if(sTextVal.charAt(i) == "."){
	    	i = sTextVal.length;
	    }
	}

	return newTextVal; 
}

function uf_CheckVal(sTextVal)	{

	sTextVal = uf_RemoveFormatting(sTextVal);	
	
	for (i=0; i < sTextVal.length; i++)	{
		if (isNaN(parseInt(sTextVal.charAt(i))))	{
			if (((sTextVal.charAt(i) == ".") && (i == (sTextVal.length-3))) || ((sTextVal.charAt(i) == "-") && (i == 0)))	{
				continue;
			}
			else	{
				sTextVal = sTextVal.substring(0,i) + sTextVal.substring((i+1));
				i--;
			}
		}
	}
	if (sTextVal == "")	{
		sTextVal = 0;
	}
	
	return sTextVal;
}


function uf_ConvertDecimal(sTextVal)	
{
	if (isNaN(parseInt(sTextVal)))
	{
	sTextVal == sTextVal
	}
	else
	{
	sTextVal = parseInt(sTextVal);
	}
	return sTextVal;
}


function uf_CheckCurr(sTextVal)	{
	if (sTextVal.length == 0){
		return sTextVal;
	}
	sTextVal = "$" + sTextVal;
	if (sTextVal.charAt(1) == "-")	{
		sTextVal = "-$" + sTextVal.substring(2);
	}
	for (j=sTextVal.length; j > -1; j--)	{
		if ((!isNaN(parseInt(sTextVal.charAt(j)))) && (!isNaN(parseInt(sTextVal.charAt(j-1)))) && (!isNaN(parseInt(sTextVal.charAt(j-2)))) && (!isNaN(parseInt(sTextVal.charAt(j-3)))))	{
			sTextVal = sTextVal.substring(0,j-2) + "," + sTextVal.substring(j-2);
			j++;
		}
	}

	return sTextVal;
}


function saveForm(){
	document.form1.saveFlag.value = 2;
	document.form1.submit();
}

// This is for opening a new pop-up window
function uf_OpenNewBrowser(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
