function strip_tags (str, allowed_tags) {
    var key = '', allowed = false;
    var matches = [];var allowed_array = [];
    var allowed_tag = '';
    var i = 0;
    var k = '';
    var html = '';
    var replacer = function (search, replace, str) {
        return str.split(search).join(replace);
    };
     // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
    }
     str += '';

    // Match tags
    matches = str.match(/(<\/?[\S][^>]*>)/gi);
     // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;}

        // Save HTML tag
        html = matches[key].toString();
         // Is tag not in allowed list? Remove from str!
        allowed = false;

        // Go through all allowed tags
        for (k in allowed_array) {            // Init
            allowed_tag = allowed_array[k];
            i = -1;

            if (i != 0) {i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}if (i != 0) {i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) {i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}

            // Determine
            if (i == 0) {allowed = true;
                break;
            }
        }
         if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }
     return str;
}

var glob_a = 0;
var glob_i = 0;


    function showUnterkunft(a) {

        $('fulldiv' + a).setStyle('display', '');
        $('shortdiv' + a).setStyle('display', 'none');
    }

    function initHideInfo(td, a, len) {

        var fullText = td.get('html');
        td.set('html', '');

        var fullDiv = new Element('div', {'id' : 'fulldiv' + a}).injectInside(td);
        fullDiv.set('html', fullText);

        var shortDiv = new Element('div', {'display' : 'none', 'id' : 'shortdiv' + a}).injectAfter(fullDiv);
        var shortTxt = fullText;        

        shortTxt = shortTxt.substr(0,len);
        while(shortTxt.substr(shortTxt.length-1, 1) != ' ' && shortTxt.length < fullText.length) {
            shortTxt = fullText.substr(0,shortTxt.length+1);
        }

        if(fullText.length > shortTxt.length) {
            fullDiv.setStyle('display', 'none');

            shortDiv.set('html', shortTxt+ '... <a class="readmore" href="javascript:showUnterkunft('+a+')">['+readmore_str+']</a>');
            shortDiv.setStyle('display', '');
        }
    }
    function workHotellists() {
        window.addEvent('domready', function() {
            if((table = $('hotel_table')) != null) {
                workHotellistRow(table);
            }else if((table = $$('.fair .onlyText table')) != null) {                
                table.each(function(s_table) { glob_a = 0; workHotellistRow(s_table); });
            }else if((table = $('unterkuenfte')) != null) {
                workHotellistRow(table);
            }

        });
    }

    function workHotellistRow(table) {
        rows = table.getElements('tr');
        var a = 0;
        
        rows.each(function(row) {

            if(a>0) {
                cols = row.getElements('td');
                td = cols[1];
                initHideInfo(td, ++glob_i, 300);
            }
            a++;
        });
    }

    void(workHotellists());
