+
+function focus_by_name(name){
+ var f = getElementByIndirectName(name);
+ if (focussable(f)) {
+ set_cursor_position(f.name);
+ return true;
+ }
+ return false;
+}
+
+$(document).ready(function () {
+ // initialize all jQuery UI tab elements:
+ $(".tabwidget").each(function(idx, element) { $(element).tabs(); });
+
+ $('input').focus(function(){
+ if (focussable(this)) window.focused_element = this;
+ });
+ // legacy. sone forms install these
+ if (typeof fokus == 'function') { fokus(); return; }
+ if (focus_by_name('cursor_fokus')) return;
+ set_cursor_to_first_element();
+});
+
+$('form').submit(function(){
+ if (window.focused_element)
+ document.forms[0].cursor_fokus.value = window.focused_element.name;
+});