function Calendar(){

	//multidimensional array with all the errors. each error is an array with keys: function and message
	this.errors;

	//last error that occurred
	this.error;

	/**
	 * Sets an error
	 *
	 * @return void
	 */
	this.setError = function(func, err){
		this.errors = this.errors ? this.errors : [];
		var key = this.errors.length;
		this.errors[key] = [];
		this.errors[key]['function'] = func;
		this.errors[key]['message'] = err;
		this.error = 'Function "' + func + '": ' + err;
	};

	/**
	 * Changes class of a column of the calendar
	 *
	 * @param string cls; the class of the cells to be changed
	 * @param boolean mode; hovered or not
	 * @return void
	 */
	this.hoverColumns = function(cls, mode){
		if(mode){
			jQuery("." + cls).addClass('hover');
		} else {
			jQuery("." + cls).removeClass('hover');
		}
	};

	/**
	 * Changes class of a row of the calendar
	 *
	 * @param object obj; the TR dom object
	 * @param boolean mode; hovered or not
	 * @return void
	 */
	this.hoverRow = function(obj, mode){
		var td = obj.getElementsByTagName('TD');
		if(td){
			for(i=0; i<td.length; i++){
				if(td[i].className && td[i].className != 'week'){
					if(mode){
						jQuery(td[i]).addClass('hover');
					} else {
						jQuery(td[i]).removeClass('hover');
					}
				}
			}
		}
	}

	/**
	 * Advances calendar with one month
	 *
	 * @param string url;
	 * @param integer year;
	 * @param integer month;
	 * @param string target; the id of the dom object
	 * @param string ajaxError; the id of the dom object thet will show the error
	 * @param string ajaxLoader; the id of the dom object that will act as a preloader
	 * @return void
	 */
	this.next = function(url, year, month, target, ajaxError, ajaxLoader){
		if(month == 12){
			month = 1;
			year++;
		} else {
			month++;
		}
		loadUrl(url + "/" + year + "/" + month, target, ajaxError, ajaxLoader);
	}

	/**
	 * Shows calendar one month before
	 *
	 * @param string url;
	 * @param integer year;
	 * @param integer month;
	 * @param string target; the id of the dom object
	 * @param string ajaxError; the id of the dom object thet will show the error
	 * @param string ajaxLoader; the id of the dom object that will act as a preloader
	 * @return void
	 */
	this.previous = function(url, year, month, target, ajaxError, ajaxLoader){
		if(month == 1){
			month = 12;
			year--;
		} else {
			month--;
		}
		loadUrl(url + "/" + year + "/" + month, target, ajaxError, ajaxLoader);
	}
}

var Calendar = new Calendar();