﻿function OpenTeaser(url)
{
	var win = window.open(url,'Vorschau','top=100,left=200,toolbar=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=700, height=600');
	win.focus();
}
			
function OpenWindowReturn( url,width,height,lposition,tposition,title)	{
	var win = window.open(url,'Vorschau','top=' + tposition + ',left=' + lposition + ',toolbar=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=' + width + ', height=' + height);
	win.focus();
	return( win )
}
			
function OpenWindow(url,width,height,lposition,tposition,title)
{
	OpenWindowReturn(url,width,height,lposition,tposition,title)
}			

function OpenWindowDruck(url,width,height,lposition,tposition,title)
{
		var win = OpenWindowReturn(url,width,height,lposition,tposition,title);
		win.print();
}

function OpenWindowDown(url,width,height,lposition,tposition,title)
{
	var win = window.open(url,'Vorschau','top=' + tposition + ',left=' + lposition + ',toolbar=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=' + width + ', height=' + height);
	window.focus();
}	

function LoeschAbfrage( aurl, atext ) {
	if (confirm('Möchten Sie den Eintrag "' + atext + '" wirklich löschen?')==true)
	{
		location.href= aurl;
	}		
}

//Parameter::::
//aLoesche bestimmt, ob der Eintrag in der VON-Listbox geloescht werden soll
//und ob in der NACH-Listbox der Eintrag hinzugefuegt werden soll
function selektiere( avon, anach, aloesche ) {
	if (avon.selectedIndex != -1 ) {
		Gewaehlt = avon.options[avon.selectedIndex]
		if (!aloesche) {
			NeuerEintrag = new Option(Gewaehlt.text, Gewaehlt.value, false, true);
			anach.options[anach.options.length] = NeuerEintrag;				
		} else {
			avon.options[avon.selectedIndex] = null;
		}
	} else {
		alert('Bitte wählen Sie einen Eintrag aus!');
	}
}

//Parameter
//anachoben = true, aktiver Eintrag nach oben
//anachoben = false, aktiver Eintrag nach unten
function verschiebeListboxeintrag( alistbox, anachoben ) {
	if (alistbox.selectedIndex != -1 ) {
		index = alistbox.selectedIndex;
		if (anachoben) {
			if (index != 0 ) {
				value = alistbox.options[index].value;
				text = alistbox.options[index].text;
				alistbox.options[index].value = alistbox.options[index-1].value;
				alistbox.options[index].text = alistbox.options[index-1].text;
				alistbox.options[index-1].value = value;
				alistbox.options[index-1].text = text;
				alistbox.selectedIndex = index -1;
			}
		} else {
			if (index != alistbox.options.length-1 ) {
				value = alistbox.options[index].value;
				text = alistbox.options[index].text;
				alistbox.options[index].value = alistbox.options[index+1].value;
				alistbox.options[index].text = alistbox.options[index+1].text;
				alistbox.options[index+1].value = value;
				alistbox.options[index+1].text = text;
				alistbox.selectedIndex = index +1;
			}
		}		
	}
}

function kopiereListboxinTextfeld( anach, anachtextfeld ) {
	anachtextfeld.value = ''
	
	for (i=0;i<anach.options.length;i++) {
		anachtextfeld.value = anachtextfeld.value + anach.options[i].value + ";";
	}
	
	//alert(document.Form1.textfield.value);
}



function sucheFormelement( aname ) {
	//Durchlaufe alle Einträge		
	
	for(var i=0;i<document.Form1.elements.length; i++){				
		controlname = Form1.elements[i].name;
		laenge = controlname.length;
		if (controlname.substr( laenge-aname.length,aname.length)==aname) {
			return( Form1.elements[i]);
		}			
	}		
}

function sucheListbox( aname ) {
	return ( sucheFormelement( aname ));
}

function statuswechsel( aid ) {
	if (document.getElementById(aid).style.display != 'none') {
		document.getElementById(aid).style.display = 'none';
	} else {
		document.getElementById(aid).style.display = 'block';
	}
}