function calculate_p(ConsumoProm){
   	a=ConsumoProm-250;
   	if (a > 0){
   		rest = Math.ceil(a/25);
		cost = rest*400+3000;
		cost = cost + "";
		if (cost.length >=5){
			cost = "$"+ cost.substring(0,2) + ", "+ cost.substring(2,10);
		}else{
			cost = "$"+ cost.charAt(0) + ", "+ cost.substring(1,10);
		}
		return cost;
	}else{
		cost=3000;
		cost = cost + "";
		if (cost.length >=5){
			cost = "$"+ cost.substring(0,2) + ", "+ cost.substring(2,10);
		}else{
			cost = "$"+ cost.charAt(0) + ", "+ cost.substring(1,10);
		}
		return cost;
	}
}
function compute(){
   var f = document.Presupuesto;
   w = f.consumoPromedio.value;
   if (chkw(w)){
      f.PresupuestoV.value = calculate_p(w);
   } else { alert("Por favor introdusca el consumo promedio."); }
   switch (f.PresupuestoV.value){
		case "$3, 000":
		f.hosted_button_id.value="9967776";
		break;
		case "$3, 400":
		f.hosted_button_id.value="9967792";
		break;
		case "$3, 800":
		f.hosted_button_id.value="9967812";
		break;
		case "$4, 200":
		f.hosted_button_id.value="9967825";
		break;
		case "$4, 600":
		f.hosted_button_id.value="9967842";
		break;
		case "$5, 000":
		f.hosted_button_id.value="9967860";
		break;
		case "$5, 400":
		f.hosted_button_id.value="9967876";
		break;
		case "$5, 800":
		f.hosted_button_id.value="9967889";
		break;
		case "$6, 200":
		f.hosted_button_id.value="9967910";
		break;
		case "$6, 600":
		f.hosted_button_id.value="9967939";
		break;
		case "$7, 000":
		f.hosted_button_id.value="9967957";
		break;
   }
}
function chkw(w){
   if (isNaN(parseInt(w))){
      return false;
   } else if (w < 0){
      return false;
   }
   else{
      return true;
   }
}