﻿

function OpenWindowReturn( url,width,height,title)	{
	if (title=='') {
		title='Vorschau';
	}
	var win = window.open(url,title,'top=' + ((screen.height-height)/2) + ',left=' + ((screen.width-width)/2) + ',toolbar=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=' + width + ', height=' + height);
	win.focus();
	return( win )
}

function OpenWindowParam(url,title, param) {
	var win = window.open(url,title,param);
	win.focus();
	//return false;	
}
			
function OpenWindow(url,width,height,title)
{
	OpenWindowReturn(url,width,height,title)
}			

function OpenWindowDruck(url,width,height,title)
{
		var win = OpenWindowReturn(url,width,height,title);
		win.print();
}

function OpenWindowDown(url,width,height,lposition,tposition,title)
{
	if (title=='') {
		title='Vorschau';
	}
	var win = window.open(url,title,'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.formular.textfield.value);
}

function statuswechsel( aid ) {
	if (document.getElementById(aid).style.display != 'none') {
		document.getElementById(aid).style.display = 'none';
	} else {
		document.getElementById(aid).style.display = 'block';
	}
}

function statuswechselimg( aid, aid_button ) {
	if (document.getElementById(aid).style.display != 'none') {
		document.getElementById(aid).style.display = 'none';
		document.getElementById(aid_button).src='designs/images/button/box_min.gif';
	} else {
		document.getElementById(aid).style.display = 'block';
		document.getElementById(aid_button).src='designs/images/button/box_max.gif';
	}
}

function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)
					+ ";expires="+expire.toGMTString();
}

function eintragenMAktion(alistboxid, aaktionid, aaktion) {
	listbox = document.getElementById( alistboxid );
	aktionsbox = document.getElementById( aaktionid);
	if (listbox.selectedIndex != -1 ) {
		aktionsbox.value = aaktion + ";" + listbox.options[listbox.selectedIndex].value;
	}	
}
