/* combine : /javascript/common/celebrus/celebrusEventBuffer.js*/
/**
 * Buffer functions to handle Celebrus API calls while the CelebrusInsert.js is still loading.
 * 
 * If calls to the Celebrus API occur before the CelebrusInsert.js file has loaded the Celebrus API 
 * functions then these functions (by the same name) will 'catch' the calls, and forward them on to 
 * the API once it has loaded, subject to a timeout.
 * 
 * This process takes advantage of Javascripts optional parameters - allowing these buffer 
 * functions to be called without their timer parameter initially, and allowing the genuine 
 * Celebrus functions by the same name to accept & ignore the timer parameter if they are called 
 * from these buffer functions.
 */ 

/* Time (milliseconds) to wait between polling for the Celebrus API */
var celAPIPoll_pollDelay = 100;

/* Time (seconds) to continue polling for Celebrus API before giving up */
var celAPIPoll_timeout = 5;

/* Calculated number of polls required before timeout is reached */
var celAPIPoll_limit = celAPIPoll_timeout * 1000 / celAPIPoll_pollDelay;


/**
 * Buffer function to handle Celebrus JDWclick API call while the CelebrusInsert.js is still 
 * loading.
 * @param obj The object which the Celebrus API function will process into an event.
 * @param timer A counter to allow the call stack to exit if the JDWclick Celebrus function
 * does not become available after the number of seconds denoted in celAPIPoll_timeout.
 */
function JDWclick(obj, timer) {
	if (timer == undefined) timer = 0;
	if (timer < celAPIPoll_limit) {
		setTimeout(function(){window.JDWclick(obj, timer+1);}, celAPIPoll_pollDelay);
	}
}

/**
 * Buffer function to handle Celebrus JDWtextchange API call while the CelebrusInsert.js is still 
 * loading.
 * @param obj The object which the Celebrus API function will process into an event.
 * @param timer A counter to allow the call stack to exit if the JDWclick Celebrus function
 * does not become available after the number of seconds denoted in celAPIPoll_timeout.
 */
function JDWtextchange(obj, timer) {
	if (timer == undefined) timer = 0;
	if (timer < celAPIPoll_limit) {
		setTimeout(function(){window.JDWtextchange(obj, timer+1);}, celAPIPoll_pollDelay);
	}
}

/**
 * Buffer function to handle Celebrus JDWformsubmit API call while the CelebrusInsert.js is still 
 * loading.
 * @param obj The object which the Celebrus API function will process into an event.
 * @param timer A counter to allow the call stack to exit if the JDWclick Celebrus function
 * does not become available after the number of seconds denoted in celAPIPoll_timeout.
 */
function JDWformsubmit(obj, timer) {
	if (timer == undefined) timer = 0;
	if (timer < celAPIPoll_limit) {
		setTimeout(function(){window.JDWformsubmit(obj, timer+1);}, celAPIPoll_pollDelay);
	}
}

/**
 * Buffer function to handle Celebrus JDWevent API call while the CelebrusInsert.js is still 
 * loading.
 * @param obj The object which the Celebrus API function will process into an event.
 * @param timer A counter to allow the call stack to exit if the JDWclick Celebrus function
 * does not become available after the number of seconds denoted in celAPIPoll_timeout.
 */
function JDWevent(obj, timer) {
	if (timer == undefined) timer = 0;
	if (timer < celAPIPoll_limit) {
		setTimeout(function(){window.JDWevent(obj, timer+1);}, celAPIPoll_pollDelay);
	}
}
/* complete : /javascript/common/celebrus/celebrusEventBuffer.js*/


