/**
 * jquery.yakabox.settings.js
 * Copyright (c) 2009, Yakabod, Inc.
 *
 * Overriding jQuery settings to define standard Yakabox behavior
 *
 * $Revision: 1.18 $
 * $Date: 2011/06/10 15:42:21 $
 * Last edited by: $Author: wbonde $
 *
 * Last eror free JSLint: 20101229 07:18
 *                        Checked Options: Assume a browser,
 *                                         Allow one var statement per function
 *                                         Disallow undefined variables
 *                                         Disallow dangling _ in identifiers
 *                                         Disallow == and !=
 *                                         Disallow ++ and --
 *                                         Disallow bitwise operators
 *                                         Disallow insecure . and [^...] in /RegExp/
 *                                         Require Initial Caps for constructors
 *                                         Require parens around immediate invocations
 *                        Predefined: window
 */
( function( global )
{
  var $,
      pauseIM, oldBeforeSend, newBeforeSend;

  $ = global.jQuery;

  /**
   * jQ AJAX GLOBAL SETTINGS
	 *
	 *	The pauseIM trigger is used to tell strophe to close the current connection
	 *	so that the ajax request can go right through.  Browsers can have limit of the
	 *	number of concurrent connections and we don't want an open bind connection 
	 *	that is just listening to get in the way.
   */
  pauseIM = function( oXHR )
  {
    $( global.document ).trigger( 'pauseIM' );
  };

  if( typeof $.ajaxSettings.beforeSend === 'function' )
  {
    oldBeforeSend = $.ajaxSettings.beforeSend;
    newBeforeSend = function()
    {
      oldBeforeSend.apply( this, arguments );
      pauseIM.apply( this, arguments );
    };
  }
  else
  {
    newBeforeSend = pauseIM;
  }

  $.ajaxSetup( {
    cache:true,
		beforeSend:	newBeforeSend
  } );

  /**
   * jQ UI DIALOG GLOBAL SETTINGS
   */
  $.extend( $.ui.dialog.prototype.options, {
    modal: true,
    bgiframe: true,
    position: 'center',
    width: 630,
    height: 530,
    dialogClass: 'contentAdd',
    overlay: {
      opacity: 0.5,
      background: 'white'
    },
    resizable: true,
    draggable: true,
    closeOnEscape: false,
    show: null,
    close: function()
    {
      $( this ).dialog( 'destroy' );
    }
  } );
}( window ) );
