/**
 * This is a static class.
 * i.e.: ErrorLogger.logError(str)
 * Singleton-style implementation: ErrorLogger = new ErrorLogger();
 */
var ErrorLogger = function(){
	this.NumberOfErrors = 0;
	this.LoggedErrors = [];
    this.logError = function(str){
		//if we're in the top window
		if(parent == window) {
			var ignoredErrors = [
				/*Errors to ignore*/
			];
	        for(var i = 0; i < ignoredErrors.length; i++) {
				var errorToIgnore = ignoredErrors[i];
				if(str.match(errorToIgnore)) {
					return;
				}
			}
			if(this.NumberOfErrors < 5) {
				if($.inArray(str, this.LoggedErrors) == -1) {
					this.NumberOfErrors++;
					this.LoggedErrors.push(str);
					var toolbarVersion = typeof(facetteToolbarVersion) != "undefined" ? facetteToolbarVersion : "undefined";
					$.post("/errorlogger/logerror", {message: toolbarVersion + ": " + str});		
				}
			}	
		}
    }
}
ErrorLogger = new ErrorLogger();
