        
function add(anzahl,preis_pro_plz,stop) {
	
	if(stop==null) stop = false;
	
    index = document.getElementById('left').selectedIndex;
    
    values = new Array(); 
    text = new Array();
    for (var i = 0; i < document.getElementById('left').options.length; i++) {
     
        if (document.getElementById('left').options[i].selected) {
            values.push(document.getElementById('left').options[i].value);
            text.push(document.getElementById('left').options[i].text);
        }
    } 
    
    for (var i = 0; i < values.length; i++) {
		
		if (stop) {
			if (document.getElementById('right').options.length >= anzahl) {
				alert('Sie können maximal '+anzahl+' PLZ-Gebiete auswaehlen.');
				break;
			}
		}
		
		option = new Option(
		text[i],     
		values[i], 
		false, 
		true);
		
		//dem rechten Dropdown hinzufuegen
		document.getElementById('right').options[document.getElementById('right').length] = option;
		//aus dem linken Dropdown entfernen
		document.getElementById('left').options[index] = null;
		//Counter aktualisieren
		if (document.getElementById('right').options.length < anzahl) {
			document.getElementById('counter').innerHTML = (anzahl - document.getElementById('right').options.length);
		} else {
			document.getElementById('counter').innerHTML = '0';
		}
		
		//Formularfeld zur Datenuebergabe aktualisieren
		actForm(anzahl,preis_pro_plz);
	
		
		
    }

}

function remove(anzahl,preis_pro_plz) {
    
    index = document.getElementById('right').selectedIndex;
	
	values = new Array(); 
    text = new Array();
    for (var i = 0; i < document.getElementById('right').options.length; i++) {
     
        if (document.getElementById('right').options[i].selected) {
			if ((document.getElementById('right').options[index].getAttribute('rel')) != 'disabled') {
				values.push(document.getElementById('right').options[i].value);
				text.push(document.getElementById('right').options[i].text);
			}
        }
    } 
    
    for (var i = 0; i < values.length; i++) {
    
		option = new Option(
			document.getElementById('right').options[index].text,     
			document.getElementById('right').options[index].value, 
			false, 
			true);
		
		//dem linken Dropdown hinzufuegen
		document.getElementById('left').options[document.getElementById('left').length] = option;
		//aus dem rechten Dropdown entfernen
		document.getElementById('right').options[index] = null;
		//Counter aktualisieren
		if (document.getElementById('right').options.length < anzahl) {
			document.getElementById('counter').innerHTML = (anzahl - document.getElementById('right').options.length);
		} else {
			document.getElementById('counter').innerHTML = '0';
		}
		//Formularfeld zur Datenuebergabe aktualisieren
        actForm(anzahl,preis_pro_plz);
    }
    
}

function actForm(anzahl,preis_pro_plz) {

    temp = new Array();
    for (var i = 0; i < document.getElementById('right').options.length; i++) {
        temp.push(document.getElementById('right').options[i].value);                 
    }
    document.getElementById('loc_id').value = temp.join(',');
	
	if (document.getElementById('right').options.length > anzahl) {
		preis_netto = preis_pro_plz * document.getElementById('right').options.length;
	} else {
		preis_netto = preis_pro_plz * anzahl;	
	}

	preis_brutto = Math.round((preis_netto * 1.19) * 100) / 100;
	document.getElementById('preis').innerHTML = (preis_netto.toFixed(2))+' Euro/Monat (zzgl. 19% Mwst. = '+(preis_brutto.toFixed(2))+' Euro)';
	
	//Anzahl aktualisieren
	document.getElementById('gewaehlt').innerHTML = document.getElementById('right').options.length;
	
}

function changePic(id_pic,id_select,id_link) {
    document.getElementById(id_pic).src = 'http://'+ document.getElementById(id_select).options[document.getElementById(id_select).selectedIndex].value+'/images/flyer-klein.jpg';
    document.getElementById(id_link).href = 'http://'+ document.getElementById(id_select).options[document.getElementById(id_select).selectedIndex].value+'/images/flyer-print.pdf';
    document.getElementById('provision').innerHTML = provision_arr[document.getElementById(id_select).options.selectedIndex];
}