﻿		
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();	
}
			
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 eintragenMAktion(alistboxid, aaktionid, aaktion) {
	listbox = sucheFormelementID( alistboxid );
	aktionsbox = sucheFormelementID( aaktionid);
	if (listbox.selectedIndex != -1 ) {
		aktionsbox.value = aaktion + ";" + listbox.options[listbox.selectedIndex].value;
	}	
}

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 sucheFormelement( aname ) {
	//Durchlaufe alle Einträge		
	
	for(var i=0;i<document.formular.elements.length; i++){				
		controlname = formular.elements[i].name;
		laenge = controlname.length;
		if (controlname.substr( laenge-aname.length,aname.length)==aname) {
			return( formular.elements[i]);
		}			
	}		
}

function sucheFormelementID( aid ) {
	//Durchlaufe alle Einträge		
	for(var i=0;i<document.formular.elements.length; i++){				
		controlname = formular.elements[i].id;
		laenge = controlname.length;
		if (controlname.substr( laenge-aid.length,aid.length)==aid) {
			return( formular.elements[i]);
		}			
	}		
}

function sucheListbox( aname ) {
	return ( sucheFormelement( aname ));
}

function statuswechselSucheID( aid ) {
	control = sucheFormelementID( aid );
	if (control.style.display != 'none') {
		control.style.display = 'none';
	} else {
		control.style.display = 'block';
	}
}

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 mouseX(evt) { 
	if (evt.pageX) return evt.pageX; else if (evt.clientX)
		return evt.clientX + (document.documentElement.scrollLeft ?	document.documentElement.scrollLeft : document.body.scrollLeft);
	else return null;
}
		
function mouseY(evt) {	
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)
		return evt.clientY + (document.documentElement.scrollTop ?	document.documentElement.scrollTop : document.body.scrollTop);
	else return null;
}

function ModulToolbarAnzeigen( aCID, aModuleID, aOriginalModuleID ) {	
	Cid = aCID;
	ModuleID = aModuleID;
	OriginalModuleID = aOriginalModuleID;
	
	var btnClone = document.getElementById('btnCloneBearbeiten');
	if (ModuleID != OriginalModuleID ) {
		btnClone.style.display='inline';
	} else {
		btnClone.style.display='none';
	}
	if (parseInt(mausx)-100<0) {
		document.getElementById('ModulToolbar').style.left=mausx+20;
	} else {
		document.getElementById('ModulToolbar').style.left=mausx+20;
	}
	document.getElementById('ModulToolbar').style.top=parseInt(mausy)-30;
	document.getElementById('ModulToolbar').style.display="inline";
}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  mausx = tempX;
  mausy = tempY;
  //document.<%= formular.clientid %>.MouseX.value = tempX
  //document.<%= formular.clientid %>.MouseY.value = tempY
  return true
}

function modulBearbeiten() {
	window.location.href='default.aspx?cid='+Cid+'&amp;mid='+ModuleID+'&clear=true&cmname=admin/moduleeinstellungen.ascx&amp;cmtitle=Moduleinstellungen';
}

function modulOriginalBearbeiten() {
	window.location.href='default.aspx?cid='+Cid+'&amp;mid='+OriginalModuleID+'&clear=true&cmname=admin/moduleeinstellungen.ascx&amp;cmtitle=Moduleinstellungen';
}

function modulLoeschen() {
	window.location.href='default.aspx?cid='+Cid+'&amp;id_tabelle='+OriginalModuleID+'&clear=true&cmname=admin/loescheneintrag/mod_loeschen_modul.ascx&amp;cmtitle=Löschen';
}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture 
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove 
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s 
var tempX = 0;
var tempY = 0;
var mausx = 0;
var mausy = 0;

var ModuleID = -1;
var Cid = -1;
var OriginalModuleID = -1;