function fensterOeffnen(ziel) {
    return window.open(ziel, 'Formular', 'toolbar=no, directories=no, status=no, menubar=no, scrollbars=auto, resizable=yes, copyhistory=no, width=790, height=720');
}

function bildaustausch(nr) {
    textaustausch(nr);
    
    $('autogross').src = eval('bilder[nr]' + '.src');
    $('bild' + selected).setStyle ({
		borderColor: '#fff'
	});
    $('bild' + nr).setStyle ({
		borderColor: '#0099ff'
	});
    selected = nr;
}

function textaustausch(nr) {
    var fototext = document.createTextNode(fototexte[nr]);
    var fotoheadline = document.createTextNode('Beschreibung');
    var emptyheadline = document.createTextNode('');
    
    var hl = document.getElementById('fotoheadline');
    var el = document.getElementById('fototext');
    
    if (el.firstChild != null) {
        el.replaceChild(fototext, el.firstChild);
	} else {
        el.appendChild(fototext);
	}
    if (fototexte[nr] != null && fototexte[nr] != '') {
        if (hl.firstChild != null) {
            hl.replaceChild(fotoheadline, hl.firstChild);
		} else {
            hl.appendChild(fotoheadline);
		}
    } else {
        if (hl.firstChild != null) {
            hl.replaceChild(emptyheadline, hl.firstChild);
		} else {
            hl.appendChild(emptyheadline);
		}
    }
}

function fuellen(count) {
    for (var i = 0; i < count; i++) {
        $('bild' + i).src = eval('bilder[i].src');
	    $('bild' + i).setStyle ({
			borderColor: '#fff'
		});
    }
}

function initialisieren(nr, count) {
    fuellen(count);
	bildaustausch(nr);
}

