(function(window) {

	PrimeFaces.monitorDownload = function(start, complete) {
            if(this.cookiesEnabled()) {
                if(start) {
                    start();
                }

                window.downloadMonitor = setInterval(function() {
                    var downloadComplete = PrimeFaces.getCookie('primefaces.download');
                    
                    if(downloadComplete === 'true') {
                        if(complete) {
                            complete();
                        }
                        clearInterval(window.downloadMonitor);
                    	var expDate = new Date();
                    	expDate.setTime(expDate.getTime());
                    	$.cookie('primefaces.download', 'test', { path: '/', expires: expDate });
                    }
                    
                }, 250);
            }
        }

})(window);