var cmDebug    = 0;
var cmWebRoot  = 'http://cmcore.consortemedia.com';
var trackLoads = 1;

function cmPreProcessRequest(formData, jqForm, options) { 
    // formData is an array; here we use jQueryCM.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = jQueryCM.param(formData);
    
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    var formElement = jqForm[0];

    if (formElement.id && jQueryCM("#"+formElement.id).valid()) {
        if (cmDebug) { alert('About to submit: \n\n' + queryString); }
        
        // alert if the post is greater than IE can handle (1800 chars for the query string + allowing 248 for the base URL)
        if (queryString.length > 1800) { alert('Bad request format.'); }
        
        return true;
    } else {
        return false;
    }
} 

Function.prototype.defaults = function()
{
  var _f = this;
  var _a = Array(_f.length-arguments.length).concat(
    Array.prototype.slice.apply(arguments));
  return function()
  {
    return _f.apply(_f, Array.prototype.slice.apply(arguments).concat(
      _a.slice(arguments.length, _a.length)));
  }
}
