var Pricer = {};
Pricer.CalculateTotalCost = function(qty, total) {
    var nqty = Pricer.GetFloat(qty);
    var ntotal = Pricer.GetFloat(total);
    var thesum = parseFloat(ntotal / nqty);

    return thesum.toFixed(2)
}
Pricer.CalculatePerClick = function(qty, perclick) {
    var nqty = Pricer.GetFloat(qty);
    var nperclick = Pricer.GetFloat(perclick);
    var thesum = parseFloat(nqty * nperclick);
    //alert(nqty+" * "+nperclick);

    return thesum.toFixed(2);
}
Pricer.GetFloat = function(input) {
    var whatever = parseFloat(input);
    if (isNaN(whatever)) {
        return 1;
    }
    else {
        return whatever;
    }
}
Pricer.UpdateTotalCost = function(qty, txtBoxPerClick, txtBoxTotal) {
    var txtPerClick = document.getElementById(txtBoxPerClick);
    var txtToUpdate = document.getElementById(txtBoxTotal);

    if (txtToUpdate != null) {
        txtToUpdate.value = Pricer.CalculateTotalCost(qty, txtPerClick.value);
    }
}
Pricer.UpdatePerClick = function(qty, txtBoxTotal, txtBoxPerClick) {
    var txtTotal = document.getElementById(txtBoxTotal);
    var txtToUpdate = document.getElementById(txtBoxPerClick);

    if (txtToUpdate != null) {
        txtToUpdate.value = Pricer.CalculatePerClick(qty, txtTotal.value);
    }
}

var Enabler = {};
Enabler.Enable = function(obj) {
	
	var dis = event.target || event.srcElement;
	if(dis != null){
		dis.focus();
		dis.select();
	}
		
    var it = document.getElementById(obj);
    if (it != null) {
        it.value="+ Save";
        it.disabled = false;
    }
}
