/**
 * File gui.js
 * This file stores all cross-template java script code used in HTML user interface.
 * This file depends on the Prototype java script library.
 *
 * @author Andrew Mikhailov <amihailov@infostroy.com.ua>
 **/

/**
 * Common client-side UI controls namespace
 **/
var GUI = {
  /**
   * The client-side representation of the generic UI control
   **/
  Control : {
    highlight : function(object) {
      object.setStyle({
        backgroundColor: '#BAD3E7'
        });
    }
  },
  /**
   * The client-side representation of the text box UI control
   **/
  TextBox : {
    /**
     * Decrements the value stored in the HTML element.
     * @return Boolean False to allow compactly blocking code in event handlers.
     **/      
    decrement : function(id) {
        if ($(id)) {
          if (1 < $(id).value) {
            $(id).value--;
          }
        }
        return false;
    },
    /**
     * Increments the value stored in the HTML element.
     * @return Boolean False to allow compactly blocking code in event handlers.
     **/        
    increment : function(id) {
      if ($(id)) {
        $(id).value++;
      }
      return false;
    },
    /**
     * Loads the text box value from the combo box with the given ID
       * @return Boolean False to allow compactly blocking code in event handlers.
     **/
    loadFromComboBox : function(id, idComboBox) {
      if ($(id) && $(idComboBox)) {
        $(id).value = $(idComboBox).options[$(idComboBox).selectedIndex].text;
      }
      return false;
    }
  }
};