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 calcCost(chosen) {
        if (!chosen[0].selectedIndex) {
                for (i=0;i<chosen.length;i++) {
                        if (chosen[i].selected)
                        {
                                document.forms.cost.cost_cc.value = chosen[i].value;
                           if (i == 4)
                           {
                                document.forms.cost.attend_cc.selectedIndex = 1;
                           }
                           else
                           {
                                document.forms.cost.attend_cc.selectedIndex = 3;
                           }
                        }
                }
        }
}

function calcCostSavings(chosen) {
        if (!chosen[0].selectedIndex) {
                for (i=0;i<chosen.length;i++) {
                        if (chosen[i].selected) {
                                document.forms.savings.cost.value = chosen[i].value
                           if (i == 4)
                           {
                                document.forms.savings.attend.selectedIndex = 1;
                           }
                           else
                           {
                                document.forms.savings.attend.selectedIndex = 3;
                           }
                        }
                }
        }
}