function ibeWidgetSubmitFunction(options)
{
  //get the distribution of adults/children among the rooms
  var oRoomDistribution = distributeGuestsInRooms(options.roomsFieldValue, options.adultsFieldValue, options.childrenFieldValue);
  
  //place the values for the distribution in the hidden fields
  for (var i = 0; i < oRoomDistribution.roomAdults.length; i++)
  {
    var field = document.getElementById("numAdults["+i+"]Field");
    if (field)
    {
      field.value = oRoomDistribution.roomAdults[i];
    }
  }
  for (var i = 0; i < oRoomDistribution.roomChildren.length; i++)
  {
    var field = document.getElementById("numChildren["+i+"]Field");
    if (field)
    {
      field.value = oRoomDistribution.roomChildren[i];
    }    
  }  
  
  function createSessionIFrames()
  {
    //create iframes for doing dummy posts to make sure client has session cookies with bestwestern.com
    var iframe1Loaded = function()
    {
      //unbind so when form submits we don't get another load event
      $(this).unbind("load", iframe1Loaded).load(iframe1LoadIframe2);
      //add cloned form to iframe so we can do a dummy submission
      var $iframeBody = $(this).contents().find("body");
      var $form = $("#ibeForm").clone();
      //append form's html because IE6 has issues appending the jquery object using jquery 1.2.6
      var formHTML = $("<div>").append($form).html();
      $iframeBody.empty().append(formHTML);
      $("#ibeForm", $iframeBody).submit();
    };
    
    var iframe1LoadIframe2 = function()
    {
      //unbind so when form submits we don't get another load event
      $(this).unbind("load", iframe1LoadIframe2);
      //have to catch load event of empty iframe first because can't append content until it's loaded
      var $iframe2 = $("<iframe class='bwIframe' width='1' height='1'></iframe>");
      $iframe2.load(iframe2Loaded);  
      $("body").append($iframe2);
   
    }
    
    var iframe2Loaded = function()
    {
      //unbind so when form submits we don't get another load event
      $(this).unbind("load", iframe2Loaded).load(iframe2SubmitPage);
      //add cloned form to iframe so we can do a dummy submission
      var $iframeBody = $(this).contents().find("body");
      var $form = $("#ibeForm").clone();
      //append form's html because IE6 has issues appending the jquery object using jquery 1.2.6
      var formHTML = $("<div>").append($form).html();
      $iframeBody.empty().append(formHTML);
      $("#ibeForm", $iframeBody).submit();
    };
    
    var iframe2SubmitPage = function()
    {
      //when the second dummy submission has occured then submit the real form
      $("#ibeForm").submit();
    }
    
    //start iframe dummy submission chain
    var $iframe = $("<iframe class='bwIframe' width='1' height='1'></iframe>");
    $iframe.load(iframe1Loaded);
    $("body").append($iframe);    
  }  
  
  //the form resubmits itself after the BW iframes have loaded so
  //check if this is a user click or the forms resubmitting themselves
  //- also check that user has not posted into BW before
  if ($("body").data("settingupIBESession") != true && readCookie("hasBWSSession") != "true")
  {
    //alert("setting up session");
    $("body").data("settingupIBESession", true)
    createSessionIFrames();
    return false;
  }
  else
  {
    //alert("done setting up session!");
    createCookie("hasBWSSession", "true");
    
    if (options.webTrendsCustomerDeliveredFlag == true)
    {
      try {
        dcsMultiTrack('DCSext.ecommercedelivery', 'Customers Delivered to Booking Engine', 'DCSext.ecommercecompleted', 'Customers Delivered to Booking Engine');
      } catch (err) {
        //don't do anything
      }
    }
    
    IBEWidgetAttachGoogleAnalyticsTrackingCookiesToAction(options.form);
  }   

}
