/**
*
* This function lets a user focus on the next field in a form by pressing a certain key.
* By default, if the minus-key ('-') is pressed in a field with the class 'w2em', the
*	cursor advances to the next input sibling with the class 'w2em'.
*
*/

(function($){

	$.fn.dateFields = function (cl, code) {
		if (!cl) cl = 'w2em';
		if (!code) code = 109;
    obj = $($(this).get(0));
    obj.children('.' + cl).each(function() {
    	$(this).keydown(function (ev) {
	      if (ev.keyCode == code) {
        	e = $(ev.target).next().get(0);
          while (e != null && (e.nodeType != 1 && e.nodeName != 'INPUT')) {
          	e = $(e).next().get(0);
          }
          if (e != null) {
            e.select();
            ev.stopPropagation();
            ev.preventDefault();
          }
	      }
    	});
    });
    return null;
	};

})(jQuery)
