Index: 0.3-modules/proyectos_operativos/js/proyectos_operativos.js
===================================================================
--- 0.3-modules/proyectos_operativos/js/proyectos_operativos.js	(revision cc13fa31243235ebc0ab7f62bec109344a168ec4)
+++ 0.3-modules/proyectos_operativos/js/proyectos_operativos.js	(revision dc8ba62e44ac5814bf6409318e696e626eb2880a)
@@ -40,84 +40,75 @@
   var year_prev = parseInt(n[2], 10);
   var year_current = Drupal.settings.year_current;
-  if (year_prev == year_current && month > 0) {
-    for (var i = 0; i < month;i++) {
+  date1 = $("#edit-field-accion-esp-fechaf-0-value-datepicker-popup-0").val();
+  var n1 = date1.split("/");
+  month1 = parseInt(n1[1], 10) - 1;
+  var year_next = parseInt(n1[2], 10);
+  if (year_prev < year_current) {
+    month = 0;
+  }
+  if (year_next > year_current) {
+    month1 = 11;
+  }
+  for (var i = 0; i < 12;i++) {
+    if (i < month || i > month1) {
       $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
+      $(".field_accion_esp_programacion_m" + i + "_field").val(0);
       $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
+      $(".field_accion_esp_metaf_m" + i + "_field").val(0);
+    }
+    else {
+      $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', false);
+      $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', false);
     }
   }
-  if (year_prev > year_current) {
-    for (var i = 0; i < 12;i++) {
-      $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-      $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-    }
+  suma('field_accion_esp_metaf_0_field');
+  for (i = 0; i < 12;i++) {
+    suma('field_accion_esp_programacion_' + i + '_field');
   }
-  date = $("#edit-field-accion-esp-fechaf-0-value-datepicker-popup-0").val();
-  n = date.split("/");
-  month = parseInt(n[1], 10) - 1;
-  var year_next = parseInt(n[2], 10);
-  if (year_current == year_next && month < 11) {
-    for (var i = month + 1; i < 12; i++) {
-      $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-      $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-    }
-  }
-  if (year_next < year_current) {
-    for (var i = 0; i < 12;i++) {
-      $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-      $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-    }
+  sumatexto('field_accion_esp_programacion_dato_field');
+  for (i = 0; i < 12;i++) {
+    sumatexto('field_accion_esp_programacion_m' + i + '_field');
   }
   $("#edit-field-accion-esp-fechai-0-value-datepicker-popup-0").datepicker({ 
     onSelect: function(date) {
-        var n = date.split("/");
-        var month = parseInt(n[1], 10) - 1;
-        var year_prev = parseInt(n[2], 10);
-        var year_current = Drupal.settings.year_current;
-        var date1 = $("#edit-field-accion-esp-fechaf-0-value-datepicker-popup-0").val();
-        var n1 = date1.split("/");
-        var month1 = parseInt(n1[1], 10) - 1;
-        var year_next = parseInt(n1[2], 10);
-        var tamano = 0;
-        //se obtiene el tamanho del campo
-        $(".field_accion_esp_programacion_m0_field").each(function() {
-          tamano++;
-        });
-        if (year_prev < year_current) {
-          month = 0;
+      var n = date.split("/");
+      var month = parseInt(n[1], 10) - 1;
+      var year_prev = parseInt(n[2], 10);
+      var year_current = Drupal.settings.year_current;
+      var date1 = $("#edit-field-accion-esp-fechaf-0-value-datepicker-popup-0").val();
+      var n1 = date1.split("/");
+      var month1 = parseInt(n1[1], 10) - 1;
+      var year_next = parseInt(n1[2], 10);
+      var tamano = 0;
+      //se obtiene el tamanho del campo
+      $(".field_accion_esp_programacion_m0_field").each(function() {
+        tamano++;
+      });
+      if (year_prev < year_current) {
+        month = 0;
+      }
+      if (year_next > year_current) {
+        month1 = 11;
+      }
+      for (var i = 0; i <= 11;i++) {
+        $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
+        $(".field_accion_esp_programacion_m" + i + "_field").val(0);
+        $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
+        $(".field_accion_esp_metaf_m" + i + "_field").val(0);
+      }
+      if (year_prev <= year_current && year_next >= year_current) {
+        for (var i = month; i <= month1;i++) {
+          $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', false);
+          $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', false);
         }
-        if (year_next > year_current) {
-          month1 = 11;
-        }
-        if (year_prev <= year_current && year_next >= year_current) {
-          for (var i = month; i <= month1;i++) {
-            $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', false);
-            $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', false);
-          }
-        }
-        else {
-          for (var i = 0; i <= 11;i++) {
-            $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-            $(".field_accion_esp_programacion_m" + i + "_field").val(0);
-            $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-            $(".field_accion_esp_metaf_m" + i + "_field").val(0);
-          }
-        }
-        if (year_prev <= year_current && year_next >= year_current && month > 0) {
-          for (var i = 0; i < month;i++) {
-            $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-            $(".field_accion_esp_programacion_m" + i + "_field").val(0);
-            $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-            $(".field_accion_esp_metaf_m" + i + "_field").val(0);
-            
-          }
-          suma('field_accion_esp_metaf_0_field');
-          for (i = 0; i < 12;i++) {
-            suma('field_accion_esp_programacion_' + i + '_field');
-          }
-          sumatexto('field_accion_esp_programacion_dato_field');
-          for (i = 0; i < 12;i++) {
-            sumatexto('field_accion_esp_programacion_m' + i + '_field');
-          }
-        }
+      }
+      suma('field_accion_esp_metaf_0_field');
+      for (i = 0; i < 12;i++) {
+        suma('field_accion_esp_programacion_' + i + '_field');
+      }
+      sumatexto('field_accion_esp_programacion_dato_field');
+      for (i = 0; i < 12;i++) {
+        sumatexto('field_accion_esp_programacion_m' + i + '_field');
+      }
     }, "dateFormat": "dd/mm/yy",
   });
@@ -137,12 +128,17 @@
         tamano++;
       });
-      if (year_prev > year_current) {
-        month = 11;
+      if (year_prev < year_current) {
+        month = 0;
       }
       if (year_next > year_current) {
         month1 = 11;
       }
-
-      if (year_prev <= year_current && year_next >= year_current && month1 < 11) {
+      for (var i = 0; i <= 11;i++) {
+        $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
+        $(".field_accion_esp_programacion_m" + i + "_field").val(0);
+        $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
+        $(".field_accion_esp_metaf_m" + i + "_field").val(0);
+      }
+      if (year_prev <= year_current && year_next >= year_current) {
         for (var i = month; i <= month1;i++) {
           $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', false);
@@ -150,27 +146,12 @@
         }
       }
-      else {
-        for (var i = 0; i <= 11;i++) {
-          $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-          $(".field_accion_esp_programacion_m" + i + "_field").val(0);
-          $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-          $(".field_accion_esp_metaf_m" + i + "_field").val(0);
-        }
+      suma('field_accion_esp_metaf_0_field');
+      for (i = 0; i < 12;i++) {
+        suma('field_accion_esp_programacion_' + i + '_field');
       }
-      if (year_prev <= year_current && year_next >= year_current && month < 11)
-        for (i = month1 + 1; i < 12;i++) {
-          $(".field_accion_esp_programacion_m" + i + "_field").attr('readonly', true);
-          $(".field_accion_esp_programacion_m" + i + "_field").val(0);
-          $(".field_accion_esp_metaf_m" + i + "_field").attr('readonly', true);
-          $(".field_accion_esp_metaf_m" + i + "_field").val(0);
-        }
-        suma('field_accion_esp_metaf_0_field');
-        for (i = 0; i < 12;i++) {
-          suma('field_accion_esp_programacion_' + i + '_field');
-        }
-        sumatexto('field_accion_esp_programacion_dato_field');
-        for (i = 0; i < 12;i++) {
-          sumatexto('field_accion_esp_programacion_m' + i + '_field');
-        }
+      sumatexto('field_accion_esp_programacion_dato_field');
+      for (i = 0; i < 12;i++) {
+        sumatexto('field_accion_esp_programacion_m' + i + '_field');
+      }
     }, "dateFormat": "dd/mm/yy",
   });
