static function cutText($text, $config, $field, $at_end = FALSE) {
		$limit_value = $config[$field];
		$limit_type = $config[$field . '_type'];
		//
		if($at_end === FALSE) {
			$at_end = $config['more_text_value'];
		}
		// solved problem from: https://www.gavick.com/support/forums/47/12309.html?p=57464#p57464
		$cck_path = JPATH_BASE . DS . 'components' . DS . 'com_cck';
		if (file_exists($cck_path)) {
			if(JComponentHelper::isEnabled('com_cck', true)){
				// Force parsing plugin if SEBLOD is used
				if($config['parse_plugins'] == FALSE) {
					 $text = JHtml::_('content.prepare', $text);
				}
				$text = trim(substr(strip_tags( $text,"<br /><br><strong></strong><p></p><i></i><b></b><span></span><ul></ul><li></li><blockquote></blockquote>"),0));
			}
		}
		if($config['clean_xhtml'] == 1) {
			$allowed_html = '';
			
			if(strlen(trim($config['allowed_tags'])) > 0) {
				$allowed_html = explode(',', $config['allowed_tags']);		
				$allowed_len = count($allowed_html);
				
				for($i = 0; $i < $allowed_len; $i++) {
					$allowed_html[$i] = '<' . $allowed_html[$i] . '>';
				}
				
				$allowed_html = implode('', $allowed_html);
			}
			
			if($limit_type == 'words' && $limit_value > 0){			
				$temp = explode(' ', strip_tags($text, $allowed_html));
			
				if(count($temp) > $limit_value){
					for($i=0; $i<$limit_value; $i++) {
						$cutted[$i] = $temp[$i];
					}
					$cutted = implode(' ', $cutted);
					$cutted = rtrim($cutted, '\'"!,.');
					$text = $cutted . $at_end;
				} else {
					$text = strip_tags($text, $allowed_html);
				}
			} elseif($limit_type == 'words' && $limit_value == 0) {
				return '';
			} else {
				if(JString::strlen($text) > $limit_value){
					$cutted = JString::substr(strip_tags($text, $allowed_html), 0, $limit_value);
					$cutted = rtrim($cutted, '\'"!,.');
					$text = $cutted . $at_end;
				} else {
					$text = strip_tags($text, $allowed_html);
				}
			}
		} else {
			if($limit_type == 'words' && $limit_value > 0) {
				$temp = explode(' ', strip_tags($text));
			
				if(count($temp) > $limit_value){
					$text = NSP_GK5_Utils::cutHTML(str_replace(array('<p>', '</p>'), '', $text), $limit_value, $limit_type);
					$text .= $at_end;
				}
			} elseif ($limit_type == 'words' && $limit_value == 0) {
				return '';
			} else {
				if(JString::strlen(strip_tags($text)) > $limit_value) {
					$text = NSP_GK5_Utils::cutHTML(str_replace(array('<p>', '</p>'), '', $text), $limit_value, $limit_type);
					$text .= $at_end;
				}
			}
		}
		// replace unnecessary entities at end of the cutted text
		$toReplace = array('&&', '&a&', '&am&', '&amp&', '&q&', '&qu&', '&quo&', '&quot&', '&ap&', '&apo&', '&apos&');
		$text = str_replace($toReplace, '&', $text);
		//
		return $text;
	}