/* Copyright 2011 the Melange authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @author <a href="mailto:madhusudancs@gmail.com">Madhusudan.C.S</a>
 */
(function () {
  /** @lends melange.action */

  if (window.melange === undefined) {
    throw new Error("Melange not loaded");
  }

  var melange = window.melange;

  /** Package that handles all action buttons related functions
    * @name melange.action
    * @namespace melange.action
    * @borrows melange.logging.debugDecorator.log as log
    */
  melange.action = window.melange.action = function () {
    return new melange.action();
  };

  /** Shortcut to current package.
    * @private
    */
  var $m = melange.logging.debugDecorator(melange.action);

  melange.error.createErrors([
  ]);

  $m.createFloatMenu = function () {
    var name = "#floatMenu";
    var menuYloc = null;
    jQuery(document).ready(function(){
      menuYloc = parseInt(jQuery(name).css("top").substring(
          0, jQuery(name).css("top").indexOf("px")))
      jQuery(window).scroll(function () {
        offset = menuYloc + jQuery(document).scrollTop()+"px";
        jQuery(name).animate({top: offset},{duration: 500, queue: false});
      });
    });
  }

  $m.createToggleButton = function () {
    $(window).load(function() {
      $('.on_off :checkbox').iphoneStyle({
        checkedLabel: 'Yes', uncheckedLabel: 'No'
      });
      $('.disabled :checkbox').iphoneStyle({
        checkedLabel: 'Yes', uncheckedLabel: 'No'
      });
      $('.long :checkbox').iphoneStyle({
        checkedLabel: 'Enable', uncheckedLabel: 'Disable'
      });

      var onchange_checkbox = $('.onchange :checkbox').iphoneStyle();
      setInterval(function toggleCheckbox() {
        onchange_checkbox.attr(
          'checked', !onchange_checkbox.is(':checked')).change();
        $('span#status').html(onchange_checkbox.is(':checked').toString());
      }, 2500);
    });
  }

  $m.createCluetip = function () {
    jQuery(document).ready(function() {
      jQuery('a.load-tooltip').cluetip({
        local:true,
        cursor: 'pointer',
        showTitle:false,
        tracking:true,
        dropShadow:false
      });
    });
  }

  $m.createActionBox = function () {
    $m.createCluetip();
    $m.createToggleButton();
  }
}());

@@ -2113,16 +2113,260 @@
  %7D);%0A%0A  
+/* This function exists as a show case function to show that this%0A   * functionality of chaining the onchange of some other button to%0A   * this button is possible. It is currently not used anywhere. */%0A  $m.createOnChangeButton = function () %7B%0A
     var 
@@ -2385,17 +2385,22 @@
 ckbox = 
-$
+jQuery
 ('.oncha
@@ -2434,18 +2434,16 @@
 ();%0A    
-  
 setInter
@@ -2470,26 +2470,24 @@
 heckbox() %7B%0A
-  
       onchan
@@ -2512,18 +2512,16 @@
         
-  
 'checked
@@ -2574,19 +2574,22 @@
 ;%0A      
-  
-$
+jQuery
 ('span#s
@@ -2651,18 +2651,16 @@
 ));%0A    
-  
 %7D, 2500)
@@ -2661,24 +2661,16 @@
  2500);%0A
-    %7D);%0A
   %7D%0A%0A  $

Refactor the on change chanined toggle buttons to its own function.