window.addEvent('domready', function() {
	 $('wrapper').getElements('.col1-info a').addEvent('mouseenter', function(){
		this.setProperties({
			'onclick': 'this.blur();',
			'href': 'javascript:void(0);'
		});
		this.getElement('img').removeProperty('title');
		var text = this.getParent('tr').getNext('tr').getChildren('td').get('text');
		toolTip(this, {
			'text': text
		});
	});
	
	var natschke = $('tx_t4tnatschke_pi1_vvergleich');
	if(natschke) {
		var maxitems = 3;
		var checkbox = natschke.getElements('input[name^=tx_t4tnatschke_pi1_tarif_]');
		var checkBoxArray = [];
		checkbox.each(function(item, key) {
			if(item.getProperty('checked')) {
				checkBoxArray.push(item);
			}
		});	
		checkbox.addEvent('click', function() {
			if(!this.getProperty('checked')) {
				checkBoxArray.erase(this);
				return true;
			}
			checkBoxArray.push(this);
			checkbox.removeProperty('checked');
			if(checkBoxArray.length > maxitems)	checkBoxArray.shift();
			checkBoxArray.each(function(item){
				item.setProperty('checked', 'checked');
			});
		});
                // Preselect PHV-Tipps
                if(checkBoxArray.length == 0) {
                    var tipps = natschke.getElements('tr.tipp');
                    tipps.each(function(item, key) {
                        if(checkBoxArray.length<3) {
                            var tippbox = item.getLast('td').getFirst('input');
                            tippbox.setProperty('checked', 'checked');
                            checkBoxArray.push(tippbox);
                        }
                    });
                }
	}
});
