/*
  SM 01/05/2009 3:53:41 PM
  Select the first tab in which "qf_elem_err" is found.
  This is a quickform error element, as set by QuickFormHelper's initRenderer() function.
*/

$(document).ready(function(){

  // search for qf_elem_err
  jqFirstErr = $('.qf_elem_err:first');
  if(0 == jqFirstErr.length) { return; }

  // find first parent div with class = ui-tabs-panel
  var tab_err_div_id = jqFirstErr.parents(".ui-tabs-panel:first").attr('id');
  //alert('id found:'+tab_err_div_id);
  
  // Quick check to make sure we found in id - probably don't need this.
  if(0 == $.trim(tab_err_div_id).length) { 
    alert("quickform_tab_error_selector: Can't find ID for tab with QF error on it."); 
    return; 
  }
  
  // click the corresponding tab "button"
  $("#"+tab_err_div_id+"_button").trigger('click');
  
});
