/**
 * Trim method
 * @extends String Object
 */
String.prototype.trim = function() { 
	return this.replace(/^\s+|\s+$/, ''); 
};

/**
 * Wrap method
 * @extends String Object
 * @author Dominik Bulaj <dominik@bulaj.com>
 */
String.prototype.wrap = function(width, str) {
	if (typeof width == 'undefined') { 
		width = 80; 
	}
	if (typeof str == 'undefined') { 
		str = "\n"; 
	}

	out = '';
	for(i=0; i<this.length; i++) {
		if(i%width==0 && i>0) {
			out += str;
		}
		out += this.substr(i, 1);
	}
	return out; 
};

/**
 * Truncate method
 * @extends String Object
 * @author Dominik Bulaj <dominik@bulaj.com>
 */
String.prototype.truncate = function(max_length, str) {
	if (typeof max_length == 'undefined') { 
		max_length = 80; 
	}
	if (typeof str == 'undefined') { 
		str = "..."; 
	}
	
	out = '';
	if (this.length > max_length) {
		out = this.substring(0, max_length-3);
		if (out.substr(-1) != ' ') {
			out = out.replace(/(.+)([ ]+.+)/, '$1');
		}
		out += '...';
	}
	return out;
}

/*
 * Wlasne funkcje i klasy
 */
function cform_reset() {
	if (confirm('Czy napewno usunąć treść formularza?')) {
		$('#cform')[0].reset();
		return true;
	}
	return false;
}

