function mtSponsoredLinkList(partner, keyword) {
    this.partner   = partner;
    this.keyword   = keyword;
    this.trigger   = 0;
    this.highlight = false;
    this.sLinkList = new Array();
    this.hasNext=function() {
    if ( this.trigger < this.sLinkList.length ) {
            return true;
        }
        return false;
    }
    this.getNext=function() {
        if ( this.hasNext() ) {
            return this.sLinkList[this.trigger++];
        }
        return false;
    }
    this.getRemainders=function() {
        return this.sLinkList.length - this.trigger;
    }
    this.getHeadline=function() {
        var headline = '';
        switch ( this.partner ) {
            case "google" :
                if ( this.keyword == '' ) {
                    headline = '<a href="https://www.google.com/adsense/support/bin/request.py?contact=abg_afc&url=http://www.meinestadt.de/&hl=de&client=ca-pub-8726208069393245">Google Anzeigen</a>';
                } else {
                    headline = '<a href="https://www.google.com/adsense/support/bin/request.py?contact=abg_afc&url=http://www.meinestadt.de/&hl=de&client=ca-pub-8726208069393245">Google-Anzeigen</a>';
                }
                break;
            case "google-afs" :
                headline = 'Anzeigen';
                break;
            case "overture" :
            case "yahoo" :
                headline = '<a onclick="s_objectID=\'http://www.meinestadt.de/x/popup_engine.php?overturePopup=1_1\';return this.s_oc?this.s_oc(e):true" href="/x/popup_engine.php?overturePopup=1" target="_blank" style="text-decoration: none; color: rgb(111, 111, 111);">Sponsoren-Links<\/a>';
                break;
            default :
                headline = 'Sponsoren-Links';
                beak;
        }
        return headline;
    }
    this.normalizeYahoo=function(zSr) {
        for ( k = 6; (k < zSr.length); k += 6 ) {
            // erzeuge neues sponsored link object
            var Link = new mtSponsoredLink(zSr[k+3], zSr[k+4], zSr[k+2], zSr[k], '');
            this.sLinkList[this.sLinkList.length] = Link;
        }
    }
    this.normalizeGoogle=function(ads) {
        for ( i = 0; i < ads.length; i++ ) {
            // erzeuge neues sponsored link object
            var Link = new mtSponsoredLink(ads[i].line1, ads[i].visible_url, ads[i].url, ads[i].line2, ads[i].line3);
            this.sLinkList[this.sLinkList.length] = Link;
        }
    }
}

function mtSponsoredLink( title, display_url, link_url, description_line_1, description_line_2 ) {
    this.title = mtUnHTMLspecialChar(title);
    this.displayUrl = display_url;
    this.linkUrl = link_url;
    this.descriptionLine1 = mtUnHTMLspecialChar(description_line_1);
    this.descriptionLine2 = mtUnHTMLspecialChar(description_line_2);
    this.description = '';
    this.getDescription=function(mode, maxLength) {
        this.description = ( mode == 'W' ) ? this.descriptionLine1 + ' ' + this.descriptionLine2 : this.descriptionLine1 + '<br>' + this.descriptionLine2;
        if ( maxLength > 0 ) {
            return mtSubStringWord(this.description, maxLength, '...');
        }
        return this.description;
    }
}

function mtSubStringWord(string, maxLength, postFix) {
    if ( string.length > maxLength ) {
        while ( string.substr(maxLength, 1) != ' ' ) {
            if ( maxLength >= string.length ) {
                return string;
            }
            maxLength++;
        }
        return string.substr(0, maxLength) + postFix;
    }
    return string;
}

function mtEscapeDoubleQuotes(s) {
    var str = String(s);
    return str.replace(/"/g, '&quot;');
}

function mtTextBolding( stringText, stringToBold ) {
    if ( stringToBold == '' ) {
        return stringText;
    }
    var regex = new RegExp("(" + stringToBold + ")","ig");
    return stringText.replace(regex, "<b>$1</b>");
}